Mercurial > hg > Members > kono > nitros9-code
annotate level1/modules/kernel/krn.asm @ 2018:505c8d261ef6
Futher division of krn, commnents added
author | boisy |
---|---|
date | Wed, 08 Mar 2006 01:58:50 +0000 |
parents | f273e28ea8d0 |
children | 9dafc4b4c6dd |
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 * |----------------------------------| | |
2012 | 18 * $0220-$0221 | IOMan I/O Call Pointer | |
19 * |----------------------------------| | |
1453 | 20 * | System Dispatch Table | |
21 * $0222-$0291 | (Room for 56 addresses) | | |
22 * |----------------------------------| | |
23 * $0292-$02FF | User Dispatch Table | | |
24 * | (Room for 56 addresses) | | |
25 * $0300---->|==================================| | |
26 * | | | |
27 * | | | |
28 * $0300-$03FF | Module Directory Entries | | |
29 * | (Room for 64 entries) | | |
30 * | | | |
31 * $0400---->|==================================| | |
32 * | | | |
33 * $0400-$04FF | System Stack | | |
34 * | | | |
35 * $0500---->|==================================| | |
36 * | |
37 * Edt/Rev YYYY/MM/DD Modified by | |
38 * Comment | |
39 * ------------------------------------------------------------------ | |
40 * 14 1985/??/?? | |
41 * From Tandy OS-9 Level One VR 02.00.00 | |
42 * | |
43 * 15 2002/07/21 Boisy G. Pitre | |
44 * Module validation consists only of module header parity check. | |
45 * CRC check is not done unless D.CRC is set to 1, which is NOT the | |
46 * default case. By default, D.CRC is set to 0, thus there is no | |
47 * CRC checking. Speeds up module loads quite a bit. The Init module | |
48 * has a bit in a compatibility byte that can turn on/off CRC checking | |
49 * | |
50 * 15r1 2003/12/09 Boisy G. Pitre | |
1460 | 51 * Kernel no longer scans for modules in I/O space. Also, F$PrsNam now |
52 * 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
|
53 * |
5f18094d961d
kernel modules renamed to krn, updated makefiles, clock2_tc3 now clock2_cloud9...
boisy
parents:
1460
diff
changeset
|
54 * 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
|
55 * Renamed to 'krn' |
1453 | 56 |
1587
5f18094d961d
kernel modules renamed to krn, updated makefiles, clock2_tc3 now clock2_cloud9...
boisy
parents:
1460
diff
changeset
|
57 nam krn |
1453 | 58 ttl NitrOS-9 Level 1 Kernel |
59 | |
60 ifp1 | |
61 use defsfile | |
62 use scfdefs | |
63 endc | |
64 | |
65 tylg set Systm+Objct | |
66 atrv set ReEnt+rev | |
67 rev set $01 | |
68 edition set 15 | |
69 | |
2012 | 70 ModTop mod eom,name,tylg,atrv,OS9Cold,size |
1453 | 71 |
72 size equ . | |
73 | |
1663 | 74 name fcs /Krn/ |
1453 | 75 fcb edition |
76 | |
77 InitNam fcs /Init/ | |
78 | |
1622 | 79 P2Nam fcs /krnp2/ |
1453 | 80 |
81 VectCode bra SWI3Jmp $0100 | |
82 nop | |
83 bra SWI2Jmp $0103 | |
84 nop | |
85 bra SWIJmp $0106 | |
86 nop | |
87 bra NMIJmp $0109 | |
88 nop | |
89 bra IRQJmp $010C | |
90 nop | |
91 bra FIRQJmp $010F | |
92 | |
93 SWI3Jmp jmp [>D.SWI3] | |
94 SWI2Jmp jmp [>D.SWI2] | |
95 SWIJmp jmp [>D.SWI] | |
96 NMIJmp jmp [>D.NMI] | |
97 IRQJmp jmp [>D.IRQ] | |
98 FIRQJmp jmp [>D.FIRQ] | |
99 VectCSz equ *-VectCode | |
100 | |
101 | |
102 SysTbl fcb F$Link | |
103 fdb FLink-*-2 | |
104 fcb F$Fork | |
105 fdb FFork-*-2 | |
106 fcb F$Chain | |
107 fdb FChain-*-2 | |
108 fcb F$Chain+$80 | |
109 fdb SFChain-*-2 | |
110 fcb F$PrsNam | |
111 fdb FPrsNam-*-2 | |
112 fcb F$CmpNam | |
113 fdb FCmpNam-*-2 | |
114 fcb F$SchBit | |
115 fdb FSchBit-*-2 | |
116 fcb F$AllBit | |
117 fdb FAllBit-*-2 | |
118 fcb F$DelBit | |
119 fdb FDelBit-*-2 | |
120 fcb F$CRC | |
121 fdb FCRC-*-2 | |
122 fcb F$SRqMem+$80 | |
123 fdb FSRqMem-*-2 | |
124 fcb F$SRtMem+$80 | |
125 fdb FSRtMem-*-2 | |
126 fcb F$AProc+$80 | |
127 fdb FAProc-*-2 | |
128 fcb F$NProc+$80 | |
129 fdb FNProc-*-2 | |
130 fcb F$VModul+$80 | |
131 fdb FVModul-*-2 | |
132 fcb F$SSvc | |
133 fdb FSSvc-*-2 | |
134 fcb $80 | |
135 | |
1460 | 136 IFNE H6309 |
137 Zoro fcb $00 | |
138 ENDC | |
139 | |
1453 | 140 * |
141 * OS-9 Genesis! | |
1460 | 142 |
1453 | 143 OS9Cold equ * |
144 * clear out system globals from $0020-$0400 | |
145 ldx #D.FMBM | |
1460 | 146 IFNE H6309 |
147 ldw #$400-D.FMBM | |
148 leay Zoro,pc | |
149 tfm y,x+ | |
150 ELSE | |
1453 | 151 ldy #$400-D.FMBM |
152 clra | |
153 clrb | |
154 L007F std ,x++ | |
155 leay -2,y | |
156 bne L007F | |
1460 | 157 ENDC |
158 | |
1453 | 159 * set up system globals |
1460 | 160 IFNE H6309 |
161 ldd #$200 | |
162 ELSE | |
1453 | 163 inca |
164 inca D = $200 | |
1460 | 165 ENDC |
1453 | 166 std <D.FMBM $200 = start of free memory bitmap |
167 addb #$20 | |
168 std <D.FMBM+2 $220 = end of free memory bitmap | |
169 addb #$02 | |
170 std <D.SysDis $222 = addr of sys dispatch tbl | |
171 addb #$70 | |
172 std <D.UsrDis $292 = addr of usr dispatch tbl | |
173 clrb | |
174 inca D = $300 | |
175 std <D.ModDir $300 = mod dir start | |
176 stx <D.ModDir+2 X = $400 = mod dir end | |
177 leas >$0100,x S = $500 (system stack?) | |
178 | |
179 * Check for valid RAM starting at $400 | |
180 ChkRAM leay ,x | |
181 ldd ,y store org contents in D | |
182 ldx #$00FF | |
183 stx ,y write pattern to ,Y | |
184 cmpx ,y same as what we wrote? | |
185 bne L00C2 nope, not RAM here! | |
186 ldx #$FF00 try different pattern | |
187 stx ,y write it to ,Y | |
188 cmpx ,y same as what we wrote? | |
189 bne L00C2 nope, not RAM here! | |
190 std ,y else restore org contents | |
191 leax >$0100,y check top of next 256 block | |
192 cmpx #Bt.Start stop short of boot track mem | |
193 bcs ChkRAM | |
194 leay ,x | |
195 * Here, Y = end of RAM | |
196 L00C2 leax ,y X = end of RAM | |
197 stx <D.MLIM save off memory limit | |
198 | |
199 * Copy vector code over to address $100 | |
200 pshs y,x | |
1460 | 201 IFNE H6309 |
202 leax >VectCode,pcr | |
203 ldy #D.XSWI3 | |
204 ldw #VectCSz | |
205 tfm x+,y+ | |
206 ELSE | |
1453 | 207 leax >VectCode,pcr |
208 ldy #D.XSWI3 | |
209 ldb #VectCSz | |
210 L00D2 lda ,x+ | |
211 sta ,y+ | |
212 decb | |
213 bne L00D2 | |
1460 | 214 ENDC |
1453 | 215 puls y,x |
1460 | 216 |
217 * Validate modules at top of RAM (kernel, etc.) | |
1453 | 218 L00DB lbsr ValMod |
219 bcs L00E6 | |
220 ldd M$Size,x | |
221 leax d,x go past module | |
222 bra L00EC | |
223 L00E6 cmpb #E$KwnMod | |
224 beq L00EE | |
225 leax 1,x | |
1460 | 226 * Modification to stop scan into I/O space -- Added by BGP |
1453 | 227 L00EC cmpx #Bt.Start+Bt.Size |
228 bcs L00DB | |
1460 | 229 * Copy vectors to system globals |
1453 | 230 L00EE leay >Vectors,pcr |
2012 | 231 leax >ModTop,pcr |
1453 | 232 pshs x |
233 ldx #D.SWI3 | |
234 L00FB ldd ,y++ | |
235 addd ,s | |
236 std ,x++ | |
2012 | 237 cmpx #D.NMI |
1453 | 238 bls L00FB |
239 leas 2,s restore stack | |
240 | |
241 * fill in more system globals | |
242 leax >URtoSs,pcr | |
243 stx <D.URtoSs | |
244 leax >UsrIRQ,pcr | |
245 stx <D.UsrIRQ | |
246 leax >UsrSvc,pcr | |
247 stx <D.UsrSvc | |
248 leax >SysIRQ,pcr | |
249 stx <D.SysIRQ | |
250 stx <D.SvcIRQ | |
251 leax >SysSvc,pcr | |
252 stx <D.SysSvc | |
253 stx <D.SWI2 | |
254 leax >Poll,pcr | |
255 stx <D.Poll | |
256 leax >Clock,pcr | |
257 stx <D.Clock | |
258 stx <D.AltIRQ | |
259 | |
260 * install system calls | |
261 leay >SysTbl,pcr | |
262 lbsr InstSSvc | |
263 | |
264 * link to init module | |
265 lda #Systm+0 | |
266 leax >InitNam,pcr | |
267 os9 F$Link | |
268 lbcs OS9Cold | |
269 stu <D.Init | |
270 lda Feature1,u get feature byte 1 | |
271 bita #CRCOn CRC on? | |
272 beq GetMem branch if not (already cleared earlier) | |
273 inc <D.CRC else turn on CRC checking | |
274 GetMem ldd MaxMem+1,u | |
275 clrb | |
276 cmpd <D.MLIM | |
277 bcc L0158 | |
278 std <D.MLIM | |
279 L0158 ldx <D.FMBM | |
280 ldb #$F8 | |
281 stb ,x | |
282 clra | |
283 ldb <D.MLIM | |
284 negb | |
285 tfr d,y | |
286 negb | |
287 lbsr L065A | |
288 | |
2012 | 289 * jump into krnp2 here |
1453 | 290 leax >P2Nam,pcr |
291 lda #Systm+Objct | |
292 os9 F$Link | |
293 lbcs OS9Cold | |
294 jmp ,y | |
2012 | 295 |
1453 | 296 SWI3 pshs pc,x,b |
297 ldb #P$SWI3 | |
298 bra L018C | |
299 SWI2 pshs pc,x,b | |
300 ldb #P$SWI2 | |
301 bra L018C | |
302 DUMMY rti | |
303 SVCIRQ jmp [>D.SvcIRQ] | |
304 SWI pshs pc,x,b | |
305 ldb #P$SWI | |
306 L018C ldx >D.Proc | |
307 ldx b,x get SWI entry | |
308 stx 3,s put in PC on stack | |
309 puls pc,x,b | |
310 | |
311 UsrIRQ leay <L01B1,pcr | |
312 * transition from user to system state | |
313 URtoSs clra | |
314 tfr a,dp clear direct page | |
2012 | 315 ldx <D.Proc get current process desc |
316 ldd <D.SysSvc get system state system call vector | |
317 std <D.SWI2 store in D.SWI2 | |
318 ldd <D.SysIRQ get system IRQ vector | |
319 std <D.SvcIRQ store in D.SvcIRQ | |
320 leau ,s point U to S | |
321 stu P$SP,x and save in process P$SP | |
322 lda P$State,x get state field in proc desc | |
323 ora #SysState mark process to be in system state | |
324 sta P$State,x store it | |
325 jmp ,y jump to ,y | |
1453 | 326 |
327 L01B1 jsr [>D.Poll] | |
328 bcc L01BD | |
329 ldb ,s | |
330 orb #$10 | |
331 stb ,s | |
332 L01BD lbra L0255 | |
333 | |
334 SysIRQ clra | |
335 tfr a,dp | |
336 jsr [>D.Poll] | |
337 bcc L01CF | |
338 ldb ,s | |
339 orb #$10 | |
340 stb ,s | |
341 L01CF rti | |
342 Poll comb | |
343 rts | |
344 | |
2017
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
345 * Default clock routine - executed 60 times/sec |
1453 | 346 Clock ldx <D.SProcQ |
347 beq L01FD | |
348 lda P$State,x | |
349 bita #TimSleep | |
350 beq L01FD | |
351 ldu P$SP,x | |
352 ldd P$SP,u | |
353 subd #$0001 | |
354 std P$SP,u | |
355 bne L01FD | |
356 L01E7 ldu P$Queue,x | |
357 bsr L021A | |
358 leax ,u | |
359 beq L01FB | |
360 lda P$State,x | |
361 bita #TimSleep | |
362 beq L01FB | |
363 ldu P$SP,x | |
364 ldd P$SP,u | |
365 beq L01E7 | |
366 L01FB stx <D.SProcQ | |
2017
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
367 L01FD dec <D.Slice decrement slice |
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
368 bne ClockRTI if not 0, exit ISR |
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
369 lda <D.TSlice else get default time slice |
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
370 sta <D.Slice and save it as slice |
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
371 ldx <D.Proc get proc desc of current proc |
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
372 beq ClockRTI if none, exit ISR |
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
373 lda P$State,x get process state |
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
374 ora #TimOut set timeout bit |
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
375 sta P$State,x and store back |
1453 | 376 bpl L0212 branch if not system state |
377 ClockRTI rti | |
378 | |
379 L0212 leay >L0255,pcr | |
380 bra URtoSs | |
381 | |
2006 | 382 |
383 *FAProc ldx R$X,u Get ptr to process to activate | |
384 *L0D11 clrb | |
385 * pshs cc,b,x,y,u | |
386 * lda P$Prior,x Get process priority | |
387 * sta P$Age,x Save it as age (How long it's been around) | |
388 * orcc #IntMasks Shut down IRQ's | |
389 * ldu #(D.AProcQ-P$Queue) Get ptr to active process queue | |
390 * bra L0D29 Go through the chain | |
391 ** Update active process queue | |
392 ** X=Process to activate | |
393 ** U=Current process in queue links | |
394 *L0D1F inc P$Age,u update current process age | |
395 * bne L0D25 wrap? | |
396 * dec P$Age,u yes, reset it to max. | |
397 *L0D25 cmpa P$Age,u match process ages?? | |
398 * bhi L0D2B no, skip update | |
399 *L0D29 leay ,u point Y to current process | |
400 *L0D2B ldu P$Queue,u get pointer to next process in chain | |
401 * bne L0D1F Still more in chain, keep going | |
402 * ldd P$Queue,y | |
403 * stx P$Queue,y save new process to chain | |
404 * std P$Queue,x | |
405 * puls cc,b,x,y,u,pc | |
406 | |
407 | |
2018 | 408 use faproc.asm |
409 | |
2012 | 410 * User-State system call entry point |
1453 | 411 UsrSvc leay <L024E,pcr |
412 orcc #IntMasks | |
413 lbra URtoSs | |
414 | |
415 L024E andcc #^IntMasks | |
416 ldy <D.UsrDis | |
2012 | 417 bsr DoSysCall |
1453 | 418 L0255 ldx <D.Proc get current proc desc |
419 beq FNProc branch to FNProc if none | |
2012 | 420 orcc #IntMasks mask interrupts |
421 ldb P$State,x get state value in proc desc | |
422 andb #^SysState turn off system state flag | |
423 stb P$State,x save state value | |
424 bitb #TimOut timeout bit set? | |
425 beq L02D1 branch if not | |
426 andb #^TimOut else turn off bit | |
427 stb P$State,x in state value | |
1453 | 428 bsr L021A |
429 bra FNProc | |
430 | |
2012 | 431 * System-State system call entry point |
1453 | 432 SysSvc clra |
433 tfr a,dp set direct page to 0 | |
2012 | 434 leau ,s point U to SP |
435 ldy <D.SysDis get system state dispatch table ptr | |
436 bsr DoSysCall | |
1453 | 437 rti |
438 | |
2012 | 439 * Entry: Y = Dispatch table (user or system) |
440 DoSysCall | |
441 pshs u | |
1453 | 442 ldx R$PC,u point X to PC |
443 ldb ,x+ get func code at X | |
444 stx R$PC,u restore updated PC | |
2012 | 445 lslb high bit set? |
446 bcc L0288 branch if not (non I/O call) | |
447 rorb else restore B (its an I/O call) | |
448 ldx -2,y grab IOMan vector | |
449 * Note: should check if X is zero in case IOMan was not installed. | |
1453 | 450 bra L0290 |
2012 | 451 L0288 cmpb #$37*2 |
1453 | 452 bcc L02A7 |
453 ldx b,y X = addr of system call | |
454 beq L02A7 | |
455 L0290 jsr ,x jsr into system call | |
456 L0292 puls u | |
457 tfr cc,a | |
458 bcc FixCC branch if no error | |
459 stb R$B,u store error code | |
460 FixCC ldb R$CC,u get caller's CC | |
461 andb #^(Negative+Zero+TwosOvfl+Carry) | |
462 stb R$CC,u | |
463 anda #Negative+Zero+TwosOvfl+Carry | |
464 ora R$CC,u | |
465 sta R$CC,u | |
466 rts | |
467 L02A7 comb | |
468 ldb #E$UnkSvc | |
469 bra L0292 | |
470 | |
471 * no signal handler, exit with signal value as exit code | |
472 L02AC ldb P$State,x | |
473 orb #SysState | |
474 stb P$State,x | |
475 ldb <P$Signal,x | |
476 andcc #^(IntMasks) | |
477 os9 F$Exit | |
478 | |
479 FNProc clra | |
480 clrb | |
481 std <D.Proc | |
482 bra L02C2 | |
483 * execution goes here when there are no active processes | |
484 L02C0 cwai #^(IntMasks) | |
485 L02C2 orcc #IntMasks | |
486 ldx <D.AProcQ get next active process | |
487 beq L02C0 CWAI if none | |
488 ldd P$Queue,x get queue ptr | |
489 std <D.AProcQ store in Active Q | |
490 stx <D.Proc store in current process | |
491 lds P$SP,x get process' stack ptr | |
492 L02D1 ldb P$State,x get state | |
493 bmi L0308 branch if system state | |
494 bitb #Condem process condemned? | |
495 bne L02AC branch if so... | |
496 ldb <P$Signal,x get signal no | |
497 beq L02FF branch if none | |
498 decb decrement | |
499 beq L02FC branch if wake up | |
500 ldu <P$SigVec,x get signal handler addr | |
501 beq L02AC branch if none | |
502 ldy <P$SigDat,x get data addr | |
503 ldd $06,s | |
504 pshs u,y,b,a | |
505 ldu $0A,s | |
506 lda <P$Signal,x | |
507 ldb $09,s | |
508 tfr d,y | |
509 ldd $06,s | |
510 pshs u,y,b,a | |
511 clrb | |
512 L02FC stb <P$Signal,x | |
513 L02FF ldd <P$SWI2,x | |
514 std <D.SWI2 | |
515 ldd <D.UsrIRQ | |
516 std <D.SvcIRQ | |
517 L0308 rti | |
518 | |
519 FLink pshs u save caller regs | |
520 ldd R$A,u | |
521 ldx R$X,u | |
522 lbsr L0443 | |
523 bcc FLinkOK | |
524 ldb #E$MNF | |
525 bra L033D | |
526 * U = module dir entry | |
527 FLinkOK ldy ,u get module ptr | |
528 ldb M$Revs,y | |
529 bitb #ReEnt reentrant? | |
530 bne L032A branch if so | |
531 tst $02,u link count zero? | |
532 beq L032A yep, ok to link to nonreent | |
533 comb else module is busy | |
534 ldb #E$ModBsy | |
535 bra L033D | |
536 L032A inc $02,u increment link count | |
537 ldu ,s get caller regs from stack | |
538 stx R$X,u | |
539 sty R$U,u | |
540 ldd M$Type,y | |
541 std R$D,u | |
542 ldd M$IDSize,y | |
543 leax d,y | |
544 stx R$Y,u | |
545 L033D puls pc,u | |
546 | |
547 FVModul pshs u | |
548 ldx R$X,u | |
549 bsr ValMod | |
550 puls y | |
551 stu R$U,y | |
552 rts | |
553 * X = address of module to validate | |
554 ValMod bsr ChkMHCRC | |
555 bcs L039A | |
556 lda M$Type,x | |
557 pshs x,a | |
558 ldd M$Name,x | |
559 leax d,x X = addr of name in mod | |
560 puls a | |
561 lbsr L0443 | |
562 puls x | |
563 bcs L039B | |
564 ldb #E$KwnMod | |
565 cmpx ,u | |
566 beq L03A1 | |
567 lda M$Revs,x | |
568 anda #RevsMask | |
569 pshs a | |
570 ldy ,u | |
571 lda M$Revs,y | |
572 anda #RevsMask | |
573 cmpa ,s+ same revision as other mod? | |
574 bcc L03A1 | |
575 pshs y,x | |
576 ldb M$Size,u | |
577 bne L0395 | |
578 ldx ,u | |
579 cmpx <D.BTLO | |
580 bcc L0395 | |
581 ldd $02,x | |
582 addd #$00FF | |
583 tfr a,b | |
584 clra | |
585 tfr d,y | |
586 ldb ,u | |
587 ldx <D.FMBM | |
588 os9 F$DelBit | |
589 clr $02,u | |
590 L0395 puls y,x | |
591 L0397 stx ,u | |
592 clrb | |
593 L039A rts | |
594 L039B leay ,u | |
595 bne L0397 | |
596 ldb #E$DirFul | |
597 L03A1 coma | |
598 rts | |
599 | |
600 * check module header and CRC | |
601 * X = address of potential module | |
602 ChkMHCRC ldd ,x | |
603 cmpd #M$ID12 sync bytes? | |
604 bne L03B1 nope, not a module here | |
605 leay M$Parity,x | |
606 bsr ChkMHPar check header parity | |
607 bcc L03B5 branch if ok | |
608 L03B1 comb | |
609 ldb #E$BMID | |
610 rts | |
611 | |
612 L03B5 | |
613 * Following 4 lines added to support no CRC checks - 2002/07/21 | |
614 lda <D.CRC is CRC checking on? | |
615 bne DoCRCCk branch if so | |
616 clrb | |
617 rts | |
618 | |
619 DoCRCCk pshs x | |
620 ldy M$Size,x | |
621 bsr ChkMCRC checkm module CRC | |
622 puls pc,x | |
623 * check module header parity | |
624 * Y = pointer to parity byte | |
625 ChkMHPar pshs y,x | |
626 clra | |
627 ChkM010 eora ,x+ | |
628 cmpx 2,s compare to addr of M$Parity | |
629 bls ChkM010 | |
630 cmpa #$FF | |
631 puls pc,y,x | |
632 * X = address of potential module | |
633 * Y = size of module | |
634 ChkMCRC ldd #$FFFF | |
635 pshs b,a | |
636 pshs b,a | |
637 leau 1,s | |
638 L03D4 lda ,x+ | |
639 bsr CRCAlgo | |
640 leay -1,y dec Y (size of module) | |
641 bne L03D4 continue | |
642 clr -1,u | |
643 lda ,u | |
644 cmpa #CRCCon1 | |
645 bne L03EC | |
646 ldd 1,u | |
647 cmpd #CRCCon23 | |
648 beq L03EF | |
649 L03EC comb | |
650 ldb #E$BMCRC | |
651 L03EF puls pc,y,x | |
652 | |
2018 | 653 use fcrc.asm |
1453 | 654 |
655 L0443 ldu #$0000 | |
656 tfr a,b | |
657 anda #TypeMask | |
658 andb #LangMask | |
659 pshs u,y,x,b,a | |
660 bsr EatSpace | |
661 cmpa #PDELIM pathlist char? | |
662 beq L049C branch if so | |
663 lbsr ParseNam parse name | |
664 bcs L049D return if error | |
665 ldu <D.ModDir | |
666 L045B pshs u,y,b | |
667 ldu ,u | |
668 beq L048B | |
669 ldd $04,u | |
670 leay d,u | |
671 ldb ,s | |
672 lbsr L07AB | |
673 bcs L0493 | |
674 lda $05,s | |
675 beq L0476 | |
676 eora $06,u | |
677 anda #$F0 | |
678 bne L0493 | |
679 L0476 lda $06,s | |
680 beq L0480 | |
681 eora $06,u | |
682 anda #$0F | |
683 bne L0493 | |
684 L0480 puls u,x,b | |
685 stu $06,s | |
686 bsr EatSpace | |
687 stx $02,s | |
688 clra | |
689 bra L049D | |
690 L048B ldd $0B,s | |
691 bne L0493 | |
692 ldd $03,s | |
693 std $0B,s | |
694 L0493 puls u,y,b | |
695 leau $04,u | |
696 cmpu <D.ModDir+2 | |
697 bcs L045B | |
698 L049C comb | |
699 L049D puls pc,u,y,x,b,a | |
700 | |
701 EatSpace lda #C$SPAC | |
702 EatSpc10 cmpa ,x+ | |
703 beq EatSpc10 | |
704 lda ,-x | |
705 rts | |
706 | |
707 FFork ldx <D.PrcDBT | |
708 os9 F$All64 | |
709 bcs L0517 | |
710 ldx <D.Proc | |
711 pshs x save calling proc desc on stack | |
712 ldd P$User,x | |
713 std P$User,y | |
714 lda P$Prior,x | |
715 clrb | |
716 std P$Prior,y | |
717 ldb #SysState | |
718 stb P$State,y | |
719 sty <D.Proc | |
720 ldd <P$NIO,x | |
721 std <P$NIO,y | |
722 ldd <P$NIO+2,x | |
723 std <P$NIO+2,y | |
724 leax <P$DIO,x | |
725 leay <P$DIO,y | |
726 ldb #DefIOSiz | |
727 * copy I/O stuff from parent to child | |
728 L04D7 lda ,x+ | |
729 sta ,y+ | |
730 decb | |
731 bne L04D7 | |
732 * X/Y = address of path table in respective proc desc | |
733 * Dup stdin/stdout/stderr | |
734 ldb #$03 | |
735 L04E0 lda ,x+ | |
736 os9 I$Dup | |
737 bcc L04E8 | |
738 clra | |
739 L04E8 sta ,y+ | |
740 decb | |
741 bne L04E0 | |
742 bsr L0553 | |
743 bcs L050C | |
744 puls y get parent proc desc | |
745 sty <D.Proc | |
746 lda P$ID,x get ID of new process | |
747 sta R$A,u store in caller's A | |
748 ldb P$CID,y get child id of parent | |
749 sta P$CID,y store new proc in parent's CID | |
750 lda P$ID,y get ID of parent | |
751 std P$PID,x store in child proc desc | |
752 ldb P$State,x update state of child | |
753 andb #^SysState | |
754 stb P$State,x | |
755 os9 F$AProc insert child in active Q | |
756 rts | |
757 L050C pshs b | |
758 os9 F$Exit | |
759 comb | |
760 puls x,b | |
761 stx <D.Proc | |
762 rts | |
763 L0517 comb | |
764 ldb #E$PrcFul | |
765 rts | |
766 | |
767 FChain bsr L0543 | |
768 bcs L0531 | |
769 orcc #IntMasks | |
770 ldb $0D,x | |
771 andb #$7F | |
772 stb $0D,x | |
773 L0527 os9 F$AProc | |
774 os9 F$NProc | |
775 | |
776 SFChain bsr L0543 | |
777 bcc L0527 | |
778 L0531 pshs b | |
779 stb <P$Signal,x | |
780 ldb P$State,x | |
781 orb #Condem | |
782 stb P$State,x | |
783 ldb #$FF | |
784 stb P$Prior,x | |
785 comb | |
786 puls pc,b | |
787 L0543 pshs u | |
788 ldx <D.Proc | |
789 ldu <P$PModul,x | |
790 os9 F$UnLink | |
791 ldu ,s | |
792 bsr L0553 | |
793 puls pc,u | |
794 L0553 ldx <D.Proc | |
795 pshs u,x | |
796 ldd <D.UsrSvc | |
797 std <P$SWI,x | |
798 std <P$SWI2,x | |
799 std <P$SWI3,x | |
800 clra | |
801 clrb | |
802 sta <P$Signal,x | |
803 std <P$SigVec,x | |
804 lda R$A,u | |
805 ldx R$X,u | |
806 os9 F$Link | |
807 bcc L0578 | |
808 os9 F$Load | |
809 bcs L05E7 | |
810 L0578 ldy <D.Proc | |
811 stu <P$PModul,y | |
812 cmpa #Prgrm+Objct | |
813 beq L058B | |
814 cmpa #Systm+Objct | |
815 beq L058B | |
816 comb | |
817 ldb #E$NEMod | |
818 bra L05E7 | |
819 L058B leay ,u Y = addr of module | |
820 ldu 2,s get U off stack (caller regs) | |
821 stx R$X,u | |
822 lda R$B,u | |
823 clrb | |
824 cmpd M$Mem,y compare passed mem to module's | |
825 bcc L059B branch if less than | |
826 ldd M$Mem,y | |
827 L059B addd #$0000 | |
828 bne L05A0 | |
829 L05A0 os9 F$Mem | |
830 bcs L05E7 | |
831 subd #R$Size subtract registers | |
832 subd R$Y,u subtract parameter area | |
833 bcs L05E5 | |
834 ldx R$U,u get parameter area | |
835 ldd R$Y,u get parameter size | |
836 pshs b,a | |
837 beq L05BE | |
838 leax d,x point to end of param area | |
839 L05B6 lda ,-x get byte, dec X | |
840 sta ,-y save byte in data area, dec X | |
841 cmpx R$U,u at top of param area? | |
842 bhi L05B6 | |
843 * set up registers for return of F$Fork/F$Chain | |
844 L05BE ldx <D.Proc | |
845 sty -$08,y put in X on caller stack | |
846 leay -R$Size,y back up register size | |
847 sty P$SP,x | |
848 lda P$ADDR,x | |
849 clrb | |
850 std R$U,y lowest address | |
851 sta R$DP,y set direct page | |
852 adda P$PagCnt,x | |
853 std R$Y,y | |
854 puls b,a | |
855 std R$D,y size of param area | |
856 ldb #Entire | |
857 stb R$CC,y | |
858 ldu <P$PModul,x get addr of prim. mod | |
859 ldd M$Exec,u | |
860 leau d,u | |
861 stu R$PC,y put in PC on caller reg | |
862 clrb | |
863 L05E5 ldb #E$IForkP | |
864 L05E7 puls pc,u,x | |
865 | |
2017
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
866 use fsrqmem.asm |
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
867 |
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
868 use fallbit.asm |
1453 | 869 |
870 use fprsnam.asm | |
871 | |
872 use fcmpnam.asm | |
873 | |
2018 | 874 use fssvc.asm |
2017
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
875 |
1453 | 876 emod |
877 eom equ * | |
878 | |
879 fdb Clock | |
2012 | 880 Vectors fdb SWI3 SWI3 |
881 fdb SWI2 SWI2 | |
882 fdb DUMMY FIRQ | |
883 fdb SVCIRQ IRQ | |
884 fdb SWI SWI | |
885 fdb DUMMY NMI | |
1453 | 886 |
887 end |