Mercurial > hg > Members > kono > nitros9-code
annotate level1/modules/clock.asm @ 1945:89bba8b61def
Level 1 slow time update bug fixed
author | boisy |
---|---|
date | Mon, 05 Dec 2005 01:15:10 +0000 |
parents | 8234be91628d |
children | d88e7ec829a5 |
rev | line source |
---|---|
0 | 1 ******************************************************************** |
1927 | 2 * Clock - NitrOS-9 System Clock |
1313 | 3 * |
4 * CoCo 3 notes: | |
5 * Includes support for several different RTC chips, GIME Toggle | |
6 * IRQ fix, numerous minor changes. | |
0 | 7 * |
8 * $Id$ | |
9 * | |
1287 | 10 * Edt/Rev YYYY/MM/DD Modified by |
11 * Comment | |
0 | 12 * ------------------------------------------------------------------ |
1313 | 13 * ????/??/?? |
14 * NitrOS-9 2.00 distribution. | |
1287 | 15 * |
1313 | 16 * 9r4 2003/01/01 Boisy G. Pitre |
17 * Back-ported to OS-9 Level Two. | |
1287 | 18 * |
1313 | 19 * 9r5 2003/08/18 Boisy G. Pitre |
20 * Separated clock into Clock and Clock2 for modularity. | |
21 * | |
22 * 9r6 2003/09/04 Boisy G. Pitre | |
23 * Combined Level One and Level Two sources | |
1735 | 24 * |
1742 | 25 * 9r7 2004/11/27 Phill Harvey-Smith |
1735 | 26 * Fixed bug in init routine that was causing DP and CC to |
1742 | 27 * be pulled off the stack and stored in D.Proc under Level 1 |
1735 | 28 * |
1744 | 29 * 9r7 2005/01/17 Boisy G. Pitre |
30 * Fixed incorrect value for PIA initialization. Robert indicated | |
31 * that it should be $3434, not $3435. | |
32 * | |
1794 | 33 * 9r7 2005/04/08 Phill Harvey-Smith |
34 * Made the above level dependent as having PIAs inited with $3434 | |
35 * will disable the IRQ from them, this is ok for Level 2/CoCo 3 as the | |
36 * IRQ is later enabled from the GIME, however the CoCo 1,2 and Dragon | |
37 * do not posses a GIME so anything dependent on the clock tick will | |
38 * hang. So changed to conditionaly compile based on level :- | |
39 * | |
1945 | 40 * 9r8 2005/12/04 Boisy G. Pitre |
41 * Minor code optimizations, fixed issue in Level 1 where clock ran slow | |
42 * due to improper initialization of certain system globals. | |
43 | |
1927 | 44 nam Clock |
45 ttl NitrOS-9 System Clock | |
46 | |
47 ifp1 | |
48 use defsfile | |
49 ifgt Level-1 | |
50 use cc3iodefs | |
51 endc | |
52 endc | |
53 | |
54 tylg set Systm+Objct | |
55 atrv set ReEnt+rev | |
1945 | 56 rev set 8 |
1927 | 57 edition set 9 |
58 | |
59 | |
1313 | 60 *------------------------------------------------------------ |
61 * | |
62 * Start of module | |
63 * | |
1927 | 64 mod len,name,tylg,atrv,init,0 |
65 | |
66 name fcs "Clock" | |
67 fcb edition | |
68 | |
69 | |
70 ifeq Level-1 | |
71 TkPerTS equ TkPerSec/10 ticks per time slice | |
72 else | |
73 TkPerTS equ 2 ticks per time slice | |
74 endc | |
75 | |
1313 | 76 * |
1726
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
77 * Table to set up Service Calls |
1313 | 78 * |
1927 | 79 NewSvc fcb F$Time |
80 fdb FTime-*-2 | |
81 fcb F$VIRQ | |
82 fdb FVIRQ-*-2 | |
83 ifgt Level-1 | |
84 fcb F$Alarm | |
85 fdb FALARM-*-2 | |
86 endc | |
87 fcb F$STime | |
88 fdb FSTime-*-2 | |
89 fcb $80 end of service call installation table | |
90 | |
91 | |
1313 | 92 *------------------------------------------------------------ |
93 * | |
94 * Handle F$STime system call | |
95 * | |
96 * First, copy time packet from user address space to system time | |
97 * variables, then fall through to code to update RTC. | |
98 * | |
1927 | 99 FSTime equ * |
100 ifgt Level-1 | |
101 ldx <D.Proc caller's process descriptor | |
102 lda P$Task,x source is in user map | |
103 ldx R$X,u address of caller's time packet | |
104 ldu #D.Time destination address | |
105 ldb <D.SysTsk destination is in system map | |
106 lbsr STime.Mv get time packet (ignore errors) | |
107 else | |
108 ldx R$X,u | |
109 ldd ,x | |
110 std <D.Year | |
111 ldd 2,x | |
112 std <D.Day | |
113 ldd 4,x | |
114 std <D.Min | |
115 endc | |
116 lda #TkPerSec reset to start of second | |
117 sta <D.Tick | |
118 ldx <D.Clock2 get entry point to Clock2 | |
1945 | 119 clra clear carry |
1927 | 120 jmp $06,x and call SetTime entry point |
121 | |
122 | |
1313 | 123 *-------------------------------------------------- |
124 * | |
125 * Clock Initialization | |
126 * | |
127 * This vector is called by the kernel to service the first F$STime | |
1742 | 128 * call. F$STime is usually called by SysGo (with a dummy argument) |
1313 | 129 * in order to initialize the clock. F$STime is re-vectored to the |
130 * service code above to handle future F$STime calls. | |
131 * | |
132 * | |
1927 | 133 |
134 Clock2 fcs "Clock2" | |
135 | |
136 init | |
137 ifeq Level-1 | |
138 pshs dp,cc save DP and CC | |
139 clra | |
140 tfr a,dp set DP to zero | |
141 else | |
142 ldx <D.Proc save user proc | |
143 pshs x | |
144 ldx <D.SysPrc make sys for link | |
145 stx <D.Proc | |
146 endc | |
147 | |
148 leax <Clock2,pcr | |
149 lda #Sbrtn+Objct | |
150 os9 F$Link | |
151 | |
152 bcc LinkOk | |
153 | |
154 ifeq Level-1 | |
155 jmp >$FFFE level 1: jump to reset vector | |
156 else | |
157 lda #E$MNF | |
158 jmp <D.Crash level 2: jump to CRASH vector | |
159 endc | |
160 | |
161 LinkOk | |
162 ifeq Level-1 | |
163 puls cc,dp ; Restore saved dp and cc | |
164 else | |
165 puls x | |
166 stx <D.Proc restore user proc | |
167 endc | |
168 | |
169 sty <D.Clock2 save entry point | |
170 InitCont | |
171 ldx #PIA0Base point to PIA0 | |
172 clra no error for return... | |
173 pshs cc save IRQ enable status (and Carry clear) | |
174 orcc #IntMasks stop interrupts | |
175 | |
176 ifgt Level-1 | |
1313 | 177 * Note: this code can go away once we have a rel_50hz |
1927 | 178 ifeq TkPerSec-50 |
179 ldb <D.VIDMD get video mode register copy | |
180 orb #$08 set 50 Hz VSYNC bit | |
181 stb <D.VIDMD save video mode register copy | |
182 stb >$FF98 set 50 Hz VSYNC | |
183 endc | |
184 endc | |
185 | |
186 sta 1,x enable DDRA | |
187 sta ,x set port A all inputs | |
188 sta 3,x enable DDRB | |
189 coma | |
190 sta 2,x set port B all outputs | |
191 | |
1735 | 192 ; ldd #$343C [A]=PIA0 CRA contents, [B]=PIA0 CRB contents |
1927 | 193 |
194 ifgt Level-1 | |
195 ldd #$3434 as per Robert Gault's suggestion | |
196 else | |
197 ldd #$3435 IRQ needs to be left enabled for Level1, as no GIME generated IRQ | |
198 endif | |
199 | |
200 sta 1,x CA2 (MUX0) out low, port A, disable HBORD high-to-low IRQs | |
201 stb 3,x CB2 (MUX1) out low, port B, disable VBORD low-to-high IRQs | |
202 | |
203 ifgt Level-1 | |
204 lda ,x clear possible pending PIA0 HBORD IRQ | |
205 endc | |
206 lda 2,x clear possible pending PIA0 VBORD IRQ | |
207 | |
1726
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
208 * Don't need to explicitly read RTC during initialization |
1945 | 209 ldd #59*256+$01 last second and last tick |
1927 | 210 std <D.Sec will prompt RTC read at next time slice |
1945 | 211 ifeq Level-1 |
212 ldb #TkPerSec | |
213 stb <D.TSec set ticks per second | |
214 endc | |
215 ldb #TkPerTS get ticks per time slice | |
1927 | 216 stb <D.TSlice set ticks per time slice |
217 stb <D.Slice set first time slice | |
218 leax SvcIRQ,pcr set IRQ handler | |
219 stx <D.IRQ | |
220 | |
221 ifgt Level-1 | |
222 leax SvcVIRQ,pcr set VIRQ handler | |
223 stx <D.VIRQ | |
224 endc | |
225 | |
226 leay NewSvc,pcr insert syscalls | |
227 os9 F$SSvc | |
228 | |
229 ifgt Level-1 | |
230 ifne H6309 | |
231 oim #$08,<D.IRQER | |
232 else | |
233 lda <D.IRQER get shadow GIME IRQ enable register | |
234 ora #$08 set VBORD bit | |
235 sta <D.IRQER save shadow register | |
236 endc | |
237 sta >IRQEnR enable GIME VBORD IRQs | |
238 endc | |
239 | |
1726
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
240 * Call Clock2 init routine |
1927 | 241 ldy <D.Clock2 get entry point to Clock2 |
242 jsr ,y call init entry point of Clock2 | |
243 InitRts puls cc,pc recover IRQ enable status and return | |
244 | |
245 ifeq Level-1 | |
1726
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
246 * |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
247 * Clock IRQ Entry Point |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
248 * |
1945 | 249 * For CoCo 1/2, called once every 16.667 milliseconds |
1927 | 250 SvcIRQ |
251 clra | |
252 tfr a,dp set direct page to zero | |
1945 | 253 tst PIA0Base+3 get hw byte |
1927 | 254 bmi L0032 branch if sync flag on |
255 jmp [>D.SvcIRQ] else service other possible IRQ | |
1945 | 256 L0032 tst PIA0Base+2 clear interrupt |
1927 | 257 dec <D.Tick decrement tick counter |
258 bne L007F go around if not zero | |
259 ldb <D.Sec get minutes/seconds | |
1726
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
260 * Seconds increment |
1927 | 261 incb increment seconds |
262 cmpb #60 full minute? | |
263 bcs L0079 nope... | |
1726
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
264 * |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
265 * Call GetTime entry point in Clock2 |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
266 * |
1927 | 267 ldx <D.Clock2 get entry point to Clock2 |
268 jsr $03,x call GetTime entry point | |
269 fcb $8C skip next 2 bytes | |
270 L0079 stb <D.Sec update sec | |
271 L007B lda <D.TSec get ticks per second value | |
272 sta <D.Tick and repopulate tick decrement counter | |
273 L007F clra clear A | |
274 pshs a and save it on the stack | |
275 ldy <D.CLTb get pointer to VIRQ Polling Entries | |
276 bra L009E go to the processing portion of the loop | |
277 L0087 ldd Vi.Cnt,x get count down counter | |
278 subd #$0001 subtract tick count | |
279 bne L009C branch if not at terminal count ($0000) | |
280 lda #$01 | |
281 sta ,s set flag on stack to 1 | |
282 lda Vi.Stat,x get status byte | |
283 beq DelEntry branch if zero (one shot, so delete) | |
284 L0096 ora #Vi.IFlag set interrupted flag | |
285 sta Vi.Stat,x save in packet | |
286 ldd Vi.Rst,x get reset count | |
287 L009C std Vi.Cnt,x save tick count back | |
288 L009E ldx ,y++ get two bytes at Y | |
289 bne L0087 if not zero, branch | |
290 lda ,s+ else get byte off stack | |
291 beq GoAltIRQ branch if zero | |
292 ldx <D.Proc else get pointer to current process descriptor | |
293 beq L00AE branch if none | |
294 tst P$State,x test process' state | |
295 bpl UsrPoll branch if system state not set | |
296 L00AE jsr [>D.Poll] poll ISRs | |
297 bcc L00AE keep polling until carry set | |
298 GoAltIRQ | |
299 jmp [>D.AltIRQ] jump into an alternate IRQ if available | |
300 DelEntry | |
301 bsr DelVIRQ delete the VIRQ entry | |
302 bra L0096 | |
303 | |
304 UsrPoll leay >up@,pcr point to routine to execute | |
305 jmp [>D.URtoSs] User to System | |
306 up@ jsr [>D.Poll] call polling routine | |
307 bcc up@ keep polling until carry set | |
308 ldx <D.Proc get current process descriptor | |
309 ldb P$State,x and its state | |
310 andb #^SysState turn off sysstate bit | |
311 stb P$State,x save new state | |
312 ldd <P$SWI2,x | |
313 std <D.SWI2 | |
314 ldd <D.UsrIRQ | |
315 std <D.SvcIRQ | |
316 bra GoAltIRQ | |
317 | |
318 DelVIRQ pshs y,x save off Y,X | |
319 dl@ ldx ,y++ get next entry | |
320 stx -$04,y move up | |
321 bne dl@ continue until all are moved | |
322 puls y,x restore | |
323 leay -2,y move back 2 from Y (points to last entry) | |
324 rts return | |
325 | |
1726
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
326 * Install or Remove VIRQ Entry |
1927 | 327 FVIRQ pshs cc |
328 orcc #IntMasks mask all interrupts | |
329 ldy <D.CLTb get pointer to VIRQ polling table | |
330 ldx <D.Init get pointer to init module | |
331 ldb PollCnt,x get poll count | |
332 ldx R$X,u get pointer to caller's X | |
333 beq L0118 branch if removing | |
334 tst ,y entry available? | |
335 beq L010C | |
336 subb #$02 | |
337 lslb | |
338 leay b,y | |
339 tst ,y | |
340 bne PTblFul polling table full | |
341 L0106 tst ,--y | |
342 beq L0106 | |
343 leay $02,y | |
344 L010C ldx R$Y,u | |
345 stx ,y | |
346 ldy R$D,u | |
347 sty ,x | |
348 bra L0124 | |
349 L0118 leax R$Y,u X = caller's Y | |
350 L011A tst ,y end of VIRQ table | |
351 beq L0124 branch if so | |
352 cmpx ,y++ else compare to current VIRQ entry and inc Y | |
353 bne L011A continue searching if not matched | |
354 bsr DelVIRQ else delete entry | |
355 L0124 puls cc | |
356 clrb | |
357 rts | |
358 PTblFul puls cc | |
359 comb | |
360 ldb #E$Poll | |
361 rts | |
362 | |
363 | |
364 | |
1726
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
365 * F$Time system call code |
1927 | 366 FTime ldx R$X,u |
367 ldd <D.Year | |
368 std ,x | |
369 ldd <D.Day | |
370 std 2,x | |
371 ldd <D.Min | |
372 std 4,x | |
373 clrb | |
374 rts | |
375 | |
376 | |
377 | |
378 | |
379 else | |
380 | |
381 | |
382 | |
383 | |
384 * NitrOS-9 Level 2 Clock | |
385 | |
386 GI.Toggl equ %00000001 GIME CART* IRQ enable bit, for CC3 | |
387 | |
1726
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
388 * TC9 needs to reset more interrupt sources |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
389 *GI.Toggl equ %00000111 GIME SERINT*, KEYINT*, CART* IRQ enable bits |
1927 | 390 |
391 | |
1726
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
392 *--------------------------------------------------------- |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
393 * IRQ Handling starts here. |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
394 * |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
395 * Caveat: There may not be a stack at this point, so avoid using one. |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
396 * Stack is set up by the kernel between here and SvcVIRQ. |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
397 * |
1927 | 398 SvcIRQ lda >IRQEnR get GIME IRQ Status and save it. |
399 ora <D.IRQS | |
400 sta <D.IRQS | |
401 bita #$08 check for clock interrupt | |
402 beq NoClock | |
403 anda #^$08 drop clock interrupt | |
404 sta <D.IRQS | |
405 ldx <D.VIRQ set VIRQ routine to be executed | |
406 clr <D.QIRQ ---x IS clock IRQ | |
407 bra ContIRQ | |
408 | |
409 NoClock leax DoPoll,pcr if not clock IRQ, just poll IRQ source | |
410 ifne H6309 | |
411 oim #$FF,<D.QIRQ ---x set flag to NOT clock IRQ | |
412 else | |
413 lda #$FF | |
414 sta <D.QIRQ | |
415 endc | |
416 ContIRQ stx <D.SvcIRQ | |
417 jmp [D.XIRQ] chain through Kernel to continue IRQ handling | |
418 | |
1726
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
419 *------------------------------------------------------------ |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
420 * |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
421 * IRQ handling re-enters here on VSYNC IRQ. |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
422 * |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
423 * - Count down VIRQ timers, mark ones that are done |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
424 * - Call DoPoll/DoToggle to service VIRQs and IRQs and reset GIME |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
425 * - Call Keyboard scan |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
426 * - Update time variables |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
427 * - At end of minute, check alarm |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
428 * |
1927 | 429 SvcVIRQ clra flag if we find any VIRQs to service |
430 pshs a | |
431 ldy <D.CLTb get address of VIRQ table | |
432 bra virqent | |
433 | |
434 virqloop | |
435 ifgt Level-2 | |
436 ldd 2,y get Level 3 extended map type | |
437 orcc #IntMasks | |
438 sta >$0643 | |
439 stb >$0645 | |
440 std >$FFA1 | |
441 andcc #^IntMasks | |
442 endc | |
443 | |
444 ldd Vi.Cnt,x decrement tick count | |
445 ifne H6309 | |
446 decd --- subd #1 | |
447 else | |
448 subd #$0001 | |
449 endc | |
450 bne notzero is this one done? | |
451 lda Vi.Stat,x should we reset? | |
452 bmi doreset | |
453 lbsr DelVIRQ no, delete this entry | |
454 doreset ora #$01 mark this VIRQ as triggered. | |
455 sta Vi.Stat,x | |
456 lda #$80 add VIRQ as interrupt source | |
457 sta ,s | |
458 ldd Vi.Rst,x reset from Reset count. | |
459 notzero std Vi.Cnt,x | |
460 virqent ldx ,y++ | |
461 bne virqloop | |
462 | |
463 ifgt Level-2 | |
464 puls d | |
465 orcc #Carry | |
466 stb >$0643 | |
467 stb >$FFA1 | |
468 incb | |
469 stb >$0645 | |
470 stb >$FFA1 | |
471 andcc #^IntMasks | |
472 else | |
473 puls a get VIRQ status flag: high bit set if VIRQ | |
474 endc | |
475 | |
476 ora <D.IRQS Check to see if other hardware IRQ pending. | |
477 bita #%10110111 any V/IRQ interrupts pending? | |
478 beq toggle | |
479 ifgt Level-2 | |
480 lbsr DoPoll yes, go service them. | |
481 else | |
482 bsr DoPoll yes, go service them. | |
483 endc | |
484 bra KbdCheck | |
485 toggle equ * | |
486 ifgt Level-2 | |
487 lbsr DoToggle no, toggle GIME anyway | |
488 else | |
489 bsr DoToggle no, toggle GIME anyway | |
490 endc | |
491 | |
492 KbdCheck | |
493 ifgt Level-2 | |
494 lda >$0643 grab current map type | |
495 ldb >$0645 | |
496 pshs d save it | |
497 orcc #IntMasks IRQs off | |
498 lda >$0660 SCF local memory ---x | |
499 sta >$0643 into DAT image ---x | |
500 sta >$FFA1 and into RAM ---x | |
501 inca | |
502 sta >$0645 | |
503 sta >$FFA2 map in SCF, CC3IO, WindInt, etc. | |
504 endc | |
505 | |
506 jsr [>D.AltIRQ] go update mouse, gfx cursor, keyboard, etc. | |
507 | |
508 ifgt Level-2 | |
509 puls d restore original map type ---x | |
510 orcc #IntMasks | |
511 sta >$0643 into system DAT image ---x | |
512 stb >$0645 | |
513 std >$FFA1 and into RAM ---x | |
514 andcc #$AF | |
515 endc | |
516 | |
517 dec <D.Tick end of second? | |
518 bne VIRQend no, skip time update and alarm check | |
519 lda #TkPerSec reset tick count | |
520 sta <D.Tick | |
521 | |
1726
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
522 * ATD: Modified to call real time clocks on every minute ONLY. |
1927 | 523 inc <D.Sec go up one second |
524 lda <D.Sec grab current second | |
525 cmpa #60 end of minute? | |
526 blo VIRQend no, skip time update and alarm check | |
527 clr <D.Sec reset second count to zero | |
528 | |
1726
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
529 * |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
530 * Call GetTime entry point in Clock2 |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
531 * |
1927 | 532 ldx <D.Clock2 get entry point to Clock2 |
533 jsr $03,x call GetTime entry point | |
534 | |
535 NoGet ldd >WGlobal+G.AlPID | |
536 ble VIRQend Quit if no Alarm set | |
537 ldd >WGlobal+G.AlPckt+3 does Hour/Minute agree? | |
538 cmpd <D.Hour | |
539 bne VIRQend | |
540 ldd >WGlobal+G.AlPckt+1 does Month/Day agree? | |
541 cmpd <D.Month | |
542 bne VIRQend | |
543 ldb >WGlobal+G.AlPckt+0 does Year agree? | |
544 cmpb <D.Year | |
545 bne VIRQend | |
546 ldd >WGlobal+G.AlPID | |
547 cmpd #1 | |
548 beq checkbel | |
549 os9 F$Send | |
550 bra endalarm | |
551 checkbel ldb <D.Sec sound bell for 15 seconds | |
552 andb #$F0 | |
553 beq dobell | |
554 endalarm ldd #$FFFF | |
555 std >WGlobal+G.AlPID | |
556 bra VIRQend | |
557 dobell ldx >WGlobal+G.BelVec | |
558 beq VIRQend | |
559 jsr ,x | |
560 VIRQend jmp [>D.Clock] jump to kernel's timeslice routine | |
561 | |
1726
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
562 *------------------------------------------------------------ |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
563 * Interrupt polling and GIME reset code |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
564 * |
1927 | 565 |
1726
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
566 * |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
567 * Call [D.Poll] until all interrupts have been handled |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
568 * |
1927 | 569 DoPoll |
570 ifgt Level-2 | |
571 lda >$0643 Level 3: get map type | |
572 ldb >$0645 | |
573 pshs d save for later | |
574 endc | |
575 d@ jsr [>D.Poll] call poll routine | |
576 bcc d@ until error (error -> no interrupt found) | |
577 | |
578 ifgt Level-2 | |
579 puls d | |
580 orcc #IntMasks | |
581 sta >$0643 | |
582 stb >$0645 | |
583 std >$FFA1 | |
584 andcc #^IntMasks | |
585 endc | |
586 | |
1726
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
587 * |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
588 * Reset GIME to avoid missed IRQs |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
589 * |
1927 | 590 DoToggle |
591 lda #^GI.Toggl mask off CART* bit | |
592 anda <D.IRQS | |
593 sta <D.IRQS | |
594 lda <D.IRQER get current enable register status | |
595 tfr a,b | |
596 anda #^GI.Toggl mask off CART* bit | |
597 orb #GI.Toggl --- ensure that 60Hz IRQ's are always enabled | |
598 sta >IRQEnR disable CART | |
599 stb >IRQEnR enable CART | |
600 clrb | |
601 rts | |
602 | |
603 | |
1726
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
604 *------------------------------------------------------------ |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
605 * |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
606 * Handle F$VIRQ system call |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
607 * |
1927 | 608 FVIRQ pshs cc |
609 orcc #IntMasks disable interrupts | |
610 ldy <D.CLTb address of VIRQ table | |
611 ldx <D.Init address of INIT | |
612 ldb PollCnt,x number of polling table entries from INIT | |
613 ldx R$X,u zero means delete entry | |
614 beq RemVIRQ | |
615 ifgt Level-2 | |
616 bra FindVIRQ ---x | |
617 | |
618 v.loop leay 4,y ---x | |
619 endc | |
620 FindVIRQ | |
621 ldx ,y++ is VIRQ entry null? | |
622 beq AddVIRQ if yes, add entry here | |
623 decb | |
624 bne FindVIRQ | |
625 puls cc | |
626 comb | |
627 ldb #E$Poll | |
628 rts | |
629 | |
630 AddVIRQ | |
631 ifgt Level-2 | |
632 ldx R$Y,u | |
633 stx ,y | |
634 lda >$0643 | |
635 ldb >$0645 | |
636 std 2,y | |
637 else | |
638 leay -2,y point to first null VIRQ entry | |
639 ldx R$Y,u | |
640 stx ,y | |
641 endc | |
642 ldy R$D,u | |
643 sty ,x | |
644 bra virqexit | |
645 | |
646 ifgt Level-2 | |
647 v.chk leay 4,y | |
648 RemVIRQ ldx ,y | |
649 else | |
650 RemVIRQ ldx ,y++ | |
651 endc | |
652 beq virqexit | |
653 cmpx R$Y,u | |
654 bne RemVIRQ | |
655 bsr DelVIRQ | |
656 virqexit puls cc | |
657 clrb | |
658 rts | |
659 | |
660 DelVIRQ pshs x,y | |
661 DelVLup | |
662 ifgt Level-2 | |
663 ldq ,y++ move entries up in table | |
664 leay 2,y | |
665 stq -8,y | |
666 bne DelVLup | |
667 puls x,y,pc | |
668 else | |
669 ldx ,y++ move entries up in table | |
670 stx -4,y | |
671 bne DelVLup | |
672 puls x,y | |
673 leay -2,y | |
674 rts | |
675 endc | |
676 | |
677 ifgt Level-1 | |
1726
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
678 *------------------------------------------------------------ |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
679 * |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
680 * Handle F$Alarm call |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
681 * |
1927 | 682 FAlarm ldx #WGlobal+G.AlPckt |
683 ldd R$D,u | |
684 bne DoAlarm | |
685 std G.AlPID-G.AlPckt,x erase F$Alarm PID, Signal. | |
686 rts | |
687 | |
688 DoAlarm tsta if PID != 0, set alarm for this process | |
689 bne SetAlarm | |
690 cmpd #1 1 -> Set system-wide alarm | |
691 bne GetAlarm | |
692 SetAlarm | |
693 std G.AlPID-G.AlPckt,x | |
694 ldy <D.Proc | |
695 lda P$Task,y move from process task | |
696 ldb <D.SysTsk to system task | |
697 ldx R$X,u from address given in X | |
698 ldu #WGlobal+G.AlPckt | |
699 ldy #5 move 5 bytes | |
700 bra FMove | |
701 | |
702 GetAlarm | |
703 cmpd #2 | |
704 bne AlarmErr | |
705 ldd G.AlPID-G.AlPckt,x | |
706 std R$D,u | |
707 bra RetTime | |
708 AlarmErr | |
709 comb | |
710 ldb #E$IllArg | |
711 rts | |
712 endc | |
713 | |
1726
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
714 *------------------------------------------------------------ |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
715 * |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
716 * Handle F$Time System call |
043d330e2f0e
Recomposed source lines to share more common code between Level 1
boisy
parents:
1658
diff
changeset
|
717 * |
1927 | 718 FTime equ * |
719 ifgt Level-1 | |
720 ldx #D.Time address of system time packet | |
721 RetTime ldy <D.Proc get pointer to current proc descriptor | |
722 ldb P$Task,y process Task number | |
723 lda <D.SysTsk from System Task | |
724 ldu R$X,u | |
725 STime.Mv | |
726 ldy #6 move 6 bytes | |
727 FMove os9 F$Move | |
728 else | |
729 ldx R$X,u get pointer to caller's space | |
730 ldd <D.Year get year and month | |
731 std ,x | |
732 ldd <D.Day get day and hour | |
733 std 2,x | |
734 ldd <D.Min get minute and second | |
735 std 4,x | |
736 clrb | |
737 endc | |
738 rts | |
739 | |
740 endc | |
741 | |
742 emod | |
743 len equ * | |
744 end |