From 9220263651f90651ce0106bd1f570ac0cd598597 Mon Sep 17 00:00:00 2001 From: Leo Date: Fri, 8 Oct 2010 10:50:03 +0000 Subject: [PATCH] * Merged fat16-test back into trunk. * eol-style set. git-svn-id: svn://cu.loc/avr-cpm/trunk@139 57430480-672e-4586-8877-bcf8adbbf3b7 --- avrcpm/avr/dsk_fat16.asm | 63 ++-- avrcpm/avr/dsk_fsys.asm | 46 ++- avrcpm/avr/dsk_mgr.asm | 617 ++++++++++++++++++++------------------- avrcpm/avr/dsk_ram.asm | 136 ++++----- avrcpm/avr/init.asm | 20 +- avrcpm/avr/mmc.asm | 36 +-- avrcpm/cpm/bios.mac | 8 +- 7 files changed, 487 insertions(+), 439 deletions(-) diff --git a/avrcpm/avr/dsk_fat16.asm b/avrcpm/avr/dsk_fat16.asm index 42c3ae0..86d2519 100644 --- a/avrcpm/avr/dsk_fat16.asm +++ b/avrcpm/avr/dsk_fat16.asm @@ -36,7 +36,8 @@ ; Defines for FAT16 Structures ; ############################################################################ -#define PARTID_FAT16 0x0E +#define PARTID1_FAT16 0x0E +#define PARTID2_FAT16 0x06 /*These are the Offsets to the Variables within the Bootsector of a FAT16 Partition. @@ -49,7 +50,8 @@ #define FAT16_BSO_NUMFATCP 0x10 ; Offset to Ammount of FAT Copys #define FAT16_BSO_NUMDIRENT 0x11 ; Offset to Max. Root Dir. Entrys #define FAT16_FIRST_IMAGENAME 'A' ; First letter of filename to search -#define FAT16_LAST_IMAGENAME 'Z' ; Last letter of filename to search +#define FAT16_LAST_IMAGENAME 'A'+MAXDISKS-1 ; Last letter of filename to + ; search ; ############################################################################ ; Start of Data Segment @@ -72,8 +74,11 @@ fat_ptr2dat: .byte 4 ; pointer to the first data sector fat_last_dsk: .byte 1 ; number of disk with entry in cache fat_log_clust: .byte 2 ; last searched logical cluster fat_clust_offset: .byte 1 ; offset within the cluster -fat_clust_ptr: .byte 4; ; sector of last real cluster +fat_clust_ptr: .byte 4 ; sector of last real cluster +/* This Variable is only needed within the scanning of the directory +for tempoary variable storage.. todo: optimize away :-) */ +fat_temp: .byte 3 ; for tempoary use ; ############################################################################ ; Start of Code Segment @@ -144,7 +149,7 @@ fat_reset_cache: fat_add_partition: .if FAT16_DEBUG > 0 - printstring "fat16 part found",0 + printstring "fat16 part found" printnewline .endif @@ -188,7 +193,7 @@ fat_add_partition: fat_scan_partition: .if FAT16_DEBUG > 0 - printstring "fat16 scanning",0 + printstring "fat16 scanning" printnewline .endif @@ -199,7 +204,7 @@ fat_scan_partition: .if FAT16_DEBUG > 0 - printstring "free entrys in ptable ?",0 + printstring "free entrys in ptable ?" printnewline .endif @@ -209,7 +214,7 @@ fat_scan_partition: breq fat_scan_error .if FAT16_DEBUG > 0 - printstring "read fat bootblock.",0 + printstring "read fat bootblock." printnewline .endif @@ -233,7 +238,7 @@ fat_scan_error: fat_bootblock_check: .if FAT16_DEBUG > 0 - printstring "fat16 bootblock check",0 + printstring "fat16 bootblock check" printnewline .endif @@ -243,7 +248,7 @@ fat_bootblock_check: sts fat_clustersize,temp .if FAT16_DEBUG > 0 - printstring "Sectors per Cluster ",0 + printstring "Sectors per Cluster " rcall printhex printnewline .endif @@ -254,7 +259,7 @@ fat_bootblock_check: sts fat_last_dsk,temp ; low byte .if FAT16_DEBUG > 0 - printstring "Ammount of FAT copies: ",0 + printstring "Ammount of FAT copies: " rcall printhex printnewline .endif @@ -267,7 +272,7 @@ fat_bootblock_check: sts fat_numdirentrys+1,temp2 ; high byte .if FAT16_DEBUG > 0 - printstring "Max. entrys in Rootdir.: ",0 + printstring "Max. entrys in Rootdir.: " rcall printhexw printnewline .endif @@ -281,7 +286,7 @@ fat_bootblock_check: ldd yl,z+2 ldd yh,z+3 - printstring "Begin of Volume at: ",0 + printstring "Begin of Volume at: " mov temp ,yl mov temp2,yh rcall printhexw @@ -299,7 +304,7 @@ fat_bootblock_check: sts fat_log_clust+1,temp2 ; high byte .if FAT16_DEBUG > 0 - printstring "Sectors per FAT__: ",0 + printstring "Sectors per FAT__: " rcall printhexw printnewline .endif @@ -327,7 +332,7 @@ fat_bootblock_check: sts fat_ptr2fat+3,yh .if FAT16_DEBUG > 1 - printstring "Begin of FAT at___: ",0 + printstring "Begin of FAT at___: " mov temp ,yl mov temp2,yh rcall printhexw @@ -369,7 +374,7 @@ fat_calc_dp_lend: .if FAT16_DEBUG > 1 - printstring "Begin of DIR at___: ",0 + printstring "Begin of DIR at___: " mov temp ,yl mov temp2,yh rcall printhexw @@ -413,7 +418,7 @@ fat_calc_dp_lend: sts fat_ptr2dat+3,yh .if FAT16_DEBUG > 1 - printstring "Begin of Data at__: ",0 + printstring "Begin of Data at__: " mov temp ,yl mov temp2,yh rcall printhexw @@ -517,16 +522,16 @@ fat_look_for_loop: cpi temp,'G' brne fat_look_not_ok - sts fat_clust_ptr ,zl - sts fat_clust_ptr+1,zh - sts fat_clust_ptr+2,temp2 + sts fat_temp ,zl + sts fat_temp+1,zh + sts fat_temp+2,temp2 rjmp fat_store_new_entry fat_scan_for_more: - lds zl ,fat_clust_ptr - lds zh ,fat_clust_ptr+1 - lds temp2,fat_clust_ptr+2 + lds zl ,fat_temp + lds zh ,fat_temp+1 + lds temp2,fat_temp+2 fat_look_not_ok: adiw z,32 @@ -580,7 +585,7 @@ fat_store_new_entry: ; Found a valid image .if FAT16_DEBUG > 1 - printstring "Found a valid Image ! Z=",0 + printstring "Found a valid Image ! Z=" mov temp ,zl mov temp2,zh rcall printhexw @@ -651,7 +656,7 @@ fat_look_store: rcall fat_gethostsec - printstring "Begin of Image at: ",0 + printstring "Begin of Image at: " mov temp ,yl mov temp2,yh rcall printhexw @@ -767,13 +772,13 @@ fat_find_phsy_clust: ldd yh,z+2 .if FAT16_DBG_FAT > 0 - printstring "Search log. Cluster ",0 + printstring "Search log. Cluster " mov temp,xl mov temp2,xh lcall printhexw printnewline - printstring "Search phys. Cluster ",0 + printstring "Search phys. Cluster " mov temp ,yl mov temp2,yh lcall printhexw @@ -830,7 +835,7 @@ fat_next_phsy_clust: fat_found_phsy_clust: .if FAT16_DBG_FAT > 0 - printstring "Found phys. Cluster at:",0 + printstring "Found phys. Cluster at:" mov temp,yl mov temp2,yh lcall printhexw @@ -980,7 +985,7 @@ fat_wrong_cache_clst: ; Found the physical sector .if FAT16_DBG_FAT > 0 - printstring "Found phys. Sector at:",0 + printstring "Found phys. Sector at:" mov temp,yl mov temp2,yh lcall printhexw @@ -1006,7 +1011,7 @@ fat_add_offset: ; Found the physical sector .if FAT16_DBG_FAT > 0 - printstring "Sector with Offset at:",0 + printstring "Sector with Offset at:" mov temp,yl mov temp2,yh lcall printhexw diff --git a/avrcpm/avr/dsk_fsys.asm b/avrcpm/avr/dsk_fsys.asm index 8565620..1f3a195 100644 --- a/avrcpm/avr/dsk_fsys.asm +++ b/avrcpm/avr/dsk_fsys.asm @@ -35,7 +35,7 @@ ;***************************************************** ;* CP/M to host disk constants * ;***************************************************** - .equ MAXDISKS = 6 ;Max number of Disks (partitions) + .equ MAXDISKS = 8 ;Max number of Disks (partitions) .equ PARTENTRY_SIZE = 9 ;Size of a Partitiontableentry .equ blksize = 1024 ;CP/M allocation size .equ hostsize = 512 ;host disk sector size @@ -351,6 +351,42 @@ tmpdpb: .byte 15 ; Test DPBs (avrcpm format) dpblist: +;dpb243 + .db 0x1A,0x00 ;spt + .db 0x03,0x07 ;block shift, bock mask + .db 0x00,0xF2 ;extent mask, low(disk size -1), + .db 0x00,0x3F ;high(disk size -1), low(dir max) + .db 0x00,0xC0 ;high(dir max), alloc0 + .db 0x00,0x10 ;alloc1, low(chk size) + .db 0x00,0x02 ;high(chk size), low(offset) + .db 0x00,0x00 ;high(offset), fill +;dpb243 + .db 0x1A,0x00 ;spt + .db 0x03,0x07 ;block shift, bock mask + .db 0x00,0xF2 ;extent mask, low(disk size -1), + .db 0x00,0x3F ;high(disk size -1), low(dir max) + .db 0x00,0xC0 ;high(dir max), alloc0 + .db 0x00,0x10 ;alloc1, low(chk size) + .db 0x00,0x02 ;high(chk size), low(offset) + .db 0x00,0x00 ;high(offset), fill +;dpb243 + .db 0x1A,0x00 ;spt + .db 0x03,0x07 ;block shift, bock mask + .db 0x00,0xF2 ;extent mask, low(disk size -1), + .db 0x00,0x3F ;high(disk size -1), low(dir max) + .db 0x00,0xC0 ;high(dir max), alloc0 + .db 0x00,0x10 ;alloc1, low(chk size) + .db 0x00,0x02 ;high(chk size), low(offset) + .db 0x00,0x00 ;high(offset), fill +;dpb243 + .db 0x1A,0x00 ;spt + .db 0x03,0x07 ;block shift, bock mask + .db 0x00,0xF2 ;extent mask, low(disk size -1), + .db 0x00,0x3F ;high(disk size -1), low(dir max) + .db 0x00,0xC0 ;high(dir max), alloc0 + .db 0x00,0x10 ;alloc1, low(chk size) + .db 0x00,0x02 ;high(chk size), low(offset) + .db 0x00,0x00 ;high(offset), fill ;dpb243 .db 0x1A,0x00 ;spt .db 0x03,0x07 ;block shift, bock mask @@ -431,9 +467,6 @@ cpydpb_l: pop zh ret -; clear drive table -; for now, only entries 1 - 3 are cleared. - ; ==================================================================== ; Function: Clear drive table ; ==================================================================== @@ -446,12 +479,12 @@ cpydpb_l: ; Description: ; ==================================================================== -; For now, only entries 1 - 3 are cleared. +; For now, only entries 1 - 7 are cleared. dsk_drvtblinit: ldsw x,biosdrvtbl adiw x,2 - ldi temp3,3 + ldi temp3,7 dsk_drvi_l: ldi temp,0 ldi temp2,0 @@ -690,7 +723,6 @@ dsk_read: cpi temp,dskType_None brne PC+2 rjmp dsk_read_err - ; It must be a FAT16-Imagefile or CP/M Partition. sts unacnt,_0 sbi flags,rsflag ;must read data diff --git a/avrcpm/avr/dsk_mgr.asm b/avrcpm/avr/dsk_mgr.asm index eae22a6..805c607 100644 --- a/avrcpm/avr/dsk_mgr.asm +++ b/avrcpm/avr/dsk_mgr.asm @@ -1,307 +1,310 @@ -; Various Management functions for the Interaction with the File- -; systems -; -; Copyright (C) 2010 Frank Zoll -; -; This file is part of avrcpm. -; -; avrcpm is free software: you can redistribute it and/or modify it -; under the terms of the GNU General Public License as published by -; the Free Software Foundation, either version 3 of the License, or -; (at your option) any later version. -; -; avrcpm is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with avrcpm. If not, see . -; -; $Id$ -; - - -;-------------------------- Defines for the disk management Structures - -;----------------------------------------------- Start of Data Segment - - .dseg - -; ------------------------------- Start of Code Segment - .cseg - -; ==================================================================== -; Function: Scans a Disk for CP/M Partions -; ==================================================================== -; Parameters -; -------------------------------------------------------------------- -; -; Registers : [w] temp Number of disk images (raw and fat16) found. -; + 0x80 if sd card changes. (not used, doesn't work) -; SREG : Z according to temp -; -------------------------------------------------------------------- -; Description: -; This Function scans an SD-Cards Boot-Sector for valid Partitions. -; First all original CP/M Partitions will be usesed as Drives for -; the CPM-System. Wenn all CP/M Partitions are found, a second -; scann will be made. In the second Scan, the first FAT16 Partition -; on the Disk will be used for a detailed analyses. If there -; are any Files like "cpm_x.img" are found, these Files will be -; used as Disks by the CP/M- System. ( x must be in the Range A to D ) -; ==================================================================== -mgr_init_partitions: - - sts ndisks,_0 ; Set Number of Disks to 0 - -; Initialize partition table - ldiw y,hostparttbl - ldi temp2,PARTENTRY_SIZE*MAXDISKS -mgr_picl: - st y+,_0 - dec temp2 - brne mgr_picl - -; Start mmc Card interaction - lcall mmcInit - andi temp,MMCST_NOINIT & MMCST_NODISK - brne mgr_pierr - -;Load first sector from MMC (boot sector) - ldiw y,0 ; Sector 0 - movw x,y - lcall mmcReadSect - tst temp - breq mgr_check_bootsektor - -mgr_pierr: - clr temp - ret - -mgr_check_bootsektor: -;Pointer to first table entry - ldiw y,hostparttbl - ldi temp3,0 ;temp3 holds number of found disks (paritions) - -;Test, if it has a valid MBR - - lds temp,hostbuf+510 ;MBR signature (0xAA55) at and of sector? - lds temp2,hostbuf+510+1 - ldi temp4,0xAA - cpi temp,0x55 - cpc temp2,temp4 - breq mgr_search - -;No MBR, no partition table ... - - inc temp3 ;pretend we have one. - sts ndisks,temp3 - ldi temp,high((1<<16) * 128/512) - ldi temp2,dskType_CPM - std y+0,temp2 - std y+1,_0 ;start at beginning of card - std y+2,_0 - std y+3,_0 - std y+4,_0 - std y+5,_0 ;max CP/M 2.2 disk size - std y+6,temp ; - std y+7,_0 - std y+8,_0 - rjmp mgr_pend - -; Search for valid Partitions and ImageFiles -mgr_search: - ldiw z,hostbuf+510-64 ;Point to first byte of partition table - ldi temp4,4 ;Partition table has 4 entries. - -mgr_ploop: - -; Get Partitiontype - ldd temp,z+PART_TYPE - -; Test for CP/M Partition - cpi temp,PARTID_CPM - brne mgr_nextp - - rcall cpm_add_partition - - inc temp3 - sts ndisks,temp3 - cpi temp3,MAXDISKS - breq mgr_pend - -mgr_nextp: - adiw zl,16 - dec temp4 - brne mgr_ploop - -#if FAT16_SUPPORT - -; Test for FAT16 Partition - ldiw z,hostbuf+510-64 ;Point to first byte of partition table - ldi temp4,4 - -mgr_ploop2: -; Get Partitiontype - ldd temp,z+PART_TYPE - -; Test for FAT Partition - cpi temp,PARTID_FAT16 - brne mgr_nextp2 - - rcall fat_add_partition - - rcall fat_scan_partition - rcall fat_reset_cache - - rjmp mgr_pend ;Stop after first FAT16 parrtition found. - -mgr_nextp2: - adiw zl,16 - dec temp4 - brne mgr_ploop2 -#endif - -mgr_pend: - lds temp,ndisks ;return # of "disks" - tst temp - ret - - -; ==================================================================== -; Function: Print partition table info -; ==================================================================== -; Parameters -; -------------------------------------------------------------------- -; Registers : none -; Variables : [r] hostparttbl Table with Partitioninformations -; [r] hostparttbltop Pointer to the Top of the Table -; -------------------------------------------------------------------- -; Description: -; ==================================================================== - -mgr_prnt_parttbl: - ldiw z,hostparttbl - lds yl,ndisks - ldi xh,'A' - -pprl: - ldd temp ,z+1 ;Get partition start - ldd temp2,z+2 - ldd temp3,z+3 - ldd temp4,z+4 - - printnewline - - cp temp,_0 ;If zero ... - cpc temp2,_0 - cpc temp3,_0 - cpc temp4,_0 - breq mgr_prnop ;... no partition table at 0 - -; Partitiontype examining - ldd xl,z+0 -; CP/M ? - cpi xl,dskType_CPM - brne mgr_prtb_nocpm - rcall mgr_prnt_diskname - rcall mgr_prnt_table_cpm - rjmp mgr_prnt_size - -mgr_prtb_nocpm: -#if FAT16_SUPPORT -; FAT16 ? - cpi xl,dskType_FAT - brne mgr_prtb_nofat - rcall mgr_prnt_diskname - rcall mgr_prnt_table_fat - rjmp mgr_prnt_size -mgr_prtb_nofat: -#endif -#if 0 /* RAMDISK is not on SD card */ -; RAMDISK ? - cpi xl,dskType_RAM - brne mgr_prnt_err - rcall mgr_prnt_diskname - rcall mgr_prnt_table_ram - rjmp mgr_prnt_size -#endif -mgr_prnt_err: -; Entry Error - rcall mgr_prnt_table_err - rjmp mgr_prnt_size - -mgr_prnop: - rcall mgr_prnt_diskname - rcall mgr_prnt_image - -mgr_prnt_size: - lcall print_ultoa - printstring ", size: " - - ldd temp ,z+5 ;Get partition size - ldd temp2,z+6 - ldd temp3,z+7 - ldd temp4,z+8 - - lsr temp4 - ror temp3 - ror temp2 - ror temp - lcall print_ultoa - printstring "KB." - -mgr_goto_next_part: - adiw z,PARTENTRY_SIZE - inc xh - dec yl - brne pprl - -mgr_pppre: - ret - - -mgr_prnt_fatsize: - lcall print_ultoa - printstring ", size: " - - ldd temp ,z+5 ;Get partition size - ldd temp2,z+6 - ldd temp3,z+7 - ldd temp4,z+8 - - lcall print_ultoa - printstring "BYTE." - - rjmp mgr_goto_next_part - -mgr_prnt_diskname: - push temp - mov temp,xh - lcall uartputc - ldi temp,':' - lcall uartputc - pop temp - ret - -mgr_prnt_table_cpm: - printstring "CP/M partition at: " - ret - -mgr_prnt_table_fat: - printstring "FAT16 File-Image at: " - ret - -mgr_prnt_table_ram: - printstring "Ramdisk at: " - ret - -mgr_prnt_table_err: - printstring "Unknown Entry at: " - ret - -mgr_prnt_image: - printstring "Assuming CP/M image at: " - ret - - +; Various Management functions for the Interaction with the File- +; systems +; +; Copyright (C) 2010 Frank Zoll +; +; This file is part of avrcpm. +; +; avrcpm is free software: you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by +; the Free Software Foundation, either version 3 of the License, or +; (at your option) any later version. +; +; avrcpm is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with avrcpm. If not, see . +; +; $Id$ +; + + +;-------------------------- Defines for the disk management Structures + +;----------------------------------------------- Start of Data Segment + + .dseg + +; ------------------------------- Start of Code Segment + .cseg + +; ==================================================================== +; Function: Scans a Disk for CP/M Partions +; ==================================================================== +; Parameters +; -------------------------------------------------------------------- +; +; Registers : [w] temp Number of disk images (raw and fat16) found. +; + 0x80 if sd card changes. (not used, doesn't work) +; SREG : Z according to temp +; -------------------------------------------------------------------- +; Description: +; This Function scans an SD-Cards Boot-Sector for valid Partitions. +; First all original CP/M Partitions will be usesed as Drives for +; the CPM-System. Wenn all CP/M Partitions are found, a second +; scann will be made. In the second Scan, the first FAT16 Partition +; on the Disk will be used for a detailed analyses. If there +; are any Files like "cpm_x.img" are found, these Files will be +; used as Disks by the CP/M- System. ( x must be in the Range A to D ) +; ==================================================================== +mgr_init_partitions: + + sts ndisks,_0 ; Set Number of Disks to 0 + +; Initialize partition table + ldiw y,hostparttbl + ldi temp2,PARTENTRY_SIZE*MAXDISKS +mgr_picl: + st y+,_0 + dec temp2 + brne mgr_picl + +; Start mmc Card interaction + lcall mmcInit + andi temp,MMCST_NOINIT & MMCST_NODISK + brne mgr_pierr + +;Load first sector from MMC (boot sector) + ldiw y,0 ; Sector 0 + movw x,y + lcall mmcReadSect + tst temp + breq mgr_check_bootsektor + +mgr_pierr: + clr temp + ret + +mgr_check_bootsektor: +;Pointer to first table entry + ldiw y,hostparttbl + ldi temp3,0 ;temp3 holds number of found disks (paritions) + +;Test, if it has a valid MBR + + lds temp,hostbuf+510 ;MBR signature (0xAA55) at and of sector? + lds temp2,hostbuf+510+1 + ldi temp4,0xAA + cpi temp,0x55 + cpc temp2,temp4 + breq mgr_search + +;No MBR, no partition table ... + + inc temp3 ;pretend we have one. + sts ndisks,temp3 + ldi temp,high((1<<16) * 128/512) + ldi temp2,dskType_CPM + std y+0,temp2 + std y+1,_0 ;start at beginning of card + std y+2,_0 + std y+3,_0 + std y+4,_0 + std y+5,_0 ;max CP/M 2.2 disk size + std y+6,temp ; + std y+7,_0 + std y+8,_0 + rjmp mgr_pend + +; Search for valid Partitions and ImageFiles +mgr_search: + ldiw z,hostbuf+510-64 ;Point to first byte of partition table + ldi temp4,4 ;Partition table has 4 entries. + +mgr_ploop: + +; Get Partitiontype + ldd temp,z+PART_TYPE + +; Test for CP/M Partition + cpi temp,PARTID_CPM + brne mgr_nextp + + rcall cpm_add_partition + + inc temp3 + sts ndisks,temp3 + cpi temp3,MAXDISKS + breq mgr_pend + +mgr_nextp: + adiw zl,16 + dec temp4 + brne mgr_ploop + +#if FAT16_SUPPORT + +; Test for FAT16 Partition + ldiw z,hostbuf+510-64 ;Point to first byte of partition table + ldi temp4,4 + +mgr_ploop2: +; Get Partitiontype + ldd temp,z+PART_TYPE + +; Test for FAT Partition Type 1 + cpi temp,PARTID1_FAT16 + breq mgr_fatfound + +; Test for FAT Partition Type 2 + cpi temp,PARTID2_FAT16 + brne mgr_nextp2 + +mgr_fatfound: + rcall fat_add_partition + rcall fat_scan_partition + rcall fat_reset_cache + rjmp mgr_pend ;Stop after first FAT16 partition found. + +mgr_nextp2: + adiw zl,16 + dec temp4 + brne mgr_ploop2 +#endif + +mgr_pend: + lds temp,ndisks ;return # of "disks" + tst temp + ret + + +; ==================================================================== +; Function: Print partition table info +; ==================================================================== +; Parameters +; -------------------------------------------------------------------- +; Registers : none +; Variables : [r] hostparttbl Table with Partitioninformations +; [r] hostparttbltop Pointer to the Top of the Table +; -------------------------------------------------------------------- +; Description: +; ==================================================================== + +mgr_prnt_parttbl: + ldiw z,hostparttbl + lds yl,ndisks + ldi xh,'A' + +pprl: + ldd temp ,z+1 ;Get partition start + ldd temp2,z+2 + ldd temp3,z+3 + ldd temp4,z+4 + + printnewline + + cp temp,_0 ;If zero ... + cpc temp2,_0 + cpc temp3,_0 + cpc temp4,_0 + breq mgr_prnop ;... no partition table at 0 + +; Partitiontype examining + ldd xl,z+0 +; CP/M ? + cpi xl,dskType_CPM + brne mgr_prtb_nocpm + rcall mgr_prnt_diskname + rcall mgr_prnt_table_cpm + rjmp mgr_prnt_size + +mgr_prtb_nocpm: +#if FAT16_SUPPORT +; FAT16 ? + cpi xl,dskType_FAT + brne mgr_prtb_nofat + rcall mgr_prnt_diskname + rcall mgr_prnt_table_fat + rjmp mgr_prnt_size +mgr_prtb_nofat: +#endif +#if 0 /* RAMDISK is not on SD card */ +; RAMDISK ? + cpi xl,dskType_RAM + brne mgr_prnt_err + rcall mgr_prnt_diskname + rcall mgr_prnt_table_ram + rjmp mgr_prnt_size +#endif +mgr_prnt_err: +; Entry Error + rcall mgr_prnt_table_err + rjmp mgr_prnt_size + +mgr_prnop: + rcall mgr_prnt_diskname + rcall mgr_prnt_image + +mgr_prnt_size: + lcall print_ultoa + printstring ", size: " + + ldd temp ,z+5 ;Get partition size + ldd temp2,z+6 + ldd temp3,z+7 + ldd temp4,z+8 + + lsr temp4 + ror temp3 + ror temp2 + ror temp + lcall print_ultoa + printstring "KB." + +mgr_goto_next_part: + adiw z,PARTENTRY_SIZE + inc xh + dec yl + brne pprl + +mgr_pppre: + ret + + +mgr_prnt_fatsize: + lcall print_ultoa + printstring ", size: " + + ldd temp ,z+5 ;Get partition size + ldd temp2,z+6 + ldd temp3,z+7 + ldd temp4,z+8 + + lcall print_ultoa + printstring "BYTE." + + rjmp mgr_goto_next_part + +mgr_prnt_diskname: + push temp + mov temp,xh + lcall uartputc + ldi temp,':' + lcall uartputc + pop temp + ret + +mgr_prnt_table_cpm: + printstring "CP/M partition at: " + ret + +mgr_prnt_table_fat: + printstring "FAT16 File-Image at: " + ret + +mgr_prnt_table_ram: + printstring "Ramdisk at: " + ret + +mgr_prnt_table_err: + printstring "Unknown Entry at: " + ret + +mgr_prnt_image: + printstring "Assuming CP/M image at: " + ret + + diff --git a/avrcpm/avr/dsk_ram.asm b/avrcpm/avr/dsk_ram.asm index 4216506..2edda4f 100644 --- a/avrcpm/avr/dsk_ram.asm +++ b/avrcpm/avr/dsk_ram.asm @@ -18,37 +18,37 @@ ; along with avrcpm. If not, see . ; ; $Id$ -; - -#ifndef RAMDSK_SUPPORT - #define RAMDSK_SUPPORT 0 -#endif - -#if RAMDSK_SUPPORT - +; + +#ifndef RAMDSK_SUPPORT + #define RAMDSK_SUPPORT 0 +#endif + +#if RAMDSK_SUPPORT + ;-------------------------------------- Defines for RAMDISK Structures - + ;----------------------------------------------- Start of Data Segment - .dseg - -rdskbuf: .byte 128 ; Buffer for RAM-Disk interaktions - + .dseg + +rdskbuf: .byte 128 ; Buffer for RAM-Disk interaktions + ; ---------------------------------------------- Start of Code Segment - .cseg + .cseg -; ==================================================================== +; ==================================================================== ; Function: Calculate an sets the adress of Sector within the RAMDISK -; ==================================================================== -; Parameters -; -------------------------------------------------------------------- -; Registers : none -; Variables : [r] seeksec Sector to read -; [r] seektrk Track to read -; [w] temp3 Number of Bytes per Sector (128) -; -------------------------------------------------------------------- -; Description: -; ==================================================================== +; ==================================================================== +; Parameters +; -------------------------------------------------------------------- +; Registers : none +; Variables : [r] seeksec Sector to read +; [r] seektrk Track to read +; [w] temp3 Number of Bytes per Sector (128) +; -------------------------------------------------------------------- +; Description: +; ==================================================================== rdsk_adr: @@ -79,29 +79,29 @@ rdsk_adr: .endif ret -; ==================================================================== +; ==================================================================== ; Function: Does a read opperation on a RAMDISK -; ==================================================================== -; Parameters -; -------------------------------------------------------------------- -; Registers : none -; Variables : [r] seeksec Sector to read -; [r] seektrk Track to read -; [r] flags RW operation Flags -; [w] erflag Error Status of the operation -; -------------------------------------------------------------------- -; Description: -; ==================================================================== +; ==================================================================== +; Parameters +; -------------------------------------------------------------------- +; Registers : none +; Variables : [r] seeksec Sector to read +; [r] seektrk Track to read +; [r] flags RW operation Flags +; [w] erflag Error Status of the operation +; -------------------------------------------------------------------- +; Description: +; ==================================================================== rdsk_read: - + .if DISK_DEBUG > 1 printnewline printstring "rd-adr: " .endif rcall rdsk_adr - + rdsk_rdl: DRAM_SETADDR xl, ~(1< 1 @@ -195,20 +195,20 @@ rdsk_wrl: ldi temp,~RAM_DQ_MASK | (1< 1 @@ -616,7 +616,7 @@ mmcReadWord: lds temp,mmcCardType sbrs temp,log2(CT_BLOCK) rcall mul_yx_512 ;Convert to byte address (*512) - + ldi temp2,CMD17 rcall mmcCmd ldi temp2,RES_ERROR @@ -644,30 +644,30 @@ mmc_rcvw_start: mmc_rcvw_rl: sbiw yl,1 breq mmc_rcvw_rle - cp zl,_0 - cpc zh,_0 - breq mmc_rcvw_sto - - sbiw zl,1 + cp zl,_0 + cpc zh,_0 + breq mmc_rcvw_sto + + sbiw zl,1 spi_waitm in temp,SPDR out SPDR,_255 rjmp mmc_rcvw_rl -mmc_rcvw_sto: - mov zl,temp +mmc_rcvw_sto: + mov zl,temp spi_waitm in temp,SPDR out SPDR,_255 - mov zh,temp - + mov zh,temp + mmc_rcvw_rl2: sbiw yl,1 breq mmc_rcvw_rle spi_waitm in temp,SPDR out SPDR,_255 - rjmp mmc_rcvw_rl2 + rjmp mmc_rcvw_rl2 mmc_rcvw_rle: rcall spi_wait ; while SPI module shifts in crc part1. rcall spi_rcvr ;Read second crc. @@ -682,7 +682,7 @@ mmc_rdexw: rcall printhex printstring " " .endif - ret + ret ;-------------------------------------------------------------- ; Write sector diff --git a/avrcpm/cpm/bios.mac b/avrcpm/cpm/bios.mac index 3cc4fde..24d88ac 100644 --- a/avrcpm/cpm/bios.mac +++ b/avrcpm/cpm/bios.mac @@ -176,7 +176,7 @@ boot0: ld e,0 ld c,'I'-'A' call seldsk - jp z,boot1 + jp z,boot1 ;no ram disk call getdpb ;de = dpb of first ram disk @@ -330,12 +330,10 @@ seldsk: ld a,e ;reselection bit rrca jp c,getdph ;skip, if disk already active - in a,(15) ;querry, if disk exists ld hl,0 + in a,(15) ;querry, if disk exists or a - jp z,getdph - xor a - ret + ret z getdph: ld hl,drvtbl ld b,0 -- 2.39.2