X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp-cpm3.git/blobdiff_plain/c6fa15797141c957dff6863f3bb212966f1a27fa..afbcea2d821d1166ae347338ae52a64f3ee51e57:/cbios/sdio.180 diff --git a/cbios/sdio.180 b/cbios/sdio.180 index 37b7276..28ed4dd 100644 --- a/cbios/sdio.180 +++ b/cbios/sdio.180 @@ -10,7 +10,7 @@ ; Variables containing parameters passed by BDOS - extrn @xdph + extrn @xdph,@op extrn @adrv,@rdrv extrn @trk,@sect,@cnt extrn @dma,@dbnk @@ -19,19 +19,17 @@ extrn @ermde ; BDOS error mode - ; Utility routines in standard BIOS + ; Utility routines extrn ?wboot ; warm boot vector - extrn ?pmsg,pr.inln ; print message @, print inline message - extrn pr.crlf ; print - extrn ?pderr ; print BIOS disk error header - extrn ?conin,?cono ; con in and out - extrn ?const ; get console status - - extrn bnk2phy ; - extrn msg.sm ; - extrn msg.recv ; - extrn add_hla + extrn ?pmsg ; print message @ + extrn pr.idx ; print indexed message + extrn pr.inln,pr.crlf ; print inline message, print + extrn pr.errors ; print BIOS disk error header + extrn bnk2phy ; translate banked to physical linear address + extrn msg.sm ; send message to AVR + extrn msg.recv ; receive message from AVR + extrn add_hla ; add to ; Port Address Equates @@ -41,7 +39,7 @@ ; CP/M 3 Disk definition macros - include cpm3slr.lib + maclib cpm3slr.lib ; Z180 macro library instruction definitions (ignored by slr180) @@ -58,6 +56,11 @@ bell equ 7 ; Extended Disk Parameter Headers (XPDHs) + ; dph translate$table, - disk parameter header + ; disk$parameter$block, + ; checksum$size, (optional) + ; alloc$size (optional) + dw sd$write dw sd$read dw sd$login @@ -118,8 +121,16 @@ sd7: dph 0,dpbsimhd512 cseg ; DPB must be resident + ; dpb physical$sector$size, - disk parameter block + ; physical$sectors$per$track, + ; number$tracks, + ; block$size, + ; number$dir$entries, + ; track$offset, + ; checksum$vec$size (optional) + dpbsimhd512: - dpb 512,8,2048,4096,1024,6 + dpb 512,8,2048,4096,1024,6,8100h dseg ; rest is banked @@ -194,27 +205,21 @@ sd$login: ; disk READ and WRITE entry points. ; these entries are called with the following arguments: ; -; absolute drive number in @adrv (8 bits) +0 -; relative drive number in @rdrv (8 bits) +1 -; 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 +; operation type (r/w) in @op (8 bits) +0 +; absolute drive number in @adrv (8 bits) +1 +; relative drive number in @rdrv (8 bits) +2 +; disk track address in @trk (16 bits) +3 +; disk sector address in @sect(16 bits) +5 +; multi sector count in @cnt (8 bits) +7 +; disk transfer address in @dma (16 bits) +8 +; disk transfer bank in @dbnk (8 bits) +10 ; pointer to XDPH in ; ; they transfer the appropriate data, perform retries ; if necessary, then return an error code in sd$read: - ld de,read$msg ; point at " Read " - ld c,1 - jr rw$common sd$write: - 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 @@ -241,14 +246,10 @@ rwc_new_sectors: ; and send it to AVR. 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,6 + ld hl,@op ;address of arguments + ld de,send_msg+1 + ld bc,7 ldir ld (de),a ;number of sectors inc de @@ -281,50 +282,9 @@ retry: or a ret z ; check status and return to BDOS if no error -; suppress error message if BDOS is returning errors to application... - - ld a,(@ermde) - cp 0ffh - jr z,hard$error - - ; Had permanent error, print message like: - ; BIOS Err on d: T-nn, S-mm, , Retry ? - - call ?pderr ; print message header - - ld hl,(operation$name) - call ?pmsg ; last function (read or write) - - ld a,(recv_msg_rc) - and a,07fh - jr z,fatfs_err - - ld hl,drvmsg0 ; point at first driver error message - ld c,drvmsg_count - call pdecoded - -fatfs_err: - ld a,(recv_msg_rc) - tst 080h - jr z,prompt ; no fatfs error - - call pr.inln - db 'FatFs: ',0 - - ld hl,fr$msg0 ; point at first FatFs message - ld c,fr$msg$count - ld a,(recv_msg_rc+1) - call pdecoded - -prompt: - call pr.inln - db ' Retry (Y/N) ? ',0 - - call u$conin$echo ; get operator response - cp 'Y' + ld hl,print_details + call pr.errors jr z,retry ; Yes, then retry once more - -hard$error: ; otherwise, xor a ld (residual),a @@ -340,59 +300,32 @@ e_exit: ld a,c ret -; Print message to error code in A -; +;------------------------------------------------------------------------------- -pdecoded: - push bc - push de - push hl ; put pointer to first message on stack - cp c - jr c,pdc_1 - xor a -pdc_1: - ld bc,0 - ld e,a ; save message number - xor a - inc e -pdc_nxt_str: - dec e - ex (sp),hl - jr z,pdc_found - ex (sp),hl - cpir - jr z,pdc_nxt_str - ; not found (should not happen) -pdc_found: - pop hl - call ?pmsg - pop de - pop bc - ret +print_details: + ld a,(recv_msg_rc) + push af + and a,07fh + jr z,fatfs_err + ld hl,drvmsg0 ; point at first driver error message + call pr.idx -; get console input, echo it, and shift to upper case +fatfs_err: + pop af + and 080h + ret z ; no fatfs error -u$conin$echo: + call pr.inln + db 'FatFs: ',0 - call ?const - or a - jr z,u$c1 ; see if any char already struck - call ?conin - jr u$conin$echo ; yes, eat it and try again -u$c1: - call ?conin - push af - ld c,a - cp ' '-1 - call nc,?cono - pop af - cp 'a' - ret c - sub 'a'-'A' ; make upper case - ret + ld hl,fr$msg0 ; point at first FatFs message + ld a,(recv_msg_rc+1) + jp pr.idx ; return via print routine +;------------------------------------------------------------------------------- + residual: db 0 @@ -420,15 +353,8 @@ recv_msg_rc: recv_msg_len equ $ - recv_msg - ; error message components - -operation$name: - dw read$msg -read$msg: - db ', Read, ',0 -write$msg: - db ', Write, ',0 - +;------------------------------------------------------------------------------- +; error message components ; general driver errors drvmsg0: db 'Unknown Error, ',0 @@ -438,8 +364,7 @@ drvmsg3: db 'Bus Timeout, ',0 drvmsg4: db 'Access beyond disk size, ',0 drvmsg5: db 'Write protected, ',0 drvmsg6: db 'No media, ',0 -drvmsg_size equ $ - drvmsg0 -drvmsg_count equ 7 + db 0 ; fat file system errors @@ -464,7 +389,6 @@ fr$msg17: db 'NOT_ENOUGH_CORE,',0 fr$msg18: db 'TOO_MANY_OPEN_FILES,',0 fr$msg19: db 'FR_INVALID_PARAMETER,',0 fr$msg20: db 'short read/write,',0 -fr$msg$size equ $ - fr$msg0 -fr$msg$count equ 21 + db 0 end