Mercurial > hg > Members > kono > nitros9-code
annotate level1/modules/dw3.asm @ 2700:772a16760499 lwtools-port
Slight improvements
author | Boisy Pitre <boisy.pitre@nuance.com> |
---|---|
date | Fri, 20 Jul 2012 13:36:02 -0500 |
parents | 1c88a9bc6c8c |
children | 2bd966ffd6d5 |
rev | line source |
---|---|
2180 | 1 ******************************************************************** |
2 * DW3 - DriveWire 3 Low Level Subroutine Module | |
3 * | |
4 * $Id$ | |
5 * | |
6 * Edt/Rev YYYY/MM/DD Modified by | |
7 * Comment | |
8 * ------------------------------------------------------------------ | |
9 * 1 2008/01/26 Boisy G. Pitre | |
10 * Started as a segregated subroutine module. | |
2374 | 11 * |
12 * 2 2010/01/20 Boisy G. Pitre | |
13 * Added support for DWNet | |
2387 | 14 * |
15 * 3 2010/01/23 Aaron A. Wolfe | |
16 * Added dynamic polling frequency | |
17 * | |
2374 | 18 nam DW3 |
19 ttl DriveWire 3 Low Level Subroutine Module | |
2180 | 20 |
2374 | 21 ifp1 |
22 use defsfile | |
2624 | 23 use drivewire.d |
2374 | 24 endc |
2180 | 25 |
2374 | 26 tylg set Sbrtn+Objct |
27 atrv set ReEnt+rev | |
28 rev set $01 | |
2308 | 29 |
2374 | 30 mod eom,name,tylg,atrv,start,0 |
2180 | 31 |
2308 | 32 * irq |
2374 | 33 IRQPckt fcb $00,$01,$0A ;IRQ packet Flip(1),Mask(1),Priority(1) bytes |
2308 | 34 * Default time packet |
2374 | 35 DefTime fcb 109,12,31,23,59,59 |
2180 | 36 |
2435 | 37 * for dynamic poll frequency, number of ticks between firing poller - should we move to dwdefs? |
2387 | 38 * speed 1 = interactive (typing) |
39 PollSpd1 fcb 3 | |
2435 | 40 * speed 2 = bulk transfer (depending on how much processing needs to be done to incoming stream, 5-8 seems good) |
2387 | 41 PollSpd2 fcb 6 |
2435 | 42 * speed 3 = idle |
2387 | 43 PollSpd3 fcb 40 |
44 * X pollidle -> drop to next slower rate | |
45 PollIdle fcb 60 | |
46 | |
47 | |
2374 | 48 name fcs /dw3/ |
2180 | 49 |
50 * DriveWire subroutine entry table | |
2374 | 51 start lbra Init |
52 bra Read | |
53 nop | |
54 lbra Write | |
2180 | 55 |
56 * Term | |
57 * | |
58 * Entry: | |
59 * U = address of device memory area | |
60 * | |
61 * Exit: | |
62 * CC = carry set on error | |
63 * B = error code | |
64 * | |
2374 | 65 Term |
66 clrb clear Carry | |
67 rts | |
2180 | 68 |
2374 | 69 Read |
70 use dwread.asm | |
71 | |
72 Write | |
73 use dwwrite.asm | |
2308 | 74 |
2638
4655eabf00c0
dw3.asm is now common... dwinit.asm now added to for port specific initialization
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
75 |
4655eabf00c0
dw3.asm is now common... dwinit.asm now added to for port specific initialization
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
76 use dwinit.asm |
4655eabf00c0
dw3.asm is now common... dwinit.asm now added to for port specific initialization
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
77 |
2308 | 78 * Init |
79 * | |
80 * Entry: | |
81 * Y = address of device descriptor | |
82 * U = address of device memory area | |
83 * | |
84 * Exit: | |
85 * CC = carry set on error | |
86 * B = error code | |
87 * | |
88 * Initialize the serial device | |
2374 | 89 Init |
90 clrb clear Carry | |
91 pshs y,x,cc then push CC on stack | |
2638
4655eabf00c0
dw3.asm is now common... dwinit.asm now added to for port specific initialization
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
92 bsr DWInit |
2308 | 93 |
94 ; allocate DW statics page | |
2374 | 95 pshs u |
96 ldd #$0100 | |
97 os9 F$SRqMem | |
98 tfr u,x | |
99 puls u | |
100 lbcs InitEx | |
101 ifgt Level-1 | |
102 stx <D.DWStat | |
103 else | |
104 stx >D.DWStat | |
105 endc | |
2308 | 106 ; clear out 256 byte page at X |
2374 | 107 clrb |
108 loop@ clr ,x+ | |
109 decb | |
110 bne loop@ | |
2308 | 111 |
2321
6a5ada3e2666
added DWINIT op code, dw3 now sends on init just before installing VIRQ
aaronwolfe
parents:
2316
diff
changeset
|
112 * send OP_DWINIT |
6a5ada3e2666
added DWINIT op code, dw3 now sends on init just before installing VIRQ
aaronwolfe
parents:
2316
diff
changeset
|
113 ; setup DWsub command |
2374 | 114 pshs u |
2429
65541e2444dc
use dwinit to become compatible with dw3 server
aaronwolfe
parents:
2422
diff
changeset
|
115 ldb #1 ; DRIVER VERSION |
2374 | 116 lda #OP_DWINIT ; load command |
2429
65541e2444dc
use dwinit to become compatible with dw3 server
aaronwolfe
parents:
2422
diff
changeset
|
117 pshs d ; command store on stack |
2374 | 118 leax ,s ; point X to stack |
2429
65541e2444dc
use dwinit to become compatible with dw3 server
aaronwolfe
parents:
2422
diff
changeset
|
119 ldy #2 ; 1 byte to send |
2374 | 120 ifgt Level-1 |
121 ldu <D.DWSubAddr | |
122 else | |
123 ldu >D.DWSubAddr | |
124 endc | |
2640
8d24c482646e
o increased timeout in atari dwread.asm module
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2638
diff
changeset
|
125 jsr DW$Write,u ; call DWrite |
2429
65541e2444dc
use dwinit to become compatible with dw3 server
aaronwolfe
parents:
2422
diff
changeset
|
126 leas 1,s ; leave one byte on stack for response |
65541e2444dc
use dwinit to become compatible with dw3 server
aaronwolfe
parents:
2422
diff
changeset
|
127 |
65541e2444dc
use dwinit to become compatible with dw3 server
aaronwolfe
parents:
2422
diff
changeset
|
128 ; read protocol version response, 1 byte |
65541e2444dc
use dwinit to become compatible with dw3 server
aaronwolfe
parents:
2422
diff
changeset
|
129 leax ,s ; point X to stack head |
65541e2444dc
use dwinit to become compatible with dw3 server
aaronwolfe
parents:
2422
diff
changeset
|
130 ldy #1 ; 1 byte to retrieve |
2640
8d24c482646e
o increased timeout in atari dwread.asm module
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2638
diff
changeset
|
131 jsr DW$Read,u ; call DWRead |
8d24c482646e
o increased timeout in atari dwread.asm module
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2638
diff
changeset
|
132 IFNE atari-1 |
2429
65541e2444dc
use dwinit to become compatible with dw3 server
aaronwolfe
parents:
2422
diff
changeset
|
133 beq InstIRQ ; branch if no error |
2640
8d24c482646e
o increased timeout in atari dwread.asm module
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2638
diff
changeset
|
134 ENDC |
2429
65541e2444dc
use dwinit to become compatible with dw3 server
aaronwolfe
parents:
2422
diff
changeset
|
135 leas 3,s ; error, cleanup stack (u and 1 byte from read) |
65541e2444dc
use dwinit to become compatible with dw3 server
aaronwolfe
parents:
2422
diff
changeset
|
136 lbra InitEx ; don't install IRQ handler |
2374 | 137 |
2308 | 138 * install ISR |
2374 | 139 InstIRQ |
2429
65541e2444dc
use dwinit to become compatible with dw3 server
aaronwolfe
parents:
2422
diff
changeset
|
140 puls a,u ; a has proto version from server.. not used yet |
65541e2444dc
use dwinit to become compatible with dw3 server
aaronwolfe
parents:
2422
diff
changeset
|
141 |
65541e2444dc
use dwinit to become compatible with dw3 server
aaronwolfe
parents:
2422
diff
changeset
|
142 ifgt Level-1 |
2374 | 143 ldx <D.DWStat |
144 else | |
145 ldx >D.DWStat | |
146 endc | |
147 leax DW.VIRQPkt,x | |
148 pshs u | |
149 tfr x,u | |
150 leax Vi.Stat,x ;fake VIRQ status register | |
151 lda #$80 ;VIRQ flag clear, repeated VIRQs | |
152 sta ,x ;set it while we're here... | |
153 tfr x,d ;copy fake VIRQ status register address | |
154 leax IRQPckt,pcr ;IRQ polling packet | |
155 leay IRQSvc,pcr ;IRQ service entry | |
156 os9 F$IRQ ;install | |
157 puls u | |
158 bcs InitEx ;exit with error | |
2387 | 159 clra |
160 ldb PollSpd3,pcr ; start at idle | |
2374 | 161 ifgt Level-1 |
162 ldx <D.DWStat | |
163 else | |
164 ldx >D.DWStat | |
165 endc | |
166 leax DW.VIRQPkt,x | |
167 std Vi.Rst,x ; reset count | |
168 tfr x,y ; move VIRQ software packet to Y | |
169 tryagain | |
170 ldx #$0001 ; code to install new VIRQ | |
171 os9 F$VIRQ ; install | |
172 bcc IRQok ; no error, continue | |
173 cmpb #E$UnkSvc | |
174 bne InitEx | |
2308 | 175 ; if we get an E$UnkSvc error, then clock has not been initialized, so do it here |
2374 | 176 leax DefTime,pcr |
177 os9 F$STime | |
178 bra tryagain ; note: this has the slim potential of looping forever | |
179 IRQok | |
180 ifgt Level-1 | |
181 ldx <D.DWStat | |
182 else | |
183 ldx >D.DWStat | |
184 endc | |
2308 | 185 ; cheat: we know DW.StatTbl is at offset $00 from D.DWStat, do not bother with leax |
2374 | 186 leax DW.StatTbl,x |
187 tfr u,d | |
188 ldb <V.PORT+1,u ; get our port # | |
189 sta b,x ; store in table | |
2308 | 190 |
2374 | 191 InitEx |
192 puls cc,x,y,pc | |
2308 | 193 |
194 | |
195 ; *********************************************************************** | |
196 ; Interrupt handler - Much help from Darren Atkinson | |
2374 | 197 |
198 IRQMulti3 anda #$0F ; mask first 4 bits, a is now port #+1 | |
199 deca ; we pass +1 to use 0 for no data | |
200 pshs a ; save port # | |
201 cmpb RxGrab,u ; compare room in buffer to server's byte | |
202 bhs IRQM06 ; room left >= server's bytes, no problem | |
203 | |
204 stb RxGrab,u ; else replace with room left in our buffer | |
2308 | 205 |
206 ; also limit to end of buffer | |
2374 | 207 IRQM06 ldd RxBufEnd,u ; end addr of buffer |
208 subd RxBufPut,u ; subtract current write pointer, result is # bytes left going forward in buff. | |
209 | |
210 IRQM05 cmpb RxGrab,u ; compare b (room left) to grab bytes | |
211 bhs IRQM03 ; branch if we have room for grab bytes | |
2308 | 212 |
2374 | 213 stb RxGrab,u ; else set grab to room left |
214 | |
2308 | 215 ; send multiread req |
2374 | 216 IRQM03 puls a ; port # is on stack |
217 ldb RxGrab,u | |
2308 | 218 |
2374 | 219 pshs u |
220 | |
2308 | 221 ; setup DWsub command |
2374 | 222 pshs d ; (a port, b bytes) |
223 lda #OP_SERREADM ; load command | |
224 pshs a ; command store on stack | |
225 leax ,s ; point X to stack | |
226 ldy #3 ; 3 bytes to send | |
2308 | 227 |
2374 | 228 ifgt Level-1 |
229 ldu <D.DWSubAddr | |
230 else | |
231 ldu >D.DWSubAddr | |
232 endc | |
2640
8d24c482646e
o increased timeout in atari dwread.asm module
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2638
diff
changeset
|
233 jsr DW$Write,u ; call DWrite |
2308 | 234 |
2374 | 235 leas 3,s ; clean 3 DWsub args from stack |
2308 | 236 |
2374 | 237 ldx ,s ; pointer to this port's area (from U prior), leave it on stack |
238 ldb RxGrab,x ; set B to grab bytes | |
239 clra ; 0 in high byte | |
240 tfr d,y ; set # bytes for DW | |
2308 | 241 |
2374 | 242 ldx RxBufPut,x ; point X to insert position in this port's buffer |
2308 | 243 ; receive response |
2640
8d24c482646e
o increased timeout in atari dwread.asm module
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2638
diff
changeset
|
244 jsr DW$Read,u ; call DWRead |
2308 | 245 ; handle errors? |
246 | |
247 | |
2374 | 248 puls u |
249 ldb RxGrab,u ; our grab bytes | |
2308 | 250 |
251 ; set new RxBufPut | |
2374 | 252 ldx RxBufPut,u ; current write pointer |
253 abx ; add b (# bytes) to RxBufPut | |
254 cmpx RxBufEnd,u ; end of Rx buffer? | |
255 blo IRQM04 ; no, go keep laydown pointer | |
256 ldx RxBufPtr,u ; get Rx buffer start address | |
257 IRQM04 stx RxBufPut,u ; set new Rx data laydown pointer | |
2308 | 258 |
259 ; set new RxDatLen | |
2374 | 260 ldb RxDatLen,u |
261 addb RxGrab,u | |
262 stb RxDatLen,u ; store new value | |
263 | |
264 lbra CkSSig ; had to lbra | |
265 | |
266 IRQMulti | |
2387 | 267 ; set IRQ freq for bulk |
268 pshs a | |
269 lda PollSpd2,pcr | |
270 lbsr IRQsetFRQ | |
271 puls a | |
272 | |
2308 | 273 ; initial grab bytes |
2374 | 274 stb RxGrab,u |
275 | |
2308 | 276 ; limit server bytes to bufsize - datlen |
2374 | 277 ldb RxBufSiz,u ; size of buffer |
278 subb RxDatLen,u ; current bytes in buffer | |
279 bne IRQMulti3 ; continue, we have some space in buffer | |
2308 | 280 ; no room in buffer |
2374 | 281 tstb |
282 lbne CkSSig ;had to lbra | |
283 lbra IRQExit ;had to lbra | |
284 | |
2308 | 285 |
286 ; **** IRQ ENTRY POINT | |
2374 | 287 IRQSvc equ * |
288 pshs cc,dp ; save system cc,DP | |
289 orcc #IntMasks ; mask interrupts | |
2308 | 290 |
291 ; mark VIRQ handled (note U is pointer to our VIRQ packet in DP) | |
2374 | 292 lda Vi.Stat,u ; VIRQ status register |
293 anda #^Vi.IFlag ; clear flag in VIRQ status register | |
294 sta Vi.Stat,u ; save it... | |
2308 | 295 |
296 ; poll server for incoming serial data | |
297 | |
298 ; send request | |
2374 | 299 lda #OP_SERREAD ; load command |
300 pshs a ; command store on stack | |
301 leax ,s ; point X to stack | |
302 ldy #1 ; 1 byte to send | |
2308 | 303 |
2374 | 304 ifgt Level-1 |
305 ldu <D.DWSubAddr | |
306 else | |
307 ldu >D.DWSubAddr | |
308 endc | |
2640
8d24c482646e
o increased timeout in atari dwread.asm module
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2638
diff
changeset
|
309 jsr DW$Write,u ; call DWrite |
2308 | 310 |
311 ; receive response | |
2374 | 312 leas -1,s ; one more byte to fit response |
313 leax ,s ; point X to stack head | |
314 ldy #2 ; 2 bytes to retrieve | |
2640
8d24c482646e
o increased timeout in atari dwread.asm module
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2638
diff
changeset
|
315 jsr DW$Read,u ; call DWRead |
2374 | 316 beq IRQSvc2 ; branch if no error |
317 leas 2,s ; error, cleanup stack 2 | |
318 lbra IRQExit2 ; don't reset error count on the way out | |
2308 | 319 |
320 ; process response | |
2374 | 321 IRQSvc2 |
322 ldd ,s++ ; pull returned status byte into A,data into B (set Z if zero, N if multiread) | |
2387 | 323 bne IRQGotOp ; branch if D != 0 (something to do) |
324 * this is a NOP response.. do we need to reschedule | |
325 ifgt Level-1 | |
326 ldx <D.DWStat | |
327 else | |
328 ldx >D.DWStat | |
329 endc | |
2422 | 330 lda DW.VIRQPkt+Vi.Rst+1,x |
2387 | 331 cmpa PollSpd3,pcr |
332 lbeq IRQExit ;we are already at idle speed | |
2308 | 333 |
2387 | 334 lda DW.VIRQNOP,x |
335 inca | |
336 cmpa PollIdle,pcr | |
337 beq FRQdown | |
338 | |
339 sta DW.VIRQNOP,x ;inc NOP count, exit | |
340 lbra IRQExit | |
341 | |
2422 | 342 FRQdown lda DW.VIRQPkt+Vi.Rst+1,x |
2387 | 343 cmpa PollSpd1,pcr |
344 beq FRQd1 | |
345 lda PollSpd3,pcr | |
346 FRQd2 | |
2422 | 347 sta DW.VIRQPkt+Vi.Rst+1,x |
2387 | 348 clr DW.VIRQNOP,x |
349 lbra IRQExit | |
350 FRQd1 lda PollSpd2,pcr | |
351 bra FRQd2 | |
2374 | 352 |
2308 | 353 ; save back D on stack and build our U |
2387 | 354 IRQGotOp pshs d |
2661
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
355 * mode switch on bits 7+6 of A: 00 = vserial, 01 = vwindow, 10 = wirebug?, 11 = ? |
2374 | 356 anda #$C0 ; mask last 6 bits |
357 beq mode00 ; virtual serial mode | |
2311 | 358 ; future - handle other modes |
2661
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
359 cmpa #%01000000 ; vwindow? |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
360 beq mode01 |
2374 | 361 lbra IRQExit ; for now, bail |
362 | |
2661
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
363 * Virtual Window Handler |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
364 mode01 |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
365 lda ,s |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
366 anda #%00110000 |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
367 beq key |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
368 lbra IRQExit |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
369 |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
370 key |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
371 lda ,s |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
372 anda #$0F |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
373 ora #$10 |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
374 ifgt Level-1 |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
375 ldx <D.DWStat |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
376 else |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
377 ldx >D.DWStat |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
378 endc |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
379 ; cheat: we know DW.StatTbl is at offset $00 from D.DWStat, do not bother with leax |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
380 ; leax DW.StatTbl,x |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
381 lda a,x |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
382 clrb |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
383 tfr d,u |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
384 puls d |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
385 lbra IRQPutch |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
386 |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
387 |
9e9ed6d6b4c2
Updated so that scdwn handles SS.Montr
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2640
diff
changeset
|
388 * Virtual Serial Handler |
2374 | 389 mode00 lda ,s ; restore A |
390 anda #$0F ; mask first 4 bits, a is now port #+1 | |
391 beq IRQCont ; if we're here with 0 in the port, its not really a port # (can we jump straight to status?) | |
392 deca ; we pass +1 to use 0 for no data | |
2308 | 393 ; here we set U to the static storage area of the device we are working with |
2374 | 394 ifgt Level-1 |
395 ldx <D.DWStat | |
396 else | |
397 ldx >D.DWStat | |
398 endc | |
2308 | 399 ; cheat: we know DW.StatTbl is at offset $00 from D.DWStat, do not bother with leax |
400 ; leax DW.StatTbl,x | |
2374 | 401 lda a,x |
402 bne IRQCont ; if A is 0, then this device is not active, so exit | |
403 puls d | |
404 lbra IRQExit | |
405 IRQCont | |
406 clrb | |
407 tfr d,u | |
408 | |
409 puls d | |
2308 | 410 |
2311 | 411 * multiread/status flag is in bit 4 of A |
2374 | 412 bita #$10 |
2387 | 413 beq IRQPutch ; branch for read1 if multiread not set |
2374 | 414 |
2311 | 415 * all 0s in port means status, anything else is multiread |
2374 | 416 |
417 bita #$0F ;mask bit 7-4 | |
418 beq dostat ;port # all 0, this is a status response | |
2387 | 419 lbra IRQMulti ;its not all 0, this is a multiread |
2308 | 420 |
2314
5f76d1a611f6
term signal sending for serread port status responses
aaronwolfe
parents:
2313
diff
changeset
|
421 |
5f76d1a611f6
term signal sending for serread port status responses
aaronwolfe
parents:
2313
diff
changeset
|
422 * in status events, databyte is split, 4bits status, 4bits port # |
2374 | 423 dostat bitb #$F0 ;mask low bits |
424 lbne IRQExit ;we only implement code 0000, term | |
2314
5f76d1a611f6
term signal sending for serread port status responses
aaronwolfe
parents:
2313
diff
changeset
|
425 * set u to port # |
2374 | 426 ifgt Level-1 |
427 ldx <D.DWStat | |
428 else | |
429 ldx >D.DWStat | |
430 endc | |
431 lda b,x | |
432 bne statcont ; if A is 0, then this device is not active, so exit | |
433 lbra IRQExit | |
2372 | 434 |
2387 | 435 * IRQ set freq routine |
436 * sets freq and clears NOP counter | |
437 * a = desired IRQ freq | |
438 IRQsetFRQ pshs x ; preserve | |
439 ifgt Level-1 | |
440 ldx <D.DWStat | |
441 else | |
442 ldx >D.DWStat | |
443 endc | |
2422 | 444 sta DW.VIRQPkt+Vi.Rst+1,x |
445 * +++ BGP +++ added following line so that the counter (which was copied by | |
446 * clock before calling us) gets reset to the same value the reset value. Without | |
447 * this line, we get called again with the PRIOR Vi.Rst value. | |
448 sta DW.VIRQPkt+Vi.Cnt+1,x | |
2387 | 449 clr DW.VIRQNOP,x |
450 puls x | |
451 rts | |
452 | |
453 | |
2372 | 454 * This routine roots through process descriptors in a queue and |
455 * checks to see if the process has a path that is open to the device | |
2699
1c88a9bc6c8c
Reworked to make the searching of the paths in a process more efficient
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2698
diff
changeset
|
456 * represented by the static storage pointer in U. If so, the S$HUP |
2372 | 457 * signal is sent to that process |
458 * | |
2699
1c88a9bc6c8c
Reworked to make the searching of the paths in a process more efficient
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2698
diff
changeset
|
459 * Note: we start with path 0 and continue until we get to either (a) the |
1c88a9bc6c8c
Reworked to make the searching of the paths in a process more efficient
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2698
diff
changeset
|
460 * last path for that process or (b) a hit on the static storage that we |
1c88a9bc6c8c
Reworked to make the searching of the paths in a process more efficient
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2698
diff
changeset
|
461 * are seeking. |
1c88a9bc6c8c
Reworked to make the searching of the paths in a process more efficient
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2698
diff
changeset
|
462 * |
2372 | 463 * Entry: X = process descriptor to evaluate |
464 * U = static storage of device we want to check against | |
2374 | 465 RootThrough |
2699
1c88a9bc6c8c
Reworked to make the searching of the paths in a process more efficient
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2698
diff
changeset
|
466 clrb |
2374 | 467 leay P$Path,x |
468 pshs x | |
2699
1c88a9bc6c8c
Reworked to make the searching of the paths in a process more efficient
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2698
diff
changeset
|
469 loop cmpb #NumPaths |
1c88a9bc6c8c
Reworked to make the searching of the paths in a process more efficient
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2698
diff
changeset
|
470 beq out |
1c88a9bc6c8c
Reworked to make the searching of the paths in a process more efficient
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2698
diff
changeset
|
471 incb |
2374 | 472 lda ,y+ |
473 beq loop | |
474 pshs y | |
475 ifgt Level-1 | |
476 ldx <D.PthDBT | |
477 else | |
478 ldx >D.PthDBT | |
479 endc | |
480 os9 F$Find64 | |
2700 | 481 puls y |
482 bcs loop +BGP+ Jul 20, 2012: continue even if error in F$Find64 | |
2374 | 483 ldx PD.DEV,y |
484 leax V$STAT,x | |
2372 | 485 |
2374 | 486 cmpu ,x |
487 bne loop | |
488 | |
489 ldx ,s | |
490 lda P$ID,x | |
491 ldb #S$HUP | |
492 os9 F$Send | |
2372 | 493 |
2374 | 494 out puls x |
495 ldx P$Queue,x | |
496 bne RootThrough | |
497 rts | |
498 | |
499 statcont clrb | |
500 tfr d,u | |
2372 | 501 * NEW: root through all process descriptors. if any has a path open to this |
502 * device, send then S$HUP | |
2374 | 503 ldx <D.AProcQ |
2383
b399116a3b5f
Now we have a /N descriptor... and the code in scdwn.asm to handle it.
boisy
parents:
2375
diff
changeset
|
504 beq dowaitq |
2374 | 505 bsr RootThrough |
2383
b399116a3b5f
Now we have a /N descriptor... and the code in scdwn.asm to handle it.
boisy
parents:
2375
diff
changeset
|
506 dowaitq ldx <D.WProcQ |
b399116a3b5f
Now we have a /N descriptor... and the code in scdwn.asm to handle it.
boisy
parents:
2375
diff
changeset
|
507 beq dosleepq |
2374 | 508 bsr RootThrough |
2383
b399116a3b5f
Now we have a /N descriptor... and the code in scdwn.asm to handle it.
boisy
parents:
2375
diff
changeset
|
509 dosleepq ldx <D.SProcQ |
2375 | 510 beq CkLPRC |
2374 | 511 bsr RootThrough |
2372 | 512 |
2387 | 513 CkLPRC |
2374 | 514 lda <V.LPRC,u |
515 beq IRQExit ; no last process, bail | |
516 ldb #S$HUP | |
517 os9 F$Send ; send signal, don't think we can do anything about an error result anyway.. so | |
518 bra CkSuspnd ; do we need to go check suspend? | |
2314
5f76d1a611f6
term signal sending for serread port status responses
aaronwolfe
parents:
2313
diff
changeset
|
519 |
2308 | 520 ; put byte B in port As buffer - optimization help from Darren Atkinson |
2387 | 521 IRQPutCh |
522 ; set IRQ freq for bulk | |
2422 | 523 lda PollSpd1,pcr |
2387 | 524 lbsr IRQsetFRQ |
525 ldx RxBufPut,u ; point X to the data buffer | |
2374 | 526 |
2308 | 527 ; process interrupt/quit characters here |
528 ; note we will have to do this in the multiread (ugh) | |
2374 | 529 tfr b,a ; put byte in A |
530 ldb #S$Intrpt | |
531 cmpa V.INTR,u | |
532 beq send@ | |
533 ldb #S$Abort | |
534 cmpa V.QUIT,u | |
535 bne store | |
536 send@ lda V.LPRC,u | |
537 beq IRQExit | |
538 os9 F$Send | |
539 bra IRQExit | |
2308 | 540 |
2374 | 541 store |
2308 | 542 ; store our data byte |
2374 | 543 sta ,x+ ; store and increment buffer pointer |
544 | |
2308 | 545 ; adjust RxBufPut |
2374 | 546 cmpx RxBufEnd,u ; end of Rx buffer? |
547 blo IRQSkip1 ; no, go keep laydown pointer | |
548 ldx RxBufPtr,u ; get Rx buffer start address | |
549 IRQSkip1 stx RxBufPut,u ; set new Rx data laydown pointer | |
2308 | 550 |
551 ; increment RxDatLen | |
2374 | 552 inc RxDatLen,u |
2308 | 553 |
2374 | 554 CkSSig |
555 lda <SSigID,u ; send signal on data ready? | |
556 beq CkSuspnd | |
557 ldb <SSigSg,u ; else get signal code | |
558 os9 F$Send | |
559 clr <SSigID,u | |
560 bra IRQExit | |
2308 | 561 |
562 ; check if we have a process waiting for data | |
2374 | 563 CkSuspnd |
564 lda <V.WAKE,u ; V.WAKE? | |
565 beq IRQExit ; no | |
566 clr <V.WAKE,u ; clear V.WAKE | |
567 | |
2308 | 568 ; wake up waiter for read |
2374 | 569 ifeq Level-1 |
570 ldb #S$Wake | |
571 os9 F$Send | |
572 else | |
573 clrb | |
574 tfr d,x ; copy process descriptor pointer | |
575 lda P$State,x ; get state flags | |
576 anda #^Suspend ; clear suspend state | |
577 sta P$State,x ; save state flags | |
578 endc | |
2308 | 579 |
2374 | 580 IRQExit |
581 IRQExit2 puls cc,dp,pc ; restore interrupts cc,dp, return | |
2180 | 582 |
2374 | 583 emod |
584 eom equ * | |
585 end |