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 ;----------------------------------------------- Start of Data Segment
31 ; ------------------------------- Start of Code Segment
34 ; ====================================================================
35 ; Function: Scans a Disk for CP/M Partions
36 ; ====================================================================
38 ; --------------------------------------------------------------------
40 ; Registers : [w] temp Number of disk images (raw and fat16) found.
41 ; + 0x80 if sd card changes. (not used, doesn't work)
42 ; SREG : Z according to temp
43 ; --------------------------------------------------------------------
45 ; This Function scans an SD-Cards Boot-Sector for valid Partitions.
46 ; First all original CP/M Partitions will be usesed as Drives for
47 ; the CPM-System. Wenn all CP/M Partitions are found, a second
48 ; scann will be made. In the second Scan, the first FAT16 Partition
49 ; on the Disk will be used for a detailed analyses. If there
50 ; are any Files like "cpm_x.img" are found, these Files will be
51 ; used as Disks by the CP/M- System. ( x must be in the Range A to D )
52 ; ====================================================================
55 sts ndisks,_0 ; Set Number of Disks to 0
57 ; Initialize partition table
59 ldi temp2,PARTENTRY_SIZE*MAXDISKS
65 ; Start mmc Card interaction
67 andi temp,MMCST_NOINIT & MMCST_NODISK
70 ;Load first sector from MMC (boot sector)
75 breq mgr_check_bootsektor
82 ;Pointer to first table entry
84 ldi temp3,0 ;temp3 holds number of found disks (paritions)
86 ;Test, if it has a valid MBR
88 lds temp,hostbuf+510 ;MBR signature (0xAA55) at and of sector?
89 lds temp2,hostbuf+510+1
95 ;No MBR, no partition table ...
97 inc temp3 ;pretend we have one.
99 ldi temp,high((1<<16) * 128/512)
100 ldi temp2,dskType_CPM
102 std y+1,_0 ;start at beginning of card
106 std y+5,_0 ;max CP/M 2.2 disk size
112 ; Search for valid Partitions and ImageFiles
114 ldiw z,hostbuf+510-64 ;Point to first byte of partition table
115 ldi temp4,4 ;Partition table has 4 entries.
122 ; Test for CP/M Partition
126 rcall cpm_add_partition
140 ; Test for FAT16 Partition
141 ldiw z,hostbuf+510-64 ;Point to first byte of partition table
148 ; Test for FAT Partition
149 cpi temp,PARTID_FAT16
152 rcall fat_add_partition
154 rcall fat_scan_partition
155 rcall fat_reset_cache
157 rjmp mgr_pend ;Stop after first FAT16 parrtition found.
166 lds temp,ndisks ;return # of "disks"
171 ; ====================================================================
172 ; Function: Print partition table info
173 ; ====================================================================
175 ; --------------------------------------------------------------------
177 ; Variables : [r] hostparttbl Table with Partitioninformations
178 ; [r] hostparttbltop Pointer to the Top of the Table
179 ; --------------------------------------------------------------------
181 ; ====================================================================
189 ldd temp ,z+1 ;Get partition start
196 cp temp,_0 ;If zero ...
200 breq mgr_prnop ;... no partition table at 0
202 ; Partitiontype examining
207 rcall mgr_prnt_diskname
208 rcall mgr_prnt_table_cpm
216 rcall mgr_prnt_diskname
217 rcall mgr_prnt_table_fat
221 #if 0 /* RAMDISK is not on SD card */
225 rcall mgr_prnt_diskname
226 rcall mgr_prnt_table_ram
231 rcall mgr_prnt_table_err
235 rcall mgr_prnt_diskname
240 printstring ", size: "
242 ldd temp ,z+5 ;Get partition size
255 adiw z,PARTENTRY_SIZE
266 printstring ", size: "
268 ldd temp ,z+5 ;Get partition size
276 rjmp mgr_goto_next_part
288 printstring "CP/M partition at: "
292 printstring "FAT16 File-Image at: "
296 printstring "Ramdisk at: "
300 printstring "Unknown Entry at: "
304 printstring "Assuming CP/M image at: "