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 Type 1
149 cpi temp,PARTID1_FAT16
152 ; Test for FAT Partition Type 2
153 cpi temp,PARTID2_FAT16
157 rcall fat_add_partition
158 rcall fat_scan_partition
159 rcall fat_reset_cache
160 rjmp mgr_pend ;Stop after first FAT16 partition found.
169 lds temp,ndisks ;return # of "disks"
174 ; ====================================================================
175 ; Function: Print partition table info
176 ; ====================================================================
178 ; --------------------------------------------------------------------
180 ; Variables : [r] hostparttbl Table with Partitioninformations
181 ; [r] hostparttbltop Pointer to the Top of the Table
182 ; --------------------------------------------------------------------
184 ; ====================================================================
192 ldd temp ,z+1 ;Get partition start
199 cp temp,_0 ;If zero ...
203 breq mgr_prnop ;... no partition table at 0
205 ; Partitiontype examining
210 rcall mgr_prnt_diskname
211 rcall mgr_prnt_table_cpm
219 rcall mgr_prnt_diskname
220 rcall mgr_prnt_table_fat
224 #if 0 /* RAMDISK is not on SD card */
228 rcall mgr_prnt_diskname
229 rcall mgr_prnt_table_ram
234 rcall mgr_prnt_table_err
238 rcall mgr_prnt_diskname
243 printstring ", size: "
245 ldd temp ,z+5 ;Get partition size
258 adiw z,PARTENTRY_SIZE
269 printstring ", size: "
271 ldd temp ,z+5 ;Get partition size
279 rjmp mgr_goto_next_part
291 printstring "CP/M partition at: "
295 printstring "FAT16 File-Image at: "
299 printstring "Ramdisk at: "
303 printstring "Unknown Entry at: "
307 printstring "Assuming CP/M image at: "