Mercurial > hg > Members > kono > nitros9-code
annotate level1/modules/kernel/krn.asm @ 2006:31ca1a8e9a3a
Added comments
author | boisy |
---|---|
date | Fri, 03 Mar 2006 19:01:54 +0000 |
parents | e0208af7e616 |
children | 775551ca320f |
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 | |
2006 | 394 |
395 *FAProc ldx R$X,u Get ptr to process to activate | |
396 *L0D11 clrb | |
397 * pshs cc,b,x,y,u | |
398 * lda P$Prior,x Get process priority | |
399 * sta P$Age,x Save it as age (How long it's been around) | |
400 * orcc #IntMasks Shut down IRQ's | |
401 * ldu #(D.AProcQ-P$Queue) Get ptr to active process queue | |
402 * bra L0D29 Go through the chain | |
403 ** Update active process queue | |
404 ** X=Process to activate | |
405 ** U=Current process in queue links | |
406 *L0D1F inc P$Age,u update current process age | |
407 * bne L0D25 wrap? | |
408 * dec P$Age,u yes, reset it to max. | |
409 *L0D25 cmpa P$Age,u match process ages?? | |
410 * bhi L0D2B no, skip update | |
411 *L0D29 leay ,u point Y to current process | |
412 *L0D2B ldu P$Queue,u get pointer to next process in chain | |
413 * bne L0D1F Still more in chain, keep going | |
414 * ldd P$Queue,y | |
415 * stx P$Queue,y save new process to chain | |
416 * std P$Queue,x | |
417 * puls cc,b,x,y,u,pc | |
418 | |
419 | |
420 ************************************************** | |
421 * System Call: F$AProc | |
422 * | |
423 * Function: Insert process into active process queue | |
424 * | |
425 * Input: X = Address of process descriptor | |
426 * | |
427 * Output: None (U and Y are preserved) | |
428 * | |
429 * Error: CC = C bit set; B = error code | |
430 * | |
431 * "An Ode to Dr. Lee" | |
432 * (1:27PM, Feb 23, 2006) | |
433 * | |
434 * Sitting in CMPS 455, I listen to Dr. Lee, | |
435 * His teaching style is as awful as any can be. | |
436 * Operating System Principles I have seen many times before, | |
437 * And as a result, this class is a major bore. | |
438 * As he talks about file systems, I work on NitrOS-9, | |
439 * even though I pay no attention, I do not fall behind. | |
440 * | |
441 * - Anonymous Student who returned | |
442 * to university to complete his | |
443 * computer science degree while working | |
444 * on The NitrOS-9 Project. | |
445 * | |
446 FAProc ldx R$X,u get ptr to process to activate | |
447 L021A pshs u,y save U/Y on stack | |
448 ldu #(D.AProcQ-P$Queue) | |
1453 | 449 bra L0228 |
2006 | 450 L0221 ldb P$Age,u get process age |
451 incb update it | |
452 beq L0228 branch if wrap | |
453 stb P$Age,u save it back to proc desc | |
454 L0228 ldu P$Queue,u get pointer to queue this process queue | |
455 bne L0221 branch if process is in active queue | |
456 ldu #(D.AProcQ-P$Queue) | |
457 lda P$Prior,x get process priority | |
458 sta P$Age,x save it as age (How long its been around) | |
459 orcc #IntMasks mask interrupts | |
460 L0235 leay ,u point Y to current process | |
461 ldu P$Queue,u get pointer to queue | |
1453 | 462 beq L023F |
2006 | 463 cmpa P$Age,u match process ages? |
464 bls L0235 no, skip update | |
1453 | 465 L023F stu P$Queue,x |
466 stx P$Queue,y | |
467 clrb | |
2006 | 468 puls pc,u,y restore U/Y and return |
469 | |
1453 | 470 |
471 UsrSvc leay <L024E,pcr | |
472 orcc #IntMasks | |
473 lbra URtoSs | |
474 | |
475 L024E andcc #^IntMasks | |
476 ldy <D.UsrDis | |
477 bsr L0278 | |
478 L0255 ldx <D.Proc get current proc desc | |
479 beq FNProc branch to FNProc if none | |
480 orcc #IntMasks | |
481 ldb P$State,x | |
482 andb #^SysState | |
483 stb P$State,x | |
484 bitb #TimOut | |
485 beq L02D1 | |
486 andb #^TimOut | |
487 stb P$State,x | |
488 bsr L021A | |
489 bra FNProc | |
490 | |
491 * system call entry | |
492 SysSvc clra | |
493 tfr a,dp set direct page to 0 | |
494 leau ,s | |
495 ldy <D.SysDis | |
496 bsr L0278 | |
497 rti | |
498 | |
499 L0278 pshs u | |
500 ldx R$PC,u point X to PC | |
501 ldb ,x+ get func code at X | |
502 stx R$PC,u restore updated PC | |
503 lslb multiply by 2 | |
504 bcc L0288 branch if user call | |
505 rorb | |
506 ldx -2,y | |
507 bra L0290 | |
508 L0288 cmpb #$6E | |
509 bcc L02A7 | |
510 ldx b,y X = addr of system call | |
511 beq L02A7 | |
512 L0290 jsr ,x jsr into system call | |
513 L0292 puls u | |
514 tfr cc,a | |
515 bcc FixCC branch if no error | |
516 stb R$B,u store error code | |
517 FixCC ldb R$CC,u get caller's CC | |
518 andb #^(Negative+Zero+TwosOvfl+Carry) | |
519 stb R$CC,u | |
520 anda #Negative+Zero+TwosOvfl+Carry | |
521 ora R$CC,u | |
522 sta R$CC,u | |
523 rts | |
524 L02A7 comb | |
525 ldb #E$UnkSvc | |
526 bra L0292 | |
527 | |
528 * no signal handler, exit with signal value as exit code | |
529 L02AC ldb P$State,x | |
530 orb #SysState | |
531 stb P$State,x | |
532 ldb <P$Signal,x | |
533 andcc #^(IntMasks) | |
534 os9 F$Exit | |
535 | |
536 FNProc clra | |
537 clrb | |
538 std <D.Proc | |
539 bra L02C2 | |
540 * execution goes here when there are no active processes | |
541 L02C0 cwai #^(IntMasks) | |
542 L02C2 orcc #IntMasks | |
543 ldx <D.AProcQ get next active process | |
544 beq L02C0 CWAI if none | |
545 ldd P$Queue,x get queue ptr | |
546 std <D.AProcQ store in Active Q | |
547 stx <D.Proc store in current process | |
548 lds P$SP,x get process' stack ptr | |
549 L02D1 ldb P$State,x get state | |
550 bmi L0308 branch if system state | |
551 bitb #Condem process condemned? | |
552 bne L02AC branch if so... | |
553 ldb <P$Signal,x get signal no | |
554 beq L02FF branch if none | |
555 decb decrement | |
556 beq L02FC branch if wake up | |
557 ldu <P$SigVec,x get signal handler addr | |
558 beq L02AC branch if none | |
559 ldy <P$SigDat,x get data addr | |
560 ldd $06,s | |
561 pshs u,y,b,a | |
562 ldu $0A,s | |
563 lda <P$Signal,x | |
564 ldb $09,s | |
565 tfr d,y | |
566 ldd $06,s | |
567 pshs u,y,b,a | |
568 clrb | |
569 L02FC stb <P$Signal,x | |
570 L02FF ldd <P$SWI2,x | |
571 std <D.SWI2 | |
572 ldd <D.UsrIRQ | |
573 std <D.SvcIRQ | |
574 L0308 rti | |
575 | |
576 FLink pshs u save caller regs | |
577 ldd R$A,u | |
578 ldx R$X,u | |
579 lbsr L0443 | |
580 bcc FLinkOK | |
581 ldb #E$MNF | |
582 bra L033D | |
583 * U = module dir entry | |
584 FLinkOK ldy ,u get module ptr | |
585 ldb M$Revs,y | |
586 bitb #ReEnt reentrant? | |
587 bne L032A branch if so | |
588 tst $02,u link count zero? | |
589 beq L032A yep, ok to link to nonreent | |
590 comb else module is busy | |
591 ldb #E$ModBsy | |
592 bra L033D | |
593 L032A inc $02,u increment link count | |
594 ldu ,s get caller regs from stack | |
595 stx R$X,u | |
596 sty R$U,u | |
597 ldd M$Type,y | |
598 std R$D,u | |
599 ldd M$IDSize,y | |
600 leax d,y | |
601 stx R$Y,u | |
602 L033D puls pc,u | |
603 | |
604 FVModul pshs u | |
605 ldx R$X,u | |
606 bsr ValMod | |
607 puls y | |
608 stu R$U,y | |
609 rts | |
610 * X = address of module to validate | |
611 ValMod bsr ChkMHCRC | |
612 bcs L039A | |
613 lda M$Type,x | |
614 pshs x,a | |
615 ldd M$Name,x | |
616 leax d,x X = addr of name in mod | |
617 puls a | |
618 lbsr L0443 | |
619 puls x | |
620 bcs L039B | |
621 ldb #E$KwnMod | |
622 cmpx ,u | |
623 beq L03A1 | |
624 lda M$Revs,x | |
625 anda #RevsMask | |
626 pshs a | |
627 ldy ,u | |
628 lda M$Revs,y | |
629 anda #RevsMask | |
630 cmpa ,s+ same revision as other mod? | |
631 bcc L03A1 | |
632 pshs y,x | |
633 ldb M$Size,u | |
634 bne L0395 | |
635 ldx ,u | |
636 cmpx <D.BTLO | |
637 bcc L0395 | |
638 ldd $02,x | |
639 addd #$00FF | |
640 tfr a,b | |
641 clra | |
642 tfr d,y | |
643 ldb ,u | |
644 ldx <D.FMBM | |
645 os9 F$DelBit | |
646 clr $02,u | |
647 L0395 puls y,x | |
648 L0397 stx ,u | |
649 clrb | |
650 L039A rts | |
651 L039B leay ,u | |
652 bne L0397 | |
653 ldb #E$DirFul | |
654 L03A1 coma | |
655 rts | |
656 | |
657 * check module header and CRC | |
658 * X = address of potential module | |
659 ChkMHCRC ldd ,x | |
660 cmpd #M$ID12 sync bytes? | |
661 bne L03B1 nope, not a module here | |
662 leay M$Parity,x | |
663 bsr ChkMHPar check header parity | |
664 bcc L03B5 branch if ok | |
665 L03B1 comb | |
666 ldb #E$BMID | |
667 rts | |
668 | |
669 L03B5 | |
670 * Following 4 lines added to support no CRC checks - 2002/07/21 | |
671 lda <D.CRC is CRC checking on? | |
672 bne DoCRCCk branch if so | |
673 clrb | |
674 rts | |
675 | |
676 DoCRCCk pshs x | |
677 ldy M$Size,x | |
678 bsr ChkMCRC checkm module CRC | |
679 puls pc,x | |
680 * check module header parity | |
681 * Y = pointer to parity byte | |
682 ChkMHPar pshs y,x | |
683 clra | |
684 ChkM010 eora ,x+ | |
685 cmpx 2,s compare to addr of M$Parity | |
686 bls ChkM010 | |
687 cmpa #$FF | |
688 puls pc,y,x | |
689 * X = address of potential module | |
690 * Y = size of module | |
691 ChkMCRC ldd #$FFFF | |
692 pshs b,a | |
693 pshs b,a | |
694 leau 1,s | |
695 L03D4 lda ,x+ | |
696 bsr CRCAlgo | |
697 leay -1,y dec Y (size of module) | |
698 bne L03D4 continue | |
699 clr -1,u | |
700 lda ,u | |
701 cmpa #CRCCon1 | |
702 bne L03EC | |
703 ldd 1,u | |
704 cmpd #CRCCon23 | |
705 beq L03EF | |
706 L03EC comb | |
707 ldb #E$BMCRC | |
708 L03EF puls pc,y,x | |
709 | |
710 * F$CRC | |
711 FCRC ldx R$X,u | |
712 ldy R$Y,u | |
713 beq L0402 | |
714 ldu R$U,u | |
715 L03FA lda ,x+ | |
716 bsr CRCAlgo | |
717 leay -1,y | |
718 bne L03FA | |
719 L0402 clrb | |
720 rts | |
721 | |
722 CRCAlgo eora ,u | |
723 pshs a | |
724 ldd $01,u | |
725 std ,u | |
726 clra | |
727 ldb ,s | |
728 lslb | |
729 rola | |
730 eora 1,u | |
731 std 1,u | |
732 clrb | |
733 lda ,s | |
734 lsra | |
735 rorb | |
736 lsra | |
737 rorb | |
738 eora 1,u | |
739 eorb 2,u | |
740 std 1,u | |
741 lda ,s | |
742 lsla | |
743 eora ,s | |
744 sta ,s | |
745 lsla | |
746 lsla | |
747 eora ,s | |
748 sta ,s | |
749 lsla | |
750 lsla | |
751 lsla | |
752 lsla | |
753 eora ,s+ | |
754 bpl L0442 | |
755 ldd #$8021 | |
756 eora ,u | |
757 sta ,u | |
758 eorb 2,u | |
759 stb 2,u | |
760 L0442 rts | |
761 | |
762 L0443 ldu #$0000 | |
763 tfr a,b | |
764 anda #TypeMask | |
765 andb #LangMask | |
766 pshs u,y,x,b,a | |
767 bsr EatSpace | |
768 cmpa #PDELIM pathlist char? | |
769 beq L049C branch if so | |
770 lbsr ParseNam parse name | |
771 bcs L049D return if error | |
772 ldu <D.ModDir | |
773 L045B pshs u,y,b | |
774 ldu ,u | |
775 beq L048B | |
776 ldd $04,u | |
777 leay d,u | |
778 ldb ,s | |
779 lbsr L07AB | |
780 bcs L0493 | |
781 lda $05,s | |
782 beq L0476 | |
783 eora $06,u | |
784 anda #$F0 | |
785 bne L0493 | |
786 L0476 lda $06,s | |
787 beq L0480 | |
788 eora $06,u | |
789 anda #$0F | |
790 bne L0493 | |
791 L0480 puls u,x,b | |
792 stu $06,s | |
793 bsr EatSpace | |
794 stx $02,s | |
795 clra | |
796 bra L049D | |
797 L048B ldd $0B,s | |
798 bne L0493 | |
799 ldd $03,s | |
800 std $0B,s | |
801 L0493 puls u,y,b | |
802 leau $04,u | |
803 cmpu <D.ModDir+2 | |
804 bcs L045B | |
805 L049C comb | |
806 L049D puls pc,u,y,x,b,a | |
807 | |
808 EatSpace lda #C$SPAC | |
809 EatSpc10 cmpa ,x+ | |
810 beq EatSpc10 | |
811 lda ,-x | |
812 rts | |
813 | |
814 FFork ldx <D.PrcDBT | |
815 os9 F$All64 | |
816 bcs L0517 | |
817 ldx <D.Proc | |
818 pshs x save calling proc desc on stack | |
819 ldd P$User,x | |
820 std P$User,y | |
821 lda P$Prior,x | |
822 clrb | |
823 std P$Prior,y | |
824 ldb #SysState | |
825 stb P$State,y | |
826 sty <D.Proc | |
827 ldd <P$NIO,x | |
828 std <P$NIO,y | |
829 ldd <P$NIO+2,x | |
830 std <P$NIO+2,y | |
831 leax <P$DIO,x | |
832 leay <P$DIO,y | |
833 ldb #DefIOSiz | |
834 * copy I/O stuff from parent to child | |
835 L04D7 lda ,x+ | |
836 sta ,y+ | |
837 decb | |
838 bne L04D7 | |
839 * X/Y = address of path table in respective proc desc | |
840 * Dup stdin/stdout/stderr | |
841 ldb #$03 | |
842 L04E0 lda ,x+ | |
843 os9 I$Dup | |
844 bcc L04E8 | |
845 clra | |
846 L04E8 sta ,y+ | |
847 decb | |
848 bne L04E0 | |
849 bsr L0553 | |
850 bcs L050C | |
851 puls y get parent proc desc | |
852 sty <D.Proc | |
853 lda P$ID,x get ID of new process | |
854 sta R$A,u store in caller's A | |
855 ldb P$CID,y get child id of parent | |
856 sta P$CID,y store new proc in parent's CID | |
857 lda P$ID,y get ID of parent | |
858 std P$PID,x store in child proc desc | |
859 ldb P$State,x update state of child | |
860 andb #^SysState | |
861 stb P$State,x | |
862 os9 F$AProc insert child in active Q | |
863 rts | |
864 L050C pshs b | |
865 os9 F$Exit | |
866 comb | |
867 puls x,b | |
868 stx <D.Proc | |
869 rts | |
870 L0517 comb | |
871 ldb #E$PrcFul | |
872 rts | |
873 | |
874 FChain bsr L0543 | |
875 bcs L0531 | |
876 orcc #IntMasks | |
877 ldb $0D,x | |
878 andb #$7F | |
879 stb $0D,x | |
880 L0527 os9 F$AProc | |
881 os9 F$NProc | |
882 | |
883 SFChain bsr L0543 | |
884 bcc L0527 | |
885 L0531 pshs b | |
886 stb <P$Signal,x | |
887 ldb P$State,x | |
888 orb #Condem | |
889 stb P$State,x | |
890 ldb #$FF | |
891 stb P$Prior,x | |
892 comb | |
893 puls pc,b | |
894 L0543 pshs u | |
895 ldx <D.Proc | |
896 ldu <P$PModul,x | |
897 os9 F$UnLink | |
898 ldu ,s | |
899 bsr L0553 | |
900 puls pc,u | |
901 L0553 ldx <D.Proc | |
902 pshs u,x | |
903 ldd <D.UsrSvc | |
904 std <P$SWI,x | |
905 std <P$SWI2,x | |
906 std <P$SWI3,x | |
907 clra | |
908 clrb | |
909 sta <P$Signal,x | |
910 std <P$SigVec,x | |
911 lda R$A,u | |
912 ldx R$X,u | |
913 os9 F$Link | |
914 bcc L0578 | |
915 os9 F$Load | |
916 bcs L05E7 | |
917 L0578 ldy <D.Proc | |
918 stu <P$PModul,y | |
919 cmpa #Prgrm+Objct | |
920 beq L058B | |
921 cmpa #Systm+Objct | |
922 beq L058B | |
923 comb | |
924 ldb #E$NEMod | |
925 bra L05E7 | |
926 L058B leay ,u Y = addr of module | |
927 ldu 2,s get U off stack (caller regs) | |
928 stx R$X,u | |
929 lda R$B,u | |
930 clrb | |
931 cmpd M$Mem,y compare passed mem to module's | |
932 bcc L059B branch if less than | |
933 ldd M$Mem,y | |
934 L059B addd #$0000 | |
935 bne L05A0 | |
936 L05A0 os9 F$Mem | |
937 bcs L05E7 | |
938 subd #R$Size subtract registers | |
939 subd R$Y,u subtract parameter area | |
940 bcs L05E5 | |
941 ldx R$U,u get parameter area | |
942 ldd R$Y,u get parameter size | |
943 pshs b,a | |
944 beq L05BE | |
945 leax d,x point to end of param area | |
946 L05B6 lda ,-x get byte, dec X | |
947 sta ,-y save byte in data area, dec X | |
948 cmpx R$U,u at top of param area? | |
949 bhi L05B6 | |
950 * set up registers for return of F$Fork/F$Chain | |
951 L05BE ldx <D.Proc | |
952 sty -$08,y put in X on caller stack | |
953 leay -R$Size,y back up register size | |
954 sty P$SP,x | |
955 lda P$ADDR,x | |
956 clrb | |
957 std R$U,y lowest address | |
958 sta R$DP,y set direct page | |
959 adda P$PagCnt,x | |
960 std R$Y,y | |
961 puls b,a | |
962 std R$D,y size of param area | |
963 ldb #Entire | |
964 stb R$CC,y | |
965 ldu <P$PModul,x get addr of prim. mod | |
966 ldd M$Exec,u | |
967 leau d,u | |
968 stu R$PC,y put in PC on caller reg | |
969 clrb | |
970 L05E5 ldb #E$IForkP | |
971 L05E7 puls pc,u,x | |
972 | |
973 FSRqMem ldd R$D,u | |
974 addd #$00FF | |
975 clrb | |
976 std R$D,u | |
977 ldx <D.FMBM+2 | |
978 ldd #$01FF | |
979 pshs b,a | |
980 bra L0604 | |
981 L05FA dec $01,s | |
982 ldb $01,s | |
983 L05FE lsl ,s | |
984 bcc L060A | |
985 rol ,s | |
986 L0604 leax -1,x | |
987 cmpx <D.FMBM | |
988 bcs L0620 | |
989 L060A lda ,x | |
990 anda ,s | |
991 bne L05FA | |
992 dec 1,s | |
993 subb 1,s | |
994 cmpb 1,u | |
995 rora | |
996 addb 1,s | |
997 rola | |
998 bcs L05FE | |
999 ldb 1,s | |
1000 clra | |
1001 incb | |
1002 L0620 leas 2,s | |
1003 bcs L0635 | |
1004 ldx <D.FMBM | |
1005 tfr d,y | |
1006 ldb 1,u | |
1007 clra | |
1008 exg d,y | |
1009 bsr L065A | |
1010 exg a,b | |
1011 std 8,u | |
1012 L0633 clra | |
1013 rts | |
1014 L0635 comb | |
1015 ldb #E$MemFul | |
1016 rts | |
1017 | |
1018 FSRtMem ldd R$D,u | |
1019 addd #$00FF | |
1020 tfr a,b | |
1021 clra | |
1022 tfr d,y | |
1023 ldd R$U,u | |
1024 beq L0633 | |
1025 tstb | |
1026 beq L064E | |
1027 comb | |
1028 ldb #E$BPAddr | |
1029 rts | |
1030 L064E exg a,b | |
1031 ldx <D.FMBM | |
1032 bra L06AD | |
1033 | |
1034 FAllBit ldd R$D,u | |
1035 leau R$X,u | |
1036 pulu y,x | |
1037 L065A pshs y,x,b,a | |
1038 bsr L0690 | |
1039 tsta | |
1040 pshs a | |
1041 bmi L0671 | |
1042 lda ,x | |
1043 L0665 ora ,s | |
1044 leay -1,y | |
1045 beq L0689 | |
1046 lsr ,s | |
1047 bcc L0665 | |
1048 sta ,x+ | |
1049 L0671 tfr y,d | |
1050 sta ,s | |
1051 lda #$FF | |
1052 bra L067B | |
1053 L0679 sta ,x+ | |
1054 L067B subb #$08 | |
1055 bcc L0679 | |
1056 dec ,s | |
1057 bpl L0679 | |
1058 L0683 lsla | |
1059 incb | |
1060 bne L0683 | |
1061 ora ,x | |
1062 L0689 sta ,x | |
1063 clra | |
1064 leas 1,s | |
1065 puls pc,y,x,b,a | |
1066 L0690 pshs b | |
1067 lsra | |
1068 rorb | |
1069 lsra | |
1070 rorb | |
1071 lsra | |
1072 rorb | |
1073 leax d,x | |
1074 puls b | |
1075 lda #$80 | |
1076 andb #$07 | |
1077 beq L06A6 | |
1078 L06A2 lsra | |
1079 decb | |
1080 bne L06A2 | |
1081 L06A6 rts | |
1082 | |
1083 FDelBit ldd R$D,u | |
1084 leau R$X,u | |
1085 pulu y,x | |
1086 L06AD pshs y,x,b,a | |
1087 bsr L0690 | |
1088 coma | |
1089 pshs a | |
1090 bpl L06C4 | |
1091 lda ,x | |
1092 L06B8 anda ,s | |
1093 leay -1,y | |
1094 beq L06D8 | |
1095 asr ,s | |
1096 bcs L06B8 | |
1097 sta ,x+ | |
1098 L06C4 tfr y,d | |
1099 bra L06CA | |
1100 L06C8 clr ,x+ | |
1101 L06CA subd #$0008 | |
1102 bhi L06C8 | |
1103 beq L06D8 | |
1104 L06D1 lsla | |
1105 incb | |
1106 bne L06D1 | |
1107 coma | |
1108 anda ,x | |
1109 L06D8 sta ,x | |
1110 clr ,s+ | |
1111 puls pc,y,x,b,a | |
1112 | |
1113 FSchBit pshs u | |
1114 ldd R$D,u | |
1115 ldx R$X,u | |
1116 ldy R$Y,u | |
1117 ldu R$U,u | |
1118 bsr L06F3 | |
1119 puls u | |
1120 std R$D,u | |
1121 sty R$Y,u | |
1122 rts | |
1123 L06F3 pshs u,y,x,b,a | |
1124 pshs y,b,a | |
1125 clr 8,s | |
1126 clr 9,s | |
1127 tfr d,y | |
1128 bsr L0690 | |
1129 pshs a | |
1130 bra L0710 | |
1131 L0703 leay $01,y | |
1132 sty $05,s | |
1133 L0708 lsr ,s | |
1134 bcc L0714 | |
1135 ror ,s | |
1136 leax $01,x | |
1137 L0710 cmpx $0B,s | |
1138 bcc L0732 | |
1139 L0714 lda ,x | |
1140 anda ,s | |
1141 bne L0703 | |
1142 leay $01,y | |
1143 tfr y,d | |
1144 subd $05,s | |
1145 cmpd $03,s | |
1146 bcc L0739 | |
1147 cmpd $09,s | |
1148 bls L0708 | |
1149 std $09,s | |
1150 ldd $05,s | |
1151 std $01,s | |
1152 bra L0708 | |
1153 L0732 ldd $01,s | |
1154 std $05,s | |
1155 coma | |
1156 bra L073B | |
1157 L0739 std $09,s | |
1158 L073B leas $05,s | |
1159 puls pc,u,y,x,b,a | |
1160 | |
1161 | |
1162 use fprsnam.asm | |
1163 | |
1164 use fcmpnam.asm | |
1165 | |
1166 *FCmpNam ldb R$B,u | |
1167 * leau R$X,u | |
1168 * pulu y,x | |
1169 *L07AB pshs y,x,b,a | |
1170 *L07AD lda ,y+ | |
1171 * bmi L07BE | |
1172 * decb | |
1173 * beq L07BA | |
1174 * eora ,x+ | |
1175 * anda #$DF | |
1176 * beq L07AD | |
1177 *L07BA orcc #Carry | |
1178 * puls pc,y,x,b,a | |
1179 *L07BE decb | |
1180 * bne L07BA | |
1181 * eora ,x | |
1182 * anda #$5F | |
1183 * bne L07BA | |
1184 * puls y,x,b,a | |
1185 *L07C9 andcc #^Carry | |
1186 * rts | |
1187 | |
1188 FSSvc ldy R$Y,u | |
1189 bra InstSSvc | |
1190 SSvcLoop tfr b,a put syscall code in A | |
1191 anda #$7F kill hi bit | |
1192 cmpa #$7F is code $7F? | |
1193 beq SSvcOK | |
1194 cmpa #$37 compare against highest call allowed | |
1195 bcs SSvcOK branch if A less than highest call | |
1196 comb | |
1197 ldb #E$ISWI | |
1198 rts | |
1199 SSvcOK lslb | |
1200 ldu <D.SysDis | |
1201 leau b,u U points to entry in table | |
1202 ldd ,y++ get addr of func | |
1203 leax d,y get absolute addr | |
1204 stx ,u store in system table | |
1205 bcs InstSSvc branch if system only | |
1206 stx <$70,u else store in user table too | |
1207 InstSSvc ldb ,y+ get system call code in B | |
1208 cmpb #$80 end of table? | |
1209 bne SSvcLoop branch if not | |
1210 rts | |
1211 | |
1212 emod | |
1213 eom equ * | |
1214 | |
1215 fdb Clock | |
1216 Vectors fdb SWI3 SWI3 | |
1217 fdb SWI2 SWI2 | |
1218 fdb DUMMY FIRQ | |
1219 fdb SVCIRQ IRQ | |
1220 fdb SWI SWI | |
1221 fdb DUMMY NMI | |
1222 | |
1223 end | |
1224 |