Mercurial > hg > Members > kono > nitros9-code
annotate level1/modules/kernel.asm @ 300:e2ac8a38f22c
Changed module edition
author | boisy |
---|---|
date | Mon, 22 Jul 2002 05:01:12 +0000 |
parents | eda95fad0c31 |
children | c863af5b4ea1 |
rev | line source |
---|---|
0 | 1 ******************************************************************** |
2 * OS9p1 - OS-9 Level One V2 P1 module | |
3 * | |
4 * $Id$ | |
5 * | |
6 * Ed. Comments Who YY/MM/DD | |
7 * ------------------------------------------------------------------ | |
201 | 8 * 14 From Tandy OS-9 Level One VR 02.00.00 |
300 | 9 * 15 Module validation consists only of module BGP 02/07/21 |
10 * header parity check. CRC check is not done | |
11 * unless D.CRC is set to 1, which is NOT the | |
12 * default case. By default, D.CRC is set | |
13 * to 0, thus there is no CRC checking. Speeds | |
14 * up module loads quite a bit. | |
0 | 15 |
16 | |
17 nam OS9 | |
18 ttl OS-9 Level One V2 P1 module | |
19 | |
20 ifp1 | |
21 use defsfile | |
22 use scfdefs | |
23 endc | |
24 | |
25 tylg set Systm+Objct | |
26 atrv set ReEnt+rev | |
27 rev set $01 | |
300 | 28 edition set 15 |
0 | 29 |
30 L0000 mod eom,name,tylg,atrv,OS9Cold,size | |
31 | |
32 size equ . | |
33 | |
34 name fcs /OS9/ | |
35 fcb edition | |
36 | |
37 fcc /CC/ | |
38 | |
39 InitNam fcs /INIT/ | |
40 | |
41 P2Nam fcs /OS9P2/ | |
42 | |
43 VectCode bra SWI3Jmp | |
44 nop | |
45 bra SWI2Jmp | |
46 nop | |
47 bra SWIJmp | |
48 nop | |
49 bra NMIJmp | |
50 nop | |
51 bra IRQJmp | |
52 nop | |
53 bra FIRQJmp | |
54 | |
55 SWI3Jmp jmp [>D.SWI3] | |
56 SWI2Jmp jmp [>D.SWI2] | |
57 SWIJmp jmp [>D.SWI] | |
58 NMIJmp jmp [>D.NMI] | |
59 IRQJmp jmp [>D.IRQ] | |
60 FIRQJmp jmp [>D.FIRQ] | |
61 VectCSz equ *-VectCode | |
62 | |
63 | |
64 SysTbl fcb F$Link | |
65 fdb FLink-*-2 | |
66 | |
67 fcb F$Fork | |
68 fdb FFork-*-2 | |
69 | |
70 fcb F$Chain | |
71 fdb FChain-*-2 | |
72 | |
73 fcb F$Chain+$80 | |
74 fdb SFChain-*-2 | |
75 | |
76 fcb F$PrsNam | |
77 fdb FPrsNam-*-2 | |
78 | |
79 fcb F$CmpNam | |
80 fdb FCmpNam-*-2 | |
81 | |
82 fcb F$SchBit | |
83 fdb FSchBit-*-2 | |
84 | |
85 fcb F$AllBit | |
86 fdb FAllBit-*-2 | |
87 | |
88 fcb F$DelBit | |
89 fdb FDelBit-*-2 | |
90 | |
91 fcb F$CRC | |
92 fdb FCRC-*-2 | |
93 | |
94 fcb F$SRqMem+$80 | |
95 fdb FSRqMem-*-2 | |
96 | |
97 fcb F$SRtMem+$80 | |
98 fdb FSRtMem-*-2 | |
99 | |
100 fcb F$AProc+$80 | |
101 fdb FAProc-*-2 | |
102 | |
103 fcb F$NProc+$80 | |
104 fdb FNProc-*-2 | |
105 | |
106 fcb F$VModul+$80 | |
107 fdb FVModul-*-2 | |
108 | |
109 fcb F$SSvc | |
110 fdb FSSvc-*-2 | |
111 | |
112 fcb $80 | |
113 | |
114 * | |
115 * OS-9 Genesis! | |
116 OS9Cold equ * | |
117 * clear out system globals from $0020-$0400 | |
118 ldx #D.FMBM | |
119 ldy #$400-D.FMBM | |
120 clra | |
121 clrb | |
122 L007F std ,x++ | |
123 leay -2,y | |
124 bne L007F | |
125 * set up system globals | |
126 inca | |
127 inca D = $200 | |
128 std <D.FMBM $200 = start of free memory bitmap | |
129 addb #$20 | |
130 std <D.FMBM+2 $220 = end of free memory bitmap | |
131 addb #$02 | |
132 std <D.SysDis $222 = addr of sys dispatch tbl | |
133 addb #$70 | |
296 | 134 std <D.UsrDis $292 = addr of usr dispatch tbl |
0 | 135 clrb |
136 inca D = $300 | |
137 std <D.ModDir $300 = mod dir start | |
138 stx <D.ModDir+2 X = $400 = mod dir end | |
139 leas >$0100,x S = $500 (system stack?) | |
140 | |
141 * Check for valid RAM starting at $400 | |
142 ChkRAM leay ,x | |
143 ldd ,y store org contents in D | |
144 ldx #$00FF | |
145 stx ,y write pattern to ,Y | |
146 cmpx ,y same as what we wrote? | |
147 bne L00C2 nope, not RAM here! | |
148 ldx #$FF00 try different pattern | |
149 stx ,y write it to ,Y | |
150 cmpx ,y same as what we wrote? | |
151 bne L00C2 nope, not RAM here! | |
152 std ,y else restore org contents | |
153 leax >$0100,y check top of next 256 block | |
154 cmpx #$EF00 stop short of boot track mem | |
155 bcs ChkRAM | |
156 leay ,x | |
157 * Here, Y = end of RAM | |
158 L00C2 leax ,y X = end of RAM | |
159 stx <D.MLIM save off memory limit | |
160 | |
161 * Copy vector code over to address $100 | |
162 pshs y,x | |
163 leax >VectCode,pcr | |
247 | 164 ldy #D.XSWI3 |
0 | 165 ldb #VectCSz |
166 L00D2 lda ,x+ | |
167 sta ,y+ | |
168 decb | |
169 bne L00D2 | |
170 puls y,x | |
171 * validate modules at top of RAM (kernel, etc.) | |
172 L00DB lbsr ValMod | |
173 bcs L00E6 | |
174 ldd M$Size,x | |
175 leax d,x go past module | |
176 bra L00EC | |
177 L00E6 cmpb #E$KwnMod | |
178 beq L00EE | |
179 leax 1,x | |
180 L00EC bne L00DB | |
181 | |
182 * copy vectors to system globals | |
183 L00EE leay >Vectors,pcr | |
184 leax >L0000,pcr | |
185 pshs x | |
186 ldx #D.SWI3 | |
187 L00FB ldd ,y++ | |
188 addd ,s | |
189 std ,x++ | |
190 cmpx #$0036 | |
191 bls L00FB | |
192 leas 2,s restore stack | |
193 | |
194 * fill in more system globals | |
195 leax >URtoSs,pcr | |
196 stx <D.URtoSs | |
197 leax >UsrIRQ,pcr | |
198 stx <D.UsrIRQ | |
199 leax >UsrSvc,pcr | |
200 stx <D.UsrSvc | |
201 leax >SysIRQ,pcr | |
202 stx <D.SysIRQ | |
203 stx <D.SvcIRQ | |
204 leax >SysSvc,pcr | |
205 stx <D.SysSvc | |
206 stx <D.SWI2 | |
207 leax >Poll,pcr | |
208 stx <D.Poll | |
209 leax >Clock,pcr | |
210 stx <D.Clock | |
211 stx <D.AltIRQ | |
212 | |
213 * install system calls | |
214 leay >SysTbl,pcr | |
215 lbsr InstSSvc | |
216 | |
217 * link to init module | |
218 lda #Systm+0 | |
219 leax >InitNam,pcr | |
220 os9 F$Link | |
221 lbcs OS9Cold | |
222 stu <D.Init | |
223 ldd MaxMem+1,u | |
224 clrb | |
225 cmpd <D.MLIM | |
226 bcc L0158 | |
227 std <D.MLIM | |
228 L0158 ldx <D.FMBM | |
229 ldb #$F8 | |
230 stb ,x | |
231 clra | |
232 ldb <D.MLIM | |
233 negb | |
234 tfr d,y | |
235 negb | |
236 lbsr L065A | |
237 | |
238 * jump into OS9p2 here | |
239 leax >P2Nam,pcr | |
240 lda #Systm+Objct | |
241 os9 F$Link | |
242 lbcs OS9Cold | |
243 jmp ,y | |
165 | 244 SWI3 pshs pc,x,b |
0 | 245 ldb #P$SWI3 |
246 bra L018C | |
165 | 247 SWI2 pshs pc,x,b |
0 | 248 ldb #P$SWI2 |
249 bra L018C | |
247 | 250 DUMMY rti |
165 | 251 SVCIRQ jmp [>D.SvcIRQ] |
252 SWI pshs pc,x,b | |
0 | 253 ldb #P$SWI |
254 L018C ldx >D.Proc | |
255 ldx b,x get SWI entry | |
256 stx 3,s put in PC on stack | |
257 puls pc,x,b | |
258 | |
259 UsrIRQ leay <L01B1,pcr | |
260 * transition from user to system state | |
261 URtoSs clra | |
262 tfr a,dp clear direct page | |
263 ldx <D.Proc | |
264 ldd <D.SysSvc | |
265 std <D.SWI2 | |
266 ldd <D.SysIRQ | |
267 std <D.SvcIRQ | |
268 leau ,s | |
269 stu P$SP,x | |
270 lda P$State,x | |
271 ora #SysState | |
272 sta P$State,x | |
273 jmp ,y | |
274 | |
275 L01B1 jsr [>D.Poll] | |
276 bcc L01BD | |
277 ldb ,s | |
278 orb #$10 | |
279 stb ,s | |
280 L01BD lbra L0255 | |
281 | |
282 SysIRQ clra | |
283 tfr a,dp | |
284 jsr [>D.Poll] | |
285 bcc L01CF | |
286 ldb ,s | |
287 orb #$10 | |
288 stb ,s | |
289 L01CF rti | |
290 Poll comb | |
291 rts | |
292 | |
293 Clock ldx <D.SProcQ | |
294 beq L01FD | |
295 lda P$State,x | |
296 bita #TimSleep | |
297 beq L01FD | |
298 ldu P$SP,x | |
299 ldd P$SP,u | |
300 subd #$0001 | |
301 std P$SP,u | |
302 bne L01FD | |
303 L01E7 ldu P$Queue,x | |
304 bsr L021A | |
305 leax ,u | |
306 beq L01FB | |
307 lda P$State,x | |
308 bita #TimSleep | |
309 beq L01FB | |
310 ldu P$SP,x | |
311 ldd P$SP,u | |
312 beq L01E7 | |
313 L01FB stx <D.SProcQ | |
314 L01FD dec <D.Slice | |
315 bne ClockRTI | |
316 lda <D.TSlice | |
317 sta <D.Slice | |
318 ldx <D.Proc | |
319 beq ClockRTI | |
320 lda P$State,x | |
321 ora #TimOut | |
322 sta P$State,x | |
323 bpl L0212 branch if not system state | |
324 ClockRTI rti | |
325 | |
326 L0212 leay >L0255,pcr | |
327 bra URtoSs | |
328 | |
329 * X = proc desc | |
330 FAProc ldx R$X,u | |
331 L021A pshs u,y | |
332 ldu #$003F | |
333 bra L0228 | |
334 L0221 ldb P$Age,u | |
335 incb | |
336 beq L0228 | |
337 stb P$Age,u | |
338 L0228 ldu P$Queue,u U = proc desc | |
339 bne L0221 | |
340 ldu #$003F | |
341 lda P$Prior,x | |
342 sta P$Age,x | |
343 orcc #IntMasks | |
344 L0235 leay ,u | |
345 ldu P$Queue,u | |
346 beq L023F | |
347 cmpa P$Age,u | |
348 bls L0235 | |
349 L023F stu P$Queue,x | |
350 stx P$Queue,y | |
351 clrb | |
352 puls pc,u,y | |
353 | |
354 UsrSvc leay <L024E,pcr | |
355 orcc #IntMasks | |
356 lbra URtoSs | |
357 | |
358 L024E andcc #^IntMasks | |
359 ldy <D.UsrDis | |
360 bsr L0278 | |
361 L0255 ldx <D.Proc get current proc desc | |
362 beq FNProc branch to FNProc if none | |
363 orcc #IntMasks | |
364 ldb P$State,x | |
365 andb #^SysState | |
366 stb P$State,x | |
367 bitb #TimOut | |
368 beq L02D1 | |
369 andb #^TimOut | |
370 stb P$State,x | |
371 bsr L021A | |
372 bra FNProc | |
373 | |
374 * system call entry | |
375 SysSvc clra | |
376 tfr a,dp set direct page to 0 | |
377 leau ,s | |
378 ldy <D.SysDis | |
379 bsr L0278 | |
380 rti | |
381 | |
382 L0278 pshs u | |
383 ldx R$PC,u point X to PC | |
384 ldb ,x+ get func code at X | |
385 stx R$PC,u restore updated PC | |
386 lslb multiply by 2 | |
387 bcc L0288 branch if user call | |
388 rorb | |
389 ldx -2,y | |
390 bra L0290 | |
391 L0288 cmpb #$6E | |
392 bcc L02A7 | |
393 ldx b,y X = addr of system call | |
394 beq L02A7 | |
395 L0290 jsr ,x jsr into system call | |
396 L0292 puls u | |
397 tfr cc,a | |
398 bcc FixCC branch if no error | |
399 stb R$B,u store error code | |
400 FixCC ldb R$CC,u get caller's CC | |
401 andb #^(Negative+Zero+TwosOvfl+Carry) | |
402 stb R$CC,u | |
403 anda #Negative+Zero+TwosOvfl+Carry | |
404 ora R$CC,u | |
405 sta R$CC,u | |
406 rts | |
407 L02A7 comb | |
408 ldb #E$UnkSvc | |
409 bra L0292 | |
410 | |
411 * no signal handler, exit with signal value as exit code | |
412 L02AC ldb P$State,x | |
413 orb #SysState | |
414 stb P$State,x | |
415 ldb <P$Signal,x | |
416 andcc #^(IntMasks) | |
417 os9 F$Exit | |
418 | |
419 FNProc clra | |
420 clrb | |
421 std <D.Proc | |
422 bra L02C2 | |
423 * execution goes here when there are no active processes | |
424 L02C0 cwai #^(IntMasks) | |
425 L02C2 orcc #IntMasks | |
426 ldx <D.AProcQ get next active process | |
427 beq L02C0 CWAI if none | |
428 ldd P$Queue,x get queue ptr | |
429 std <D.AProcQ store in Active Q | |
430 stx <D.Proc store in current process | |
431 lds P$SP,x get process' stack ptr | |
432 L02D1 ldb P$State,x get state | |
433 bmi L0308 branch if system state | |
434 bitb #Condem process condemned? | |
435 bne L02AC branch if so... | |
436 ldb <P$Signal,x get signal no | |
437 beq L02FF branch if none | |
438 decb decrement | |
439 beq L02FC branch if wake up | |
440 ldu <P$SigVec,x get signal handler addr | |
441 beq L02AC branch if none | |
442 ldy <P$SigDat,x get data addr | |
443 ldd $06,s | |
444 pshs u,y,b,a | |
445 ldu $0A,s | |
446 lda <P$Signal,x | |
447 ldb $09,s | |
448 tfr d,y | |
449 ldd $06,s | |
450 pshs u,y,b,a | |
451 clrb | |
452 L02FC stb <P$Signal,x | |
453 L02FF ldd <P$SWI2,x | |
454 std <D.SWI2 | |
455 ldd <D.UsrIRQ | |
456 std <D.SvcIRQ | |
457 L0308 rti | |
458 | |
459 FLink pshs u save caller regs | |
460 ldd R$A,u | |
461 ldx R$X,u | |
462 lbsr L0443 | |
463 bcc FLinkOK | |
464 ldb #E$MNF | |
465 bra L033D | |
466 * U = module dir entry | |
467 FLinkOK ldy ,u get module ptr | |
468 ldb M$Revs,y | |
469 bitb #ReEnt reentrant? | |
470 bne L032A branch if so | |
471 tst $02,u link count zero? | |
472 beq L032A yep, ok to link to nonreent | |
473 comb else module is busy | |
474 ldb #E$ModBsy | |
475 bra L033D | |
476 L032A inc $02,u increment link count | |
477 ldu ,s get caller regs from stack | |
478 stx R$X,u | |
479 sty R$U,u | |
480 ldd M$Type,y | |
481 std R$D,u | |
482 ldd M$IDSize,y | |
483 leax d,y | |
484 stx R$Y,u | |
485 L033D puls pc,u | |
486 | |
487 FVModul pshs u | |
488 ldx R$X,u | |
489 bsr ValMod | |
490 puls y | |
491 stu R$U,y | |
492 rts | |
493 * X = address of module to validate | |
494 ValMod bsr ChkMHCRC | |
495 bcs L039A | |
496 lda M$Type,x | |
497 pshs x,a | |
498 ldd M$Name,x | |
499 leax d,x X = addr of name in mod | |
500 puls a | |
501 lbsr L0443 | |
502 puls x | |
503 bcs L039B | |
504 ldb #E$KwnMod | |
505 cmpx ,u | |
506 beq L03A1 | |
507 lda M$Revs,x | |
508 anda #RevsMask | |
509 pshs a | |
510 ldy ,u | |
511 lda M$Revs,y | |
512 anda #RevsMask | |
513 cmpa ,s+ same revision as other mod? | |
514 bcc L03A1 | |
515 pshs y,x | |
516 ldb M$Size,u | |
517 bne L0395 | |
518 ldx ,u | |
519 cmpx <D.BTLO | |
520 bcc L0395 | |
521 ldd $02,x | |
522 addd #$00FF | |
523 tfr a,b | |
524 clra | |
525 tfr d,y | |
526 ldb ,u | |
527 ldx <D.FMBM | |
528 os9 F$DelBit | |
529 clr $02,u | |
530 L0395 puls y,x | |
531 L0397 stx ,u | |
532 clrb | |
533 L039A rts | |
534 L039B leay ,u | |
535 bne L0397 | |
536 ldb #E$DirFul | |
537 L03A1 coma | |
538 rts | |
539 | |
540 * check module header and CRC | |
541 * X = address of potential module | |
542 ChkMHCRC ldd ,x | |
543 cmpd #M$ID12 sync bytes? | |
544 bne L03B1 nope, not a module here | |
545 leay M$Parity,x | |
546 bsr ChkMHPar check header parity | |
547 bcc L03B5 branch if ok | |
548 L03B1 comb | |
549 ldb #E$BMID | |
550 rts | |
297
eda95fad0c31
Added check for D.CRC switch to prevent CRC checking (off by default)
boisy
parents:
296
diff
changeset
|
551 |
eda95fad0c31
Added check for D.CRC switch to prevent CRC checking (off by default)
boisy
parents:
296
diff
changeset
|
552 L03B5 |
eda95fad0c31
Added check for D.CRC switch to prevent CRC checking (off by default)
boisy
parents:
296
diff
changeset
|
553 * Following 4 lines added to support no CRC checks - 2002/07/21 |
eda95fad0c31
Added check for D.CRC switch to prevent CRC checking (off by default)
boisy
parents:
296
diff
changeset
|
554 lda <D.CRC is CRC checking on? |
eda95fad0c31
Added check for D.CRC switch to prevent CRC checking (off by default)
boisy
parents:
296
diff
changeset
|
555 bne DoCRCCk branch if so |
eda95fad0c31
Added check for D.CRC switch to prevent CRC checking (off by default)
boisy
parents:
296
diff
changeset
|
556 clrb |
eda95fad0c31
Added check for D.CRC switch to prevent CRC checking (off by default)
boisy
parents:
296
diff
changeset
|
557 rts |
eda95fad0c31
Added check for D.CRC switch to prevent CRC checking (off by default)
boisy
parents:
296
diff
changeset
|
558 |
eda95fad0c31
Added check for D.CRC switch to prevent CRC checking (off by default)
boisy
parents:
296
diff
changeset
|
559 DoCRCCk pshs x |
0 | 560 ldy M$Size,x |
561 bsr ChkMCRC checkm module CRC | |
562 puls pc,x | |
563 * check module header parity | |
564 * Y = pointer to parity byte | |
565 ChkMHPar pshs y,x | |
566 clra | |
567 ChkM010 eora ,x+ | |
568 cmpx 2,s compare to addr of M$Parity | |
569 bls ChkM010 | |
570 cmpa #$FF | |
571 puls pc,y,x | |
572 * X = address of potential module | |
573 * Y = size of module | |
574 ChkMCRC ldd #$FFFF | |
575 pshs b,a | |
576 pshs b,a | |
577 leau 1,s | |
578 L03D4 lda ,x+ | |
579 bsr CRCAlgo | |
580 leay -1,y dec Y (size of module) | |
581 bne L03D4 continue | |
582 clr -1,u | |
583 lda ,u | |
584 cmpa #CRCCon1 | |
585 bne L03EC | |
586 ldd 1,u | |
587 cmpd #CRCCon23 | |
588 beq L03EF | |
589 L03EC comb | |
590 ldb #E$BMCRC | |
591 L03EF puls pc,y,x | |
592 | |
593 * F$CRC | |
594 FCRC ldx R$X,u | |
595 ldy R$Y,u | |
596 beq L0402 | |
597 ldu R$U,u | |
598 L03FA lda ,x+ | |
599 bsr CRCAlgo | |
600 leay -1,y | |
601 bne L03FA | |
602 L0402 clrb | |
603 rts | |
604 | |
605 CRCAlgo eora ,u | |
606 pshs a | |
607 ldd $01,u | |
608 std ,u | |
609 clra | |
610 ldb ,s | |
611 lslb | |
612 rola | |
613 eora 1,u | |
614 std 1,u | |
615 clrb | |
616 lda ,s | |
617 lsra | |
618 rorb | |
619 lsra | |
620 rorb | |
621 eora 1,u | |
622 eorb 2,u | |
623 std 1,u | |
624 lda ,s | |
625 lsla | |
626 eora ,s | |
627 sta ,s | |
628 lsla | |
629 lsla | |
630 eora ,s | |
631 sta ,s | |
632 lsla | |
633 lsla | |
634 lsla | |
635 lsla | |
636 eora ,s+ | |
637 bpl L0442 | |
638 ldd #$8021 | |
639 eora ,u | |
640 sta ,u | |
641 eorb 2,u | |
642 stb 2,u | |
643 L0442 rts | |
644 | |
645 L0443 ldu #$0000 | |
646 tfr a,b | |
647 anda #TypeMask | |
648 andb #LangMask | |
649 pshs u,y,x,b,a | |
650 bsr EatSpace | |
651 cmpa #PDELIM pathlist char? | |
652 beq L049C branch if so | |
653 lbsr L074D parse name | |
654 bcs L049D return if error | |
655 ldu <D.ModDir | |
656 L045B pshs u,y,b | |
657 ldu ,u | |
658 beq L048B | |
659 ldd $04,u | |
660 leay d,u | |
661 ldb ,s | |
662 lbsr L07AB | |
663 bcs L0493 | |
664 lda $05,s | |
665 beq L0476 | |
666 eora $06,u | |
667 anda #$F0 | |
668 bne L0493 | |
669 L0476 lda $06,s | |
670 beq L0480 | |
671 eora $06,u | |
672 anda #$0F | |
673 bne L0493 | |
674 L0480 puls u,x,b | |
675 stu $06,s | |
676 bsr EatSpace | |
677 stx $02,s | |
678 clra | |
679 bra L049D | |
680 L048B ldd $0B,s | |
681 bne L0493 | |
682 ldd $03,s | |
683 std $0B,s | |
684 L0493 puls u,y,b | |
685 leau $04,u | |
686 cmpu <D.ModDir+2 | |
687 bcs L045B | |
688 L049C comb | |
689 L049D puls pc,u,y,x,b,a | |
690 | |
691 EatSpace lda #C$SPAC | |
692 EatSpc10 cmpa ,x+ | |
693 beq EatSpc10 | |
694 lda ,-x | |
695 rts | |
696 | |
697 FFork ldx <D.PrcDBT | |
698 os9 F$All64 | |
699 bcs L0517 | |
700 ldx <D.Proc | |
701 pshs x save calling proc desc on stack | |
702 ldd P$User,x | |
703 std P$User,y | |
704 lda P$Prior,x | |
705 clrb | |
706 std P$Prior,y | |
707 ldb #SysState | |
708 stb P$State,y | |
709 sty <D.Proc | |
710 ldd <P$NIO,x | |
711 std <P$NIO,y | |
712 ldd <P$NIO+2,x | |
713 std <P$NIO+2,y | |
714 leax <P$DIO,x | |
715 leay <P$DIO,y | |
716 ldb #DefIOSiz | |
717 * copy I/O stuff from parent to child | |
718 L04D7 lda ,x+ | |
719 sta ,y+ | |
720 decb | |
721 bne L04D7 | |
722 * X/Y = address of path table in respective proc desc | |
723 * Dup stdin/stdout/stderr | |
724 ldb #$03 | |
725 L04E0 lda ,x+ | |
726 os9 I$Dup | |
727 bcc L04E8 | |
728 clra | |
729 L04E8 sta ,y+ | |
730 decb | |
731 bne L04E0 | |
732 bsr L0553 | |
733 bcs L050C | |
734 puls y get parent proc desc | |
735 sty <D.Proc | |
736 lda P$ID,x get ID of new process | |
737 sta R$A,u store in caller's A | |
738 ldb P$CID,y get child id of parent | |
739 sta P$CID,y store new proc in parent's CID | |
740 lda P$ID,y get ID of parent | |
741 std P$PID,x store in child proc desc | |
742 ldb P$State,x update state of child | |
743 andb #^SysState | |
744 stb P$State,x | |
745 os9 F$AProc insert child in active Q | |
746 rts | |
747 L050C pshs b | |
748 os9 F$Exit | |
749 comb | |
750 puls x,b | |
751 stx <D.Proc | |
752 rts | |
753 L0517 comb | |
754 ldb #E$PrcFul | |
755 rts | |
756 | |
757 FChain bsr L0543 | |
758 bcs L0531 | |
759 orcc #IntMasks | |
760 ldb $0D,x | |
761 andb #$7F | |
762 stb $0D,x | |
763 L0527 os9 F$AProc | |
764 os9 F$NProc | |
765 | |
766 SFChain bsr L0543 | |
767 bcc L0527 | |
768 L0531 pshs b | |
769 stb <P$Signal,x | |
770 ldb P$State,x | |
771 orb #Condem | |
772 stb P$State,x | |
773 ldb #$FF | |
774 stb P$Prior,x | |
775 comb | |
776 puls pc,b | |
777 L0543 pshs u | |
778 ldx <D.Proc | |
779 ldu <P$PModul,x | |
780 os9 F$UnLink | |
781 ldu ,s | |
782 bsr L0553 | |
783 puls pc,u | |
784 L0553 ldx <D.Proc | |
785 pshs u,x | |
786 ldd <D.UsrSvc | |
787 std <P$SWI,x | |
788 std <P$SWI2,x | |
789 std <P$SWI3,x | |
790 clra | |
791 clrb | |
792 sta <P$Signal,x | |
793 std <P$SigVec,x | |
794 lda R$A,u | |
795 ldx R$X,u | |
796 os9 F$Link | |
797 bcc L0578 | |
798 os9 F$Load | |
799 bcs L05E7 | |
800 L0578 ldy <D.Proc | |
801 stu <P$PModul,y | |
802 cmpa #Prgrm+Objct | |
803 beq L058B | |
804 cmpa #Systm+Objct | |
805 beq L058B | |
806 comb | |
807 ldb #E$NEMod | |
808 bra L05E7 | |
809 L058B leay ,u Y = addr of module | |
810 ldu 2,s get U off stack (caller regs) | |
811 stx R$X,u | |
812 lda R$B,u | |
813 clrb | |
814 cmpd M$Mem,y compare passed mem to module's | |
815 bcc L059B branch if less than | |
816 ldd M$Mem,y | |
817 L059B addd #$0000 | |
818 bne L05A0 | |
819 L05A0 os9 F$Mem | |
820 bcs L05E7 | |
821 subd #R$Size subtract registers | |
822 subd R$Y,u subtract parameter area | |
823 bcs L05E5 | |
824 ldx R$U,u get parameter area | |
825 ldd R$Y,u get parameter size | |
826 pshs b,a | |
827 beq L05BE | |
828 leax d,x point to end of param area | |
829 L05B6 lda ,-x get byte, dec X | |
830 sta ,-y save byte in data area, dec X | |
831 cmpx R$U,u at top of param area? | |
832 bhi L05B6 | |
833 * set up registers for return of F$Fork/F$Chain | |
834 L05BE ldx <D.Proc | |
835 sty -$08,y put in X on caller stack | |
836 leay -R$Size,y back up register size | |
837 sty P$SP,x | |
838 lda P$ADDR,x | |
839 clrb | |
840 std R$U,y lowest address | |
841 sta R$DP,y set direct page | |
842 adda P$PagCnt,x | |
843 std R$Y,y | |
844 puls b,a | |
845 std R$D,y size of param area | |
846 ldb #Entire | |
847 stb R$CC,y | |
848 ldu <P$PModul,x get addr of prim. mod | |
849 ldd M$Exec,u | |
850 leau d,u | |
851 stu R$PC,y put in PC on caller reg | |
852 clrb | |
853 L05E5 ldb #E$IForkP | |
854 L05E7 puls pc,u,x | |
855 | |
856 FSRqMem ldd R$D,u | |
857 addd #$00FF | |
858 clrb | |
859 std R$D,u | |
860 ldx <D.FMBM+2 | |
861 ldd #$01FF | |
862 pshs b,a | |
863 bra L0604 | |
864 L05FA dec $01,s | |
865 ldb $01,s | |
866 L05FE lsl ,s | |
867 bcc L060A | |
868 rol ,s | |
869 L0604 leax -1,x | |
870 cmpx <D.FMBM | |
871 bcs L0620 | |
872 L060A lda ,x | |
873 anda ,s | |
874 bne L05FA | |
875 dec 1,s | |
876 subb 1,s | |
877 cmpb 1,u | |
878 rora | |
879 addb 1,s | |
880 rola | |
881 bcs L05FE | |
882 ldb 1,s | |
883 clra | |
884 incb | |
885 L0620 leas 2,s | |
886 bcs L0635 | |
887 ldx <D.FMBM | |
888 tfr d,y | |
889 ldb 1,u | |
890 clra | |
891 exg d,y | |
892 bsr L065A | |
893 exg a,b | |
894 std 8,u | |
895 L0633 clra | |
896 rts | |
897 L0635 comb | |
898 ldb #E$MemFul | |
899 rts | |
900 | |
901 FSRtMem ldd R$D,u | |
902 addd #$00FF | |
903 tfr a,b | |
904 clra | |
905 tfr d,y | |
906 ldd R$U,u | |
907 beq L0633 | |
908 tstb | |
909 beq L064E | |
910 comb | |
911 ldb #E$BPAddr | |
912 rts | |
913 L064E exg a,b | |
914 ldx <D.FMBM | |
915 bra L06AD | |
916 | |
917 FAllBit ldd R$D,u | |
918 leau R$X,u | |
919 pulu y,x | |
920 L065A pshs y,x,b,a | |
921 bsr L0690 | |
922 tsta | |
923 pshs a | |
924 bmi L0671 | |
925 lda ,x | |
926 L0665 ora ,s | |
927 leay -1,y | |
928 beq L0689 | |
929 lsr ,s | |
930 bcc L0665 | |
931 sta ,x+ | |
932 L0671 tfr y,d | |
933 sta ,s | |
934 lda #$FF | |
935 bra L067B | |
936 L0679 sta ,x+ | |
937 L067B subb #$08 | |
938 bcc L0679 | |
939 dec ,s | |
940 bpl L0679 | |
941 L0683 lsla | |
942 incb | |
943 bne L0683 | |
944 ora ,x | |
945 L0689 sta ,x | |
946 clra | |
947 leas 1,s | |
948 puls pc,y,x,b,a | |
949 L0690 pshs b | |
950 lsra | |
951 rorb | |
952 lsra | |
953 rorb | |
954 lsra | |
955 rorb | |
956 leax d,x | |
957 puls b | |
958 lda #$80 | |
959 andb #$07 | |
960 beq L06A6 | |
961 L06A2 lsra | |
962 decb | |
963 bne L06A2 | |
964 L06A6 rts | |
965 | |
966 FDelBit ldd R$D,u | |
967 leau R$X,u | |
968 pulu y,x | |
969 L06AD pshs y,x,b,a | |
970 bsr L0690 | |
971 coma | |
972 pshs a | |
973 bpl L06C4 | |
974 lda ,x | |
975 L06B8 anda ,s | |
976 leay -1,y | |
977 beq L06D8 | |
978 asr ,s | |
979 bcs L06B8 | |
980 sta ,x+ | |
981 L06C4 tfr y,d | |
982 bra L06CA | |
983 L06C8 clr ,x+ | |
984 L06CA subd #$0008 | |
985 bhi L06C8 | |
986 beq L06D8 | |
987 L06D1 lsla | |
988 incb | |
989 bne L06D1 | |
990 coma | |
991 anda ,x | |
992 L06D8 sta ,x | |
993 clr ,s+ | |
994 puls pc,y,x,b,a | |
995 | |
996 FSchBit pshs u | |
997 ldd R$D,u | |
998 ldx R$X,u | |
999 ldy R$Y,u | |
1000 ldu R$U,u | |
1001 bsr L06F3 | |
1002 puls u | |
1003 std R$D,u | |
1004 sty R$Y,u | |
1005 rts | |
1006 L06F3 pshs u,y,x,b,a | |
1007 pshs y,b,a | |
1008 clr 8,s | |
1009 clr 9,s | |
1010 tfr d,y | |
1011 bsr L0690 | |
1012 pshs a | |
1013 bra L0710 | |
1014 L0703 leay $01,y | |
1015 sty $05,s | |
1016 L0708 lsr ,s | |
1017 bcc L0714 | |
1018 ror ,s | |
1019 leax $01,x | |
1020 L0710 cmpx $0B,s | |
1021 bcc L0732 | |
1022 L0714 lda ,x | |
1023 anda ,s | |
1024 bne L0703 | |
1025 leay $01,y | |
1026 tfr y,d | |
1027 subd $05,s | |
1028 cmpd $03,s | |
1029 bcc L0739 | |
1030 cmpd $09,s | |
1031 bls L0708 | |
1032 std $09,s | |
1033 ldd $05,s | |
1034 std $01,s | |
1035 bra L0708 | |
1036 L0732 ldd $01,s | |
1037 std $05,s | |
1038 coma | |
1039 bra L073B | |
1040 L0739 std $09,s | |
1041 L073B leas $05,s | |
1042 puls pc,u,y,x,b,a | |
1043 | |
1044 FPrsNam ldx R$X,u | |
1045 bsr L074D | |
1046 std R$D,u | |
1047 bcs L0749 | |
1048 stx R$X,u | |
1049 L0749 sty R$Y,u | |
1050 rts | |
1051 L074D lda ,x | |
1052 cmpa #PDELIM pathlist char? | |
1053 bne L0755 branch if not | |
1054 leax 1,x go past pathlist char | |
1055 L0755 leay ,x | |
1056 clrb | |
1057 lda ,y+ | |
1058 anda #$7F | |
1059 bsr L0792 | |
1060 bcs L0772 | |
1061 L0760 incb | |
1062 lda -1,y | |
1063 bmi L076F hi bit set on this char, done | |
1064 lda ,y+ | |
1065 anda #$7F | |
1066 bsr IllChar | |
1067 bcc L0760 | |
1068 lda ,-y | |
1069 L076F andcc #^Carry | |
1070 rts | |
1071 L0772 cmpa #C$COMA comma? | |
1072 bne L0778 | |
1073 L0776 lda ,y+ | |
1074 L0778 cmpa #C$SPAC space? | |
1075 beq L0776 | |
1076 lda ,-y | |
1077 comb | |
1078 ldb #E$BNam | |
1079 rts | |
1080 | |
1081 * check for illegal characters in a pathlist | |
1082 IllChar cmpa #C$PERD period? | |
1083 beq L07C9 branch if so | |
1084 cmpa #'0 zero? | |
1085 bcs L07A2 branch if less than | |
1086 cmpa #'9 number? | |
1087 bls L07C9 branch if lower/same | |
1088 cmpa #'_ underscore? | |
1089 beq L07C9 branch if so | |
1090 L0792 cmpa #'A A? | |
1091 bcs L07A2 branch if less than | |
1092 cmpa #'Z Z? | |
1093 bls L07C9 branch if less or equal | |
1094 cmpa #'a a? | |
1095 bcs L07A2 branch if lower | |
1096 cmpa #'z z? | |
1097 bls L07C9 branch if less or equal | |
1098 L07A2 orcc #Carry | |
1099 rts | |
1100 | |
1101 FCmpNam ldb R$B,u | |
1102 leau R$X,u | |
1103 pulu y,x | |
1104 L07AB pshs y,x,b,a | |
1105 L07AD lda ,y+ | |
1106 bmi L07BE | |
1107 decb | |
1108 beq L07BA | |
1109 eora ,x+ | |
1110 anda #$DF | |
1111 beq L07AD | |
1112 L07BA orcc #Carry | |
1113 puls pc,y,x,b,a | |
1114 L07BE decb | |
1115 bne L07BA | |
1116 eora ,x | |
1117 anda #$5F | |
1118 bne L07BA | |
1119 puls y,x,b,a | |
1120 L07C9 andcc #^Carry | |
1121 rts | |
1122 | |
1123 FSSvc ldy R$Y,u | |
1124 bra InstSSvc | |
1125 SSvcLoop tfr b,a put syscall code in A | |
1126 anda #$7F kill hi bit | |
1127 cmpa #$7F is code $7F? | |
1128 beq SSvcOK | |
1129 cmpa #$37 | |
1130 bcs SSvcOK branch if A less than $37 | |
1131 comb | |
1132 ldb #E$ISWI | |
1133 rts | |
1134 SSvcOK lslb | |
1135 ldu <D.SysDis | |
1136 leau b,u U points to entry in table | |
1137 ldd ,y++ get addr of func | |
1138 leax d,y get absolute addr | |
1139 stx ,u store in system table | |
1140 bcs InstSSvc branch if system only | |
1141 stx <$70,u else store in user table too | |
1142 InstSSvc ldb ,y+ get system call code in B | |
1143 cmpb #$80 end of table? | |
1144 bne SSvcLoop branch if not | |
1145 rts | |
1146 | |
1147 emod | |
1148 eom equ * | |
1149 | |
165 | 1150 fdb Clock |
247 | 1151 Vectors fdb SWI3 SWI3 |
1152 fdb SWI2 SWI2 | |
1153 fdb DUMMY FIRQ | |
1154 fdb SVCIRQ IRQ | |
1155 fdb SWI SWI | |
1156 fdb DUMMY NMI | |
0 | 1157 |
1158 end | |
1159 |