1 ; Various Management functions for the Interaction with the File-
4 ; Copyright (C) 2010 Frank Zoll
6 ; This file is part of avrcpm.
8 ; avrcpm is free software: you can redistribute it and/or modify it
9 ; under the terms of the GNU General Public License as published by
10 ; the Free Software Foundation, either version 3 of the License, or
11 ; (at your option) any later version.
13 ; avrcpm is distributed in the hope that it will be useful,
14 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ; GNU General Public License for more details.
18 ; You should have received a copy of the GNU General Public License
19 ; along with avrcpm. If not, see <http://www.gnu.org/licenses/>.
25 ; -------------------------- Defines for the disk management Structures
27 ; Partition Table Structures
35 * (see http://www.win.tue.nl/~aeb/partitions/partition_types-1.html)
37 #define PARTID1_FAT16 0x0E
38 #define PARTID2_FAT16 0x06
39 #define PARTID_CPM 0x52
42 ; ------------------------------------------------ Start of Code Segment
45 ; ====================================================================
46 ; Function: Scans a Disk for CP/M Partions
47 ; ====================================================================
49 ; --------------------------------------------------------------------
51 ; Registers : [w] temp Number of disk images (raw and fat16) found.
52 ; + 0x80 if sd card changes. (not used, doesn't work)
53 ; SREG : Z according to temp
54 ; --------------------------------------------------------------------
56 ; This Function scans an SD-Cards Boot-Sector for valid Partitions.
57 ; First all original CP/M Partitions will be usesed as Drives for
58 ; the CPM-System. Wenn all CP/M Partitions are found, a second
59 ; scann will be made. In the second Scan, the first FAT16 Partition
60 ; on the Disk will be used for a detailed analyses. If there
61 ; are any Files like "cpm_x.img" are found, these Files will be
62 ; used as Disks by the CP/M- System. ( x must be in the Range A to D )
63 ; ====================================================================
66 sts ndisks,_0 ; Set Number of Disks to 0
68 ; Initialize partition table
70 ldi temp2,PARTENTRY_SIZE*MAXDISKS
76 ; Start mmc Card interaction
78 andi temp,MMCST_NOINIT | MMCST_NODISK
81 ;Load first sector from MMC (boot sector)
87 breq mgr_check_bootsektor
94 ;Pointer to first table entry
96 ldi temp3,0 ;temp3 holds number of found disks (paritions)
98 ;Test, if it has a valid MBR
100 lds temp,hostbuf+510 ;MBR signature (0xAA55) at and of sector?
102 lds temp,hostbuf+510+1
107 ;No MBR, no partition table ...
111 inc temp3 ;pretend we have one.
113 ldi temp,high((1<<16) * 128/512)
114 ldi temp2,dskType_CPM
116 std y+1,_0 ;start at beginning of card
120 std y+5,_0 ;max CP/M 2.2 disk size
124 rcall dpb_imgdata_get
126 #endif /* CPMDSK_SUPPORT */
134 ; Search for valid Partitions and ImageFiles
135 ldiw z,hostbuf+510-64 ;Point to first byte of partition table
142 ; Test for CP/M Partition
146 rcall cpm_add_partition
149 adiw y,PARTENTRY_SIZE
155 cpi zl,low(hostbuf+510) ;End of partition table reached?
157 #endif /* CPMDSK_SUPPORT */
161 ; Test for FAT16 Partition
162 ldiw z,hostbuf+510-64 ;Point to first byte of partition table
168 ; Test for FAT Partition Type 1
169 cpi temp,PARTID1_FAT16
172 ; Test for FAT Partition Type 2
173 cpi temp,PARTID2_FAT16
177 rcall fat_add_partition
178 rcall fat_scan_partition
179 rcall fat_reset_cache
180 rjmp mgr_pend ;Stop after first FAT16 partition found.
184 cpi zl,low(hostbuf+510)
186 #endif /* FAT16_SUPPORT */
194 rcall dpb_imgdata_get
199 lds temp,ndisks ;return # of "disks"
204 ; ====================================================================
205 ; Function: Print partition table info
206 ; ====================================================================
208 ; --------------------------------------------------------------------
210 ; Variables : [r] hostparttbl Table with Partitioninformations
211 ; [r] hostparttbltop Pointer to the Top of the Table
212 ; --------------------------------------------------------------------
214 ; ====================================================================
230 ldd temp ,z+1 ;Get partition start
235 ; Partitiontype examining
242 cp temp,_0 ;If zero ...
246 brne mgr_prchkcpm ;... no partition table at 0
248 rcall mgr_prnt_diskname
256 rcall mgr_prnt_diskname
257 rcall mgr_prnt_table_cpm
266 rcall mgr_prnt_diskname
267 rcall mgr_prnt_table_fat
272 #if 0 /* RAMDISK is not on SD card */
276 brne mgr_prnt_noramdisk
277 rcall mgr_prnt_diskname
278 rcall mgr_prnt_table_ram
285 rcall mgr_prnt_table_err
289 printstring ", size: "
291 ldd temp ,z+5 ;Get partition size
301 adiw z,PARTENTRY_SIZE
322 printstring "CP/M partition at: "
326 printstring "Assuming CP/M image at: "
332 printstring "FAT16 File-Image '"
344 printstring "Ramdisk at: "
349 printstring "Unknown Entry at: "