Mercurial > hg > Members > kono > nitros9-code
comparison level1/modules/ioman.asm @ 0:6641a883d6b0
Initial revision
author | boisy |
---|---|
date | Thu, 04 Apr 2002 16:34:12 +0000 |
parents | |
children | ce04e3883dec |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:6641a883d6b0 |
---|---|
1 ******************************************************************** | |
2 * IOMan - OS-9 Level One V2 I/O Manager module | |
3 * | |
4 * $Id$ | |
5 * | |
6 * Ed. Comments Who YY/MM/DD | |
7 * ------------------------------------------------------------------ | |
8 * 11 Tandy/Microware original version | |
9 | |
10 nam IOMan | |
11 ttl OS-9 Level One V2 I/O Manager module | |
12 | |
13 ifp1 | |
14 use defsfile | |
15 endc | |
16 | |
17 tylg set Systm+Objct | |
18 atrv set ReEnt+rev | |
19 rev set $01 | |
20 * edition $0B = Stock OS-9 Level One Vr. 2.00 IOMan | |
21 * edition $0C = IO Queue sort bug fixed | |
22 edition equ $0C | |
23 | |
24 mod eom,name,tylg,atrv,IOManEnt,size | |
25 | |
26 size equ . | |
27 | |
28 name fcs /IOMan/ | |
29 fcb edition | |
30 | |
31 * IOMan is called from OS9p2 | |
32 IOManEnt equ * | |
33 * allocate device and polling tables | |
34 ldx <D.Init | |
35 lda PollCnt,x | |
36 ldb #POLSIZ | |
37 mul | |
38 pshs b,a | |
39 lda DevCnt,x | |
40 ldb #DEVSIZ | |
41 mul | |
42 pshs b,a | |
43 addd 2,s add devsize to polsiz | |
44 addd #$0018 | |
45 addd #$00FF bring up to next page | |
46 clrb | |
47 os9 F$SRqMem | |
48 bcs Crash | |
49 * clear allocated mem | |
50 leax ,u | |
51 L0033 clr ,x+ | |
52 subd #$0001 | |
53 bhi L0033 | |
54 stu <D.PolTbl | |
55 ldd ,s++ get dev size | |
56 leax d,u | |
57 stx <D.DevTbl | |
58 addd ,s++ get poll size | |
59 leax d,u | |
60 stx <D.CLTB | |
61 ldx <D.PthDBT | |
62 os9 F$All64 | |
63 bcs Crash | |
64 stx <D.PthDBT | |
65 os9 F$Ret64 | |
66 leax >DPoll,pcr | |
67 stx <D.Poll | |
68 * install I/O system calls | |
69 leay <IOCalls,pcr | |
70 os9 F$SSvc | |
71 rts return to OS9p2 | |
72 | |
73 Crash jmp [>$FFFE] | |
74 | |
75 IOCalls fcb $7F | |
76 fdb UsrIO-*-2 | |
77 | |
78 fcb F$Load | |
79 fdb FLoad-*-2 | |
80 | |
81 fcb F$PErr | |
82 fdb FPErr-*-2 | |
83 | |
84 fcb F$IOQu+$80 | |
85 fdb FIOQu-*-2 | |
86 | |
87 fcb $FF | |
88 fdb SysIO-*-2 | |
89 | |
90 fcb F$IRQ+$80 | |
91 fdb FIRQ-*-2 | |
92 | |
93 fcb F$IODel+$80 | |
94 fdb FIODel-*-2 | |
95 | |
96 fcb $80 | |
97 | |
98 FIODel ldx R$X,u | |
99 ldu <D.Init | |
100 ldb DevCnt,u get device count | |
101 ldu <D.DevTbl | |
102 L0083 ldy V$DESC,u | |
103 beq L0094 | |
104 cmpx V$DESC,u | |
105 beq L009B | |
106 cmpx V$DRIV,u | |
107 beq L009B | |
108 cmpx V$FMGR,u | |
109 beq L009B | |
110 L0094 leau DEVSIZ,u | |
111 decb | |
112 bne L0083 | |
113 clrb | |
114 rts | |
115 L009B comb | |
116 ldb #E$ModBsy | |
117 rts | |
118 | |
119 UsrIODis fdb IAttach-UsrIODis | |
120 fdb IDetach-UsrIODis | |
121 fdb IDup-UsrIODis | |
122 fdb IUsrCall-UsrIODis | |
123 fdb IUsrCall-UsrIODis | |
124 fdb IMakDir-UsrIODis | |
125 fdb IChgDir-UsrIODis | |
126 fdb IDelete-UsrIODis | |
127 fdb UISeek-UsrIODis | |
128 fdb UIRead-UsrIODis | |
129 fdb UIWrite-UsrIODis | |
130 fdb UIRead-UsrIODis | |
131 fdb UIWrite-UsrIODis | |
132 fdb UIGetStt-UsrIODis | |
133 fdb UISeek-UsrIODis | |
134 fdb UIClose-UsrIODis | |
135 fdb IDeletX-UsrIODis | |
136 | |
137 SysIODis fdb IAttach-SysIODis | |
138 fdb IDetach-SysIODis | |
139 fdb SIDup-SysIODis | |
140 fdb ISysCall-SysIODis | |
141 fdb ISysCall-SysIODis | |
142 fdb IMakDir-SysIODis | |
143 fdb IChgDir-SysIODis | |
144 fdb IDelete-SysIODis | |
145 fdb SISeek-SysIODis | |
146 fdb SIRead-SysIODis | |
147 fdb SIWrite-SysIODis | |
148 fdb SIRead-SysIODis | |
149 fdb SIWrite-SysIODis | |
150 fdb SIGetStt-SysIODis | |
151 fdb SISeek-SysIODis | |
152 fdb SIClose-SysIODis | |
153 fdb IDeletX-SysIODis | |
154 | |
155 UsrIO leax <UsrIODis,pcr | |
156 bra IODsptch | |
157 SysIO leax <SysIODis,pcr | |
158 IODsptch cmpb #I$DeletX | |
159 bhi L00FA | |
160 pshs b | |
161 lslb multiply by 2 | |
162 ldd b,x offset | |
163 leax d,x get addr | |
164 puls b | |
165 jmp ,x jump to it! | |
166 L00FA comb | |
167 ldb #E$UnkSvc | |
168 rts | |
169 | |
170 IAttach ldb #$11 | |
171 L0100 clr ,-s | |
172 decb | |
173 bpl L0100 | |
174 stu <$10,s caller regs | |
175 lda R$A,u | |
176 sta $09,s device mode | |
177 ldx R$X,u | |
178 lda #Devic+0 | |
179 os9 F$Link link to device desc. | |
180 bcs L0139 | |
181 stu $04,s address of mod hdr | |
182 ldy <$10,s get caller regs | |
183 stx R$X,y save updated ptr | |
184 ldd M$Port+1,u get port addr | |
185 std $0C,s save on stack | |
186 ldd M$PDev,u get driver name | |
187 leax d,u point X to driver name | |
188 lda #Drivr+0 | |
189 os9 F$Link link to driver | |
190 bcs L0139 | |
191 stu ,s save driver addr on stack | |
192 ldu $04,s get addr of dev desc. | |
193 ldd M$FMgr,u get file mgr name | |
194 leax d,u point X to fmgr name | |
195 lda #FlMgr+0 | |
196 os9 F$Link link to fmgr | |
197 L0139 bcc L0149 | |
198 * error on attach, so detach | |
199 L013B stb <$11,s save fmgr addr on stack | |
200 leau ,s point U to S | |
201 os9 I$Detach | |
202 leas <$11,s clean up stack | |
203 comb | |
204 puls pc,b return to caller | |
205 L0149 stu $06,s save fmgr addr | |
206 ldx <D.Init | |
207 ldb DevCnt,x | |
208 lda DevCnt,x | |
209 ldu D.DevTbl | |
210 L0153 ldx V$DESC,u get desc addr | |
211 beq L0188 | |
212 cmpx $04,s same? | |
213 bne L016E branch if not | |
214 ldx V$STAT,u get stat | |
215 bne L016C branch if zero | |
216 pshs a | |
217 lda V$USRS,u get user count | |
218 beq L0168 | |
219 os9 F$IOQu | |
220 L0168 puls a | |
221 bra L0153 | |
222 L016C stu $0E,s save dev entry on stack | |
223 L016E ldx V$DESC,u get dev desc ptr | |
224 ldy M$Port+1,x | |
225 cmpy $0C,s compare to port addr on stack | |
226 bne L0188 | |
227 ldx V$DRIV,u | |
228 cmpx ,s compare to driver addr on stack | |
229 bne L0188 | |
230 ldx V$STAT,u get static | |
231 stx $02,s save static on stack | |
232 tst V$USRS,u test user count | |
233 beq L0188 branch if zero | |
234 sta $0A,s store on stack | |
235 L0188 leau DEVSIZ,u go to next entry | |
236 decb decrement count | |
237 bne L0153 go back to loop if not zero | |
238 ldu $0E,s get dev entry off stack | |
239 lbne L01E6 | |
240 ldu D.DevTbl | |
241 L0195 ldx V$DESC,u get dev desc ptr | |
242 beq L01A6 branch if zero | |
243 leau DEVSIZ,u | |
244 deca | |
245 bne L0195 continue loop | |
246 ldb #E$DevOvf device table overflow | |
247 bra L013B | |
248 L01A2 ldb #E$BMode bad mode | |
249 bra L013B | |
250 L01A6 ldx $02,s get static storage off stack | |
251 lbne L01DD | |
252 stu $0E,s save off dev entry on stack | |
253 ldx ,s get driver addr off stack | |
254 ldd M$Mem,x get memory requirement | |
255 addd #$00FF round up to next page | |
256 clrb | |
257 os9 F$SRqMem | |
258 lbcs L013B | |
259 stu $02,s save off on stack | |
260 L01BF clr ,u+ clear static mem | |
261 subd #$0001 | |
262 bhi L01BF | |
263 ldd $0C,s get port addr off stack | |
264 ldu $02,s get static storage ptr | |
265 clr V.PAGE,u | |
266 std V.PORT,u save addr | |
267 ldy $04,s get dev desc addr | |
268 ldx ,s get driver addr | |
269 ldd M$Exec,x get driver exec | |
270 jsr d,x call Init routine | |
271 lbcs L013B | |
272 ldu $0E,s get dev entry | |
273 L01DD ldb #$08 copy 8 bytes from stack to dev entry | |
274 L01DF lda b,s | |
275 sta b,u | |
276 decb | |
277 bpl L01DF | |
278 L01E6 ldx V$DESC,u get dev desc | |
279 ldb M$Revs,x | |
280 lda $09,s get device mode off stack | |
281 anda M$Mode,x AND mode with desc mode | |
282 ldx V$DRIV,u get driver ptr | |
283 anda M$Mode,x AND mode with driver mode | |
284 cmpa $09,s compare with passed mode | |
285 lbne L01A2 branch if error | |
286 inc V$USRS,u else inc user count of dev entry | |
287 bne L01FE branch if not overflow from 255->0 | |
288 dec V$USRS,u else dec | |
289 L01FE ldx <$10,s get caller regs | |
290 stu R$U,x | |
291 leas <$12,s restore stack | |
292 clrb | |
293 rts | |
294 | |
295 IDetach ldu R$U,u | |
296 ldx V$DESC,u | |
297 ldb V$USRS,u get user count | |
298 bne L0218 branch if not zero | |
299 pshs u,b | |
300 ldu V$STAT,u | |
301 pshs u | |
302 bra L0254 | |
303 L0218 lda #255 | |
304 cmpa V$USRS,u 255 users? | |
305 lbeq L0283 branch if so | |
306 dec V$USRS,u else dec user count | |
307 lbne L0271 branch if dec not 0 | |
308 ldx <D.Init | |
309 ldb DevCnt,x | |
310 pshs u,b | |
311 ldx V$STAT,u | |
312 clr V$STAT,u | |
313 clr V$STAT+1,u | |
314 ldy <D.DevTbl | |
315 L0235 cmpx V$STAT,y | |
316 beq L0267 | |
317 leay DEVSIZ,y | |
318 decb | |
319 bne L0235 | |
320 ldy <D.Proc | |
321 ldb P$ID,y | |
322 stb V$USRS,u | |
323 ldy V$DESC,u | |
324 ldu V$DRIV,u | |
325 exg x,u X pts to driver, U pts to static | |
326 ldd M$Exec,x | |
327 leax d,x | |
328 pshs u | |
329 jsr $0F,x call term routine | |
330 L0254 puls u | |
331 ldx 1,s get U from stack (dev entry to detach) | |
332 ldx V$DRIV,x | |
333 ldd M$Mem,x get memory requirements | |
334 addd #$00FF round up to next page | |
335 clrb | |
336 os9 F$SRtMem return mem | |
337 ldx 1,s get U from stack (dev entry to detach) | |
338 ldx V$DESC,x get dev desc ptr | |
339 L0267 puls u,b get U,B | |
340 ldx V$DESC,u | |
341 clr V$DESC,u | |
342 clr V$DESC+1,u | |
343 clr V$USRS,u | |
344 L0271 ldy V$DRIV,u | |
345 ldu V$FMGR,u | |
346 os9 F$UnLink unlink file manager | |
347 leau ,y | |
348 os9 F$UnLink unlink driver | |
349 leau ,x | |
350 os9 F$UnLink unlink descriptor | |
351 L0283 lbsr L04D9 | |
352 clrb | |
353 rts | |
354 | |
355 * user state I$Dup | |
356 IDup bsr FindPath | |
357 bcs IDupRTS | |
358 pshs x,a | |
359 lda R$A,u | |
360 lda a,x | |
361 bsr L02A1 | |
362 bcs L029D | |
363 puls x,b | |
364 stb R$A,u | |
365 sta b,x | |
366 rts | |
367 L029D puls pc,x,a | |
368 | |
369 * system state I$Dup | |
370 SIDup lda R$A,u | |
371 L02A1 lbsr FindPDsc | |
372 bcs IDupRTS | |
373 inc PD.CNT,y | |
374 IDupRTS rts | |
375 | |
376 | |
377 * find next free path position in current proc | |
378 FindPath ldx <D.Proc | |
379 leax <P$PATH,x | |
380 clra | |
381 L02AF tst a,x | |
382 beq L02BC | |
383 inca | |
384 cmpa #NumPaths | |
385 bcs L02AF | |
386 comb | |
387 ldb #E$PthFul | |
388 rts | |
389 L02BC andcc #^Carry | |
390 rts | |
391 | |
392 IUsrCall bsr FindPath | |
393 bcs L02D1 | |
394 pshs u,x,a | |
395 bsr ISysCall | |
396 puls u,x,a | |
397 bcs L02D1 | |
398 ldb R$A,u | |
399 stb a,x | |
400 sta R$A,u | |
401 L02D1 rts | |
402 | |
403 ISysCall pshs b | |
404 ldb R$A,u | |
405 bsr L0349 | |
406 bcs L02E6 | |
407 puls b | |
408 lbsr CallFMgr | |
409 bcs L02F5 | |
410 lda PD.PD,y | |
411 sta R$A,u | |
412 rts | |
413 L02E6 puls pc,a | |
414 | |
415 * make directory | |
416 IMakDir pshs b | |
417 ldb #DIR.+WRITE. | |
418 L02EC bsr L0349 | |
419 bcs L02E6 | |
420 puls b | |
421 lbsr CallFMgr | |
422 L02F5 pshs b,cc | |
423 ldu PD.DEV,y | |
424 os9 I$Detach | |
425 lda PD.PD,y | |
426 ldx <D.PthDBT | |
427 os9 F$Ret64 | |
428 puls pc,b,cc | |
429 | |
430 * change directory | |
431 IChgDir pshs b | |
432 ldb R$A,u | |
433 orb #DIR. | |
434 bsr L0349 | |
435 bcs L02E6 | |
436 puls b | |
437 lbsr CallFMgr | |
438 bcs L02F5 | |
439 ldu <D.Proc | |
440 ldb PD.MOD,y | |
441 bitb #PWRIT.+PREAD.+UPDAT. | |
442 beq L0329 | |
443 ldx PD.DEV,y | |
444 stx <P$DIO,u | |
445 inc V$USRS,x | |
446 bne L0329 | |
447 dec V$USRS,x | |
448 L0329 bitb #PEXEC.+EXEC. | |
449 beq L0338 | |
450 ldx PD.DEV,y | |
451 stx <P$DIO+6,u | |
452 inc V$USRS,x | |
453 bne L0338 | |
454 dec V$USRS,x | |
455 L0338 clrb | |
456 bra L02F5 | |
457 | |
458 IDelete pshs b | |
459 ldb #$02 | |
460 bra L02EC | |
461 | |
462 IDeletX ldb #$87 | |
463 pshs b | |
464 ldb $01,u | |
465 bra L02EC | |
466 | |
467 * create path descriptor and initialize | |
468 * Entry: | |
469 * B = path mode | |
470 L0349 pshs u | |
471 ldx <D.PthDBT | |
472 os9 F$All64 | |
473 bcs L03A8 | |
474 inc PD.CNT,y | |
475 stb PD.MOD,y | |
476 ldx R$X,u | |
477 L0358 lda ,x+ | |
478 cmpa #$20 | |
479 beq L0358 | |
480 leax -1,x | |
481 stx R$X,u | |
482 ldb PD.MOD,y | |
483 cmpa #PDELIM | |
484 beq L037E | |
485 ldx <D.Proc | |
486 bitb #PEXEC.+EXEC. | |
487 beq L0373 | |
488 ldx <P$DIO+6,x | |
489 bra L0376 | |
490 L0373 ldx <P$DIO,x | |
491 L0376 beq L03AA | |
492 ldx V$DESC,x | |
493 ldd M$Name,x | |
494 leax d,x | |
495 L037E pshs y | |
496 os9 F$PrsNam | |
497 puls y | |
498 bcs L03AA | |
499 lda PD.MOD,y | |
500 os9 I$Attach | |
501 stu PD.DEV,y | |
502 bcs L03AC | |
503 ldx V$DESC,u | |
504 leax <M$Opt,x | |
505 ldb ,x+ | |
506 leau <PD.DTP,y | |
507 cmpb #$20 | |
508 bls L03A4 | |
509 ldb #$1F | |
510 L03A0 lda ,x+ | |
511 sta ,u+ | |
512 L03A4 decb | |
513 bpl L03A0 | |
514 clrb | |
515 L03A8 puls pc,u | |
516 L03AA ldb #E$BPNam | |
517 L03AC pshs b | |
518 lda ,y | |
519 ldx <D.PthDBT | |
520 os9 F$Ret64 | |
521 puls b | |
522 coma | |
523 bra L03A8 | |
524 L03BA lda $01,u | |
525 cmpa #$10 | |
526 bcc L03CB | |
527 ldx <D.Proc | |
528 leax <$26,x | |
529 andcc #^Carry | |
530 lda a,x | |
531 bne L03CE | |
532 L03CB comb | |
533 ldb #E$BPNum | |
534 L03CE rts | |
535 | |
536 UISeek bsr L03BA | |
537 bcc GetPDsc | |
538 rts | |
539 | |
540 SISeek lda R$A,u | |
541 GetPDsc bsr FindPDsc | |
542 lbcc CallFMgr | |
543 rts | |
544 | |
545 UIRead bsr L03BA | |
546 bcc L03E4 | |
547 rts | |
548 | |
549 SIRead lda R$A,u | |
550 L03E4 pshs b | |
551 ldb #$05 | |
552 L03E8 bsr FindPDsc | |
553 bcs L040B | |
554 bitb $01,y | |
555 beq L0409 | |
556 ldd $06,u | |
557 beq L03F8 | |
558 addd $04,u | |
559 bcs L03FD | |
560 L03F8 puls b | |
561 lbra CallFMgr | |
562 L03FD ldb #$F4 | |
563 lda ,s | |
564 bita #$02 | |
565 beq L040B | |
566 ldb #$F5 | |
567 bra L040B | |
568 L0409 ldb #E$BMode | |
569 L040B com ,s+ | |
570 rts | |
571 | |
572 UIWrite bsr L03BA | |
573 bcc L0415 | |
574 rts | |
575 | |
576 SIWrite lda R$A,u | |
577 L0415 pshs b | |
578 ldb #$02 | |
579 bra L03E8 | |
580 | |
581 | |
582 * find path descriptor of path passed in A | |
583 * Exit: | |
584 * Y = addr of path desc (if no error) | |
585 FindPDsc pshs x | |
586 ldx <D.PthDBT | |
587 os9 F$Find64 | |
588 puls x | |
589 lbcs L03CB | |
590 L0428 rts | |
591 | |
592 UIGetStt lbsr L03BA | |
593 bcc L0431 | |
594 rts | |
595 | |
596 SIGetStt lda R$A,u | |
597 L0431 pshs b,a | |
598 lda R$B,u | |
599 sta 1,s place in B on stack | |
600 puls a get A | |
601 bsr GetPDsc | |
602 puls a A holds func code | |
603 pshs b,cc | |
604 ldb <PD.DTP,y | |
605 cmpb #DT.NFM | |
606 beq L044D | |
607 tsta test func code | |
608 beq GSOpt | |
609 cmpa #SS.DevNm | |
610 beq GSDevNm | |
611 L044D puls pc,b,cc | |
612 GSOpt leax <PD.DTP,y | |
613 L0452 ldy R$X,u | |
614 ldb #32 | |
615 L0457 lda ,x+ copy 32 bytes from X to Y | |
616 sta ,y+ | |
617 decb | |
618 bne L0457 | |
619 leas 2,s fix stack | |
620 clrb | |
621 rts | |
622 * get device name | |
623 GSDevNm ldx PD.DEV,y | |
624 ldx V$DESC,x | |
625 ldd M$Name,x | |
626 leax d,x | |
627 bra L0452 | |
628 | |
629 UIClose lbsr L03BA | |
630 bcs L0428 | |
631 pshs b | |
632 ldb R$A,u | |
633 clr b,x | |
634 puls b | |
635 bra L047D | |
636 | |
637 SIClose lda R$A,u | |
638 L047D bsr FindPDsc | |
639 bcs L0428 | |
640 dec PD.CNT,y | |
641 tst PD.CPR,y | |
642 bne L0489 | |
643 bsr CallFMgr | |
644 L0489 tst PD.CNT,y | |
645 bne L0428 | |
646 lbra L02F5 | |
647 | |
648 L0490 os9 F$IOQu | |
649 comb | |
650 ldb <P$Signal,x | |
651 bne L04A4 | |
652 L0499 ldx <D.Proc | |
653 ldb P$ID,x | |
654 clra | |
655 lda PD.CPR,y | |
656 bne L0490 | |
657 stb PD.CPR,y | |
658 L04A4 rts | |
659 | |
660 * B = entry point into FMgr | |
661 * Y = path desc | |
662 CallFMgr pshs u,y,x,b | |
663 bsr L0499 | |
664 bcs L04C1 | |
665 stu PD.RGS,y | |
666 lda <PD.DTP,y | |
667 ldx PD.DEV,y | |
668 ldx V$FMGR,x | |
669 ldd M$Exec,x | |
670 leax d,x | |
671 ldb ,s | |
672 subb #$83 subtract offset from B | |
673 lda #$03 size of one entry | |
674 mul compute | |
675 jsr d,x branch into file manager | |
676 L04C1 pshs b,cc | |
677 bsr L04D9 | |
678 ldy $05,s get path desc off stack | |
679 lda <PD.DTP,y | |
680 ldx <D.Proc | |
681 lda P$ID,x | |
682 cmpa PD.CPR,y | |
683 bne L04D5 | |
684 clr PD.CPR,y | |
685 L04D5 puls b,cc | |
686 puls pc,u,y,x,a | |
687 | |
688 L04D9 pshs y,x | |
689 ldy <D.Proc | |
690 lda <P$IOQN,y | |
691 beq L04F3 | |
692 clr <P$IOQN,y | |
693 ldb #S$Wake | |
694 os9 F$Send | |
695 ldx <D.PrcDBT | |
696 os9 F$Find64 | |
697 clr <P$IOQP,y | |
698 L04F3 clrb | |
699 puls pc,y,x | |
700 | |
701 * IRQ install routine | |
702 FIRQ ldx R$X,u | |
703 ldb ,x B = flip byte | |
704 ldx 1,x X = mask/priority | |
705 clra | |
706 pshs cc | |
707 pshs x,b | |
708 ldx <D.Init | |
709 ldb PollCnt,x | |
710 ldx <D.PolTbl | |
711 ldy R$X,u | |
712 beq RmvIRQEn | |
713 tst 1,s mask byte | |
714 beq L0572 | |
715 decb dec poll table count | |
716 lda #POLSIZ | |
717 mul | |
718 leax d,x point to last entry in table | |
719 lda Q$MASK,x | |
720 bne L0572 | |
721 orcc #FIRQMask+IRQMask | |
722 L051C ldb 2,s get priority byte | |
723 cmpb -1,x compare with prev entry's prior | |
724 bcs L052F | |
725 ldb #POLSIZ else copy prev entry | |
726 L0524 lda ,-x | |
727 sta POLSIZ,x | |
728 decb | |
729 bne L0524 | |
730 cmpx <D.PolTbl | |
731 bhi L051C | |
732 L052F ldd R$D,u get dev stat reg | |
733 std Q$POLL,x save it | |
734 ldd ,s++ get flip/mask | |
735 sta Q$FLIP,x save flip | |
736 stb Q$MASK,x save mask | |
737 ldb ,s+ get priority | |
738 stb Q$PRTY,x save priority | |
739 ldd R$Y,u get IRQ svc addr | |
740 std Q$SERV,x save | |
741 ldd R$U,u get IRQ svc mem ptr | |
742 std Q$STAT,x save | |
743 puls pc,cc | |
744 * remove IRQ poll entry | |
745 RmvIRQEn leas 4,s clean stack | |
746 ldy R$U,u | |
747 L054C cmpy Q$STAT,x | |
748 beq L0558 | |
749 leax POLSIZ,x | |
750 decb | |
751 bne L054C | |
752 clrb | |
753 rts | |
754 L0558 pshs b,cc | |
755 orcc #FIRQMask+IRQMask | |
756 bra L0565 | |
757 L055E ldb POLSIZ,x | |
758 stb ,x+ | |
759 deca | |
760 bne L055E | |
761 L0565 lda #POLSIZ | |
762 dec 1,s dec count | |
763 bne L055E | |
764 L056B clr ,x+ | |
765 deca | |
766 bne L056B | |
767 puls pc,a,cc | |
768 L0572 leas 4,s clean stack | |
769 L0574 comb | |
770 ldb #E$Poll | |
771 rts | |
772 | |
773 * IRQ polling routine | |
774 DPoll ldy <D.PolTbl | |
775 ldx <D.Init | |
776 ldb PollCnt,x | |
777 bra L0586 | |
778 L0581 leay POLSIZ,y | |
779 decb | |
780 beq L0574 | |
781 L0586 lda [Q$POLL,y] | |
782 eora Q$FLIP,y | |
783 bita Q$MASK,y | |
784 beq L0581 | |
785 ldu Q$STAT,y | |
786 pshs y,b | |
787 jsr [<Q$SERV,y] | |
788 puls y,b | |
789 bcs L0581 | |
790 rts | |
791 | |
792 * load a module | |
793 FLoad pshs u | |
794 ldx R$X,u | |
795 bsr L05BC | |
796 bcs L05BA | |
797 inc $02,u increment link count | |
798 ldy ,u get mod header addr | |
799 ldu ,s get caller regs | |
800 stx R$X,u | |
801 sty R$U,u | |
802 lda M$Type,y | |
803 ldb M$Revs,y | |
804 std R$D,u | |
805 ldd M$Exec,y | |
806 leax d,y | |
807 stx R$Y,u | |
808 L05BA puls pc,u | |
809 | |
810 L05BC lda #EXEC. | |
811 os9 I$Open | |
812 bcs L0632 | |
813 leas -$0A,s make room on stack | |
814 ldu #$0000 | |
815 pshs u,y,x | |
816 sta 6,s save path | |
817 L05CC ldd 4,s get U (caller regs) from stack | |
818 bne L05D2 | |
819 stu 4,s | |
820 L05D2 lda 6,s get path | |
821 leax 7,s point to place on stack | |
822 ldy #M$IDSize read M$IDSize bytes | |
823 os9 I$Read | |
824 bcs L061E | |
825 ldd ,x | |
826 cmpd #M$ID12 | |
827 bne L061C | |
828 ldd $09,s get module size | |
829 os9 F$SRqMem allocate mem | |
830 bcs L061E | |
831 ldb #M$IDSize | |
832 L05F0 lda ,x+ copy over first M$IDSize bytes | |
833 sta ,u+ | |
834 decb | |
835 bne L05F0 | |
836 lda $06,s get path | |
837 leax ,u point X at updated U | |
838 ldu $09,s get module size | |
839 leay -M$IDSize,u subtract count | |
840 os9 I$Read | |
841 leax -M$IDSize,x | |
842 bcs L060B | |
843 os9 F$VModul validate module | |
844 bcc L05CC | |
845 L060B pshs u,b | |
846 leau ,x point U at memory allocated | |
847 ldd M$Size,x | |
848 os9 F$SRtMem return mem | |
849 puls u,b | |
850 cmpb #E$KwnMod | |
851 beq L05CC | |
852 bra L061E | |
853 L061C ldb #E$BMID | |
854 L061E puls u,y,x | |
855 lda ,s get path | |
856 stb ,s save error code | |
857 os9 I$Close close path | |
858 ldb ,s | |
859 leas $0A,s clear up stack | |
860 cmpu #$0000 | |
861 bne L0632 | |
862 coma | |
863 L0632 rts | |
864 | |
865 | |
866 ErrHead fcc /ERROR #/ | |
867 ErrNum equ *-ErrHead | |
868 fcb $2F,$3A,$30,$0D | |
869 ErrLen equ *-ErrHead | |
870 | |
871 FPErr ldx <D.Proc | |
872 lda <P$PATH+2,x get stderr path | |
873 beq L0674 | |
874 leas -ErrLen,s make room on stack | |
875 * copy error message to stack | |
876 leax <ErrHead,pcr | |
877 leay ,s | |
878 L064C lda ,x+ | |
879 sta ,y+ | |
880 cmpa #$0D | |
881 bne L064C | |
882 ldb R$B,u get error # | |
883 L0656 inc ErrNum+0,s | |
884 subb #$64 | |
885 bcc L0656 | |
886 L065C dec ErrNum+1,s | |
887 addb #$0A | |
888 bcc L065C | |
889 addb #$30 | |
890 stb ErrNum+2,s | |
891 ldx <D.Proc | |
892 leax ,s point to error message | |
893 ldu <D.Proc | |
894 lda <P$PATH+2,u | |
895 os9 I$WritLn write message | |
896 leas ErrLen,s fix up stack | |
897 L0674 rts | |
898 | |
899 FIOQu ldy <D.Proc | |
900 L0678 lda <P$IOQN,y | |
901 beq L06A0 | |
902 cmpa R$A,u | |
903 bne L0699 | |
904 clr <P$IOQN,y | |
905 ldx <D.PrcDBT | |
906 os9 F$Find64 | |
907 lbcs L070F | |
908 clr <P$IOQP,y | |
909 ldb #S$Wake | |
910 os9 F$Send | |
911 ldu <D.Proc | |
912 bra L06AB | |
913 L0699 ldx <D.PrcDBT | |
914 os9 F$Find64 | |
915 bcc L0678 | |
916 L06A0 lda R$A,u | |
917 ldu <D.Proc | |
918 ldx <D.PrcDBT | |
919 os9 F$Find64 | |
920 bcs L070F | |
921 L06AB leax ,y X = proc desc | |
922 lda <P$IOQN,y | |
923 beq L06D1 | |
924 ldx <D.PrcDBT | |
925 os9 F$Find64 | |
926 bcs L070F | |
927 ldb P$Age,u | |
928 | |
929 ifeq edition-$0B | |
930 | |
931 * Note: the following line is a bug | |
932 cmpd P$Age,y | |
933 | |
934 else | |
935 | |
936 cmpb P$Age,y | |
937 | |
938 endc | |
939 | |
940 bls L06AB | |
941 ldb ,u | |
942 stb <P$IOQN,x | |
943 ldb P$ID,x | |
944 stb <P$IOQP,u | |
945 clr <P$IOQP,y | |
946 exg y,u | |
947 bra L06AB | |
948 L06D1 lda P$ID,u | |
949 sta <P$IOQN,y | |
950 lda P$ID,y | |
951 sta <P$IOQP,u | |
952 ldx #$0000 | |
953 os9 F$Sleep | |
954 ldu <D.Proc | |
955 lda <P$IOQP,u | |
956 beq L070C | |
957 ldx <D.PrcDBT | |
958 os9 F$Find64 | |
959 bcs L070C | |
960 lda <P$IOQN,y | |
961 beq L070C | |
962 lda <P$IOQN,u | |
963 sta <P$IOQN,y | |
964 beq L070C | |
965 clr <P$IOQN,u | |
966 ldx <D.PrcDBT | |
967 os9 F$Find64 | |
968 bcs L070C | |
969 lda <P$IOQP,u | |
970 sta <P$IOQP,y | |
971 L070C clr <P$IOQP,u | |
972 L070F rts | |
973 | |
974 emod | |
975 eom equ * | |
976 end |