X-Git-Url: http://cloudbase.mooo.com/gitweb/avrcpm.git/blobdiff_plain/6421790873fa5bdb8e1d525cac42764faf0f0af3..78bd9e8524f84694b03511147a5698c337141f01:/dsk_fsys.asm diff --git a/dsk_fsys.asm b/dsk_fsys.asm index 6f2da7a..6645bf9 100644 --- a/dsk_fsys.asm +++ b/dsk_fsys.asm @@ -27,7 +27,7 @@ ;***************************************************** ;* Disk-Manager constants * ;***************************************************** - .equ dskType_None = 0 + .equ dskType_None = 0 .equ dskType_CPM = 1 .equ dskType_FAT = 2 .equ dskType_RAM = 3 @@ -35,16 +35,16 @@ ;***************************************************** ;* 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 ; .equ hostspt = 20 ;host disk sectors/trk - .equ hostblk = hostsize/128 ;CP/M sects/host buff -; .equ CPMSPT = hostblk*hostspt;CP/M sectors/track - .equ CPMSPT = 26 ; + .equ hostblk = hostsize/128 ;CP/M sects/host buff +; .equ CPMSPT = hostblk*hostspt ;CP/M sectors/track + .equ CPMSPT = 26 ; .equ SECMSK = hostblk-1 ;sector mask - .equ SECSHF = log2(hostblk) ;sector shift + .equ SECSHF = log2(hostblk) ;sector shift ;***************************************************** ;* BDOS constants on entry to write * @@ -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 @@ -73,7 +79,7 @@ wrtype: .byte 1 ;write operation type dmaadr: .byte 2 ;last dma address hostbuf: .byte hostsize ;host buffer (from/to SD-card) -hostparttbl: .byte PARTENTRY_SIZE*MAXDISKS ;host partition table (type, start sector, sector count) +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) @@ -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.