91
|
1 * COPYRIGHT BURKE & BURKE 1987
|
|
2 * ALL RIGHTS RESERVED
|
|
3 *
|
|
4 * COCO XT UTILITY ROUTINES
|
|
5 *
|
|
6 * Date Who Description
|
|
7 * -------- --- ---------------------------------
|
|
8 * 08-14-87 CJB Added modification history.
|
|
9 * Added assembly switch for controller
|
|
10 * in slot 1.
|
|
11 *
|
|
12 * 10-26-87 CJB Added conditional assembly to leave
|
|
13 * interrupts enabled if IRQFLG zero.
|
|
14 *
|
|
15 * 11-20-87 CJB Fixed IRQ DISABLE bug (uses switch IRQFLG)
|
|
16 * Added work-around for F$SLEEP bug (GRFDRV ONLY)
|
|
17 *
|
|
18 * 12-20-87 CJB Added routine to sleep or delay while waiting
|
|
19 * for disk seeks (SNOOZE)
|
|
20 *
|
|
21 * 01/28/88 CJB Added improved slot switching and slot
|
|
22 * independence. Slot # in PD.DNS
|
|
23 *
|
|
24 * 02/08/88 CJB Added SAVSLT for improved read cache performance
|
|
25 * 05/18/88 cjb Added CLR V.WAKE,U in SLOT4 routine
|
|
26 * 07/14/91 cjb Rev. 2.5 added support for fast recalibration
|
|
27 *
|
|
28
|
|
29 page
|
|
30 *
|
|
31 * Select HD controller slot SPARESEL in multi-Pak.
|
|
32 *
|
|
33 * Enter w/ Reg-U -> static storage,
|
|
34 * Reg-Y -> path descriptor
|
|
35 *
|
|
36 * The active ROM/CART slot is preserved.
|
|
37 *
|
|
38 * This routine is normally called with interrupts enabled.
|
|
39 * It disables them if IRQFLG is 1, for use on L1, V1
|
|
40 * systems.
|
|
41 *
|
|
42 * Note that this routine does *NOT* set the DMA semaphore.
|
|
43 * This is only done once, at the very beginning of each command.
|
|
44 *
|
|
45 SLOT3 equ *
|
|
46
|
|
47 ifeq IRQFLG ;If level 2, or version 2 of level 1
|
|
48 pshs CC ;Save entry CC
|
|
49 endc
|
|
50
|
|
51 orcc #$50 ;No interrupts during MPAK update
|
|
52
|
|
53 bsr SavSlt ;Save old slot #, get to A
|
|
54 anda #%11110000
|
|
55 ora PD.DNS,Y ;Use device's slot #
|
|
56 sta >MPAK
|
|
57
|
|
58 ifeq IRQFLG ;If level 2, or version 2 of level 1
|
|
59 puls CC,PC ; restore entry CC
|
|
60 else
|
|
61 rts ; exit with interrupts disabled
|
|
62 endc
|
|
63
|
|
64 * Utility to save old slot
|
|
65 * Preserves B:X
|
|
66
|
|
67 SavSlt lda >MPAK
|
|
68 sta OldSlt,U
|
|
69 rts
|
|
70
|
|
71 *
|
|
72 * Restore original slot SPARESEL in multi-PAK.
|
|
73 *
|
|
74 * Enter w/ Reg-U -> static storage
|
|
75 *
|
|
76 * This routine preserves carry and B, since it is called
|
|
77 * before returning an error code.
|
|
78 *
|
|
79 * The active ROM slot and CART interrupt is also preserved.
|
|
80 *
|
|
81 * This routine is always called with interrupts disabled.
|
|
82 * (or with interrupts enabled and SLOT4 selected already)
|
|
83 * It always enables interrupts.
|
|
84 *
|
|
85 * Note that this routine does *NOT* clear the DMA semaphore
|
|
86 * unless entered at Release. This is only done once, at
|
|
87 * the very end of each command.
|
|
88 *
|
|
89 Release orcc #$50 ;Force no interrupts during updates
|
|
90
|
|
91 lda #0 ;preserve carry
|
|
92 * sta >D.DMAReq ;clear "DMA in use" semaphore
|
|
93 sta >DMASEM ;Zero OS9 level-dependent semaphore
|
|
94
|
|
95 SLOT4 orcc #$50 ;Force no interrupts during update
|
|
96
|
|
97 lda OLDSLT,U ;Recover old slot
|
|
98 sta >MPAK
|
|
99 lda #0 ;Preserve carry
|
|
100 sta V.WAKE,U ;Free anyone waiting on us.
|
|
101
|
|
102 andcc #$AF ;Enable interrupts
|
|
103 rts
|
|
104
|
|
105 *
|
|
106 * Wait for end of other processes disk I/O. This is
|
|
107 * indicated by semaphore $6A = 0. Grab semaphore
|
|
108 * as soon as it frees up.
|
|
109 *
|
|
110 * Assumes slot 3 is selected at entry, and interrupts
|
|
111 * are enabled.
|
|
112 *
|
|
113 * Always exits with slot 3 selected and interrupts disabled.
|
|
114 *
|
|
115 Semfor pshs U,X,Y,B,A,CC
|
|
116
|
|
117 * Wait for semaphore loop . . .
|
|
118 Sem0 orcc #$50 ;No interrupts!
|
|
119
|
|
120 tst >DMASEM ;Check OS9 level-dependent semaphore
|
|
121 * tst >D.DMAReq ;Check semaphore
|
|
122 bne W6.SLP
|
|
123
|
|
124 * Semaphore is free. Grab it.
|
|
125
|
|
126 dec >DMASEM ;Grab OS9 level-dependent semaphore
|
|
127 * dec >D.DMAReq ;Grab semaphore!
|
|
128 puls CC,A,B,Y,X,U ;restore interrupts, etc
|
|
129 bra Slot3 ; and select hard disk controller
|
|
130
|
|
131 *
|
|
132 * Routine to waste time during disk seeks, etc.
|
|
133 *
|
|
134 * On systems that support D.DMAReq, we set the slot to 4 and
|
|
135 * give up the processor. Otherwise, we return immediately.
|
|
136 *
|
|
137 Snooze pshs U,Y,X,D
|
|
138
|
|
139 ifeq IRQFLG ;If D.DMAReq,
|
|
140 bsr TikNap ; surrender slot and processor
|
|
141 bsr Slot3 ; map controller in again
|
|
142 endc
|
|
143
|
|
144 puls D,X,Y,U,PC
|
|
145
|
|
146 * Semaphore is busy. Sleep a bit.
|
|
147 W6.SLP bsr TikNap ;Surrender the processor
|
|
148 bra Sem0
|
|
149
|
|
150 *
|
|
151 * Force slot 4, enable interrupts,
|
|
152 * Sleep for the rest of this tick.
|
|
153 *
|
|
154 TikNap pshs X ;Save entry X
|
|
155 bsr Slot4 ;Select slot 4, enable interrupts
|
|
156
|
|
157 ifne (XLEVEL-1) ;If Level 2,
|
|
158 ldx <D.SYSPRC
|
|
159 cmpx <DPROC
|
|
160 beq TikXit ;WORKAROUND -- IF LOADING GRFDRV, NO SLEEP!
|
|
161 endc
|
|
162
|
|
163 ldx #1
|
|
164 OS9 F$Sleep ;Give up the rest of this tick
|
|
165
|
|
166 TikXit puls X,PC
|
|
167
|
|
168 page
|
|
169 *
|
|
170 * Perform a SEEK command
|
|
171 *
|
|
172 SEEK lda #WX$SIK ;Construct "SEEK" command
|
|
173 lbsr CmExec
|
|
174 rts
|
|
175
|
|
176 *
|
|
177 * Seek to track 0
|
|
178 *
|
|
179 SEEKT0 tst PD.STP,Y
|
|
180 bpl ST0A
|
|
181
|
|
182 * Here for drives that don't need recalibration
|
|
183 * Just return immediately.
|
|
184
|
|
185 clrb
|
|
186 rts
|
|
187
|
|
188 * Here for drives that need it
|
|
189
|
|
190 ST0A lda #WX$TK0 ;Create "RECALIBRATE" command
|
|
191 lbsr CmExec
|
|
192 bcs ST0XIT
|
|
193
|
|
194 ifne (Drives-1)
|
|
195 ldx actdrv,u ;Clear track number in active drive table
|
|
196 clr V.TRAK,x
|
|
197 clr V.TRAK+1,x
|
|
198 else
|
|
199 clr DRVTBL+V.TRAK,U
|
|
200 clr DRVTBL+V.TRAK+1,U
|
|
201 endc
|
|
202
|
|
203 ST0XIT rts
|
|
204
|
|
205 *
|
|
206 * end of hdutil3.src
|
|
207 *
|