From 1d26b86661bff5609cb3ae4404a0208c1b651360 Mon Sep 17 00:00:00 2001 From: Leo C Date: Sun, 17 May 2015 17:09:50 +0200 Subject: [PATCH 1/1] support multi sector tranfer. bugfix in bnk2phy (banked to physical translation). --- cbios/.gitignore | 1 + cbios/bioskrnl.180 | 2 +- cbios/mm.180 | 16 +++++++++- cbios/sdio.180 | 77 +++++++++++++++++++++++++++++++--------------- 4 files changed, 70 insertions(+), 26 deletions(-) diff --git a/cbios/.gitignore b/cbios/.gitignore index a6addbc..7d9f502 100644 --- a/cbios/.gitignore +++ b/cbios/.gitignore @@ -2,6 +2,7 @@ *.prn *.lst *.sym +*.map *.rel *.spr diff --git a/cbios/bioskrnl.180 b/cbios/bioskrnl.180 index 6ae7073..93d556d 100644 --- a/cbios/bioskrnl.180 +++ b/cbios/bioskrnl.180 @@ -800,11 +800,11 @@ sector$msg: db ', S-',0 @xdph: ds 2 ; pointer to currently selected drives dph @adrv: ds 1 ; currently selected disk drive @rdrv: ds 1 ; controller relative disk drive -@cnt: db 0 ; record count for multisector transfer @trk: ds 2 ; current track number @sect: ds 2 ; current sector number @dma: ds 2 ; current DMA address @dbnk: db 0 ; bank for DMA operations +@cnt: db 0 ; record count for multisector transfer cseg ; common memory diff --git a/cbios/mm.180 b/cbios/mm.180 index 8f63a2b..90d8144 100644 --- a/cbios/mm.180 +++ b/cbios/mm.180 @@ -55,7 +55,21 @@ bnk2log: bnk2phy: - call bnk2log + push bc + ld c,a + ld a,h + and a,0f0h + cp CA*16 + ld a,c + pop bc + + jr c,b2p_banked + xor a ; address is in common + jr b2b_cont ; base is 0 +b2p_banked: + call bnk2log ; get address base +b2b_cont: + ; fall thru ;-------------------------------------------------------------- diff --git a/cbios/sdio.180 b/cbios/sdio.180 index 2b84aea..e6c12ea 100644 --- a/cbios/sdio.180 +++ b/cbios/sdio.180 @@ -12,8 +12,8 @@ ; Variables containing parameters passed by BDOS extrn @adrv,@rdrv - extrn @dma,@trk,@sect - extrn @dbnk + extrn @trk,@sect,@cnt + extrn @dma,@dbnk ; System Control Block variables @@ -115,6 +115,8 @@ sd$init3: ; parameter header pointed at by sd$login: + xor a + ld (residual),a ld hl,send_msg+1 ld (hl),0 ;login function inc hl @@ -153,9 +155,9 @@ sd$login: ; ; absolute drive number in @adrv (8 bits) +0 ; relative drive number in @rdrv (8 bits) +1 -; multi sector count in @cnt (8 bits) +2 (currently unused) -; disk track address in @trk (16 bits) +3 -; disk sector address in @sect(16 bits) +5 +; disk track address in @trk (16 bits) +2 +; disk sector address in @sect(16 bits) +4 +; multi sector count in @cnt (8 bits) +6 ; disk transfer address in @dma (16 bits) +7 ; disk transfer bank in @dbnk (8 bits) +9 ; pointer to XDPH in @@ -164,27 +166,50 @@ sd$login: ; if necessary, then return an error code in sd$read: - ld hl,read$msg ; point at " Read " - ld a,1 + ld de,read$msg ; point at " Read " + ld c,1 jr rw$common - sd$write: - ld hl,write$msg ; point at " Write " - ld a,2 - ;fall thru + ld de,write$msg ; point at " Write " + ld c,2 +rw$common: + ld hl,residual ; remainng sectors from last multi io? + ld a,(hl) + sub a,1 + jr c,rwc_new_sectors + + ld (hl),a + xor a + ret + +rwc_new_sectors: + ld b,1 ; assume 1 sector to transfer + ld a,(@cnt) + or a + jr z,rwc_doit + + ld b,a ; number of sectors to transfer + dec a ; save remaining + ld (hl),a + xor a ; reset multi sector count + ld (@cnt),a ; compute pysical transfer address ; prepare message ; and send it to AVR. -rw$common: - ld (operation$name),HL ; save message for errors - ld de,send_msg+1 - ld (de),a - inc de +rwc_doit: + ld hl,send_msg+1 + ld (hl),c + inc hl + ld a,b + ex de,hl + ld (operation$name),hl ; save message for errors ld hl,@adrv ;address of arguments - ld bc,7 + ld bc,6 ldir + ld (de),a + inc de push de ld e,(hl) ;dma address inc hl @@ -214,6 +239,9 @@ more$retries: or a ret z ; check status and return to BDOS if no error + xor a + ld (residual),a + ; suppress error message if BDOS is returning errors to application... ld a,(@ermde) @@ -233,7 +261,7 @@ more$retries: ;TODO: rc errorcode ld a,(recv_msg_rc) - tst 080h + tst 080h jr z,fs_end fatfs_err: @@ -293,19 +321,21 @@ u$c1: ret +residual: + db 0 send_msg: db 2 ; disk command ds 1 ; subcommand (login/read/write) ds 1 ; @adrv ds 1 ; @rdrv - ; -read/write- -login- - ds 1 ; @cnt 3 byte - ds 2 ; @trk xdph address -send_msg_login_len equ $ - send_msg - ds 2 ; @sect + ; -read/write- -login- + ds 2 ; @trk xdph address + ds 2 ; @sect (3 byte) + ds 1 ; @cnt ds 3 ; transfer addr send_msg_rw_len equ $ - send_msg +send_msg_login_len equ 7 recv_msg: @@ -381,4 +411,3 @@ FR_LOCKED, /* (16) The operation is rejected according to the file sharing poli FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */ FR_INVALID_PARAMETER /* (19) Given parameter is invalid */ - -- 2.39.2