X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp-cpm3.git/blobdiff_plain/b625464d4bbdadce5b262e6b1b8d5eca16fa227d..f1710b4798b98078e7d1c8d07691ec1aea03855f:/cbios/sdio.180 diff --git a/cbios/sdio.180 b/cbios/sdio.180 index c706aa6..774ed12 100644 --- a/cbios/sdio.180 +++ b/cbios/sdio.180 @@ -10,6 +10,7 @@ ; Variables containing parameters passed by BDOS + extrn @xdph extrn @adrv,@rdrv extrn @trk,@sect,@cnt extrn @dma,@dbnk @@ -57,6 +58,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 @@ -117,8 +123,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 @@ -129,6 +143,8 @@ dpbsimhd512: ; called for first time initialization. sd$init0: + call pr.inln ; + db 'sdio: SD Card driver'cr,lf,0 ret sd$init1: @@ -145,6 +161,9 @@ sd$init7: ; be logged into for the purpose of density determination. ; It may adjust the parameters contained in the disk ; parameter header pointed at by +; +; absolute drive number in @adrv (8 bits) +0 +; relative drive number in @rdrv (8 bits) +1 sd$login: xor a @@ -176,8 +195,11 @@ sd$login: ld b,recv_msg_len ; max receive message len call msg.recv -; ld a,(recv_msg_rc) -; or a + ld a,(recv_msg_rc) + or a + ret z + ld hl,0 + ld (@xdph),hl ret ; @@ -313,21 +335,24 @@ prompt: call u$conin$echo ; get operator response cp 'Y' - jr z,retry ; Yes, then retry 10 more times + jr z,retry ; Yes, then retry once more hard$error: ; otherwise, xor a ld (residual),a - - ld a,1 ; return hard error to BDOS + ld a,(recv_msg_rc) ; return hard error to BDOS + ld c,0ffh + cp 6 ; media changed? + jr z,e_exit + ld c,2 + cp 5 ; disk read only? + jr z,e_exit + dec c +e_exit: + ld a,c ret -cancel: ; here to abort job - jp ?wboot ; leap directly to warmstart vector - - - ; Print message to error code in A ; @@ -417,15 +442,19 @@ read$msg: write$msg: db ', Write, ',0 + ; general driver errors + drvmsg0: db 'Unknown Error, ',0 drvmsg1: db 'Invalid Parameter(s), ',0 drvmsg2: db 'Invalid Drive, ',0 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 3 - +drvmsg_count equ 7 -; table of pointers to error message strings + ; fat file system errors fr$msg0: db 'Unknown Error,',0 fr$msg1: db 'DISK_ERR,',0 @@ -449,6 +478,6 @@ 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 20 +fr$msg$count equ 21 end