151
|
1 ********************************************************************
|
|
2 * CCHDisk - Tandy hard disk driver
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Ed. Comments Who YY/MM/DD
|
|
7 * ------------------------------------------------------------------
|
201
|
8 * 4 From Tandy OS-9 Level One VR 02.00.00
|
151
|
9
|
0
|
10 nam CCHDisk
|
|
11 ttl Tandy hard disk driver
|
|
12
|
|
13 * Disassembled 98/08/23 17:28:39 by Disasm v1.6 (C) 1988 by RML
|
|
14
|
|
15 ifp1
|
|
16 use defsfile
|
|
17 use rbfdefs
|
|
18 endc
|
|
19
|
|
20 tylg set Drivr+Objct
|
|
21 atrv set ReEnt+rev
|
|
22 rev set $01
|
201
|
23 edition set 4
|
0
|
24
|
|
25 mod eom,name,tylg,atrv,start,size
|
|
26
|
257
|
27 rmb DRVBEG
|
0
|
28 u000F rmb 91
|
|
29 u006A rmb 61
|
|
30 u00A7 rmb 2
|
|
31 u00A9 rmb 1
|
|
32 u00AA rmb 1
|
|
33 u00AB rmb 2
|
|
34 u00AD rmb 2
|
|
35 u00AF rmb 1
|
|
36 u00B0 rmb 1
|
|
37 u00B1 rmb 1
|
|
38 u00B2 rmb 1
|
|
39 u00B3 rmb 1
|
|
40 u00B4 rmb 1
|
|
41 u00B5 rmb 1
|
|
42 u00B6 rmb 1
|
|
43 u00B7 rmb 1
|
|
44 u00B8 rmb 1
|
|
45 u00B9 rmb 1
|
|
46 u00BA rmb 1
|
|
47 u00BB rmb 1
|
|
48 u00BC rmb 2
|
|
49 u00BE rmb 1
|
|
50 u00BF rmb 2
|
|
51 u00C1 rmb 2
|
|
52 size equ .
|
256
|
53
|
|
54 fcb DIR.+SHARE.+PREAD.+PWRIT.+PEXEC.+READ.+WRITE.+EXEC.
|
0
|
55
|
1068
|
56 IFGT Level-1
|
|
57 name fcs /CC3HDisk/
|
|
58 ELSE
|
0
|
59 name fcs /CCHDisk/
|
1068
|
60 ENDC
|
0
|
61 fcb edition
|
|
62
|
|
63 start lbra Init
|
|
64 lbra Read
|
|
65 lbra Write
|
|
66 lbra GetStat
|
|
67 lbra SetStat
|
|
68 lbra Term
|
|
69
|
|
70 * Init
|
|
71 *
|
|
72 * Entry:
|
|
73 * Y = address of device descriptor
|
|
74 * U = address of device memory area
|
|
75 *
|
|
76 * Exit:
|
|
77 * CC = carry set on error
|
|
78 * B = error code
|
|
79 *
|
|
80 Init lbsr L04D4
|
|
81 lda >$FF51
|
|
82 cmpa #$08
|
|
83 beq L0037
|
|
84 comb
|
|
85 ldb #E$NotRdy
|
|
86 bra L0083
|
|
87 L0037 lbsr L04C0
|
|
88 bcs L0083
|
|
89 ldd #$FFFF
|
|
90 std >u00A9,u
|
|
91 std >u00A7,u
|
|
92 leax <$25,y
|
|
93 ldd ,x++
|
|
94 sta >u00B3,u
|
|
95 stb >u00BE,u
|
|
96 ldd ,x++
|
|
97 std >u00BF,u
|
|
98 ldd ,x++
|
|
99 std >u00C1,u
|
|
100 lda ,x
|
|
101 sta >u00B2,u
|
|
102 lda #$04
|
|
103 leay u000F,u
|
|
104 ldb #$FF
|
|
105 L006C stb ,y
|
|
106 stb <$15,y
|
|
107 leay <$26,y
|
|
108 deca
|
|
109 bne L006C
|
|
110 ldd #256
|
|
111 pshs u
|
|
112 os9 F$SRqMem
|
|
113 tfr u,x
|
|
114 puls u
|
|
115 L0083 bcs L00C7
|
|
116 stx >u00AB,u
|
|
117 leax >$0100,x
|
|
118 stx >u00AD,u
|
|
119 bra L00C6
|
|
120
|
|
121 * Term
|
|
122 *
|
|
123 * Entry:
|
|
124 * U = address of device memory area
|
|
125 *
|
|
126 * Exit:
|
|
127 * CC = carry set on error
|
|
128 * B = error code
|
|
129 *
|
|
130 Term pshs u
|
|
131 ldu >u00AB,u
|
|
132 ldd #256
|
|
133 os9 F$SRtMem
|
|
134 puls u
|
|
135
|
|
136 * GetStat
|
|
137 *
|
|
138 * Entry:
|
|
139 * A = function code
|
|
140 * Y = address of path descriptor
|
|
141 * U = address of device memory area
|
|
142 *
|
|
143 * Exit:
|
|
144 * CC = carry set on error
|
|
145 * B = error code
|
|
146 *
|
|
147 GetStat clrb
|
|
148 rts
|
|
149
|
|
150 * Read
|
|
151 *
|
|
152 * Entry:
|
|
153 * B = MSB of the disk's LSN
|
|
154 * X = LSB of the disk's LSN
|
|
155 * Y = address of path descriptor
|
|
156 * U = address of device memory area
|
|
157 *
|
|
158 * Exit:
|
|
159 * CC = carry set on error
|
|
160 * B = error code
|
|
161 *
|
|
162 Read lbsr L04D4
|
|
163 cmpx #$0000
|
|
164 bne L00CB
|
|
165 tstb
|
|
166 bne L00CB
|
|
167 bsr L00D1
|
|
168 bcs L00C7
|
|
169 ldx $08,y
|
|
170 pshs y,x
|
|
171 ldy >u00A7,u
|
|
172 ldb #$14
|
|
173 L00BD lda b,x
|
|
174 sta b,y
|
|
175 decb
|
|
176 bpl L00BD
|
|
177 puls y,x
|
|
178 L00C6 clrb
|
|
179 L00C7 lbsr L04E1
|
|
180 rts
|
|
181 L00CB bsr L00D1
|
|
182 bcs L00C7
|
|
183 bra L00C6
|
|
184 L00D1 lbsr L033F
|
|
185 bcs L00E3
|
|
186 ldx $08,y
|
|
187 lda #$02
|
|
188 sta >u00B9,u
|
|
189 lda #$20
|
|
190 lbsr L028C
|
|
191 L00E3 rts
|
|
192
|
|
193 * Write
|
|
194 *
|
|
195 * Entry:
|
|
196 * B = MSB of the disk's LSN
|
|
197 * X = LSB of the disk's LSN
|
|
198 * Y = address of path descriptor
|
|
199 * U = address of device memory area
|
|
200 *
|
|
201 * Exit:
|
|
202 * CC = carry set on error
|
|
203 * B = error code
|
|
204 *
|
|
205 Write lbsr L04D4
|
|
206 bsr L014A
|
|
207 bcs L00C7
|
|
208 pshs x,b
|
|
209 bsr L0100
|
|
210 puls x,b
|
|
211 bcs L00C7
|
|
212 tst <$28,y
|
|
213 bne L00C6
|
|
214 bsr L0113
|
|
215 bcc L00C6
|
|
216 ldb <$00F5
|
|
217 bra L00C7
|
|
218 L0100 lbsr L033F
|
|
219 bcs L0112
|
|
220 lda #$03
|
|
221 sta >u00B9,u
|
|
222 lda #$30
|
|
223 ldx $08,y
|
|
224 lbsr L028C
|
|
225 L0112 rts
|
|
226 L0113 pshs x,b,a
|
|
227 ldx $08,y
|
|
228 pshs x
|
|
229 ldx >u00AB,u
|
|
230 stx $08,y
|
|
231 ldx $04,s
|
|
232 bsr L00D1
|
|
233 puls x
|
|
234 stx $08,y
|
|
235 bcs L0148
|
|
236 lda #$20
|
|
237 pshs u,y,a
|
|
238 ldy >u00AB,u
|
|
239 tfr x,u
|
|
240 L0134 ldx ,u
|
|
241 cmpx ,y
|
|
242 bne L0144
|
257
|
243 leau $08,u
|
0
|
244 leay $08,y
|
|
245 dec ,s
|
|
246 bne L0134
|
|
247 bra L0146
|
|
248 L0144 orcc #Carry
|
|
249 L0146 puls u,y,a
|
|
250 L0148 puls pc,x,b,a
|
|
251 L014A pshs b
|
|
252 ldb >$FF50
|
|
253 beq L0179
|
|
254 lda <$21,y
|
|
255 bne L015C
|
|
256 andb #$80
|
|
257 bne L0174
|
|
258 bra L0179
|
|
259 L015C cmpa #$01
|
|
260 bne L0166
|
|
261 andb #$40
|
|
262 bne L0174
|
|
263 bra L0179
|
|
264 L0166 cmpa #$02
|
|
265 bne L0170
|
|
266 andb #$20
|
|
267 bne L0174
|
|
268 bra L0179
|
|
269 L0170 andb #$10
|
|
270 beq L0179
|
|
271 L0174 comb
|
|
272 ldb #E$WP
|
|
273 stb ,s
|
|
274 L0179 puls pc,b
|
|
275
|
|
276 * SetStat
|
|
277 *
|
|
278 * Entry:
|
|
279 * A = function code
|
|
280 * Y = address of path descriptor
|
|
281 * U = address of device memory area
|
|
282 *
|
|
283 * Exit:
|
|
284 * CC = carry set on error
|
|
285 * B = error code
|
|
286 *
|
|
287 SetStat lbsr L04D4
|
|
288 lbsr L0460
|
|
289 ldx PD.RGS,y
|
|
290 ldb R$B,x
|
|
291 cmpb #SS.Reset
|
|
292 bne L018E
|
|
293 lbsr L04A5
|
|
294 bra L01A1
|
|
295 L018E cmpb #SS.WTrk
|
|
296 bne L0196
|
|
297 bsr L01B5
|
|
298 bra L01A1
|
|
299 L0196 cmpb #SS.SQD
|
|
300 bne L019E
|
|
301 bsr L01A8
|
|
302 bra L01A1
|
|
303 L019E comb
|
|
304 ldb #E$UnkSvc
|
|
305 L01A1 lbcs L00C7
|
|
306 lbra L00C6
|
|
307
|
|
308 L01A8 ldd <$25,y
|
|
309 exg a,b
|
|
310 std >u00B6,u
|
|
311 lbsr L0496
|
|
312 rts
|
|
313
|
|
314 L01B5 ldd $8,x
|
|
315 cmpd #$0000
|
|
316 bne L01C3
|
|
317 ldd $6,x
|
|
318 cmpa #$00
|
|
319 beq L01C5
|
|
320 L01C3 clrb
|
|
321 rts
|
|
322 L01C5 pshs u,y,x
|
|
323 clr >u00AF,u
|
|
324 clr >u00B0,u
|
|
325 clr >u00B1,u
|
|
326 lda <$2A,y
|
|
327 bsr L023D
|
|
328 L01D8 lda <$2A,y
|
|
329 sta >u00B4,u
|
|
330 lda >u00B2,u
|
|
331 sta >u00B5,u
|
|
332 lda >u00B8,u
|
|
333 anda #$F8
|
|
334 sta >u00B8,u
|
|
335 lda >u00B1,u
|
|
336 ora >u00B8,u
|
|
337 sta >u00B8,u
|
|
338 ldd >u00AF,u
|
|
339 exg a,b
|
|
340 std >u00B6,u
|
|
341 lda #$03
|
|
342 sta >u00B9,u
|
|
343 lda #$50
|
|
344 ldx >u00AB,u
|
|
345 bsr L028C
|
|
346 bcs L023B
|
|
347 lda >u00B1,u
|
|
348 inca
|
|
349 sta >u00B1,u
|
|
350 cmpa <$27,y
|
|
351 bcs L01D8
|
|
352 clr >u00B1,u
|
|
353 ldd >u00AF,u
|
|
354 addd #$0001
|
|
355 std >u00AF,u
|
|
356 cmpd <$25,y
|
|
357 bcs L01D8
|
|
358 clrb
|
|
359 L023B puls pc,u,y,x
|
|
360 L023D pshs y,x,b,a
|
|
361 ldb <$2D,y
|
|
362 stb >u00BB,u
|
|
363 sta >u00BA,u
|
|
364 lsla
|
|
365 ldx >u00AB,u
|
|
366 leay a,x
|
|
367 nega
|
|
368 pshs y,x,b,a
|
|
369 clra
|
|
370 L0255 clr ,x
|
|
371 sta $01,x
|
|
372 inca
|
|
373 cmpa >u00BA,u
|
|
374 beq L0278
|
|
375 ldb >u00BB,u
|
|
376 lslb
|
|
377 abx
|
|
378 cmpx $04,s
|
|
379 bcs L026E
|
|
380 ldb ,s
|
|
381 leax b,x
|
|
382 L026E cmpx $02,s
|
|
383 bne L0255
|
|
384 leax $02,x
|
|
385 stx $02,s
|
|
386 bra L0255
|
|
387 L0278 ldy $04,s
|
|
388 lda #$00
|
|
389 L027D cmpy >u00AD,u
|
|
390 beq L0288
|
|
391 sta ,y+
|
|
392 bra L027D
|
|
393 L0288 leas $06,s
|
|
394 puls pc,y,x,b,a
|
|
395 L028C pshs y,x,a
|
|
396 leax >u00B3,u
|
|
397 ldy #$FF59
|
|
398 ldb #$06
|
|
399 L0298 lda ,x+
|
|
400 sta ,y+
|
|
401 decb
|
|
402 bne L0298
|
|
403 lda ,s
|
|
404 sta ,y
|
|
405 ldy $03,s
|
|
406 ldx $01,s
|
|
407 lda >u00B9,u
|
|
408 cmpa #$03
|
|
409 beq L02C6
|
|
410 bsr L02E1
|
|
411 cmpa #$02
|
|
412 beq L02BA
|
|
413 L02B6 bsr L02F2
|
|
414 puls pc,y,x,a
|
|
415 L02BA bsr L02EB
|
|
416 L02BC lda >$FF58
|
|
417 sta ,x+
|
|
418 decb
|
|
419 bne L02BC
|
|
420 bra L02B6
|
|
421 L02C6 lda ,x+
|
|
422 sta >$FF58
|
|
423 decb
|
|
424 bne L02C6
|
|
425 bsr L02E1
|
|
426 bra L02B6
|
|
427 L02D2 lda >$FF5F
|
|
428 pshs a
|
|
429 lda >$FF5F
|
|
430 cmpa ,s
|
|
431 leas $01,s
|
|
432 bne L02D2
|
|
433 rts
|
|
434 L02E1 pshs a
|
|
435 L02E3 bsr L02D2
|
|
436 anda #$80
|
|
437 bne L02E3
|
|
438 puls pc,a
|
|
439 L02EB bsr L02D2
|
|
440 bita #$08
|
|
441 beq L02EB
|
|
442 rts
|
|
443 L02F2 bsr L02D2
|
|
444 bita #$01
|
|
445 bne L02FA
|
|
446 clrb
|
|
447 rts
|
|
448 L02FA comb
|
|
449 bita #$02
|
|
450 beq L0302
|
|
451 lbsr L04F1
|
|
452 L0302 lda >$FF59
|
|
453 bita #$80
|
|
454 bne L0332
|
|
455 bita #$40
|
|
456 bne L031F
|
|
457 bita #$10
|
|
458 bne L0322
|
|
459 bita #$04
|
|
460 bne L0336
|
|
461 bita #$02
|
|
462 bne L0322
|
|
463 bita #$01
|
|
464 bne L0326
|
|
465 clrb
|
|
466 rts
|
|
467 L031F ldb #E$CRC
|
|
468 rts
|
|
469 L0322 comb
|
|
470 ldb #E$Seek
|
|
471 rts
|
|
472 L0326 comb
|
|
473 ldb #E$Read
|
|
474 rts
|
|
475 comb
|
|
476 ldb #E$Write
|
|
477 rts
|
|
478 L032E comb
|
|
479 ldb #E$NotRdy
|
|
480 rts
|
|
481 L0332 comb
|
|
482 ldb #E$Unit
|
|
483 rts
|
|
484 L0336 lda >$FF5F
|
|
485 bita #$10
|
|
486 beq L0322
|
|
487 bra L032E
|
|
488 L033F lbsr L0460
|
|
489 bcs L0346
|
|
490 bsr L0347
|
|
491 L0346 rts
|
|
492 L0347 pshs y,x,b
|
|
493 lbsr L04C0
|
|
494 lbcs L0428
|
|
495 stx >u00BC,u
|
|
496 tstb
|
|
497 bne L0380
|
|
498 cmpx #$0000
|
|
499 bne L0380
|
|
500 leax >u00B4,u
|
|
501 ldd #$0001
|
|
502 sta $01,x
|
|
503 sta $02,x
|
|
504 sta $03,x
|
|
505 stb ,x
|
|
506 lda >u00B8,u
|
|
507 anda #$F8
|
|
508 sta >u00B8,u
|
|
509 tst >u00AA,u
|
|
510 lbne L040B
|
|
511 lbra L0427
|
|
512 L0380 ldy >u00A7,u
|
|
513 cmpb ,y
|
|
514 lbhi L042E
|
|
515 bcs L0393
|
|
516 cmpx $01,y
|
|
517 lbcc L042E
|
|
518 L0393 clr >u00B6,u
|
|
519 clr >u00B7,u
|
|
520 ldb ,s
|
|
521 ldx $01,s
|
|
522 ldy $03,s
|
|
523 tstb
|
|
524 bne L03B4
|
|
525 pshs x,b,a
|
|
526 lda <$2A,y
|
|
527 ldb <$27,y
|
|
528 mul
|
|
529 subd $02,s
|
|
530 puls x,b,a
|
|
531 bhi L03D5
|
|
532 L03B4 pshs u,y,x,b,a
|
|
533 lda >u00BE,u
|
|
534 ldy >u00BF,u
|
|
535 ldu >u00C1,u
|
|
536 bsr L0435
|
|
537 ldu $06,s
|
|
538 std >u00BC,u
|
|
539 tfr x,d
|
|
540 exg a,b
|
|
541 std >u00B6,u
|
|
542 puls u,y,x,b,a
|
|
543 L03D5 clra
|
|
544 ldb <$2A,y
|
|
545 beq L042E
|
|
546 pshs b,a
|
|
547 pshs a
|
|
548 ldd >u00BC,u
|
|
549 L03E3 subd $01,s
|
|
550 bcs L03EB
|
|
551 inc ,s
|
|
552 bra L03E3
|
|
553 L03EB addd $01,s
|
|
554 stb >u00B5,u
|
|
555 lda >u00B8,u
|
|
556 anda #$F8
|
|
557 ora ,s
|
|
558 sta >u00B8,u
|
|
559 leas $03,s
|
|
560 lda #$01
|
|
561 sta >u00B4,u
|
|
562 tst >u00AA,u
|
|
563 beq L0427
|
|
564 L040B clr >u00AA,u
|
|
565 ldy >u00A7,u
|
|
566 lda <$15,y
|
|
567 ldy $03,s
|
|
568 cmpa #$FF
|
|
569 bne L0423
|
|
570 lbsr L04A5
|
|
571 bra L0428
|
|
572 L0423 bsr L0496
|
|
573 bra L0428
|
|
574 L0427 clrb
|
|
575 L0428 bcc L042C
|
|
576 stb ,s
|
|
577 L042C puls pc,y,x,b
|
|
578 L042E puls b
|
|
579 comb
|
|
580 ldb #E$Sect
|
|
581 puls pc,y,x
|
|
582 L0435 pshs u,y,x,b,a
|
|
583 ldd $01,s
|
|
584 L0439 subd $04,s
|
|
585 bcc L0443
|
|
586 addd $04,s
|
|
587 andcc #^Carry
|
|
588 bra L0445
|
|
589 L0443 orcc #Carry
|
|
590 L0445 rol $03,s
|
|
591 rolb
|
|
592 rola
|
|
593 dec ,s
|
|
594 bne L0439
|
|
595 std ,s
|
|
596 andb $06,s
|
|
597 stb $02,s
|
|
598 ldb $07,s
|
|
599 beq L045E
|
|
600 L0457 lsr ,s
|
|
601 ror $01,s
|
|
602 decb
|
|
603 bne L0457
|
|
604 L045E puls pc,u,y,x,b,a
|
|
605 L0460 lda <$21,y
|
|
606 cmpa #$04
|
|
607 lbcc L0332
|
|
608 cmpa >u00A9,u
|
|
609 beq L0495
|
|
610 sta >u00A9,u
|
|
611 dec >u00AA,u
|
|
612 lsla
|
|
613 lsla
|
|
614 lsla
|
|
615 pshs a
|
|
616 lda >u00B8,u
|
|
617 anda #$E7
|
|
618 ora ,s
|
|
619 leas $01,s
|
|
620 sta >u00B8,u
|
|
621 pshs x
|
|
622 ldx <$1E,y
|
|
623 stx >u00A7,u
|
|
624 puls x
|
|
625 L0495 rts
|
|
626 L0496 clr >u00B9,u
|
|
627 lda <$22,y
|
|
628 anda #$0F
|
|
629 ora #$70
|
|
630 lbsr L028C
|
|
631 rts
|
|
632 L04A5 clr >u00B9,u
|
|
633 lda <$22,y
|
|
634 anda #$0F
|
|
635 ora #$10
|
|
636 lbsr L028C
|
|
637 bcs L04BF
|
|
638 ldx >u00A7,u
|
|
639 clr <$15,x
|
|
640 clr <$16,x
|
|
641 L04BF rts
|
|
642
|
|
643 L04C0 pshs b,a
|
|
644 clrb
|
|
645 L04C3 lda >$FF5F
|
|
646 bita #$40
|
|
647 bne L04D2
|
|
648 decb
|
|
649 bne L04C3
|
|
650 ldb #E$NotRdy
|
|
651 stb $01,s
|
|
652 comb
|
|
653 L04D2 puls pc,b,a
|
|
654
|
|
655 L04D4 dec <u006A
|
|
656 lda #$02
|
|
657 sta >MPI.Slct
|
|
658 lda #$08
|
|
659 L04DD sta >$FF51
|
|
660 rts
|
|
661
|
|
662 L04E1 pshs cc
|
|
663 lda #$00
|
|
664 sta >$FF51
|
|
665 lda #$03
|
|
666 sta >MPI.Slct
|
|
667 clr <u006A
|
|
668 puls pc,cc
|
|
669
|
|
670 L04F1 lda #$10
|
|
671 bra L04DD
|
|
672
|
|
673 emod
|
|
674 eom equ *
|
|
675 end
|
|
676
|