Mercurial > hg > Members > kono > nitros9-code
comparison level1/modules/dw3.asm @ 2387:8476556e5f0c
dynamic ISR/poll frequency
author | aaronwolfe |
---|---|
date | Sun, 24 Jan 2010 01:51:34 +0000 |
parents | b399116a3b5f |
children | 61778d4bb634 |
comparison
equal
deleted
inserted
replaced
2386:e454c42a134b | 2387:8476556e5f0c |
---|---|
9 * 1 2008/01/26 Boisy G. Pitre | 9 * 1 2008/01/26 Boisy G. Pitre |
10 * Started as a segregated subroutine module. | 10 * Started as a segregated subroutine module. |
11 * | 11 * |
12 * 2 2010/01/20 Boisy G. Pitre | 12 * 2 2010/01/20 Boisy G. Pitre |
13 * Added support for DWNet | 13 * Added support for DWNet |
14 | 14 * |
15 * 3 2010/01/23 Aaron A. Wolfe | |
16 * Added dynamic polling frequency | |
17 * | |
15 nam DW3 | 18 nam DW3 |
16 ttl DriveWire 3 Low Level Subroutine Module | 19 ttl DriveWire 3 Low Level Subroutine Module |
17 | 20 |
18 ifp1 | 21 ifp1 |
19 use defsfile | 22 use defsfile |
28 | 31 |
29 * irq | 32 * irq |
30 IRQPckt fcb $00,$01,$0A ;IRQ packet Flip(1),Mask(1),Priority(1) bytes | 33 IRQPckt fcb $00,$01,$0A ;IRQ packet Flip(1),Mask(1),Priority(1) bytes |
31 * Default time packet | 34 * Default time packet |
32 DefTime fcb 109,12,31,23,59,59 | 35 DefTime fcb 109,12,31,23,59,59 |
36 | |
37 * for dynamic poll frequency, number of ticks between firing poller | |
38 * speed 1 = interactive (typing) | |
39 PollSpd1 fcb 3 | |
40 * speed 2 = bulk transfer | |
41 PollSpd2 fcb 6 | |
42 * speed 3 = idle | |
43 PollSpd3 fcb 40 | |
44 * X pollidle -> drop to next slower rate | |
45 PollIdle fcb 60 | |
46 | |
33 | 47 |
34 name fcs /dw3/ | 48 name fcs /dw3/ |
35 | 49 |
36 * DriveWire subroutine entry table | 50 * DriveWire subroutine entry table |
37 start lbra Init | 51 start lbra Init |
147 leax IRQPckt,pcr ;IRQ polling packet | 161 leax IRQPckt,pcr ;IRQ polling packet |
148 leay IRQSvc,pcr ;IRQ service entry | 162 leay IRQSvc,pcr ;IRQ service entry |
149 os9 F$IRQ ;install | 163 os9 F$IRQ ;install |
150 puls u | 164 puls u |
151 bcs InitEx ;exit with error | 165 bcs InitEx ;exit with error |
152 ldd #$0003 ;lets try every 6 ticks (0.1 seconds) -- testing 3, gives better response in interactive things | 166 clra |
167 ldb PollSpd3,pcr ; start at idle | |
153 ifgt Level-1 | 168 ifgt Level-1 |
154 ldx <D.DWStat | 169 ldx <D.DWStat |
155 else | 170 else |
156 ldx >D.DWStat | 171 ldx >D.DWStat |
157 endc | 172 endc |
254 stb RxDatLen,u ; store new value | 269 stb RxDatLen,u ; store new value |
255 | 270 |
256 lbra CkSSig ; had to lbra | 271 lbra CkSSig ; had to lbra |
257 | 272 |
258 IRQMulti | 273 IRQMulti |
274 ; set IRQ freq for bulk | |
275 pshs a | |
276 lda PollSpd2,pcr | |
277 lbsr IRQsetFRQ | |
278 puls a | |
279 | |
259 ; initial grab bytes | 280 ; initial grab bytes |
260 stb RxGrab,u | 281 stb RxGrab,u |
261 | 282 |
262 ; limit server bytes to bufsize - datlen | 283 ; limit server bytes to bufsize - datlen |
263 ldb RxBufSiz,u ; size of buffer | 284 ldb RxBufSiz,u ; size of buffer |
304 lbra IRQExit2 ; don't reset error count on the way out | 325 lbra IRQExit2 ; don't reset error count on the way out |
305 | 326 |
306 ; process response | 327 ; process response |
307 IRQSvc2 | 328 IRQSvc2 |
308 ldd ,s++ ; pull returned status byte into A,data into B (set Z if zero, N if multiread) | 329 ldd ,s++ ; pull returned status byte into A,data into B (set Z if zero, N if multiread) |
309 lbeq IRQExit ; branch if D = 0 (nothing to do) | 330 bne IRQGotOp ; branch if D != 0 (something to do) |
310 ; future - handle backing off on polling interval | 331 * this is a NOP response.. do we need to reschedule |
311 | 332 ifgt Level-1 |
333 ldx <D.DWStat | |
334 else | |
335 ldx >D.DWStat | |
336 endc | |
337 lda DW.VIRQFRQ,x | |
338 cmpa PollSpd3,pcr | |
339 lbeq IRQExit ;we are already at idle speed | |
340 | |
341 lda DW.VIRQNOP,x | |
342 inca | |
343 cmpa PollIdle,pcr | |
344 beq FRQdown | |
345 | |
346 sta DW.VIRQNOP,x ;inc NOP count, exit | |
347 lbra IRQExit | |
348 | |
349 FRQdown lda DW.VIRQFRQ,x | |
350 cmpa PollSpd1,pcr | |
351 beq FRQd1 | |
352 lda PollSpd3,pcr | |
353 FRQd2 | |
354 sta DW.VIRQFRQ,x | |
355 clr DW.VIRQNOP,x | |
356 lbra IRQExit | |
357 FRQd1 lda PollSpd2,pcr | |
358 bra FRQd2 | |
312 | 359 |
313 ; save back D on stack and build our U | 360 ; save back D on stack and build our U |
314 pshs d | 361 IRQGotOp pshs d |
315 * mode switch on bits 7+6 of A: 00 = vserial, 01 = system, 10 = wirebug?, 11 = ? | 362 * mode switch on bits 7+6 of A: 00 = vserial, 01 = system, 10 = wirebug?, 11 = ? |
316 anda #$C0 ; mask last 6 bits | 363 anda #$C0 ; mask last 6 bits |
317 beq mode00 ; virtual serial mode | 364 beq mode00 ; virtual serial mode |
318 ; future - handle other modes | 365 ; future - handle other modes |
319 lbra IRQExit ; for now, bail | 366 lbra IRQExit ; for now, bail |
340 | 387 |
341 puls d | 388 puls d |
342 | 389 |
343 * multiread/status flag is in bit 4 of A | 390 * multiread/status flag is in bit 4 of A |
344 bita #$10 | 391 bita #$10 |
345 beq IRQPutch ; branch if multiread not set | 392 beq IRQPutch ; branch for read1 if multiread not set |
346 | 393 |
347 * all 0s in port means status, anything else is multiread | 394 * all 0s in port means status, anything else is multiread |
348 | 395 |
349 bita #$0F ;mask bit 7-4 | 396 bita #$0F ;mask bit 7-4 |
350 beq dostat ;port # all 0, this is a status response | 397 beq dostat ;port # all 0, this is a status response |
351 bra IRQMulti ;its not all 0, this is a multiread | 398 lbra IRQMulti ;its not all 0, this is a multiread |
352 | 399 |
353 | 400 |
354 * in status events, databyte is split, 4bits status, 4bits port # | 401 * in status events, databyte is split, 4bits status, 4bits port # |
355 dostat bitb #$F0 ;mask low bits | 402 dostat bitb #$F0 ;mask low bits |
356 lbne IRQExit ;we only implement code 0000, term | 403 lbne IRQExit ;we only implement code 0000, term |
361 ldx >D.DWStat | 408 ldx >D.DWStat |
362 endc | 409 endc |
363 lda b,x | 410 lda b,x |
364 bne statcont ; if A is 0, then this device is not active, so exit | 411 bne statcont ; if A is 0, then this device is not active, so exit |
365 lbra IRQExit | 412 lbra IRQExit |
413 | |
414 * IRQ set freq routine | |
415 * sets freq and clears NOP counter | |
416 * a = desired IRQ freq | |
417 IRQsetFRQ pshs x ; preserve | |
418 ifgt Level-1 | |
419 ldx <D.DWStat | |
420 else | |
421 ldx >D.DWStat | |
422 endc | |
423 sta DW.VIRQFRQ,x | |
424 clr DW.VIRQNOP,x | |
425 puls x | |
426 rts | |
427 | |
366 | 428 |
367 * This routine roots through process descriptors in a queue and | 429 * This routine roots through process descriptors in a queue and |
368 * checks to see if the process has a path that is open to the device | 430 * checks to see if the process has a path that is open to the device |
369 * represented by the static storage pointer in U. if so, the S$HUP | 431 * represented by the static storage pointer in U. if so, the S$HUP |
370 * signal is sent to that process | 432 * signal is sent to that process |
416 bsr RootThrough | 478 bsr RootThrough |
417 dosleepq ldx <D.SProcQ | 479 dosleepq ldx <D.SProcQ |
418 beq CkLPRC | 480 beq CkLPRC |
419 bsr RootThrough | 481 bsr RootThrough |
420 | 482 |
421 CkLPRC | 483 CkLPRC |
422 lda <V.LPRC,u | 484 lda <V.LPRC,u |
423 beq IRQExit ; no last process, bail | 485 beq IRQExit ; no last process, bail |
424 ldb #S$HUP | 486 ldb #S$HUP |
425 os9 F$Send ; send signal, don't think we can do anything about an error result anyway.. so | 487 os9 F$Send ; send signal, don't think we can do anything about an error result anyway.. so |
426 bra CkSuspnd ; do we need to go check suspend? | 488 bra CkSuspnd ; do we need to go check suspend? |
427 | 489 |
428 ; put byte B in port As buffer - optimization help from Darren Atkinson | 490 ; put byte B in port As buffer - optimization help from Darren Atkinson |
429 IRQPutCh ldx RxBufPut,u ; point X to the data buffer | 491 IRQPutCh |
492 ; set IRQ freq for bulk | |
493 lbsr IRQsetFRQ | |
494 ldx RxBufPut,u ; point X to the data buffer | |
430 | 495 |
431 ; process interrupt/quit characters here | 496 ; process interrupt/quit characters here |
432 ; note we will have to do this in the multiread (ugh) | 497 ; note we will have to do this in the multiread (ugh) |
433 tfr b,a ; put byte in A | 498 tfr b,a ; put byte in A |
434 ldb #S$Intrpt | 499 ldb #S$Intrpt |