1 ; Various Management functions for the Interaction with the File-
4 ; Copyright (C) 2010 Frank Zoll
5 ; Copyright (C) 2013 Leo C.
7 ; This file is part of avrcpm.
9 ; avrcpm is free software: you can redistribute it and/or modify it
10 ; under the terms of the GNU General Public License as published by
11 ; the Free Software Foundation, either version 3 of the License, or
12 ; (at your option) any later version.
14 ; avrcpm is distributed in the hope that it will be useful,
15 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ; GNU General Public License for more details.
19 ; You should have received a copy of the GNU General Public License
20 ; along with avrcpm. If not, see <http://www.gnu.org/licenses/>.
28 ; ====================================================================
29 ; Function: Scans a Disk for CP/M Partions
30 ; ====================================================================
32 ; --------------------------------------------------------------------
34 ; Registers : [w] temp Number of disk images (raw and fat16) found.
35 ; + 0x80 if sd card changes. (not used, doesn't work)
36 ; SREG : Z according to temp
37 ; --------------------------------------------------------------------
39 ; This Function scans an SD-Cards Boot-Sector for valid Partitions.
40 ; First all original CP/M Partitions will be usesed as Drives for
41 ; the CPM-System. Wenn all CP/M Partitions are found, a second
42 ; scann will be made. In the second Scan, the first FAT16 Partition
43 ; on the Disk will be used for a detailed analyses. If there
44 ; are any Files like "cpm_x.img" are found, these Files will be
45 ; used as Disks by the CP/M- System. ( x must be in the Range A to D )
46 ; ====================================================================
49 sts ndisks,_0 ; Set Number of Disks to 0
51 ; Initialize partition table
53 ldi temp2,PARTENTRY_SIZE*MAXDISKS
59 ; Start mmc Card interaction
61 andi temp,MMCST_NOINIT | MMCST_NODISK
64 ;Load first sector from MMC (boot sector)
70 breq mgr_check_bootsektor
77 ;Pointer to first table entry
79 ldi temp3,0 ;temp3 holds number of found disks (paritions)
81 ;Test, if it has a valid MBR
83 lds temp,hostbuf+510 ;MBR signature (0xAA55) at and of sector?
85 lds temp,hostbuf+510+1
90 ;No MBR, no partition table ...
94 inc temp3 ;pretend we have one.
96 ldi temp,high((1<<16) * 128/512)
99 std y+1,_0 ;start at beginning of card
103 std y+5,_0 ;max CP/M 2.2 disk size
107 rcall dpb_imgdata_get
109 #endif /* CPMDSK_SUPPORT */
117 ; Search for valid Partitions and ImageFiles
118 ldiw z,hostbuf+510-64 ;Point to first byte of partition table
125 ; Test for CP/M Partition
129 lcall cpm_add_partition
132 adiw y,PARTENTRY_SIZE
138 cpi zl,low(hostbuf+510) ;End of partition table reached?
140 #endif /* CPMDSK_SUPPORT */
144 ; Test for FAT16 Partition
145 ldiw z,hostbuf+510-64 ;Point to first byte of partition table
151 ; Test for FAT Partition Type 1
152 cpi temp,PARTID1_FAT16
155 ; Test for FAT Partition Type 2
156 cpi temp,PARTID2_FAT16
160 rcall fat_add_partition
161 rcall fat_scan_partition
162 rcall fat_reset_cache
163 rjmp mgr_pend ;Stop after first FAT16 partition found.
167 cpi zl,low(hostbuf+510)
169 #endif /* FAT16_SUPPORT */
177 rcall dpb_imgdata_get
182 lds temp,ndisks ;return # of "disks"
187 ; ====================================================================
188 ; Function: Print partition table info
189 ; ====================================================================
191 ; --------------------------------------------------------------------
193 ; Variables : [r] hostparttbl Table with Partitioninformations
194 ; [r] hostparttbltop Pointer to the Top of the Table
195 ; --------------------------------------------------------------------
197 ; ====================================================================
213 ldd temp ,z+1 ;Get partition start
218 ; Partitiontype examining
225 cp temp,_0 ;If zero ...
229 brne mgr_prchkcpm ;... no partition table at 0
231 rcall mgr_prnt_diskname
239 rcall mgr_prnt_diskname
240 rcall mgr_prnt_table_cpm
249 rcall mgr_prnt_diskname
250 rcall mgr_prnt_table_fat
255 #if 0 /* RAMDISK is not on SD card */
259 brne mgr_prnt_noramdisk
260 rcall mgr_prnt_diskname
261 rcall mgr_prnt_table_ram
268 rcall mgr_prnt_table_err
272 printstring ", size: "
274 ldd temp ,z+5 ;Get partition size
284 adiw z,PARTENTRY_SIZE
305 printstring "CP/M partition at: "
309 printstring "Assuming CP/M image at: "
315 printstring "FAT16 File-Image '"
327 printstring "Ramdisk at: "
332 printstring "Unknown Entry at: "