X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp-cpm3.git/blobdiff_plain/1f1b7dfac87235698d333e7078e8bd28397b0315..958f610fd7c11481fae54d758bf34619d161554a:/cbios/cfio.180 diff --git a/cbios/cfio.180 b/cbios/cfio.180 index a237bd6..fc3bea1 100644 --- a/cbios/cfio.180 +++ b/cbios/cfio.180 @@ -12,26 +12,23 @@ extrn @xdph extrn @adrv,@rdrv extrn @trk,@sect,@cnt - extrn @dma,@dbnk,@cbnk + extrn @dma,@dbnk ; System Control Block variables 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 phex2 - extrn pr.decl - extrn ?pderr ; print BIOS disk error header - extrn ?conin,?cono ; con in and out - extrn ?const ; get console status - extrn ?bnksl - - extrn bnk2phy ; - extrn add_hla + extrn ?pmsg ; print message @ + extrn pr.idx ; print indexed message + extrn pr.inln ; print inline message + extrn pr.decl ; print 32 bit decimal number + extrn pr.errors ; print BIOS disk error header + extrn ?cono ; console out + extrn bnk2phy ; translate banked to physical linear address + extrn add_hla ; add to extrn gstimer ; get timer short (16 bit) ; Port Address Equates @@ -363,6 +360,8 @@ cfi_error: ld a,1 ; return with A=1 on error ret +;------------------------------------------------------------------------------- +; print char, skipping leading blanks pr_char_nlbl: bit 0,b @@ -371,6 +370,9 @@ pr_char_nlbl: ret z res 0,b ; fall thru + +; print character, saving hl, de, bc + pr_char: push hl push de @@ -615,24 +617,23 @@ cf$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 cf$read: - ld de,read$msg ; point at " Read " ld bc,M_DIM1*256 + CmdRd ; Transfermode: i/o to memory++ jr rw$common cf$write: - ld de,write$msg ; point at " Write " ld bc,0*256 + CmdWr ; Transfermode: memory++ to i/o rw$common: @@ -648,7 +649,9 @@ rw$common: endif rwc_new_sectors: - ld (operation$name),de ; save message for errors + ld (cfstack),sp + ld sp,cfstack + in0 a,(dcntl) and a,~(M_DMS1+M_DIM1+M_DIM0) or b @@ -705,7 +708,8 @@ retry: pop hl jr c,lba_ok ld a,1 ; block# >= partition size, return error - ret + jp exit +; ret lba_ok: WAITREADY @@ -762,116 +766,61 @@ err_out: pop bc ld e,a and 10001001b ; Busy, DRQ, or Error? - ret z ; 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 + jr z,exit +; ret z ; Return to BDOS if no error - ; Had permanent error, print message like: - ; BIOS Err on d: T-nn, S-mm, , Retry ? + ld hl,print_details + call pr.errors + jp z,retry ; Yes, then retry once more + ; otherwise, + xor a + ld (residual),a - call ?pderr ; print message header + ld a,1 ; return hard error to BDOS +exit: + ld sp,(cfstack) + ret - ld hl,(operation$name) - call ?pmsg ; last function (read or write) +;------------------------------------------------------------------------------- +print_details: ld hl,msg$drq bit 3,e call nz,?pmsg bit 0,e - jr z,prompt + ret z in a,(IDEErr) - ld hl,error$table ; point at table of message addresses + ld e,8 errm1: - ld e,(hl) - inc hl - ld d,(hl) - inc hl ; get next message address - add a,a - push af ; shift left and push residual bits with status - ex de,hl - call c,?pmsg - ex de,hl ; print message, saving table pointer - pop af - jr nz,errm1 ; if any more bits left, continue - -prompt: - call pr.inln - db ' Retry (Y/N) ? ',0 - - call u$conin$echo ; get operator response - cp 'Y' - jp z,retry ; Yes, then retry - -hard$error: - ; otherwise, - xor a - ld (residual),a - - ld a,1 ; return hard error to BDOS - ret - -cancel: ; here to abort job - jp ?wboot ; leap directly to warmstart vector - - -; get console input, echo it, and shift to upper case - -u$conin$echo: - push bc -u$c0: - call ?const - or a - jr z,u$c1 ; see if any char already struck - call ?conin - jr u$c0 ; yes, eat it and try again -u$c1: - call ?conin + ld hl,b0$msg ; point at message[0] + dec e ; index of next message + add a,a ; shift left and push residual bits with status push af - ld c,a - cp ' '-1 - call nc,?cono + ld a,e + call c,pr.idx ; print it, if bit is set. pop af - pop bc - cp 'a' - ret c - sub 'a'-'A' ; make upper case + jr nz,errm1 ; if any more bits left, continue ret - ; error message components +;------------------------------------------------------------------------------- +; error message components -operation$name: - dw read$msg -read$msg: - db ', Read, ',0 -write$msg: - db ', Write, ',0 msg$drq: db 'DRQ, ',0 -error$table: - dw b7$msg - dw b6$msg - dw b5$msg - dw b4$msg - dw b3$msg - dw b2$msg - dw b1$msg - dw b0$msg - -b7$msg: db ' Bad Block detected,',0 -b6$msg: db ' Uncorrectable Data Error,',0 -b5$msg: db ' Media Changed,',0 -b4$msg: db ' Sector ID Not Found,',0 -b3$msg: db ' Media Change Requst,',0 -b2$msg: db ' Aborted Command,',0 -b1$msg: db ' Track 0 Not Found,',0 -b0$msg: db ' AM Not Found (or general error),',0 +b7$msg: db ' Bad Block detected,',0 +b6$msg: db ' Uncorrectable Data Error,',0 +b5$msg: db ' Media Changed,',0 +b4$msg: db ' Sector ID Not Found,',0 +b3$msg: db ' Media Change Requst,',0 +b2$msg: db ' Aborted Command,',0 +b1$msg: db ' Track 0 Not Found,',0 +b0$msg: db ' AM Not Found (or general error),',0 + db 0 + +;------------------------------------------------------------------------------- residual: db 0 @@ -882,4 +831,10 @@ parttbl: tmpsecbuf: ;temporary sector buffer ds 512 + rept 80 + db 07CH + endm +cfstack:: + dw 0 + end