1570
|
1 ********************************************************************
|
|
2 * rb1773 - Western Digital 1773 Disk Controller Driver
|
|
3 *
|
|
4 * A lot of references to **.CYL or <u00B6 using 16 bit registers can be
|
|
5 * changed to 8 bit registers with a +1 offset, since track #'s >255 are
|
|
6 * ignored
|
|
7 *
|
|
8 * NOTE: 512 bytes is reserved as a physical sector buffer. Any reads/
|
|
9 * writes are done from this buffer to the controller. Copies of the 256
|
|
10 * byte chunk needed are done by a block memory move
|
|
11
|
|
12 * $Id$
|
|
13 *
|
|
14 * Edt/Rev YYYY/MM/DD Modified by
|
|
15 * Comment
|
|
16 * ------------------------------------------------------------------
|
|
17 * 11 1993/05/12 ???
|
|
18 * Special opts for TC9 to slow controller reads and writes TFM's
|
|
19 * between sector buffers & in drive table init/copies.
|
|
20 * Changed software timing loop (drive spin-up) to F$Sleep for 32 ticks
|
|
21 * Shrunk (slowed slightly) error returns
|
|
22 * Added blobstop code
|
|
23 *
|
|
24 * 11r1 2003/09/03 Boisy G. Pitre
|
|
25 * Added code to sense if HW is present or not and return error if not.
|
|
26
|
|
27 nam rb1773
|
|
28 ttl Western Digital 1773 Disk Controller Driver
|
|
29
|
|
30 IFP1
|
|
31 use defsfile
|
|
32 ENDC
|
|
33
|
|
34 tylg set Drivr+Objct
|
|
35 atrv set ReEnt+rev
|
|
36 rev set $01
|
|
37 edition set 11
|
|
38
|
|
39 IFGT Level-1
|
|
40
|
|
41 * Configuration Settings
|
|
42 N.Drives equ 4 number of drives to support
|
|
43 TC9 equ 0 Set to 1 for TC9 special slowdowns
|
|
44 PRECOMP equ 0 Set to 1 to turn on write precompensation
|
|
45
|
|
46 * WD-17X3 Definitions
|
|
47 WD_Cmd equ $08
|
|
48 WD_Stat equ WD_Cmd
|
|
49 WD_Trak equ $09
|
|
50 WD_Sect equ $0A
|
|
51 WD_Data equ $0B
|
|
52
|
|
53 mod eom,name,tylg,atrv,start,size
|
|
54
|
|
55 u0000 rmb DRVBEG+(DRVMEM*N.Drives)
|
|
56 u00A7 rmb 2 Last drive table accessed (ptr)
|
|
57 u00A9 rmb 1 Bit mask for control reg (drive #, side,etc)
|
|
58 u00AA rmb 1
|
|
59 sectbuf rmb 2 Ptr to 512 byte sector buffer
|
|
60 u00AD rmb 1
|
|
61 u00AE rmb 1
|
|
62 FBlock rmb 2 block number for format
|
|
63 IFGT Level-1
|
|
64 FTask rmb 1 task number for format
|
|
65 ENDC
|
|
66 u00B1 rmb 2 Vi.Cnt word for VIRQ
|
|
67 u00B3 rmb 2 Vi.Rst word for VIRQ
|
|
68 u00B5 rmb 1 Vi.Stat byte for VIRQ (drive motor timeout)
|
|
69 u00B6 rmb 2 OS9's logical sector #
|
|
70 u00B8 rmb 1 PCDOS (512 byte sector) sector #
|
|
71 size equ .
|
|
72
|
|
73 fcb DIR.+SHARE.+PEXEC.+PWRIT.+PREAD.+EXEC.+UPDAT.
|
|
74
|
|
75 name equ *
|
|
76 IFEQ Level-1
|
|
77 fcs /CCDisk/
|
|
78 ELSE
|
|
79 fcs /rb1773/
|
|
80 ENDC
|
|
81 fcb edition
|
|
82
|
|
83 VIRQCnt fdb $00F0 Initial count for VIRQ (240)
|
|
84
|
|
85 IRQPkt fcb $00 Normal bits (flip byte)
|
|
86 fcb $01 Bit 1 is interrupt request flag (Mask byte)
|
|
87 fcb 10 Priority byte
|
|
88
|
|
89 * Init
|
|
90 *
|
|
91 * Entry:
|
|
92 * Y = address of device descriptor
|
|
93 * U = address of device memory area
|
|
94 *
|
|
95 * Exit:
|
|
96 * CC = carry set on error
|
|
97 * B = error code
|
|
98 *
|
|
99 * New code added 09/03/2003 by Boisy G. Pitre
|
|
100 * Write a pattern to $FF4B and read it back to verify that the hardware
|
|
101 * does exist.
|
|
102 Init ldx V.PORT,u get Base port address
|
|
103 lda WD_Data,x get byte at FDC Data register
|
|
104 coma complement it to modify it
|
|
105 sta WD_Data,x write it
|
|
106 clrb
|
|
107 Init2 decb delay a bit...
|
|
108 bmi Init2
|
|
109 suba WD_Data,x read it back
|
|
110 lbne NoHW if not zero, we didn't read what we wrote
|
|
111 **
|
|
112 IFEQ Level-1
|
|
113 clr >D.DskTmr flag drive motor as not running
|
|
114 ELSE
|
|
115 clr <D.MotOn flag drive motor as not running
|
|
116 ENDC
|
|
117 leax WD_Stat,x point to Status/Command register
|
|
118 lda #$D0 force Interrupt command
|
|
119 sta ,x send to FDC
|
|
120 lbsr L0406 time delay for ~ 108 cycles
|
|
121 lda ,x eat status register
|
|
122 ldd #$FF*256+N.Drives 'invalid' value & # of drives
|
|
123 sta >u00B8,u set 512 byte sector # to bogus value
|
|
124 sta >u00B8+1,u
|
|
125 leax DRVBEG,u point to start of drive tables
|
|
126 L004B sta ,x DD.TOT MSB to bogus value
|
|
127 sta <V.TRAK,x init current track # to bogus value
|
|
128 leax <DRVMEM,x point to next drive table
|
|
129 decb done all 4 drives yet?
|
|
130 bne L004B no, init them all
|
|
131 leax >NMISvc,pc point to NMI service routine
|
|
132 IFGT Level-1
|
|
133 stx <D.NMI install as system NMI
|
|
134 ELSE
|
|
135 stx >D.XNMI+1 NMI jump vector operand
|
|
136 lda #$7E JMP code
|
|
137 sta >D.XNMI NMI jump vector opcode
|
|
138 ENDC
|
|
139 pshs y save device dsc. ptr
|
|
140 leay >u00B5,u point to Vi.Stat in VIRQ packet
|
|
141 tfr y,d make it the status register ptr for IRQ
|
|
142 leay >IRQSvc,pc point to IRQ service routine
|
|
143 leax >IRQPkt,pc point to IRQ packet
|
|
144 os9 F$IRQ install IRQ
|
|
145 puls y Get back device dsc. ptr
|
|
146 bcs Return If we can't install IRQ, exit
|
|
147 ldd #512 Request 512 byte sector buffer
|
|
148 pshs u Preserve device mem ptr
|
|
149 os9 F$SRqMem Request sector buffer
|
|
150 tfr u,x Move ptr to sector buffer to x
|
|
151 puls u Restore device mem ptr
|
|
152 bcs Return If error, exit with it
|
|
153 stx >sectbuf,u Save ptr to sector buffer
|
|
154
|
|
155 * GetStat
|
|
156 *
|
|
157 * Entry:
|
|
158 * A = function code
|
|
159 * Y = address of path descriptor
|
|
160 * U = address of device memory area
|
|
161 *
|
|
162 * Exit:
|
|
163 * CC = carry set on error
|
|
164 * B = error code
|
|
165 *
|
|
166 GetStat clrb no GetStt calls - return, no error, ignore
|
|
167 Return rts
|
|
168
|
|
169 * Term
|
|
170 *
|
|
171 * Entry:
|
|
172 * U = address of device memory area
|
|
173 *
|
|
174 * Exit:
|
|
175 * CC = carry set on error
|
|
176 * B = error code
|
|
177 *
|
|
178 Term leay >u00B1,u Point to VIRQ packet
|
|
179 IFNE H6309
|
|
180 tfr 0,x "remove"
|
|
181 ELSE
|
|
182 ldx #$0000
|
|
183 ENDC
|
|
184 os9 F$VIRQ Remove VIRQ
|
|
185 IFNE H6309
|
|
186 tfr 0,x "remove"
|
|
187 ELSE
|
|
188 ldx #$0000
|
|
189 ENDC
|
|
190 os9 F$IRQ Remove IRQ
|
|
191 pshs u Save device mem ptr
|
|
192 ldu >sectbuf,u Get pointer to sector buffer
|
|
193 ldd #512 Return sector buffer memory
|
|
194 os9 F$SRtMem
|
|
195 puls u Restore device mem ptr
|
|
196 clr >DPort shut off drive motors
|
|
197 IFEQ Level-1
|
|
198 clr >D.DskTmr Clear out drive motor timeout flag
|
|
199 ELSE
|
|
200 clr <D.MotOn Clear out drive motor timeout flag
|
|
201 ENDC
|
|
202 L00AB rts return
|
|
203
|
|
204 * Check if 512 byte sector conversion needed
|
|
205 * Entry: B:X=LSN
|
|
206 * U=Static mem ptr
|
|
207 * Y=Path dsc. ptr
|
|
208 * Exit: X=New LSN (same as original for 256 byte sectors, 1/2 of original
|
|
209 * for 512 byte sectors
|
|
210 L00AC pshs x,b Save LSN
|
|
211 stx >u00B6,u Save OS9 LSN
|
|
212 lda <PD.TYP,y Get device type from path dsc.
|
|
213 anda #%00000100 Mask out all but 512 byte sector flag
|
|
214 bne L00BB 512 byte sectors, go process
|
|
215 L00CA puls pc,x,b Restore LSN & return
|
|
216
|
|
217 * 512 byte sector processing goes here
|
|
218 L00BB puls x,b Get back LSN
|
|
219 clrb Clear carry for rotate (also high byte of LSN)
|
|
220 tfr x,d Move to mathable register
|
|
221 IFNE H6309
|
|
222 rord Divide LSN by 2
|
|
223 ELSE
|
|
224 rora
|
|
225 rorb
|
|
226 ENDC
|
|
227 tfr d,x Move new LSN back to X
|
|
228 stx >u00B8,u Save 'physical' LSN (for controller)
|
|
229 clrb No error & return
|
|
230 rts
|
|
231
|
|
232 start lbra Init
|
|
233 bra Read
|
|
234 nop
|
|
235 lbra Write
|
|
236 bra GetStat
|
|
237 nop
|
|
238 lbra SetStat
|
|
239 bra Term
|
|
240 nop
|
|
241
|
|
242 * Read
|
|
243 *
|
|
244 * Entry:
|
|
245 * B = MSB of LSN
|
|
246 * X = LSB of LSN
|
|
247 * Y = address of path descriptor
|
|
248 * U = address of device memory area
|
|
249 *
|
|
250 * Exit:
|
|
251 * CC = carry set on error
|
|
252 * B = error code
|
|
253 *
|
|
254 Read bsr L00AC Go check for 512 byte sector/adjust if needed
|
|
255 lda #%10010001 Error flags (see Disto SCII source)
|
|
256 pshs x Preserve sector #
|
|
257 lbsr L0162 Go read the sector
|
|
258 puls x Restore sector #
|
|
259 bcs L00AB If error, exit
|
|
260 pshs y,x Save path dsc ptr & LSN
|
|
261 leax ,x LSN0?
|
|
262 bne L012D No, go calculate normally
|
|
263 puls y,x Yes, restore path dsc ptr & LSN
|
|
264 lda <PD.TYP,y Get type from path dsc.
|
|
265 bita #TYP.NSF Standard OS-9 format?
|
|
266 beq L00F0 Yes, skip ahead
|
|
267 lbsr L051A
|
|
268 pshs y,x save path dsc ptr
|
|
269 bra L012D
|
|
270
|
|
271 * LSN0, standard OS-9 format
|
|
272 L00F0 ldx >sectbuf,u Get ptr to sector buffer
|
|
273 pshs y,x Preserve path dsc. ptr & sector buffer ptr
|
|
274 ldy >u00A7,u Get last drive table accessed ptr
|
|
275 IFNE H6309
|
|
276 ldw #DD.SIZ # bytes to copy from new LSN0 to drive table
|
|
277 tfm x+,y+ Copy them
|
|
278 ELSE
|
|
279 ldb #DD.SIZ
|
|
280 L00F0Lp lda ,x+
|
|
281 sta ,y+
|
|
282 decb
|
|
283 bne L00F0Lp
|
|
284 ENDC
|
|
285 ldy >u00A7,u Get drive table ptr back
|
|
286 lda <DD.FMT,y Get format for disk in drive
|
|
287 ldy 2,s restore path descriptor pointer
|
|
288 ldb <PD.DNS,y Get path's density settings
|
|
289 bita #FMT.DNS Disk in drive double density?
|
|
290 beq L0115 No, all drives can read single, skip ahead
|
|
291 bitb #DNS.MFM Can our path dsc. handle double density?
|
|
292 beq erbtyp No, illegal
|
|
293 L0115 bita #FMT.TDNS Is new disk 96 tpi?
|
|
294 beq L011D No, all drives handle 48 tpi, so skip ahead
|
|
295 bitb #DNS.DTD Can path dsc. handle 96 tpi?
|
|
296 beq erbtyp No, illegal
|
|
297 L011D bita #FMT.SIDE Is new disk double sided?
|
|
298 beq L0128 No, all drives handle single sided, we're done
|
|
299 lda <PD.SID,y Get # sides path dsc. can handle
|
|
300 suba #2 sides higher or equal to 2?
|
|
301 blo erbtyp Yes, exit with illegal type error
|
|
302 L0128 clrb No error
|
|
303 * puls y,x ??? 2 USELESS LINES?
|
|
304 * pshs y,x
|
|
305 * LSN's other than 0 come straight here
|
|
306 L012D ldy 2,s Get path dsc. ptr back??
|
|
307 ldx PD.BUF,y Get path dsc. buffer ptr
|
|
308 lda <PD.TYP,y Get path dsc. disk type
|
|
309 ldy >sectbuf,u Get ptr to sector buffer
|
|
310 IFNE H6309
|
|
311 ldw #256 OS9 sector size (even if physical was 512)
|
|
312 ENDC
|
|
313 anda #%00000100 Mask out all but 512 byte sector flag
|
|
314 beq L014B If normal sector, just copy it
|
|
315 ldd >u00B6,u Get OS9's LSN (twice of the 'real' 512 sector)
|
|
316 andb #$01 Mask out all but odd/even sector indicator
|
|
317 beq L014B Even, use 1st half of 512 byte sector
|
|
318 IFNE H6309
|
|
319 addr w,y Odd, bump sector buffer ptr to 2nd half
|
|
320 ELSE
|
|
321 leay 256,y
|
|
322 ENDC
|
|
323 L014B equ *
|
|
324 IFNE H6309
|
|
325 tfm y+,x+ Copy from physical sector buffer to PD buffer
|
|
326 puls pc,y,x restore path dsc & sector buffer ptrs & return
|
|
327 ELSE
|
|
328 pshs d
|
|
329 clrb
|
|
330 L014BLp lda ,y+
|
|
331 sta ,x+
|
|
332 decb
|
|
333 bne L014BLp
|
|
334 puls pc,y,x,d restore path dsc & sector buffer ptrs & return
|
|
335 ENDC
|
|
336
|
|
337 erbtyp comb
|
|
338 ldb #E$BTyp Error - wrong type error
|
|
339 puls pc,y,x
|
|
340
|
|
341 * Read error - retry handler
|
|
342 L0159 bcc L0162 Normal retry, try reading again
|
|
343 pshs x,d Preserve regs
|
|
344 lbsr sktrk0 Seek to track 0 (attempt to recalibrate)
|
|
345 puls x,d Restore regs & try reading again
|
|
346
|
|
347 L0162 pshs x,d Preserve regs
|
|
348 bsr L016F Go read sector
|
|
349 puls x,d Restore regs (A=retry flags)
|
|
350 bcc L01D7 No error, return
|
|
351 lsra Shift retry flags
|
|
352 bne L0159 Still more retries allowed, go do them
|
|
353 * otherwise, final try before we give up
|
|
354 L016F lbsr L02AC Do double-step/precomp etc. if needed, seek
|
|
355 bcs L01D7 Error somewhere, exit with it
|
|
356 L0176 ldx >sectbuf,u Get physical sector buffer ptr
|
|
357 * pshs y,cc Preserve timeout timer & CC
|
|
358 ldb #$80 Read sector command
|
|
359 bsr L01A1 Send to controller & time delay to let it settle
|
|
360 *** Next few lines are commented out for blobstop patches
|
|
361 *L0180 bita >DPort+WD_Stat check status register
|
|
362 * bne L0197 eat it & start reading sector
|
|
363 * leay -1,y bump timeout timer down
|
|
364 * bne L0180 keep trying until it reaches 0 or sector read
|
|
365 * lda >u00A9,u get current drive settings
|
|
366 * ora #%00001000 turn drive motor on
|
|
367 * sta >DPort send to controller
|
|
368 * puls y,cc restore regs
|
|
369 * lbra L03E0 exit with Read Error
|
|
370 *** Blobstop fixes
|
|
371 stb >DPort send command to FDC
|
|
372 nop allow HALT to take effect
|
|
373 nop
|
|
374 bra L0197 and a bit more time
|
|
375 * Read loop - exited with NMI
|
|
376 * Entry: X=ptr to sector buffer
|
|
377 * B=Control register settings
|
|
378 L0197 lda >DPort+WD_Data get byte from controller
|
|
379 sta ,x+ store into sector buffer
|
|
380 * stb >DPort drive info
|
|
381 nop -- blobstop fix
|
|
382 bra L0197 Keep reading until sector done
|
|
383
|
|
384 L01A1 orcc #IntMasks Shut off IRQ & FIRQ
|
|
385 stb >DPort+WD_Cmd Send command
|
|
386 * ldy #$FFFF
|
|
387 ldb #%00101000 Double density & motor on
|
|
388 orb >u00A9,u Merge with current drive settings
|
|
389 stb >DPort Send to control register
|
|
390 ldb #%10101000 Enable halt, double density & motor on
|
|
391 orb >u00A9,u Merge that with current drive settings
|
|
392 lbra L0406 Time delay to wait for command to settle
|
|
393 * lda #$02
|
|
394 *L01BE rts
|
|
395
|
|
396 * Write
|
|
397 *
|
|
398 * Entry:
|
|
399 * B = MSB of LSN
|
|
400 * X = LSB of LSN
|
|
401 * Y = address of path descriptor
|
|
402 * U = address of device memory area
|
|
403 *
|
|
404 * Exit:
|
|
405 * CC = carry set on error
|
|
406 * B = error code
|
|
407 *
|
|
408 Write lbsr L00AC Go adjust LSN for 512 byte sector if needed
|
|
409 lda #%1001001 Retry flags for I/O errors (see Disto SCII source)
|
|
410 L01C4 pshs x,d Preserve LSN, retries
|
|
411 bsr L01E8 Go write the sector
|
|
412 puls x,d Restore LSN, retries
|
|
413 bcs L01D8 Error writing, go to write retry handler
|
|
414 tst <PD.VFY,y No error, do we want physical verify?
|
|
415 bne L01D6 No, exit without error
|
|
416 lbsr verify Go re-read & verify 32 out of 256 bytes
|
|
417 bcs L01D8 Error on verify, go to write retry handler
|
|
418 L01D6 clrb No error & return
|
|
419 L01D7 rts
|
|
420
|
|
421 * Write error retry handler
|
|
422 L01D8 lsra Shift retry flags
|
|
423 lbeq L03AF Too many retries, exit with error
|
|
424 bcc L01C4 Normal retry, attemp to re-write sector
|
|
425 pshs x,d Preserve flags & sector #
|
|
426 lbsr sktrk0 Seek to track 0 (attempt to recalibrate)
|
|
427 puls x,d Restore flags & sector #
|
|
428 bra L01C4 Try re-writing now
|
|
429
|
|
430 * 512 byte sector write here
|
|
431 L01E8 lbsr L02AC Go do double-step/write precomp if needed
|
|
432 bcs L01D7 Error, exit with it
|
|
433 pshs y,d Preserve path dsc. ptr & LSN
|
|
434 lda <PD.TYP,y Get device type
|
|
435 anda #%00000100 512 byte sector?
|
|
436 beq L020D No, skip ahead
|
|
437 lda #$91 ??? appears to be useless
|
|
438 lbsr L0176 Go read the sector in
|
|
439 ldd >u00B6,u Get OS9 LSN
|
|
440 andb #$01 Even or odd?
|
|
441 beq L020D Even, skip ahead
|
|
442 ldx >sectbuf,u Get physical sector buffer ptr
|
|
443 leax >$0100,x Point to 2nd half
|
|
444 bra L0211 Copy caller's buffer to 2nd half of sector
|
|
445
|
|
446 L020D ldx >sectbuf,u Get physical sector buffer ptr
|
|
447
|
|
448 L0211 ldy PD.BUF,y Get path dsc. buffer ptr
|
|
449 IFNE H6309
|
|
450 ldw #256 Copy write buffer to sector buffer
|
|
451 tfm y+,x+
|
|
452 ELSE
|
|
453 clrb
|
|
454 L0211Lp lda ,y+
|
|
455 sta ,x+
|
|
456 decb
|
|
457 bne L0211Lp
|
|
458 ENDC
|
|
459 puls y,d Get path dsc. ptr & LSN back
|
|
460 ldx >sectbuf,u Get physical sector buffer ptr again
|
|
461 ldb #$A0 Write sector command
|
|
462
|
|
463 * Format track comes here with B=$F0 (write track)
|
|
464 *L0224 pshs y,cc Preserve path dsc. ptr & CC
|
|
465 L0224 lbsr L01A1 Send command to controller (including delay)
|
|
466 *** Commented out for blobstop fixes
|
|
467 *L0229 bita >DPort+WD_Stat Controller done yet?
|
|
468 * bne L0240 Yes, go write sector out
|
|
469 * leay -$01,y No, bump wait counter
|
|
470 * bne L0229 Still more tries, continue
|
|
471 * lda >u00A9,u Get current drive control register settings
|
|
472 * ora #%00001000 Drive motor on (but drive select off)
|
|
473 * sta >DPort Send to controller
|
|
474 * puls y,cc Restore regs
|
|
475 * lbra L03AF Check for errors from status register
|
|
476
|
|
477 IFGT Level-1
|
|
478 *** added blobstop
|
|
479 lda FBlock+1,u get the block number for format
|
|
480 beq L0230 if not format, don't do anything
|
|
481 sta >$FFA1 otherwise map the block in
|
|
482 ENDC
|
|
483
|
|
484 L0230 stb >DPort send command to FDC
|
|
485 bra L0240 wait a bit for HALT to enable
|
|
486 * Write sector routine (Entry: B= drive/side select) (NMI will break out)
|
|
487 L0240 nop --- wait a bit more
|
|
488 lda ,x+ Get byte from write buffer
|
|
489 sta >DPort+WD_Data Save to FDC's data register
|
|
490 * EAT 2 CYCLES: TC9 ONLY (TRY 1 CYCLE AND SEE HOW IT WORKS)
|
|
491 IFEQ TC9-1
|
|
492 nop
|
|
493 nop
|
|
494 ENDC
|
|
495 * stb >DPort Set up to read next byte
|
|
496 bra L0240 Go read it
|
|
497
|
|
498 * NMI routine
|
|
499 NMISvc leas R$Size,s Eat register stack
|
|
500 * puls y,cc Get path dsc. ptr & CC
|
|
501 IFGT Level-1
|
|
502 ldx <D.SysDAT get pointer to system DAT image
|
|
503 lda 3,x get block number 1
|
|
504 sta >$FFA1 map it back into memory
|
|
505 andcc #^IntMasks turn IRQ's on again
|
|
506 ELSE
|
|
507 * puls y,cc Get path dsc. ptr & CC
|
|
508 ENDC
|
|
509 ldb >DPort+WD_Stat Get status register
|
|
510 bitb #%00000100 Did we lose data in the transfer?
|
|
511 * lbne L03E0 Yes, exit with Read Error
|
|
512 lbeq L03B2 Otherwise, check for drive errors
|
|
513 comb -- blobstop error code
|
|
514 ldb #E$DevBsy -- device busy
|
|
515 rts -- and exit
|
|
516
|
|
517 verify pshs x,d
|
|
518 ldx PD.BUF,y Get write buffer ptr
|
|
519 pshs x Preserve it
|
|
520 ldx >sectbuf,u Get sector buffer ptr
|
|
521 stx PD.BUF,y Save as write buffer ptr
|
|
522 ldx 4,s
|
|
523 lbsr L016F Go read sector we just wrote
|
|
524 puls x Get original write buffer ptr
|
|
525 stx PD.BUF,y Restore path dsc. version
|
|
526 bcs L02A3 If error reading, exit with it
|
|
527 pshs u,y Preserve device mem, path dsc. ptrs
|
|
528 ldb <PD.TYP,y Get type from path dsc.
|
|
529 ldy >sectbuf,u Get sector buffer ptr
|
|
530 andb #%00000100 512 byte sector?
|
|
531 beq L028D No, skip ahead
|
|
532 ldd >u00B6,u Get OS9's sector #
|
|
533 andb #$01 Odd/even sector?
|
|
534 beq L028D Even; compare first half
|
|
535 leay >$0100,y Odd, compare second half
|
|
536 L028D tfr x,u Move PD.BUF ptr to U (since cmpx is faster)
|
|
537 lda #32 # of 'spotty' checks to do
|
|
538 L028F ldx ,u Get 2 bytes from original write buffer
|
|
539 cmpx ,y Same as corresponding bytes in re-read sector?
|
|
540 bne L029F No, error & return
|
|
541 leau 8,u Skip next 6 bytes
|
|
542 leay 8,y
|
|
543 deca Done our 'spotty' check?
|
|
544 bne L028F No, continue
|
|
545 fcb $8C skip the next 2 bytes
|
|
546
|
|
547 L029F orcc #Carry
|
|
548 L02A1 puls u,y
|
|
549 L02A3 puls pc,x,d
|
|
550
|
|
551 L02A5 pshs a Save Caller's track #
|
|
552 ldb <V.TRAK,x Get track # drive is currently on
|
|
553 bra L02E9 Go save it to controller & continue
|
|
554
|
|
555 L02AC lbsr L0376 Go set up controller for drive, spin motor up
|
|
556 bsr L032B Get track/sector # (A=Trk, B=Sector)
|
|
557 pshs a Save track #
|
|
558 lda >u00AD,u Get side 1/2 flag
|
|
559 beq L02C4 Side 1, skip ahead
|
|
560 lda >u00A9,u Get control register settings
|
|
561 ora #%01000000 Set side 2 (drive 3) select
|
|
562 sta >u00A9,u Save it back
|
|
563 L02C4 lda <PD.TYP,y Get drive type settings
|
|
564 bita #%00000010 ??? (Base 0/1 for sector #?)
|
|
565 bne L02CC Skip ahead
|
|
566 incb Bump sector # up by 1
|
|
567 L02CC stb >DPort+WD_Sect Save into Sector register
|
|
568 ldx >u00A7,u Get last drive table accessed
|
|
569 ldb <V.TRAK,x Get current track # on device
|
|
570 lda <DD.FMT,x Get drive format specs
|
|
571 lsra Shift track & bit densities to match PD
|
|
572 eora <PD.DNS,y Check for differences with path densities
|
|
573 anda #%00000010 Keep only 48/96 tpi differences
|
|
574 pshs a Save differences
|
|
575 lda 1,s Get track # back
|
|
576 tst ,s+ Are tpi's different?
|
|
577 beq L02E9 No, continue normally
|
|
578 lsla Yes, multiply track # by 2 ('double-step')
|
|
579 lslb Multiply current track # by 2 ('double-step')
|
|
580 L02E9 stb >DPort+WD_Trak Save current track # onto controller
|
|
581
|
|
582 * From here to the line before L0307 is for write precomp, but is not used.
|
|
583 * Unless write precomp is needed, all of this is useless
|
|
584 * I think most (if not all) drives do NOT need precomp
|
|
585 IFEQ PRECOMP-1
|
|
586 ldb #21 Pre-comp track #
|
|
587 pshs b Save it
|
|
588 ldb <PD.DNS,y Get current density settings
|
|
589 andb #%00000010 Just want to check track density
|
|
590 beq L02F9 48 tpi, skip ahead
|
|
591 lsl ,s Multiply pre-comp value by 2 ('double-step')
|
|
592 L02F9 cmpa ,s+ Is track # high enough to warrant precomp?
|
|
593 bls L0307 No, continue normally
|
|
594 ldb >u00A9,u
|
|
595 orb #%00010000 Turn on Write precomp
|
|
596 stb >u00A9,u
|
|
597 ENDC
|
|
598
|
|
599 L0307 ldb >u00AA,u ??? Get flag (same drive flag?)
|
|
600 bne L0314 no, skip ahead
|
|
601 ldb ,s get track #
|
|
602 cmpb <V.TRAK,x same as current track on this drive?
|
|
603 beq L0321 yes, skip ahead
|
|
604 L0314 sta >DPort+WD_Data save track # to data register
|
|
605 ldb <PD.STP,y get stepping rate
|
|
606 andb #%00000011 just keep usable settings (6-30 ms)
|
|
607 eorb #%00011011 set proper bits for controller
|
|
608 lbsr L03E4 send command to controller & time delay
|
|
609 L0321 puls a get track # back
|
|
610 sta <V.TRAK,x save as current track #
|
|
611 sta >DPort+WD_Trak save to controller
|
|
612 clrb no error & return
|
|
613 rts
|
|
614
|
|
615 * Entry: B:X LSN
|
|
616 * Exit: A=Track #
|
|
617 * B=Sector #
|
|
618 * <u00AD=00 = Head 1 , $FF = Head 2
|
|
619 L032B tstb Sector # > 65535?
|
|
620 bne L033F Yes, illegal for floppy
|
|
621 tfr x,d Move sector # to D
|
|
622 leax ,x LSN 0?
|
|
623 beq L0371 Yes, exit this routine
|
|
624 ldx >u00A7,u Get previous drive table ptr
|
|
625 cmpd DD.TOT+1,x Within range of drive spec?
|
|
626 blo L0343 Yes, go calculate track/sector #'s
|
|
627 L033F comb Exit with Bad sector # error
|
|
628 ldb #E$Sect
|
|
629 rts
|
|
630
|
|
631 * Calculate track/sector #'s?
|
|
632 L0343 stb >u00AE,u Save LSB of LSN
|
|
633 clr ,-s Clear track # on stack
|
|
634 ldb <DD.FMT,x Get drive format
|
|
635 lsrb Shift out # sides into carry
|
|
636 ldb >u00AE,u Get LSB of LSN again
|
|
637 bcc L0367 Single sided drive, skip ahead
|
|
638 bra L035D Double sided drive, skip ahead
|
|
639 * Double sided drive handling here
|
|
640 L0355 com >u00AD,u ???? Odd/even sector track flag?
|
|
641 bne L035D Odd, so don't bump track # up
|
|
642 inc ,s Bump up track #
|
|
643
|
|
644 L035D subb DD.TKS,x Subtract # sectors/track
|
|
645 sbca #$00
|
|
646 bcc L0355 Still more sectors left, continue
|
|
647 bra L036D Wrapped, skip ahead
|
|
648 * Single sided drive handling here
|
|
649 L0365 inc ,s Bump track # up
|
|
650
|
|
651 L0367 subb DD.TKS,x Subtract # sectors/track
|
|
652 sbca #$00
|
|
653 bcc L0365 Still more, go bump the track up
|
|
654 L036D addb $03,x Bump sector # back up from negative value
|
|
655 puls a Get the track #
|
|
656 L0371 rts A=track #, B=Sector #, <u00AD=Odd
|
|
657
|
|
658 * Drive control register bit mask table
|
|
659 L0372 fcb $01 Drive 0
|
|
660 fcb $02 Drive 1
|
|
661 fcb $04 Drive 2
|
|
662 fcb $40 Drive 3 / Side select
|
|
663
|
|
664 L0376 clr >u00AA,u ???
|
|
665
|
|
666 chkdrv lda <PD.DRV,y Get drive # requested
|
|
667 cmpa #4 Drive 0-3?
|
|
668 blo L0385 Yes, continue normally
|
|
669 NoHW comb Illegal drive # error
|
|
670 ldb #E$Unit
|
|
671 rts
|
|
672
|
|
673 * Entry: A=drive #, X=LSN (Physical, not OS9 logical if PCDOS disk)
|
|
674 L0385 pshs x,d Save sector #, drive # & B???
|
|
675 leax >L0372,pc Point to drive bit mask table
|
|
676 ldb a,x Get bit mask for drive # we want
|
|
677 stb >u00A9,u Save mask
|
|
678 leax DRVBEG,u Point to beginning of drive tables
|
|
679 ldb #DRVMEM Get size of each drive table
|
|
680 mul Calculate offset to drive table we want
|
|
681 leax d,x Point to it
|
|
682 cmpx >u00A7,u Same as Last drive table accessed?
|
|
683 beq L03A6 Yes, skip ahead
|
|
684 stx >u00A7,u Save new drive table ptr
|
|
685 com >u00AA,u ??? Set flag
|
|
686 L03A6 clr >u00AD,u Set side (head) flag to side 1
|
|
687 lbsr L04B3 Go set up VIRQ to wait for drive motor
|
|
688 puls pc,x,d Restore sector #,drive #,B & return
|
|
689
|
|
690 L03AF ldb >DPort+WD_Stat Get status register from FDC
|
|
691 L03B2 bitb #%11111000 Any of the error bits set?
|
|
692 beq L03CA No, exit without error
|
|
693 aslb Drive not ready?
|
|
694 bcs L03CC Yes, use that error code
|
|
695 aslb Write protect error?
|
|
696 bcs L03D0 Yes, use that error code
|
|
697 aslb Write fault error?
|
|
698 bcs L03D4 Yes, use that error code
|
|
699 aslb Sector not found?
|
|
700 bcs L03D8 Yes, use Seek error code
|
|
701 aslb CRC error?
|
|
702 bcs L03DC Yes, use that error code
|
|
703 L03CA clrb No error & return
|
|
704 rts
|
|
705
|
|
706 L03CC ldb #E$NotRdy not ready
|
|
707 fcb $8C skip 2 bytes
|
|
708
|
|
709 L03D0 ldb #E$WP write protect
|
|
710 fcb $8C skip 2 bytes
|
|
711
|
|
712 L03D4 ldb #E$Write write error
|
|
713 fcb $8C
|
|
714
|
|
715 L03D8 ldb #E$Seek seek error
|
|
716 fcb $8C
|
|
717
|
|
718 L03DC ldb #E$CRC CRC error
|
|
719 * fcb $8C
|
|
720
|
|
721 *L03E0 ldb #E$Read Read error
|
|
722 orcc #Carry set carry
|
|
723 rts
|
|
724
|
|
725 L03E4 bsr L0404 Send command to controller & waste some time
|
|
726 L03E6 ldb >DPort+WD_Stat Check FDC status register
|
|
727 bitb #$01 Is controller still busy?
|
|
728 beq L0403 No, exit
|
|
729 ldd >VIRQCnt,pc Get initial count value for drive motor speed
|
|
730 std >u00B1,u Save it
|
|
731 bra L03E6 Wait for controller to finish previous command
|
|
732
|
|
733 * Send command to FDC
|
|
734 L03F7 lda #%00001000 Mask in Drive motor on bit
|
|
735 ora >u00A9,u Merge in drive/side selects
|
|
736 sta >DPort Turn the drive motor on & select drive
|
|
737 stb >DPort+WD_Cmd Save command & return
|
|
738 L0403 rts
|
|
739
|
|
740 L0404 bsr L03F7 Go send command to controller
|
|
741
|
|
742 * This loop has been changed from nested LBSRs to timing loop.
|
|
743 * People with crystal upgrades should modify the loop counter
|
|
744 * to get a 58+ us delay time. MINIMUM 58us.
|
|
745 L0406 pshs a 14 cycles, plus 3*loop counter
|
|
746 lda #29 (only do about a 100 cycle delay for now)
|
|
747 L0409 deca for total ~63 us delay (123 cycles max.)
|
|
748 bne L0409
|
|
749 puls a,pc restore register and exit
|
|
750
|
|
751 * SetStat
|
|
752 *
|
|
753 * Entry:
|
|
754 * A = function code
|
|
755 * Y = address of path descriptor
|
|
756 * U = address of device memory area
|
|
757 *
|
|
758 * Exit:
|
|
759 * CC = carry set on error
|
|
760 * B = error code
|
|
761 *
|
|
762 SetStat ldx PD.RGS,y Get caller's register stack ptr
|
|
763 ldb R$B,x Get function code
|
|
764 cmpb #SS.WTrk Write track?
|
|
765 beq SSWTrk Yes, go do it
|
|
766 cmpb #SS.Reset Restore head to track 0?
|
|
767 lbeq sktrk0 Yes, go do it --- beq
|
|
768 comb set carry for error
|
|
769 ldb #E$UnkSvc return illegal service request error
|
|
770 rts
|
|
771
|
|
772 SSWTrk pshs u,y preserve register stack & descriptor
|
|
773
|
|
774 IFEQ Level-1
|
|
775
|
|
776 ldd #$1A00 Size of buffer to hold entire track image
|
|
777 os9 F$SRqMem Request memory from system
|
|
778 bcs L0489 Error requesting, exit with it
|
|
779 stu >FBlock,x
|
|
780
|
|
781 ELSE
|
|
782
|
|
783 *--- new code
|
|
784 ldb #1 1 block to allocate
|
|
785 os9 F$AllRAM allocate some RAM
|
|
786 bcs L0489 error out if at all
|
|
787 leax >FBlock,u point to 'my' DAT image
|
|
788 std ,x save a copy of the block
|
|
789 os9 F$ResTsk reserve a task number for the copy
|
|
790 bcs FError error out
|
|
791 stb 2,x save temporary task number in FTask,u
|
|
792 lslb 2 bytes per entry
|
|
793 ldu <D.TskIPt get task image table pointer
|
|
794 stx b,u save pointer to the task's DAT image
|
|
795 lsrb get the right number again
|
|
796 IFNE H6309
|
|
797 tfr 0,u destination is address 0
|
|
798 ELSE
|
|
799 ldu #$0000
|
|
800 ENDC
|
|
801 *--- end new code
|
|
802
|
|
803 ldx 2,s get pointer to descriptor
|
|
804 * stu >FBlock,x
|
|
805 ldx <D.Proc Get current process ptr
|
|
806 lda P$Task,x Get task # for current process
|
|
807 * ldb <D.SysTsk Get system task #
|
|
808 ldy ,s
|
|
809 ldx PD.RGS,y Get register stack ptr
|
|
810 ldx R$X,x Get ptr to caller's track buffer
|
|
811 ldy #$1A00 Size of track buffer
|
|
812 os9 F$Move Copy from caller to temporary task
|
|
813 bcs L0479 Error copying, exit
|
|
814
|
|
815 ENDC
|
|
816
|
|
817 puls u,y
|
|
818 pshs u,y
|
|
819 lbsr L0376 Go check drive #/wait for it to spin up
|
|
820 ldx PD.RGS,y Get caller's register stack ptr
|
|
821 ldb R$Y+1,x Get caller's side/density
|
|
822 bitb #$01 Check side
|
|
823 beq L0465 Side 1, skip ahead
|
|
824 com >u00AD,u
|
|
825 ldb >u00A9,u Get current control register settings
|
|
826 orb #%01000000 Mask in side 2
|
|
827 stb >u00A9,u Save updated control register
|
|
828 L0465 lda R$U+1,x Get caller's track #
|
|
829 ldx >u00A7,u Get current drive table ptr
|
|
830 lbsr L02A5
|
|
831 bcs L0489
|
|
832 ldb #$F0 Write track command?
|
|
833 *---
|
|
834 IFEQ Level-1
|
|
835 ldx >FBlock,u
|
|
836 ELSE
|
|
837 ldx #$2000 start writing from block 1
|
|
838 ENDC
|
|
839
|
|
840 lbsr L0224 Go write the track
|
|
841 L0479 ldu 2,s
|
|
842 pshs b,cc Preserve error
|
|
843
|
|
844 IFEQ Level-1
|
|
845
|
|
846 ldu >FBlock,u Get ptr to track buffer
|
|
847 ldd #$1A00 Return track buffer
|
|
848 os9 F$SRtMem
|
|
849
|
|
850 ELSE
|
|
851
|
|
852 ldb >FTask,u point to task
|
|
853 os9 F$RelTsk release the task
|
|
854 fcb $8C skip 2 bytes
|
|
855
|
|
856 ENDC
|
|
857
|
|
858 * format comes here when block allocation passes, but task allocation
|
|
859 * gives error. So er de-allocate the block.
|
|
860 FError
|
|
861 IFGT Level-1
|
|
862 pshs b,cc save error code, cc
|
|
863 ldx >FBlock,u point to block
|
|
864 ldb #1 1 block to return
|
|
865 os9 F$DelRAM de-allocate image RAM blocks
|
|
866 clr FBlock+1,u ensure that the block # in FBlock is zero.
|
|
867 puls b,cc Restore error
|
|
868 ENDC
|
|
869
|
|
870 L0489 puls pc,u,y Restore regs & return
|
|
871
|
|
872 * seek the head to track 0
|
|
873 sktrk0 lbsr chkdrv
|
|
874 ldx >u00A7,u
|
|
875 clr <$15,x
|
|
876 lda #$05
|
|
877 L0497 ldb <PD.STP,y
|
|
878 andb #%00000011 Just keep usable settings (6-30 ms)
|
|
879 eorb #%01001011 Set proper bits for controller
|
|
880 pshs a
|
|
881 lbsr L03E4
|
|
882 puls a
|
|
883 deca
|
|
884 bne L0497
|
|
885 ldb <PD.STP,y
|
|
886 andb #%00000011 Just keep usable settings (6-30 ms)
|
|
887 eorb #%00001011 Set proper bits for controller
|
|
888 lbra L03E4
|
|
889
|
|
890 L04B3 pshs y,x,d Preserve regs
|
|
891 ldd >VIRQCnt,pc Get VIRQ initial count value
|
|
892 std >u00B1,u Save it
|
|
893 lda >u00A9,u ?Get drive?
|
|
894 ora #%00001000 Turn drive motor on for that drive
|
|
895 sta >DPort Send drive motor on command to FDC
|
|
896 IFEQ Level-1
|
|
897 lda >D.DskTmr Get VIRQ flag
|
|
898 ELSE
|
|
899 lda <D.MotOn Get VIRQ flag
|
|
900 ENDC
|
|
901 bmi L04DE Not installed yet, try installing it
|
|
902 bne L04E0 Drive already up to speed, exit without error
|
|
903
|
|
904 * Drive motor speed timing loop (could be F$Sleep call now) (was over .5 sec)
|
|
905 ldx #32 wait for 32 ticks
|
|
906 os9 F$Sleep
|
|
907
|
|
908 L04DE bsr InsVIRQ Install VIRQ to wait for drive motors
|
|
909 L04E0 clrb No error & return
|
|
910 puls pc,y,x,d
|
|
911
|
|
912 InsVIRQ lda #$01 Flag drive motor is up to speed
|
|
913 IFEQ Level-1
|
|
914 sta >D.DskTmr
|
|
915 ELSE
|
|
916 sta <D.MotOn
|
|
917 ENDC
|
|
918 ldx #$0001 Install VIRQ entry
|
|
919 leay >u00B1,u Point to packet
|
|
920 clr Vi.Stat,y Reset Status byte
|
|
921 ldd >VIRQCnt,pc Get initial VIRQ count value
|
|
922 os9 F$VIRQ Install VIRQ
|
|
923 bcc VIRQOut No error, exit
|
|
924 lda #$80 Flag that VIRQ wasn't installed
|
|
925 IFEQ Level-1
|
|
926 sta >D.DskTmr
|
|
927 ELSE
|
|
928 sta <D.MotOn
|
|
929 ENDC
|
|
930 VIRQOut clra
|
|
931 rts
|
|
932
|
|
933 * IRQ service routine for VIRQ (drive motor time)
|
|
934 * Entry: U=Ptr to VIRQ memory area
|
|
935 IRQSvc pshs a
|
|
936 lda <D.DMAReq
|
|
937 beq L0509
|
|
938 bsr InsVIRQ
|
|
939 bra IRQOut
|
|
940 L0509 sta >DPort
|
|
941 IFNE H6309
|
|
942 aim #$FE,>u00B5,u
|
|
943 ELSE
|
|
944 lda u00B5,u
|
|
945 anda #$FE
|
|
946 sta u00B5,u
|
|
947 ENDC
|
|
948 * fdb u00B5 --- so changes in data size won't affect anything
|
|
949 IFEQ Level-1
|
|
950 clr >D.DskTmr
|
|
951 ELSE
|
|
952 clr <D.MotOn
|
|
953 ENDC
|
|
954 IRQOut puls pc,a
|
|
955
|
|
956 * Non-OS9 format goes here
|
|
957 * Entry: X=LSN
|
|
958 * Y=Path dsc. ptr
|
|
959 * U=Device mem ptr
|
|
960 L051A pshs x Preserve Logical sector #
|
|
961 ldx >u00A7,u Get last drive table accessed ptr
|
|
962 clra
|
|
963 pshs x,a Save ptr & NUL byte
|
|
964 IFNE H6309
|
|
965 ldw #$14 Clear 20 bytes
|
|
966 tfm s,x+
|
|
967 ELSE
|
|
968 ldb #$14
|
|
969 L051ALp clr ,x+
|
|
970 decb
|
|
971 bne L051ALp
|
|
972 ENDC
|
|
973 puls x,a Eat NUL & get back drive table ptr
|
|
974 ldb <PD.CYL+1,y Get # cylinders on drive (ignores high byte)
|
|
975 lda <PD.SID,y Get # sides
|
|
976 mul Calculate # tracks on drive (1 per head)
|
|
977 IFNE H6309
|
|
978 decd Adjust to ignore track 0
|
|
979 ELSE
|
|
980 subd #$0001
|
|
981 ENDC
|
|
982 lda <PD.SCT+1,y Get # sectors/track
|
|
983 sta DD.TKS,x Save in drive table
|
|
984 sta <DD.SPT+1,x Save in other copy in drive table
|
|
985 mul Calculate # sectors on drive (minus track 0)
|
|
986 pshs x Preserve drive table ptr
|
|
987 tfr d,x Move # sectors on drive to X
|
|
988 lda <PD.T0S+1,y Get # sectors on track 0
|
|
989 leax a,x Add that many sectors to total
|
|
990 lda <PD.TYP,y Get device type settings
|
|
991 anda #%00000100 Mask out all but 512 byte sector flag
|
|
992 beq L0550 Not 512 byte sector, skip ahead
|
|
993 IFNE H6309
|
|
994 addr x,x Multiply by 2 (convert to 256 byte OS9 sectors)
|
|
995 ELSE
|
|
996 tfr x,d
|
|
997 leax d,x
|
|
998 ENDC
|
|
999 L0550 tfr x,d Move # sectors to D
|
|
1000 puls x Get back drive table ptr
|
|
1001 std DD.TOT+1,x Save # sectors allowed on drive
|
|
1002 lda #UPDAT.+EXEC. Owner's read/write/exec attributes
|
|
1003 sta DD.ATT,x Set attributes for disk
|
|
1004 lda <PD.DNS,y Get density settings
|
|
1005 lsla Shift for DD.FMT
|
|
1006 pshs a Preserve it a sec
|
|
1007 lda <PD.SID,y Get # sides
|
|
1008 deca Adjust to base 0
|
|
1009 ora ,s+ Merge with density settings
|
|
1010 sta <DD.FMT,x Save in device table
|
|
1011 clrb No error?
|
|
1012 puls pc,x Restore original LSN & return
|
|
1013
|
|
1014 ELSE
|
|
1015
|
|
1016 *****************************************************************
|
|
1017 * NewDisk -- copyright 1985 by Dave Lewis.
|
|
1018 * Released to public domain January, 1986
|
|
1019 * Permission granted to copy and redistribute provided this
|
|
1020 * header is included with all copies.
|
|
1021 *
|
|
1022 * This program is intended to replace the CCDisk module in the
|
|
1023 * OS9Boot file on the OS-9 system disk. It is far more
|
|
1024 * versatile than the disk driver provided with Color Computer
|
|
1025 * OS-9, and is also slightly smaller (20 bytes or so).
|
|
1026 * Some of its features are:
|
|
1027 *
|
|
1028 * -Uses the device descriptor to set head step rate. Original
|
|
1029 * had 30mS hard-coded in.
|
|
1030 * -Handles double-sided disks.
|
|
1031 * -Gets its track and side information from the disk so you
|
|
1032 * can read and write disks in any format the drive can
|
|
1033 * physically handle. You can use 40-track double sided disks
|
|
1034 * and still read/write 35-track single side disks.
|
|
1035 * -Performs some tests before attempting to use the disk.
|
|
1036 * The original CCDisk would hang the system if you tried to
|
|
1037 * access a drive without a disk in it (I know, I know - you
|
|
1038 * don't have to say `DUMMY!' - but it happens). You can
|
|
1039 * hang this one too but not as easily.
|
|
1040 * -An 80-track double sided disk holds 720Kbytes of data.
|
|
1041 * That's four and a half 35-track single siders.
|
|
1042 * -All of this stuff is completely transparent once NewDisk is
|
|
1043 * installed. NewDisk automatically senses the disk format
|
|
1044 * and conforms to it. (within limits -- don't use non-OS9
|
|
1045 * formats)
|
|
1046 *
|
|
1047 * One problem -- this program is not complete in itself. If you
|
|
1048 * want to boot from a double-sided disk you will need my
|
|
1049 * version of OS9Gen which will generate a double-sided system
|
|
1050 * disk. Don't try it with the stock version; you'll have to
|
|
1051 * reformat the disk to clean it up afterwards.
|
|
1052 *****************************************************************
|
|
1053 * Copyright 1985 by Dave Lewis.
|
|
1054 *
|
|
1055 * UUCP address is loral!dml; in S. Cal. use ihnp4!sdcc3!loral
|
|
1056 *
|
|
1057 * I'm releasing this program to public domain. Copy it, share
|
|
1058 * it, but don't you DARE sell it! I worked hard on it. Include
|
|
1059 * this header with all copies.
|
|
1060 *
|
|
1061 * If you like this program, send me 5 bucks to encourage me to
|
|
1062 * write more stuff - or at least to release it. If you send
|
|
1063 * me 10 bucks I'll send you a good (Dysan) double side disk
|
|
1064 * formatted 35 track single side with both sourcecode and
|
|
1065 * executable binary files of the following:
|
|
1066 *
|
|
1067 * - NewDisk -- single or double sided disks, any number of
|
|
1068 * tracks within reason, step rate set in device descriptor
|
|
1069 * - OS9Gen -- rewritten version that automatically senses for
|
|
1070 * single/double sided disk and puts all the boot data in
|
|
1071 * the right places. Also enters the kernel file in the
|
|
1072 * root directory, which makes Dcheck happy.
|
|
1073 * - Separate -- breaks up your bootfile into its component
|
|
1074 * modules for modification. Replace or remove any module
|
|
1075 * individually.
|
|
1076 * - Diskdescr -- sourcecode for an OS-9 disk device descriptor
|
|
1077 * with EQUates at the beginning for step rate, #tracks,
|
|
1078 * and single or double sided.
|
|
1079 * - Documentation and procedure files for installing all of
|
|
1080 * the above in most common system configurations.
|
|
1081 * - Other stuff I've written that you may find useful.
|
|
1082 *
|
|
1083 * Send to:
|
|
1084 * Dave Lewis
|
|
1085 * 4417 Idaho Apt. 4
|
|
1086 * San Diego CA 92116
|
|
1087 *****************************************************************
|
|
1088 *
|
|
1089 *
|
|
1090 * Copyright 1985 by Dave Lewis
|
|
1091 * 4417 Idaho apt. 4
|
|
1092 * San Diego, CA 92116
|
|
1093 * Released to public domain January, 1986
|
|
1094 *
|
|
1095 *
|
|
1096 *
|
|
1097 N.DRIVES EQU 3 Number of drives supported
|
|
1098 DISKRUN EQU $70 Disk run time after access
|
|
1099 NMIVECT EQU $109 NMI jump vector in RAM
|
|
1100 COMDREG EQU $FF48 1793 Command register (write)
|
|
1101 STATREG EQU $FF48 1793 Status register (read)
|
|
1102 TRAKREG EQU $FF49 1793 Track register
|
|
1103 SECTREG EQU $FF4A 1793 Sector register
|
|
1104 DATAREG EQU $FF4B 1793 Data register
|
|
1105 *
|
|
1106 MOD eom,NAME,tylg,atrv,EXEC,STORG
|
|
1107 FCB $FF Mode byte -- all modes
|
|
1108 NAME FCS 'rb1773'
|
|
1109 FCB 4 Version number
|
|
1110 *
|
|
1111 RMB DRVBEG Storage common to all drives
|
|
1112 TABL.ORG RMB DRVMEM Drive 0 parameter table
|
|
1113 RMB DRVMEM Drive 1 parameter table
|
|
1114 RMB DRVMEM Drive 2 parameter table
|
|
1115 DRV.ACT RMB 2 Active drive's table origin
|
|
1116 DPRT.IMG RMB 1 Drive control port image byte
|
|
1117 DRVS.RDY RMB 1 Drive ready flags
|
|
1118 Q.SEEK RMB 1 Same drive/track flag
|
|
1119 STORG EQU . Total storage required
|
|
1120 *
|
|
1121 * Function dispatch vectors
|
|
1122 *
|
|
1123 EXEC LBRA INIT Initialize variables
|
|
1124 LBRA READ Read one sector
|
|
1125 LBRA WRITE Write one sector
|
|
1126 LBRA RETNOERR GETSTA call is not used
|
|
1127 LBRA SETSTA Two oddball calls
|
|
1128 LBRA RETNOERR TERM call is not used
|
|
1129 *
|
|
1130 INIT CLR >D.DSKTMR Zero disk rundown timer
|
|
1131 LDA #$D0 `Force interrupt' command
|
|
1132 STA >COMDREG
|
|
1133 LDA #$FF
|
|
1134 LDB #N.DRIVES Number of drives
|
|
1135 STB V.NDRV,U
|
|
1136 LEAX TABL.ORG,U Origin of first drive table
|
|
1137 INI.TBL STA DD.TOT+1,X Make total sectors nonzero
|
|
1138 STA V.TRAK,X Force first seek to track 0
|
|
1139 CLR DD.FMT,X Make it see a 1-sided disk
|
|
1140 LEAX DRVMEM,X Go to next drive table
|
|
1141 DECB Test for last table done
|
|
1142 BNE INI.TBL Loop if not finished
|
|
1143 LEAX NMI.SVC,PCR Get address of NMI routine
|
|
1144 STX >NMIVECT+1 NMI Jump vector operand
|
|
1145 LDA #$7E Jump opcode
|
|
1146 STA >NMIVECT NMI Jump vector opcode
|
|
1147 LDA >STATREG Clear interrupt condition
|
|
1148 RETNOERR CLRB
|
|
1149 RTS
|
|
1150 *
|
|
1151 ERR.WPRT COMB Set carry flag
|
|
1152 LDB #E$WP Set error code
|
|
1153 RTS
|
|
1154 ERR.SEEK COMB Set carry flag
|
|
1155 LDB #E$SEEK Set error code
|
|
1156 RTS
|
|
1157 ERR.CRC COMB Set carry flag
|
|
1158 LDB #E$CRC Set error code
|
|
1159 RTS
|
|
1160 ERR.READ COMB Set carry flag
|
|
1161 LDB #E$READ Set error code
|
|
1162 RTS
|
|
1163 *
|
|
1164 * All disk controller commands exit via NMI. The service routine
|
|
1165 * returns control to the address on top of stack after registers
|
|
1166 * have been dumped off.
|
|
1167 *
|
|
1168 NMI.SVC LEAS R$SIZE,S Dump registers off stack
|
|
1169 LDA >STATREG Get status condition
|
|
1170 STAT.TST LSLA Test status register bit 7
|
|
1171 LBCS ERR.NRDY Status = Not Ready if set
|
|
1172 LSLA Test bit 6
|
|
1173 BCS ERR.WPRT Status = Write Protect if set
|
|
1174 LSLA Test bit 5
|
|
1175 LBCS ERR.WRT Status = Write Fault if set
|
|
1176 LSLA Test bit 4
|
|
1177 BCS ERR.SEEK Status = Record Not Found
|
|
1178 LSLA Test bit 3
|
|
1179 BCS ERR.CRC Status = CRC Error if set
|
|
1180 LSLA Test bit 2
|
|
1181 BCS ERR.READ Status = Lost Data if set
|
|
1182 CLRB No error if all 0
|
|
1183 RETURN1 RTS
|
|
1184 *
|
|
1185 READ TSTB If LSN is greater than 65,536
|
|
1186 BNE ERR.SECT return a sector error
|
|
1187 LDA #$A4 Set retry control byte
|
|
1188 CMPX #0 Is it sector 0?
|
|
1189 BNE READ2 If not, just read the data
|
|
1190 BSR READ2 If sector 0, read it and
|
|
1191 BCS RETURN1 update drive table
|
|
1192 PSHS Y,X Save X and Y
|
|
1193 LDX PD.BUF,Y Point to data buffer
|
|
1194 LDY DRV.ACT,U Point to active drive's table
|
|
1195 LDB #DD.RES+1 Counter and offset pointer
|
|
1196 SEC0LOOP LDA B,X Get byte from buffer
|
|
1197 STA B,Y Store in drive table
|
|
1198 DECB Decrement loop index
|
|
1199 BPL SEC0LOOP Loop until B < 0
|
|
1200 CLRB No error
|
|
1201 PULS X,Y,PC Pull and return
|
|
1202 *
|
|
1203 WRITE TSTB If LSN is greater than 65,536
|
|
1204 BNE ERR.SECT return a sector error
|
|
1205 LDA #$A4 Set retry control byte
|
|
1206 PSHS X,A,CC Save registers
|
|
1207 LBSR DSKSTART Start and select drive
|
|
1208 BCS EXIT.ERR Exit if error
|
|
1209 REWRITE LDX 2,S Get LSN off stack
|
|
1210 LBSR SEEK Position head at sector
|
|
1211 BCS RETRY.WR Try again if seek error
|
|
1212 BSR WRITE2 Write the sector
|
|
1213 BCS RETRY.WR Try again if write error
|
|
1214 TST PD.VFY,Y Check verify flag
|
|
1215 BNE EXIT.NER Exit without verify if off
|
|
1216 BSR VERIFY Verify sector just written
|
|
1217 BCC EXIT.NER Exit if no error
|
|
1218 RETRY.WR LDA 1,S Get retry control byte
|
|
1219 LSRA Indicate another try
|
|
1220 STA 1,S Put updated byte back
|
|
1221 BEQ EXIT.ERR If zero, no more chances
|
|
1222 BCC REWRITE If bit 0 was 0, don't home
|
|
1223 BSR HOME Home and start all over
|
|
1224 BCC REWRITE If it homed OK, try again
|
|
1225 EXIT.ERR PULS CC Restore interrupt masks
|
|
1226 COMA Set carry for error
|
|
1227 BRA CCDEXIT Finish exit
|
|
1228 *
|
|
1229 EXIT.NER PULS CC Restore interrupt masks
|
|
1230 CLRB Clear carry -- no error
|
|
1231 CCDEXIT LDA #8 Spindle motor control bit
|
|
1232 STA >DPORT Deselect disk drive
|
|
1233 PULS A,X,PC Pull and return
|
|
1234 *
|
|
1235 ERR.SECT COMB Set carry flag for error
|
|
1236 LDB #E$SECT Set error code
|
|
1237 RTS
|
|
1238 *
|
|
1239 READ2 PSHS X,A,CC CC is on top of stack
|
|
1240 LBSR DSKSTART Start drives and test
|
|
1241 BCS EXIT.ERR Abort if not ready
|
|
1242 REREAD LDX 2,S Recover LSN from stack
|
|
1243 LBSR SEEK Position head at sector
|
|
1244 BCS RETRY.RD Try again if seek error
|
|
1245 BSR READ3 Read the sector
|
|
1246 BCC EXIT.NER Read OK, return data
|
|
1247 RETRY.RD LDA 1,S Get retry control byte
|
|
1248 LSRA Indicate another try
|
|
1249 STA 1,S Put updated byte back
|
|
1250 BEQ EXIT.ERR If it was all 0, quit
|
|
1251 BCC REREAD If bit 0 was 0, don't home
|
|
1252 BSR HOME Home and start all over
|
|
1253 BCC REREAD If it won't home, quit now
|
|
1254 BRA EXIT.ERR Exit with an error
|
|
1255 *
|
|
1256 WRITE2 LDA #$A2 `Write sector' command
|
|
1257 BSR RWCMDX Execute command
|
|
1258 WAITWDRQ BITA >STATREG Wait until controller is
|
|
1259 BEQ WAITWDRQ ready to transfer data
|
|
1260 *
|
|
1261 WRTLOOP LDA ,X+ Get byte from data buffer
|
|
1262 STA >DATAREG Put it in data register
|
|
1263 STB >DPORT Activate DRQ halt function
|
|
1264 BRA WRTLOOP Loop until interrupted
|
|
1265 *
|
|
1266 VERIFY LDA #$82 `Read sector' command
|
|
1267 BSR RWCMDX Execute command
|
|
1268 WAITVDRQ BITA >STATREG Wait until controller is
|
|
1269 BEQ WAITVDRQ ready to transfer data
|
|
1270 *
|
|
1271 VFYLOOP LDA >DATAREG Get read data byte
|
|
1272 STB >DPORT Activate DRQ halt function
|
|
1273 CMPA ,X+ Compare to source data
|
|
1274 BEQ VFYLOOP Loop until interrupt if equal
|
|
1275 *
|
|
1276 ANDB #$7F Mask off DRQ halt bit
|
|
1277 STB >DPORT Disable DRQ halt function
|
|
1278 LBSR KILLCOMD Abort read command
|
|
1279 ERR.WRT COMB Set carry flag
|
|
1280 LDB #E$WRITE Set error code
|
|
1281 RTS
|
|
1282 *
|
|
1283 SS.HOME PSHS X,A,CC Set up stack for exit
|
|
1284 BSR HOME Home drive
|
|
1285 BRA SS.EXIT Skip to empty-stack exit
|
|
1286 SS.EXIT4 LEAS 2,S Exit w/4 bytes on stack
|
|
1287 SS.EXIT2 LEAS 2,S Exit w/2 bytes on stack
|
|
1288 SS.EXIT BCS EXIT.ERR Exit with error
|
|
1289 BRA EXIT.NER Exit with no error
|
|
1290 *
|
|
1291 HOME LBSR DSKSTART Start and select drive
|
|
1292 BCS RETURN2 Return if error
|
|
1293 LDX DRV.ACT,U Point to active drive's table
|
|
1294 CLR V.TRAK,X Set track number to zero
|
|
1295 LDD #$43C Home, verify, allow 3 seconds
|
|
1296 LBSR STEPEX Execute stepping command
|
|
1297 RETURN2 RTS
|
|
1298 *
|
|
1299 SETSTA LDX PD.RGS,Y Point to caller's stack
|
|
1300 LDB R$B,X Get stacked B register
|
|
1301 CMPB #SS.RESET `Home' call
|
|
1302 BEQ SS.HOME Execute Home sequence
|
|
1303 CMPB #SS.WTRK `Write track' call, used by
|
|
1304 BEQ WRT.TRAK the Format utility
|
|
1305 COMB If not one of those, it's an
|
|
1306 LDB #E$UNKSVC illegal setsta call
|
|
1307 RTS
|
|
1308 *
|
|
1309 READ3 LDA #$82 Read sector command
|
|
1310 BSR RWCMDX Set up for sector read
|
|
1311 WAITRDRQ BITA >STATREG Wait for controller to find
|
|
1312 BEQ WAITRDRQ sector and start reading
|
|
1313 *
|
|
1314 READLOOP LDA >DATAREG Get data from controller
|
|
1315 STA ,X+ Store in sector buffer
|
|
1316 STB >DPORT Activate DRQ halt function
|
|
1317 BRA READLOOP Loop until interrupted
|
|
1318 *
|
|
1319 RWCMDX LDX PD.BUF,Y Point to sector buffer
|
|
1320 LDB DPRT.IMG,U Do a side verify using the
|
|
1321 BITB #$40 DPORT image byte as a side
|
|
1322 BEQ WTKCMDX select indicator
|
|
1323 ORA #8 Compare for side 1
|
|
1324 WTKCMDX STA >COMDREG Issue command to controller
|
|
1325 LDB #$A8 Set up DRQ halt function
|
|
1326 ORB DPRT.IMG,U OR in select bits
|
|
1327 LDA #2 DRQ bit in status register
|
|
1328 RTS
|
|
1329 *
|
|
1330 * Write an entire track -- used by Format
|
|
1331 *
|
|
1332 WRT.TRAK PSHS X,A,CC Set up stack for exit
|
|
1333 LDA R$U+1,X Get track number
|
|
1334 LDB R$Y+1,X Get side select bit
|
|
1335 LDX R$X,X Get track buffer address
|
|
1336 PSHS X,D Save 'em
|
|
1337 LBSR DSKSTART Start and select drive
|
|
1338 BCS SS.EXIT4 Exit if error
|
|
1339 PULS D Get track number and side
|
|
1340 LDX DRV.ACT,U Get drive table address
|
|
1341 BSR SID.PCMP Get drive ready to go
|
|
1342 TST Q.SEEK,U Different drive/track?
|
|
1343 BNE WRT.TRK2 If not, no need to seek
|
|
1344 LDD #$103C Seek, allow 3 seconds
|
|
1345 LBSR STEPEX Execute stepping command
|
|
1346 BCS SS.EXIT2 Exit if error
|
|
1347 WRT.TRK2 PULS X Retrieve track buffer address
|
|
1348 LDA #$F0 `Write track' command
|
|
1349 BSR WTKCMDX Execute write track command
|
|
1350 LBSR WAITWDRQ Just like a Write Sector
|
|
1351 LBRA SS.EXIT Return to caller
|
|
1352 *
|
|
1353 SID.PCMP LSRB Bit 0 of B is set for
|
|
1354 BCC SIDE.ONE side 2 of disk
|
|
1355 LDB DPRT.IMG,U Get drive control image byte
|
|
1356 ORB #$40 Side 2 select bit
|
|
1357 STB DPRT.IMG,U Activate side 2 select
|
|
1358 SIDE.ONE CMPA PD.CYL+1,Y If track number exceeds #
|
|
1359 LBHI ERR.SECT of tracks, return error
|
|
1360 SD.PCMP2 LDB PD.DNS,Y Check track density of drive
|
|
1361 LSRB Shift bit 1 (TPI bit) into
|
|
1362 LSRB carry flag (1 = 96 TPI)
|
|
1363 LDB #20 Precomp starts at track 21
|
|
1364 BCC FORTYTKS on 48 TPI drives, track 41
|
|
1365 LSLB on 96 TPI drives
|
|
1366 FORTYTKS PSHS B Put B where it can be used
|
|
1367 CMPA ,S+ Does it need precomp?
|
|
1368 BLS NOPRECMP No, skip next step
|
|
1369 LDB DPRT.IMG,U Get drive control image byte
|
|
1370 ORB #$10 Write precompensation bit
|
|
1371 STB DPRT.IMG,U Activate precompensation
|
|
1372 NOPRECMP LDB V.TRAK,X Get current track number
|
|
1373 STB >TRAKREG Update disk controller
|
|
1374 CMPA V.TRAK,X Same track as last access?
|
|
1375 BEQ SAMETRAK If so, leave flag set
|
|
1376 CLR Q.SEEK,U Clear same drive/track flag
|
|
1377 SAMETRAK STA V.TRAK,X Update track number
|
|
1378 STA >DATAREG Set destination track
|
|
1379 LDB DPRT.IMG,U Get disk control byte
|
|
1380 STB >DPORT Update control port
|
|
1381 RTS
|
|
1382 *
|
|
1383 * Translate logical sector number (LSN) to physical side, track
|
|
1384 * and sector, activate write precompensation if necessary,
|
|
1385 * and execute seek command. If any error occurs, return error
|
|
1386 * number to calling routine.
|
|
1387 *
|
|
1388 SEEK LDD PD.SCT,Y Get #sectors per track
|
|
1389 PSHS X,D Put LSN and sec/trk on stack
|
|
1390 LDD 2,S Get LSN off stack
|
|
1391 CLR 2,S Set up track counter
|
|
1392 FINDTRAK INC 2,S Increment track counter
|
|
1393 SUBD ,S Subtract sectors in one track
|
|
1394 BPL FINDTRAK Loop if LSN still positive
|
|
1395 ADDD ,S++ Restore sector number
|
|
1396 INCB Sector numbers start at 1
|
|
1397 STB 1,S Save sector number
|
|
1398 PULS A Get track number
|
|
1399 DECA Compensate for extra count
|
|
1400 LDX DRV.ACT,U Get active table address
|
|
1401 LDB DD.FMT,X See if disk is double sided
|
|
1402 BITB #1 Test #sides bit
|
|
1403 BEQ SEEK2 If one-sided, skip next step
|
|
1404 LSRA Divide track number by 2
|
|
1405 ROLB Put remainder in B bit 0
|
|
1406 SEEK2 BSR SID.PCMP Set up precomp and side sel
|
|
1407 PULS B Get sector number
|
|
1408 STB >SECTREG Set destination sector
|
|
1409 TST Q.SEEK,U Same drive/track?
|
|
1410 BNE COMDEXIT If so, no need to seek
|
|
1411 LDD #$143C Seek with verify, allow 3 sec
|
|
1412 BRA STEPEX Execute stepping command
|
|
1413 *
|
|
1414 * Execute command in A and wait for it to finish. If it runs
|
|
1415 * normally or aborts with an error it will exit through NMI;
|
|
1416 * if it takes an unreasonable amount of time this routine
|
|
1417 * will abort it and set the carry flag. If the command
|
|
1418 * involves head movement, use STEPEX to set step rate.
|
|
1419 * On entry, A contains command code and B contains time limit
|
|
1420 * in 50-millisecond increments.
|
|
1421 *
|
|
1422 STEPEX PSHS A Put raw command on stack
|
|
1423 LDA PD.STP,Y Get step rate code
|
|
1424 EORA #3 Convert to 1793's format
|
|
1425 ORA ,S+ Combine with raw command
|
|
1426 COMDEX STA >COMDREG Execute command in A
|
|
1427 CLRA Clear carry flag
|
|
1428 BSR WAIT50MS Wait while command runs
|
|
1429 BCC COMDEXIT Exit if no error
|
|
1430 CMPB #E$NOTRDY Test for the three valid
|
|
1431 BEQ KCEXIT error codes for a Type 1
|
|
1432 CMPB #E$SEEK disk controller command --
|
|
1433 BEQ KCEXIT home, seek or force int-
|
|
1434 CMPB #E$CRC errupt -- and return the
|
|
1435 BEQ KCEXIT errors
|
|
1436 COMDEXIT CLRB No error, clear carry
|
|
1437 RTS
|
|
1438 *
|
|
1439 WAIT50MS LDX #$15D8 Almost exactly 50 mSec delay
|
|
1440 WAITIMER LEAX -1,X Wait specified time for disk
|
|
1441 BNE WAITIMER controller to issue NMI
|
|
1442 DECB signaling command completed
|
|
1443 BNE WAIT50MS or aborted with error
|
|
1444 KILLCOMD LDA #$D0 Force interrupt, NMI disabled
|
|
1445 STA >COMDREG Abort command in progress
|
|
1446 ERR.NRDY LDB #E$NOTRDY Set error code
|
|
1447 KCEXIT COMA Set carry to flag error
|
|
1448 RTS
|
|
1449 *
|
|
1450 *
|
|
1451 * Get selected drive ready to read or write. If spindle motors are
|
|
1452 * stopped, start them and wait until they're up to operating
|
|
1453 * speed. Check drive number and select drive if number is valid.
|
|
1454 * Monitor index pulses to ensure door is closed, disk inserted
|
|
1455 * and turning, etc. Return appropriate error code if any of
|
|
1456 * these conditions can't be met.
|
|
1457 *
|
|
1458 DSKSTART TST >D.DSKTMR Are drives already running?
|
|
1459 BNE SPINRDY If so, no need to wait
|
|
1460 CLR DRVS.RDY,U No drives are ready
|
|
1461 LDD #$80B Motor on, wait 550 mSec
|
|
1462 STA >DPORT Start spindle motors
|
|
1463 BSR WAIT50MS Wait for motors to start
|
|
1464 SPINRDY LDA PD.DRV,Y Get drive number
|
|
1465 CMPA V.NDRV,U Test for valid drive #
|
|
1466 BHS ERR.UNIT Return error if not
|
|
1467 LEAX TABL.ORG,U Compute address of active
|
|
1468 LDB #DRVMEM drive's parameter table
|
|
1469 MUL TABL.ORG + (D# * tablesize)
|
|
1470 LEAX D,X Add computed offset to origin
|
|
1471 LDA PD.DRV,Y Get drive number again
|
|
1472 LSLA Set corresponding drv select
|
|
1473 BNE NOTDRV0 bit -- 1 for D1, 2 for D2
|
|
1474 INCA Set bit 0 for drive 0
|
|
1475 NOTDRV0 TFR A,B Copy select bit
|
|
1476 ORB #$28 Enable double density
|
|
1477 ORCC #INTMASKS Disable IRQ and FIRQ
|
|
1478 STB >DPORT Enable drive
|
|
1479 STB DPRT.IMG,U Set image byte
|
|
1480 CLR Q.SEEK,U Clear same drive/track flag
|
|
1481 CMPX DRV.ACT,U Is this the same drive?
|
|
1482 BNE NEWDRIVE If not, leave flag zeroed
|
|
1483 LDB #$FF Indicate successive accesses
|
|
1484 STB Q.SEEK,U to the same drive.
|
|
1485 NEWDRIVE STX DRV.ACT,U Store table address
|
|
1486 BITA DRVS.RDY,U Has this drive been ready
|
|
1487 BNE DRVRDY since the motors started?
|
|
1488 PSHS A Save drive select bit
|
|
1489 LDD #$D405 Force int, allow 250 mSec
|
|
1490 BSR COMDEX Look for index pulse
|
|
1491 PSHS CC Save carry flag condition
|
|
1492 BSR KILLCOMD Clear index-pulse NMI state
|
|
1493 PULS CC,A Restore carry flag and A
|
|
1494 BCS RETURN3 Error if no index pulse
|
|
1495 DRVRDY ORA DRVS.RDY,U Set corresponding drive
|
|
1496 STA DRVS.RDY,U ready flag
|
|
1497 LDA #DISKRUN Restart disk rundown timer
|
|
1498 STA >D.DSKTMR
|
|
1499 LDA >STATREG Clear interrupt condition
|
|
1500 CLRB Return no error
|
|
1501 RETURN3 RTS
|
|
1502 *
|
|
1503 ERR.UNIT COMB Set carry flag
|
|
1504 LDB E$UNIT Set error code
|
|
1505 RTS
|
|
1506 *
|
|
1507 ENDC
|
|
1508
|
|
1509 emod
|
|
1510 eom equ *
|
|
1511 end
|