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
33 ; ------------------------------- Start of Code Segment
36 ; ====================================================================
37 ; Function: Scans a Disk for CP/M Partions
38 ; ====================================================================
40 ; --------------------------------------------------------------------
42 ; Variables : [w] temp Status of Operation
43 ; (0x80 - Operation Failure )
44 ; (others - Operation Suceded)
45 ; --------------------------------------------------------------------
47 ; This Function scans an SD-Cards Boot-Sector for valid Partitions.
48 ; First all original CP/M Partitions will be usesed as Drives for
49 ; the CPM-System. Wenn all CP/M Partitions are found, a second
50 ; scann will be made. In the second Scan, the first FAT16 Partition
51 ; on the Disk will be used for a detailed analyses. If there
52 ; are any Files like "cpm_x.img" are found, these Files will be
53 ; used as Disks by the CP/M- System. ( x must be in the Range A to D )
54 ; ====================================================================
57 sts ndisks,_0 ; Set Number of Disks to 0
59 ; Initialize temp partition table
61 ldi temp2,PARTENTRY_SIZE*MAXDISKS
67 ; Start mmc Card interaction
69 andi temp,MMCST_NOINIT & MMCST_NODISK
72 ;Load first sector from MMC (boot sector)
77 breq mgr_check_bootsektor
84 ;Pointer to first temp table entry
86 ;Test, if it has a valid MBR
88 ldiw z,hostbuf+510-1 ;Point to last byte of partition table
90 ldi temp3,0 ;temp3 holds number of found disks (paritions)
91 ldd temp,z+1 ;MBR signature (0xAA55) at and of sector?
98 ;No MBR, no partition table ...
99 inc temp3 ;pretend we have one.
100 ldi temp,high((1<<16) * 128/512)
101 ldi temp2,dskType_CPM
103 std y+1,_0 ;start at beginning of card
107 std y+5,_0 ;max CP/M 2.2 disk size
113 ; Search for valid Partitions and ImageFiles
115 sbiw z,63 ;Now at first byte of partition table
116 ldi temp4,high(hostbuf+510)
123 ; Test for CP/M Partition
127 rcall cpm_add_partition
135 cpi zl,low(hostbuf+510)
141 ; Test for FAT16 Partition
142 ldiw z,hostbuf+510-1-63 ;Point to first byte of partition table
143 ldi temp4,high(hostbuf+510)
150 ; Test for FAT Partition
151 cpi temp,PARTID_FAT16
154 rcall fat_add_partition
160 cpi zl,low(hostbuf+510)
167 ; Initialize RAM-Disks
168 rcall rdsk_add_partition
170 ;Store new partitions and check if the SD card has been changed.
174 ldi temp4,PARTENTRY_SIZE*MAXDISKS
193 ; SD card not changed.
196 rcall fat_scan_partition
206 ; ====================================================================
207 ; Function: Print partition table info
208 ; ====================================================================
210 ; --------------------------------------------------------------------
212 ; Variables : [r] hostparttbl Table with Partitioninformations
213 ; [r] hostparttbltop Pointer to the Top of the Table
214 ; --------------------------------------------------------------------
216 ; ====================================================================
221 ; Partitiontype examining
226 breq mgr_goto_next_part
233 rcall mgr_prnt_table_cpm
240 rcall mgr_prnt_table_fat
246 rcall mgr_prnt_table_ram
250 rcall mgr_prnt_table_err
257 ldd temp ,z+1 ;Get partition start
262 printstring ", size: "
264 ldd temp ,z+5 ;Get partition size
265 ldd temp2,z+6 ;Get partition size
266 ldd temp3,z+7 ;Get partition size
267 ldd temp4,z+8 ;Get partition size
277 adiw z,PARTENTRY_SIZE
278 ldi temp,high(hostparttbltop)
279 cpi zl, low (hostparttbltop)
289 printstring ", size: "
291 ldd temp ,z+5 ;Get partition size
292 ldd temp2,z+6 ;Get partition size
293 ldd temp3,z+7 ;Get partition size
294 ldd temp4,z+8 ;Get partition size
299 rjmp mgr_goto_next_part
302 printstring "CP/M partition at: "
306 printstring "FAT16 File-Image at: "
310 printstring "Ramdisk at: "
314 printstring "Unknown Entry at: "
318 printstring "Assuming CP/M image at: "