X-Git-Url: http://cloudbase.mooo.com/gitweb/avrcpm.git/blobdiff_plain/dcd7e502729b7ca08df21573b8d98b81a3f81b51..12a27f27734b18ba4dea8d411095cf53c3870ef2:/avr/dsk_mgr.asm diff --git a/avr/dsk_mgr.asm b/avr/dsk_mgr.asm index db62ed1..ba88cfe 100644 --- a/avr/dsk_mgr.asm +++ b/avr/dsk_mgr.asm @@ -2,6 +2,7 @@ ; systems ; ; Copyright (C) 2010 Frank Zoll +; Copyright (C) 2013 Leo C. ; ; This file is part of avrcpm. ; @@ -22,24 +23,6 @@ ; -; -------------------------- Defines for the disk management Structures - -; Partition Table Structures - -#define PART_TYPE 4 -#define PART_START 8 -#define PART_SIZE 12 - -/* - * Partition table id - * (see http://www.win.tue.nl/~aeb/partitions/partition_types-1.html) - */ -#define PARTID1_FAT16 0x0E -#define PARTID2_FAT16 0x06 -#define PARTID_CPM 0x52 - - -; ------------------------------------------------ Start of Code Segment .cseg ; ==================================================================== @@ -47,7 +30,7 @@ ; ==================================================================== ; 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 @@ -60,7 +43,7 @@ ; 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 @@ -75,12 +58,13 @@ mgr_picl: ; Start mmc Card interaction lcall mmcInit - andi temp,MMCST_NOINIT & MMCST_NODISK + andi temp,MMCST_NOINIT | MMCST_NODISK brne mgr_pierr - + ;Load first sector from MMC (boot sector) ldiw y,0 ; Sector 0 movw x,y + ldiw z,hostbuf lcall mmcReadSect tst temp breq mgr_check_bootsektor @@ -97,14 +81,16 @@ mgr_check_bootsektor: ;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 + cpi temp,0x55 + lds temp,hostbuf+510+1 + ldi temp2,0xAA + cpc temp,temp2 breq mgr_search ;No MBR, no partition table ... +#if CPMDSK_SUPPORT + inc temp3 ;pretend we have one. sts ndisks,temp3 ldi temp,high((1<<16) * 128/512) @@ -120,12 +106,16 @@ mgr_check_bootsektor: ldi temp3,0 rcall dpb_imgdata_get +#endif /* CPMDSK_SUPPORT */ + rjmp mgr_pend -; Search for valid Partitions and ImageFiles mgr_search: + +#if CPMDSK_SUPPORT + +; Search for valid Partitions and ImageFiles ldiw z,hostbuf+510-64 ;Point to first byte of partition table - ldi temp4,4 ;Partition table has 4 entries. mgr_ploop: @@ -135,24 +125,24 @@ mgr_ploop: ; Test for CP/M Partition cpi temp,PARTID_CPM brne mgr_nextp - - rcall cpm_add_partition + + lcall cpm_add_partition inc temp3 sts ndisks,temp3 adiw y,PARTENTRY_SIZE cpi temp3,MAXDISKS breq mgr_pend - + mgr_nextp: adiw z,16 - dec temp4 + cpi zl,low(hostbuf+510) ;End of partition table reached? brne mgr_ploop +#endif /* CPMDSK_SUPPORT */ #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 @@ -174,9 +164,9 @@ mgr_fatfound: mgr_nextp2: adiw zl,16 - dec temp4 + cpi zl,low(hostbuf+510) brne mgr_ploop2 -#endif +#endif /* FAT16_SUPPORT */ mgr_pend: clr temp3 @@ -207,35 +197,51 @@ mgr_pend2: ; ==================================================================== mgr_prnt_parttbl: - ldiw z,hostparttbl lds yl,ndisks - ldi xh,'A' + tst yl + brne ppr_doit + ret +ppr_doit: + push r15 + push r14 + ldiw z,hostparttbl + ldi xh,'A' pprl: + printnewline + ldd temp ,z+1 ;Get partition start ldd temp2,z+2 - ldd temp3,z+3 - ldd temp4,z+4 + ldd r14,z+3 + ldd r15,z+4 - printnewline +; Partitiontype examining + + ldd xl,z+0 + andi xl,dskType_MASK + +#if CPMDSK_SUPPORT cp temp,_0 ;If zero ... cpc temp2,_0 - cpc temp3,_0 - cpc temp4,_0 - breq mgr_prnop ;... no partition table at 0 + cpc r14,_0 + cpc r15,_0 + brne mgr_prchkcpm ;... no partition table at 0 -; Partitiontype examining - ldd xl,z+0 - andi xl,dskType_MASK + rcall mgr_prnt_diskname + rcall mgr_prnt_image + rjmp mgr_prnt_size + +mgr_prchkcpm: ; 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: +#endif + #if FAT16_SUPPORT ; FAT16 ? cpi xl,dskType_FAT @@ -245,22 +251,21 @@ mgr_prtb_nocpm: rjmp mgr_prnt_size mgr_prtb_nofat: #endif + #if 0 /* RAMDISK is not on SD card */ +#if RAMDISKCNT ; RAMDISK ? cpi xl,dskType_RAM - brne mgr_prnt_err + brne mgr_prnt_noramdisk rcall mgr_prnt_diskname rcall mgr_prnt_table_ram rjmp mgr_prnt_size +mgr_prnt_noramdisk: +#endif #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 @@ -268,53 +273,61 @@ mgr_prnt_size: ldd temp ,z+5 ;Get partition size ldd temp2,z+6 - ldi temp3,0 - ldi temp4,0 - - lsr temp4 - ror temp3 - ror temp2 + clr r14 + clr r15 + lsr temp2 ror temp lcall print_ultoa printstring "KB." -mgr_goto_next_part: +mgr_goto_next_part: adiw z,PARTENTRY_SIZE inc xh dec yl brne pprl mgr_pppre: + pop r14 + pop r15 ret - + mgr_prnt_diskname: push temp mov temp,xh lcall uartputc - ldi temp,':' - lcall uartputc + printstring ": " pop temp ret +#if CPMDSK_SUPPORT mgr_prnt_table_cpm: printstring "CP/M partition at: " ret +mgr_prnt_image: + printstring "Assuming CP/M image at: " + ret +#endif + +#if FAT16_SUPPORT mgr_prnt_table_fat: - printstring "FAT16 File-Image at: " + printstring "FAT16 File-Image '" + push temp + mov temp,r14 + lcall uartputc + clr r14 + pop temp + printstring "' at: " ret +#endif +#if RAMDISKCNT mgr_prnt_table_ram: printstring "Ramdisk at: " ret +#endif mgr_prnt_table_err: printstring "Unknown Entry at: " ret - -mgr_prnt_image: - printstring "Assuming CP/M image at: " - ret - -