1 TITLE 'sd disk handler'
3 ; CP/M-80 Version 3 -- Modular BIOS
8 ; Disk drive dispatching tables for linked BIOS
10 public sd0,sd1,sd2,sd3
12 ; Variables containing parameters passed by BDOS
18 ; System Control Block variables
20 extrn @ermde ; BDOS error mode
22 ; Utility routines in standard BIOS
24 extrn ?wboot ; warm boot vector
25 extrn ?pmsg ; print message @<HL> up to 00, saves <BC> & <DE>
26 extrn ?pdec ; print binary number in <A> from 0 to 99.
27 extrn ?pderr ; print BIOS disk error header
28 extrn ?conin,?cono ; con in and out
29 extrn ?const ; get console status
37 ; Port Address Equates
42 ; CP/M 3 Disk definition macros
46 ; Z180 macro library instruction definitions (ignored by slr180)
50 ; common control characters
57 ; Extended Disk Parameter Headers (XPDHs)
63 db 0,0 ; relative drive zero
64 sd0: dph 0,dpbsimhd512
70 db 1,0 ; relative drive one
71 sd1: dph 0,dpbsimhd512
77 db 2,0 ; relative drive zero
78 sd2: dph 0,dpbsimhd512
84 db 3,0 ; relative drive one
85 sd3: dph 0,dpbsimhd512
88 cseg ; DPB must be resident
91 dpb 512,8,2048,4096,1024,6
96 ; Disk I/O routines for standardized BIOS interface
98 ; Initialization entry point.
99 ; called for first time initialization.
107 ret ; all initialization done by drive 0
112 ; This entry is called when a logical drive is about to
113 ; be logged into for the purpose of density determination.
114 ; It may adjust the parameters contained in the disk
115 ; parameter header pointed at by <DE>
119 ld (hl),0 ;login function
129 call bnk2phy ;phys. linear address
138 ld b,send_msg_login_len
142 ld b,recv_msg_len ; max receive message len
151 ; disk READ and WRITE entry points.
152 ; these entries are called with the following arguments:
154 ; absolute drive number in @adrv (8 bits) +0
155 ; relative drive number in @rdrv (8 bits) +1
156 ; multi sector count in @cnt (8 bits) +2 (currently unused)
157 ; disk track address in @trk (16 bits) +3
158 ; disk sector address in @sect(16 bits) +5
159 ; disk transfer address in @dma (16 bits) +7
160 ; disk transfer bank in @dbnk (8 bits) +9
161 ; pointer to XDPH in <DE>
163 ; they transfer the appropriate data, perform retries
164 ; if necessary, then return an error code in <A>
167 ld hl,read$msg ; point at " Read "
172 ld hl,write$msg ; point at " Write "
176 ; compute pysical transfer address
178 ; and send it to AVR.
181 ld (operation$name),HL ; save message for errors
185 ld hl,@adrv ;address of arguments
189 ld e,(hl) ;dma address
195 call bnk2phy ;phys. linear address
211 ld b,recv_msg_len ; max receive message len
215 ret z ; check status and return to BDOS if no error
217 ; suppress error message if BDOS is returning errors to application...
223 ; Had permanent error, print message like:
224 ; BIOS Err on d: T-nn, S-mm, <operation> <type>, Retry ?
226 call ?pderr ; print message header
228 ld hl,(operation$name)
229 call ?pmsg ; last function (read or write)
246 ld hl,fr$msg0 ; point at first message
248 ld e,a ; save message number
256 ld hl,fr$msg0 ; not found, point at first message
263 call ?pmsg ; print "<BEL>, Retry (Y/N) ? "
264 call u$conin$echo ; get operator response
266 jr z,more$retries ; Yes, then retry 10 more times
270 ret ; return hard error to BDOS
272 cancel: ; here to abort job
273 jp ?wboot ; leap directly to warmstart vector
278 ; get console input, echo it, and shift to upper case
281 jp z,u$c1 ; see if any char already struck
283 jp u$conin$echo ; yes, eat it and try again
292 sub 'a'-'a' ; make upper case
299 ds 1 ; subcommand (login/read/write)
302 ; -read/write- -login-
304 ds 2 ; @trk xdph address
305 send_msg_login_len equ $ - send_msg
308 send_msg_rw_len equ $ - send_msg
317 ds 4 ; room for additional parameter
318 recv_msg_len equ $ - recv_msg
321 ; error message components
331 ; table of pointers to error message strings
333 fr$msg0: db ' Unknown FatFs Error,',0
334 fr$msg1: db ' DISK_ERR,',0
335 fr$msg2: db ' INT_ERR,',0
336 fr$msg3: db ' NOT_READY,',0
337 fr$msg4: db ' NO_FILE,',0
338 fr$msg5: db ' NO_PATH,',0
339 fr$msg6: db ' INVALID_NAME,',0
340 fr$msg7: db ' DENIED,',0
341 fr$msg8: db ' EXIST,',0
342 fr$msg9: db ' INVALID_OBJECT,',0
343 fr$msg10: db ' WRITE_PROTECTED,',0
344 fr$msg11: db ' INVALID_DRIVE,',0
345 fr$msg12: db ' NOT_ENABLED,',0
346 fr$msg13: db ' NO_FILE_SYSTEM,',0
347 fr$msg14: db ' MKFS_ABORTED,',0
348 fr$msg15: db ' TIMEOUT,',0
349 fr$msg16: db ' LOCKED,',0
350 fr$msg17: db ' NOT_ENOUGH_CORE,',0
351 fr$msg18: db ' TOO_MANY_OPEN_FILES,',0
352 fr$msg19: db ' FR_INVALID_PARAMETER,',0
353 fr$msg$size equ $ - fr$msg0
357 db ' Retry (Y/N) ? ',0
362 /* File function return code (FRESULT) */
364 FR_OK = 0, /* (0) Succeeded */
365 FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */
366 FR_INT_ERR, /* (2) Assertion failed */
367 FR_NOT_READY, /* (3) The physical drive cannot work */
368 FR_NO_FILE, /* (4) Could not find the file */
369 FR_NO_PATH, /* (5) Could not find the path */
370 FR_INVALID_NAME, /* (6) The path name format is invalid */
371 FR_DENIED, /* (7) Access denied due to prohibited access or directory full */
372 FR_EXIST, /* (8) Access denied due to prohibited access */
373 FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */
374 FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */
375 FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
376 FR_NOT_ENABLED, /* (12) The volume has no work area */
377 FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */
378 FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */
379 FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */
380 FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */
381 FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */
382 FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */
383 FR_INVALID_PARAMETER /* (19) Given parameter is invalid */