From: Leo Date: Wed, 6 Oct 2010 22:22:37 +0000 (+0000) Subject: * Merged fat16-test back into trunk. X-Git-Tag: 2.2^2~22 X-Git-Url: http://cloudbase.mooo.com/gitweb/avrcpm.git/commitdiff_plain/eb85ce65e986688fec93afe15415dd189f5ba2b2?hp=45a10977ea97d2f25291c6bb9d24e4c5990b9f7f * Merged fat16-test back into trunk. git-svn-id: svn://cu.loc/avr-cpm/trunk@130 57430480-672e-4586-8877-bcf8adbbf3b7 --- diff --git a/avrcpm/avr/8080int-jmp.asm b/avrcpm/avr/8080int-jmp.asm index 26811b5..1d7d1f3 100644 --- a/avrcpm/avr/8080int-jmp.asm +++ b/avrcpm/avr/8080int-jmp.asm @@ -680,7 +680,7 @@ do_op_outa: ; out (opl),a .endif mov temp,z_a mov temp2,opl - rcall portWrite + lcall portWrite ret ;---------------------------------------------------------------- diff --git a/avrcpm/avr/dsk_cpm.asm b/avrcpm/avr/dsk_cpm.asm index e0b819c..6835c93 100644 --- a/avrcpm/avr/dsk_cpm.asm +++ b/avrcpm/avr/dsk_cpm.asm @@ -26,7 +26,7 @@ #if CPMDSK_SUPPORT -;-------------------------------------- Defines for CPM Structures +;------------------------------------------ Defines for CPM Structures #define PART_TYPE 4 #define PART_START 8 #define PART_SIZE 12 @@ -37,11 +37,7 @@ .dseg -; Partition table offsets: -tmp_tbl: - .byte PARTENTRY_SIZE*MAXDISKS - -; ---------------------------------------------- Start of Code Segment +;----------------------------------------------- Start of Code Segment .cseg ; ==================================================================== @@ -71,9 +67,7 @@ cpm_hostparam: .endif rcall dsk_getpartentry ; get partition entry - -cpm_hostlend: lds temp,hostlba ; get sector to access lds temp2,hostlba+1 lds temp3,hostlba+2 @@ -169,11 +163,17 @@ cpm_writehost: tst temp breq cpm_rdwr_ok - rcall mgr_init_partitions - cbr temp,0x80 + rjmp cpm_rdwr_err ; skip disk change detection code + +; After a second thought, the following code doesn't make sense, because +; disk change (change of one or more disk images) can not reliably detected. +; At least with the existing code. + + rcall mgr_init_partitions ;reinit card + cbr temp,0x80 ;this should have been a test of bit 7. breq cpm_rdwr_err - rcall cpm_hostparam + rcall cpm_hostparam ;if same card, try again. breq cpm_rdwr_err rcall mmcWriteSect tst temp @@ -205,11 +205,13 @@ cpm_readhost: tst temp breq cpm_rdwr_ok - rcall mgr_init_partitions + rjmp cpm_rdwr_err ; skip disk change detection code + + rcall mgr_init_partitions ;reinit card cbr temp,0x80 breq cpm_rdwr_err - rcall cpm_hostparam + rcall cpm_hostparam ;if same card, try again. breq cpm_rdwr_err rcall mmcReadSect tst temp diff --git a/avrcpm/avr/dsk_fsys.asm b/avrcpm/avr/dsk_fsys.asm index aa91ce4..6645bf9 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 = 6 ;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 @@ -53,6 +53,12 @@ .equ WRDIR = 1 ;write to directory .equ WRUAL = 2 ;write to unallocated .equ WRTMSK= 3 ;write type mask + + .equ READ_FUNC = 7 + .equ WRITE_FUNC = 6 + .equ BOOT_FUNC = 5 + .equ HOME_FUNC = 4 + ;----------------------------------------------- Start of Data Segment .dseg @@ -95,16 +101,11 @@ hostlba: .byte 3 ;host sector number (relative to partition start) ; ==================================================================== dsk_getpartentry: + ldi zl,PARTENTRY_SIZE + mul xl,zl ldiw z,hostparttbl - mov temp,xl - -dsk_getpartentryloop: - cp temp,_0 - breq dsk_getpartentryloopend - adiw z,PARTENTRY_SIZE - dec temp - rjmp dsk_getpartentryloop -dsk_getpartentryloopend: + add zl,_tmp0 + add zh,_tmp1 ret ; ==================================================================== @@ -129,7 +130,7 @@ dskDiskCheck: tst temp brne dsk_dchpart1 -; Need to init +; No disks yet, need to init rcall mgr_init_partitions cbr temp,0x80 @@ -266,7 +267,7 @@ dsk_home: ; ==================================================================== ; Parameters ; -------------------------------------------------------------------- -; Registers : none +; Registers : in: temp ; Variables : [r] seekdsk Number of Disk to Read ; [r] seeksec Sector to read ; [r] seektrk Track to read @@ -276,7 +277,13 @@ dsk_home: dsk_read: sts erflag,_0 sbi flags,readop ; Set read operation flag + ;RAM disk? lds xl,seekdsk +#if RAMDISKCNT + cpi xl,RAMDISKNR + brlt PC+2 + rjmp rdsk_read +#endif rcall dsk_getpartentry ; Get Paritiontableentry ld temp,z ; Get Partitiontype @@ -284,10 +291,6 @@ dsk_read: cpi temp,dskType_None brne PC+2 rjmp dsk_read_err -; Is it a RamDisk ? - cpi temp,dskType_RAM - brne PC+2 - rjmp rdsk_read ; It must be a FAT16-Imagefile or CP/M Partition. sts unacnt,_0 sbi flags,rsflag ;must read data @@ -303,7 +306,7 @@ dsk_read_err: ; ==================================================================== ; Parameters ; -------------------------------------------------------------------- -; Registers : none +; Registers : in: temp Write type ; Variables : [r] seekdsk Number of Disk to Read ; [r] seeksec Sector to read ; [r] seektrk Track to read @@ -314,19 +317,21 @@ dsk_write: ;write the selected sector sts erflag,_0 cbi flags,readop ; not a read operation + ;RAM disk? lds xl,seekdsk +#if RAMDISKCNT + cpi xl,RAMDISKNR + brlt PC+2 + rjmp rdsk_write +#endif rcall dsk_getpartentry ; Get Paritiontableentry - ld temp,z ; Get Partitiontype + ld temp2,z ; Get Partitiontype ; Isn't it a Disk ? - cpi temp,dskType_None + cpi temp2,dskType_None brne PC+2 rjmp dsk_write_err -; Is it a RamDisk ? - cpi temp,dskType_RAM - brne PC+2 - rjmp rdsk_write ; It must be a FAT16-Imagefile or CP/M Partition. diff --git a/avrcpm/avr/dsk_mgr.asm b/avrcpm/avr/dsk_mgr.asm index 38901cd..4b108a3 100644 --- a/avrcpm/avr/dsk_mgr.asm +++ b/avrcpm/avr/dsk_mgr.asm @@ -22,13 +22,16 @@ ; -; ------------------------- Defines for the disk management Structures +;-------------------------- Defines for the disk management Structures ;----------------------------------------------- Start of Data Segment .dseg +; Partition table offsets: +tmp_tbl: + .byte PARTENTRY_SIZE*MAXDISKS ; ------------------------------- Start of Code Segment .cseg @@ -38,10 +41,10 @@ ; ==================================================================== ; Parameters ; -------------------------------------------------------------------- -; Registers : none -; Variables : [w] temp Status of Operation -; (0x80 - Operation Failure ) -; (others - Operation Suceded) +; +; 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. @@ -164,8 +167,16 @@ mgr_nextp2: mgr_pend: +#if 0 /* ToDo: ramdisks are not in sd-card partitions */ ; Initialize RAM-Disks rcall rdsk_add_partition +#endif + +/* + Don't use change info. It doesn't word reliably with partitions, + and it doesn't work at all with fat images: +*/ +#define CHANGEINFO 0 ;Store new partitions and check if the SD card has been changed. @@ -185,22 +196,27 @@ mgr_pcpl: mov temp,temp3 sts ndisks,temp +#if CHANGEINFO brtc mgr_pcpe +; SD card changed. +#endif tst temp breq mgr_pcpe -; SD card not changed. #if FAT16_SUPPORT rcall fat_scan_partition rcall fat_reset_cache #endif lds temp,ndisks +#if CHANGEINFO sbr temp,0x80 +#endif mgr_pcpe: + tst temp ret diff --git a/avrcpm/avr/virt_ports.asm b/avrcpm/avr/virt_ports.asm index 92c26d1..7861165 100644 --- a/avrcpm/avr/virt_ports.asm +++ b/avrcpm/avr/virt_ports.asm @@ -38,11 +38,6 @@ ;22 - Trigger - write to read, to write a sector using the above info; ; , write to allocated/dirctory/unallocated - .equ READ_FUNC = 7 - .equ WRITE_FUNC = 6 - .equ BOOT_FUNC = 5 - .equ HOME_FUNC = 4 - ;----------------------------------------------- Start of Data Segment .dseg