X-Git-Url: http://cloudbase.mooo.com/gitweb/avrcpm.git/blobdiff_plain/bd5af9a5d1b1fe3d36f5222157a0744f919b522a..4f46609843d9b56dc26b69ebf0e1d3f1a8e5a330:/dsk_fsys.asm diff --git a/dsk_fsys.asm b/dsk_fsys.asm index ccf1ae2..018aeba 100644 --- a/dsk_fsys.asm +++ b/dsk_fsys.asm @@ -18,24 +18,24 @@ ; along with avrcpm. If not, see . ; ; $Id$ -; - - +; + + ; ---------------- Defines for the Filesystem Interface ------- - + ;***************************************************** ;* Disk-Manager constants * ;***************************************************** - .equ dskType_None = 0 - .equ dskType_CPM = 1 - .equ dskType_FAT = 2 - .equ dskType_RAM = 3 + .equ dskType_None = 0 + .equ dskType_CPM = 1 + .equ dskType_FAT = 2 + .equ dskType_RAM = 3 ;***************************************************** ;* CP/M to host disk constants * ;***************************************************** - .equ MAXDISKS = 4 ;Max number of Disks (partitions) + .equ MAXDISKS = 4 ;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 @@ -52,11 +52,11 @@ .equ WRALL = 0 ;write to allocated .equ WRDIR = 1 ;write to directory .equ WRUAL = 2 ;write to unallocated - .equ WRTMSK= 3 ;write type mask + .equ WRTMSK= 3 ;write type mask ;----------------------------------------------- Start of Data Segment - .dseg - + .dseg + ndisks: .byte 1 ;Number of CP/M disks seekdsk: .byte 1 ;seek disk number @@ -70,54 +70,54 @@ unasec: .byte 1 ;last unalloc sector erflag: .byte 1 ;error reporting wrtype: .byte 1 ;write operation type -dmaadr: .byte 2 ;last dma address +dmaadr: .byte 2 ;last dma address -hostbuf: .byte hostsize ;host buffer (from/to SD-card) +hostbuf: .byte hostsize ;host buffer (from/to SD-card) hostparttbl: .byte PARTENTRY_SIZE*MAXDISKS ;host partition table (type, start sector, sector count) hostparttbltop: hostdsk: .byte 1 ;host disk number -hosttype: .byte 1 ;host disk type (same entry as 1 parition entry) -hostlba: .byte 3 ;host sector number (relative to partition start) - - +hosttype: .byte 1 ;host disk type (same entry as 1 parition entry) +hostlba: .byte 3 ;host sector number (relative to partition start) + + ; ------------------------------- Start of Code Segment - .cseg - -; ==================================================================== + .cseg + +; ==================================================================== ; Function: Get a Pointer to a Partitiontable entry -; ==================================================================== -; Parameters -; -------------------------------------------------------------------- -; Registers : [w] z Pointer to the Partitionentry -; [r] xl Number of Diskentry to Read -; -------------------------------------------------------------------- -; Description: -; ==================================================================== -dsk_getpartentry: - - ldiw z,hostparttbl - mov temp,xl - -dsk_getpartentryloop: - cp temp,_0 - breq dsk_getpartentryloopend - adiw z,PARTENTRY_SIZE - dec temp - jmp dsk_getpartentryloop -dsk_getpartentryloopend: +; ==================================================================== +; Parameters +; -------------------------------------------------------------------- +; Registers : [w] z Pointer to the Partitionentry +; [r] xl Number of Diskentry to Read +; -------------------------------------------------------------------- +; Description: +; ==================================================================== +dsk_getpartentry: + + 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: ret - -; ==================================================================== + +; ==================================================================== ; Function: -; ==================================================================== -; Parameters -; -------------------------------------------------------------------- -; Registers : none -; Variables : [r] seeksec Sector to read -; [r] seektrk Track to read -; -------------------------------------------------------------------- -; Description: -; ==================================================================== +; ==================================================================== +; Parameters +; -------------------------------------------------------------------- +; Registers : none +; Variables : [r] seeksec Sector to read +; [r] seektrk Track to read +; -------------------------------------------------------------------- +; Description: +; ==================================================================== dskDiskCheck: lds temp2,seekdsk cpi temp2,RAMDISKNR @@ -179,18 +179,18 @@ dskDmal: dskDmah: sts dmaadr+1,temp - ret + ret -; ==================================================================== +; ==================================================================== ; Function: Does a Disk interaction -; ==================================================================== -; Parameters -; -------------------------------------------------------------------- -; Registers : none -; Variables : [r] seeksec Sector to read -; [r] seektrk Track to read -; -------------------------------------------------------------------- -; Description: +; ==================================================================== +; Parameters +; -------------------------------------------------------------------- +; Registers : none +; Variables : [r] seeksec Sector to read +; [r] seektrk Track to read +; -------------------------------------------------------------------- +; Description: ; ==================================================================== dskDoIt: .if DISK_DEBUG @@ -258,77 +258,77 @@ dsk_home: sbis flags,hostwrt ;check for pending write cbi flags,hostact ;clear host active flag ret - - -; ==================================================================== + + +; ==================================================================== ; Function: Does a Disk read operation -; ==================================================================== -; Parameters -; -------------------------------------------------------------------- -; Registers : none -; Variables : [r] seekdsk Number of Disk to Read -; [r] seeksec Sector to read -; [r] seektrk Track to read -; -------------------------------------------------------------------- -; Description: +; ==================================================================== +; Parameters +; -------------------------------------------------------------------- +; Registers : none +; Variables : [r] seekdsk Number of Disk to Read +; [r] seeksec Sector to read +; [r] seektrk Track to read +; -------------------------------------------------------------------- +; Description: ; ==================================================================== dsk_read: sts erflag,_0 - sbi flags,readop ; Set read operation flag + sbi flags,readop ; Set read operation flag lds xl,seekdsk - rcall dsk_getpartentry ; Get Paritiontableentry - ld temp,z ; Get Partitiontype - -; Isn't it a Disk ? - cpi temp,dskType_None - brne PC+2 - rjmp dsk_read_err + rcall dsk_getpartentry ; Get Paritiontableentry + ld temp,z ; Get Partitiontype + +; Isn't it a Disk ? + 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. + 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 ldi temp,WRUAL ;write type sts wrtype,temp ;treat as unalloc - rjmp dsk_rwoper ;to perform the read + rjmp dsk_rwoper ;to perform the read -dsk_read_err: - ret +dsk_read_err: + ret -; ==================================================================== +; ==================================================================== ; Function: Does a Disk write operation -; ==================================================================== -; Parameters -; -------------------------------------------------------------------- -; Registers : none -; Variables : [r] seekdsk Number of Disk to Read -; [r] seeksec Sector to read -; [r] seektrk Track to read -; -------------------------------------------------------------------- -; Description: +; ==================================================================== +; Parameters +; -------------------------------------------------------------------- +; Registers : none +; Variables : [r] seekdsk Number of Disk to Read +; [r] seeksec Sector to read +; [r] seektrk Track to read +; -------------------------------------------------------------------- +; Description: ; ==================================================================== dsk_write: ;write the selected sector sts erflag,_0 - cbi flags,readop ; not a read operation + cbi flags,readop ; not a read operation lds xl,seekdsk - rcall dsk_getpartentry ; Get Paritiontableentry - ld temp,z ; Get Partitiontype - -; Isn't it a Disk ? - cpi temp,dskType_None - brne PC+2 - rjmp dsk_write_err - + rcall dsk_getpartentry ; Get Paritiontableentry + ld temp,z ; Get Partitiontype + +; Isn't it a Disk ? + cpi temp,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. + cpi temp,dskType_RAM + brne PC+2 + rjmp rdsk_write + +; It must be a FAT16-Imagefile or CP/M Partition. cbi flags,readop ;not a read operation @@ -402,24 +402,24 @@ dsk_alloc: ;not an unallocated record, requires pre-read sts unacnt,_0 ;unacnt = 0 sbi flags,rsflag ;rsflag = 1 - rjmp dsk_rwoper - -dsk_write_err: - ret - -; ==================================================================== + rjmp dsk_rwoper + +dsk_write_err: + ret + +; ==================================================================== ; Function: Does a Disk read/write operation -; ==================================================================== -; Parameters -; -------------------------------------------------------------------- -; Registers : none -; Variables : [r] seekdsk Number of Disk to Read -; [r] seeksec Sector to read -; [r] seektrk Track to read -; -------------------------------------------------------------------- -; Description: -; ==================================================================== -dsk_rwoper: +; ==================================================================== +; Parameters +; -------------------------------------------------------------------- +; Registers : none +; Variables : [r] seekdsk Number of Disk to Read +; [r] seeksec Sector to read +; [r] seektrk Track to read +; -------------------------------------------------------------------- +; Description: +; ==================================================================== +dsk_rwoper: ;enter here to perform the read/write .if DISK_DEBUG printstring ", flags: " @@ -509,7 +509,7 @@ dsk_match: pop temp2 ;get buffer number (which part of hostbuf) mul temp2,temp add zl,r0 ;offset in hostbuf - adc zh,r1 + adc zh,r1 .if DISK_DEBUG > 2 push r0 @@ -557,63 +557,67 @@ dsk_wdir: dsk_wdir1: rcall dsk_writehost ;clear host buff cbi flags,hostwrt ;buffer written - ret - -; ==================================================================== + ret + +; ==================================================================== ; Function: Does a Disk write operation -; ==================================================================== -; Parameters -; -------------------------------------------------------------------- -; Registers : none -; Variables : [r] seekdsk Number of Disk to Read -; [r] seeksec Sector to read -; [r] seektrk Track to read -; -------------------------------------------------------------------- -; Description: -; ==================================================================== -dsk_writehost: - lds xl,hostdsk - rcall dsk_getpartentry - ld temp,z - +; ==================================================================== +; Parameters +; -------------------------------------------------------------------- +; Registers : none +; Variables : [r] seekdsk Number of Disk to Read +; [r] seeksec Sector to read +; [r] seektrk Track to read +; -------------------------------------------------------------------- +; Description: +; ==================================================================== +dsk_writehost: + lds xl,hostdsk + rcall dsk_getpartentry + ld temp,z + +#if FAT16_SUPPORT ; Is it a FAT16 Diskimage ? - cpi temp,dskType_FAT - brne PC+2 - rjmp fat_writehost - + cpi temp,dskType_FAT + brne PC+2 + rjmp fat_writehost +#endif + ; Is it a CP/M Partition ? - cpi temp,dskType_CPM - brne PC+2 - rjmp cpm_writehost -; Disktype not supported -> Return - ret - -; ==================================================================== + cpi temp,dskType_CPM + brne PC+2 + rjmp cpm_writehost +; Disktype not supported -> Return + ret + +; ==================================================================== ; Function: Does a Disk read operation -; ==================================================================== -; Parameters -; -------------------------------------------------------------------- -; Registers : none -; Variables : [r] seekdsk Number of Disk to Read -; [r] seeksec Sector to read -; [r] seektrk Track to read -; -------------------------------------------------------------------- -; Description: -; ==================================================================== -dsk_readhost: - lds xl,hostdsk - rcall dsk_getpartentry - ld temp,z - +; ==================================================================== +; Parameters +; -------------------------------------------------------------------- +; Registers : none +; Variables : [r] seekdsk Number of Disk to Read +; [r] seeksec Sector to read +; [r] seektrk Track to read +; -------------------------------------------------------------------- +; Description: +; ==================================================================== +dsk_readhost: + lds xl,hostdsk + rcall dsk_getpartentry + ld temp,z + +#if FAT16_SUPPORT ; Is it a FAT16 Diskimage ? - cpi temp,dskType_FAT - brne PC+2 - rjmp fat_readhost - + cpi temp,dskType_FAT + brne PC+2 + rjmp fat_readhost +#endif + ; Is it a CP/M Partition ? - cpi temp,dskType_CPM - brne PC+2 - rjmp cpm_readhost -; Disktype not supported -> Return - ret - + cpi temp,dskType_CPM + brne PC+2 + rjmp cpm_readhost +; Disktype not supported -> Return + ret +