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