Mercurial > hg > Members > kono > nitros9-code
annotate level1/modules/kernel/krn.asm @ 2152:74fb212cb659
Changelog comes from higher up
author | boisy |
---|---|
date | Wed, 14 May 2008 02:13:22 +0000 |
parents | 0cf8513d33d7 |
children | 41a797492324 |
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 | |
2020 | 108 fcb F$Chain+SysState |
1453 | 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 | |
2020 | 122 fcb F$SRqMem+SysState |
1453 | 123 fdb FSRqMem-*-2 |
2020 | 124 fcb F$SRtMem+SysState |
1453 | 125 fdb FSRtMem-*-2 |
2020 | 126 fcb F$AProc+SysState |
1453 | 127 fdb FAProc-*-2 |
2020 | 128 fcb F$NProc+SysState |
1453 | 129 fdb FNProc-*-2 |
2020 | 130 fcb F$VModul+SysState |
1453 | 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 | |
2023 | 254 leax >Poll,pcr point to default poll routine |
255 stx <D.Poll and save it | |
256 leax >Clock,pcr get default clock routine | |
257 stx <D.Clock and save it to the vector | |
258 stx <D.AltIRQ and in the alternate IRQ vector | |
1453 | 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 | |
2023 | 311 UsrIRQ leay <DoIRQPoll,pcr |
1453 | 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 |
2023 | 316 * Note that we are putting the system state service routine address into |
317 * the D.SWI2 vector. If a system call is made while we are in system state, | |
318 * D.SWI2 will be vectored to the system state service routine vector. | |
2012 | 319 ldd <D.SysSvc get system state system call vector |
320 std <D.SWI2 store in D.SWI2 | |
2023 | 321 * The same comment above applies to the IRQ service vector. |
2012 | 322 ldd <D.SysIRQ get system IRQ vector |
323 std <D.SvcIRQ store in D.SvcIRQ | |
324 leau ,s point U to S | |
325 stu P$SP,x and save in process P$SP | |
326 lda P$State,x get state field in proc desc | |
327 ora #SysState mark process to be in system state | |
328 sta P$State,x store it | |
329 jmp ,y jump to ,y | |
1453 | 330 |
2023 | 331 DoIRQPoll |
332 jsr [>D.Poll] call vectored polling routine | |
333 bcc L01BD branch if carry clear | |
334 ldb ,s get the CC on the stack | |
335 orb #IRQMask mask IRQs | |
336 stb ,s and save it back | |
337 L01BD lbra ActivateProc | |
338 | |
339 | |
1453 | 340 |
341 SysIRQ clra | |
2023 | 342 tfr a,dp make DP be 0 |
343 jsr [>D.Poll] call the vectored IRQ polling routine | |
344 bcc L01CF branch if carry is clear | |
345 ldb ,s get the CC on the stack | |
346 orb #IRQMask mask IRQs | |
347 stb ,s and save it back | |
1453 | 348 L01CF rti |
2023 | 349 |
1453 | 350 Poll comb |
351 rts | |
352 | |
2017
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
353 * Default clock routine - executed 60 times/sec |
2023 | 354 Clock ldx <D.SProcQ get pointer to sleeping proc queue |
355 beq L01FD branch if no process sleeping | |
356 lda P$State,x get state of that process | |
357 bita #TimSleep timed sleep? | |
358 beq L01FD branch if clear | |
359 ldu P$SP,x else get process stack pointer | |
360 ldd R$X,u get the value of the process X reg | |
361 subd #$0001 subtract one from it | |
362 std P$SP,u and store it | |
363 bne L01FD branch if not zero (still will sleep) | |
364 L01E7 ldu P$Queue,x get process current queue pointer | |
365 bsr L021A | |
1453 | 366 leax ,u |
367 beq L01FB | |
2023 | 368 lda P$State,x get process state byte |
369 bita #TimSleep bit set? | |
370 beq L01FB branch if not | |
371 ldu P$SP,x get process stack pointer | |
372 ldd R$X,u then get process X register | |
373 beq L01E7 branch if zero | |
1453 | 374 L01FB stx <D.SProcQ |
2017
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
375 L01FD dec <D.Slice decrement slice |
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
376 bne ClockRTI if not 0, exit ISR |
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
377 lda <D.TSlice else get default time slice |
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
378 sta <D.Slice and save it as slice |
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
379 ldx <D.Proc get proc desc of current proc |
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
380 beq ClockRTI if none, exit ISR |
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
381 lda P$State,x get process state |
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
382 ora #TimOut set timeout bit |
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
383 sta P$State,x and store back |
1453 | 384 bpl L0212 branch if not system state |
385 ClockRTI rti | |
386 | |
2023 | 387 L0212 leay >ActivateProc,pcr |
1453 | 388 bra URtoSs |
389 | |
2006 | 390 |
391 *FAProc ldx R$X,u Get ptr to process to activate | |
392 *L0D11 clrb | |
393 * pshs cc,b,x,y,u | |
394 * lda P$Prior,x Get process priority | |
395 * sta P$Age,x Save it as age (How long it's been around) | |
396 * orcc #IntMasks Shut down IRQ's | |
397 * ldu #(D.AProcQ-P$Queue) Get ptr to active process queue | |
398 * bra L0D29 Go through the chain | |
399 ** Update active process queue | |
400 ** X=Process to activate | |
401 ** U=Current process in queue links | |
402 *L0D1F inc P$Age,u update current process age | |
403 * bne L0D25 wrap? | |
404 * dec P$Age,u yes, reset it to max. | |
405 *L0D25 cmpa P$Age,u match process ages?? | |
406 * bhi L0D2B no, skip update | |
407 *L0D29 leay ,u point Y to current process | |
408 *L0D2B ldu P$Queue,u get pointer to next process in chain | |
409 * bne L0D1F Still more in chain, keep going | |
410 * ldd P$Queue,y | |
411 * stx P$Queue,y save new process to chain | |
412 * std P$Queue,x | |
413 * puls cc,b,x,y,u,pc | |
414 | |
415 | |
2049 | 416 use faproc.asm |
2018 | 417 |
2012 | 418 * User-State system call entry point |
2023 | 419 * |
420 * All system calls made from user-state will go through this code. | |
421 UsrSvc leay <MakeSysCall,pcr | |
1453 | 422 orcc #IntMasks |
423 lbra URtoSs | |
424 | |
2023 | 425 MakeSysCall |
426 andcc #^IntMasks unmask IRQ/FIRQ | |
427 ldy <D.UsrDis get pointer to user syscall dispatch table | |
428 bsr DoSysCall go do the system call | |
429 ActivateProc | |
430 ldx <D.Proc get current proc desc | |
1453 | 431 beq FNProc branch to FNProc if none |
2012 | 432 orcc #IntMasks mask interrupts |
433 ldb P$State,x get state value in proc desc | |
434 andb #^SysState turn off system state flag | |
435 stb P$State,x save state value | |
436 bitb #TimOut timeout bit set? | |
437 beq L02D1 branch if not | |
438 andb #^TimOut else turn off bit | |
439 stb P$State,x in state value | |
1453 | 440 bsr L021A |
441 bra FNProc | |
442 | |
2012 | 443 * System-State system call entry point |
1453 | 444 SysSvc clra |
445 tfr a,dp set direct page to 0 | |
2012 | 446 leau ,s point U to SP |
447 ldy <D.SysDis get system state dispatch table ptr | |
448 bsr DoSysCall | |
1453 | 449 rti |
450 | |
2012 | 451 * Entry: Y = Dispatch table (user or system) |
452 DoSysCall | |
453 pshs u | |
1453 | 454 ldx R$PC,u point X to PC |
455 ldb ,x+ get func code at X | |
456 stx R$PC,u restore updated PC | |
2012 | 457 lslb high bit set? |
458 bcc L0288 branch if not (non I/O call) | |
459 rorb else restore B (its an I/O call) | |
460 ldx -2,y grab IOMan vector | |
461 * Note: should check if X is zero in case IOMan was not installed. | |
1453 | 462 bra L0290 |
2012 | 463 L0288 cmpb #$37*2 |
1453 | 464 bcc L02A7 |
465 ldx b,y X = addr of system call | |
466 beq L02A7 | |
467 L0290 jsr ,x jsr into system call | |
468 L0292 puls u | |
469 tfr cc,a | |
470 bcc FixCC branch if no error | |
471 stb R$B,u store error code | |
472 FixCC ldb R$CC,u get caller's CC | |
473 andb #^(Negative+Zero+TwosOvfl+Carry) | |
474 stb R$CC,u | |
475 anda #Negative+Zero+TwosOvfl+Carry | |
476 ora R$CC,u | |
477 sta R$CC,u | |
478 rts | |
479 L02A7 comb | |
480 ldb #E$UnkSvc | |
481 bra L0292 | |
482 | |
483 * no signal handler, exit with signal value as exit code | |
484 L02AC ldb P$State,x | |
485 orb #SysState | |
486 stb P$State,x | |
487 ldb <P$Signal,x | |
488 andcc #^(IntMasks) | |
489 os9 F$Exit | |
490 | |
491 FNProc clra | |
492 clrb | |
493 std <D.Proc | |
494 bra L02C2 | |
495 * execution goes here when there are no active processes | |
496 L02C0 cwai #^(IntMasks) | |
497 L02C2 orcc #IntMasks | |
498 ldx <D.AProcQ get next active process | |
499 beq L02C0 CWAI if none | |
500 ldd P$Queue,x get queue ptr | |
501 std <D.AProcQ store in Active Q | |
502 stx <D.Proc store in current process | |
503 lds P$SP,x get process' stack ptr | |
504 L02D1 ldb P$State,x get state | |
505 bmi L0308 branch if system state | |
506 bitb #Condem process condemned? | |
507 bne L02AC branch if so... | |
508 ldb <P$Signal,x get signal no | |
509 beq L02FF branch if none | |
510 decb decrement | |
511 beq L02FC branch if wake up | |
512 ldu <P$SigVec,x get signal handler addr | |
513 beq L02AC branch if none | |
514 ldy <P$SigDat,x get data addr | |
515 ldd $06,s | |
516 pshs u,y,b,a | |
517 ldu $0A,s | |
518 lda <P$Signal,x | |
519 ldb $09,s | |
520 tfr d,y | |
521 ldd $06,s | |
522 pshs u,y,b,a | |
523 clrb | |
524 L02FC stb <P$Signal,x | |
525 L02FF ldd <P$SWI2,x | |
526 std <D.SWI2 | |
527 ldd <D.UsrIRQ | |
528 std <D.SvcIRQ | |
529 L0308 rti | |
530 | |
531 FLink pshs u save caller regs | |
532 ldd R$A,u | |
533 ldx R$X,u | |
534 lbsr L0443 | |
535 bcc FLinkOK | |
536 ldb #E$MNF | |
537 bra L033D | |
538 * U = module dir entry | |
539 FLinkOK ldy ,u get module ptr | |
540 ldb M$Revs,y | |
541 bitb #ReEnt reentrant? | |
542 bne L032A branch if so | |
543 tst $02,u link count zero? | |
544 beq L032A yep, ok to link to nonreent | |
545 comb else module is busy | |
546 ldb #E$ModBsy | |
547 bra L033D | |
548 L032A inc $02,u increment link count | |
549 ldu ,s get caller regs from stack | |
550 stx R$X,u | |
551 sty R$U,u | |
552 ldd M$Type,y | |
553 std R$D,u | |
554 ldd M$IDSize,y | |
555 leax d,y | |
556 stx R$Y,u | |
557 L033D puls pc,u | |
558 | |
559 FVModul pshs u | |
560 ldx R$X,u | |
561 bsr ValMod | |
562 puls y | |
563 stu R$U,y | |
564 rts | |
565 * X = address of module to validate | |
566 ValMod bsr ChkMHCRC | |
567 bcs L039A | |
568 lda M$Type,x | |
569 pshs x,a | |
570 ldd M$Name,x | |
571 leax d,x X = addr of name in mod | |
572 puls a | |
573 lbsr L0443 | |
574 puls x | |
575 bcs L039B | |
576 ldb #E$KwnMod | |
577 cmpx ,u | |
578 beq L03A1 | |
579 lda M$Revs,x | |
580 anda #RevsMask | |
581 pshs a | |
582 ldy ,u | |
583 lda M$Revs,y | |
584 anda #RevsMask | |
585 cmpa ,s+ same revision as other mod? | |
586 bcc L03A1 | |
587 pshs y,x | |
588 ldb M$Size,u | |
589 bne L0395 | |
590 ldx ,u | |
591 cmpx <D.BTLO | |
592 bcc L0395 | |
593 ldd $02,x | |
594 addd #$00FF | |
595 tfr a,b | |
596 clra | |
597 tfr d,y | |
598 ldb ,u | |
599 ldx <D.FMBM | |
600 os9 F$DelBit | |
601 clr $02,u | |
602 L0395 puls y,x | |
603 L0397 stx ,u | |
604 clrb | |
605 L039A rts | |
606 L039B leay ,u | |
607 bne L0397 | |
608 ldb #E$DirFul | |
609 L03A1 coma | |
610 rts | |
611 | |
612 * check module header and CRC | |
613 * X = address of potential module | |
614 ChkMHCRC ldd ,x | |
615 cmpd #M$ID12 sync bytes? | |
616 bne L03B1 nope, not a module here | |
617 leay M$Parity,x | |
618 bsr ChkMHPar check header parity | |
619 bcc L03B5 branch if ok | |
620 L03B1 comb | |
621 ldb #E$BMID | |
622 rts | |
623 | |
624 L03B5 | |
625 * Following 4 lines added to support no CRC checks - 2002/07/21 | |
626 lda <D.CRC is CRC checking on? | |
627 bne DoCRCCk branch if so | |
628 clrb | |
629 rts | |
630 | |
631 DoCRCCk pshs x | |
632 ldy M$Size,x | |
633 bsr ChkMCRC checkm module CRC | |
634 puls pc,x | |
635 * check module header parity | |
636 * Y = pointer to parity byte | |
637 ChkMHPar pshs y,x | |
638 clra | |
639 ChkM010 eora ,x+ | |
640 cmpx 2,s compare to addr of M$Parity | |
641 bls ChkM010 | |
642 cmpa #$FF | |
643 puls pc,y,x | |
644 * X = address of potential module | |
645 * Y = size of module | |
646 ChkMCRC ldd #$FFFF | |
647 pshs b,a | |
648 pshs b,a | |
649 leau 1,s | |
650 L03D4 lda ,x+ | |
651 bsr CRCAlgo | |
652 leay -1,y dec Y (size of module) | |
653 bne L03D4 continue | |
654 clr -1,u | |
655 lda ,u | |
656 cmpa #CRCCon1 | |
657 bne L03EC | |
658 ldd 1,u | |
659 cmpd #CRCCon23 | |
660 beq L03EF | |
661 L03EC comb | |
662 ldb #E$BMCRC | |
663 L03EF puls pc,y,x | |
664 | |
2049 | 665 use fcrc.asm |
1453 | 666 |
667 L0443 ldu #$0000 | |
668 tfr a,b | |
669 anda #TypeMask | |
670 andb #LangMask | |
671 pshs u,y,x,b,a | |
672 bsr EatSpace | |
673 cmpa #PDELIM pathlist char? | |
674 beq L049C branch if so | |
675 lbsr ParseNam parse name | |
676 bcs L049D return if error | |
677 ldu <D.ModDir | |
678 L045B pshs u,y,b | |
679 ldu ,u | |
680 beq L048B | |
681 ldd $04,u | |
682 leay d,u | |
683 ldb ,s | |
684 lbsr L07AB | |
685 bcs L0493 | |
686 lda $05,s | |
687 beq L0476 | |
688 eora $06,u | |
689 anda #$F0 | |
690 bne L0493 | |
691 L0476 lda $06,s | |
692 beq L0480 | |
693 eora $06,u | |
694 anda #$0F | |
695 bne L0493 | |
696 L0480 puls u,x,b | |
697 stu $06,s | |
698 bsr EatSpace | |
699 stx $02,s | |
700 clra | |
701 bra L049D | |
702 L048B ldd $0B,s | |
703 bne L0493 | |
704 ldd $03,s | |
705 std $0B,s | |
706 L0493 puls u,y,b | |
707 leau $04,u | |
708 cmpu <D.ModDir+2 | |
709 bcs L045B | |
710 L049C comb | |
711 L049D puls pc,u,y,x,b,a | |
712 | |
713 EatSpace lda #C$SPAC | |
714 EatSpc10 cmpa ,x+ | |
715 beq EatSpc10 | |
716 lda ,-x | |
717 rts | |
718 | |
719 FFork ldx <D.PrcDBT | |
720 os9 F$All64 | |
721 bcs L0517 | |
722 ldx <D.Proc | |
723 pshs x save calling proc desc on stack | |
724 ldd P$User,x | |
725 std P$User,y | |
726 lda P$Prior,x | |
727 clrb | |
728 std P$Prior,y | |
729 ldb #SysState | |
730 stb P$State,y | |
731 sty <D.Proc | |
732 ldd <P$NIO,x | |
733 std <P$NIO,y | |
734 ldd <P$NIO+2,x | |
735 std <P$NIO+2,y | |
736 leax <P$DIO,x | |
737 leay <P$DIO,y | |
738 ldb #DefIOSiz | |
739 * copy I/O stuff from parent to child | |
740 L04D7 lda ,x+ | |
741 sta ,y+ | |
742 decb | |
743 bne L04D7 | |
744 * X/Y = address of path table in respective proc desc | |
745 * Dup stdin/stdout/stderr | |
746 ldb #$03 | |
747 L04E0 lda ,x+ | |
748 os9 I$Dup | |
749 bcc L04E8 | |
750 clra | |
751 L04E8 sta ,y+ | |
752 decb | |
753 bne L04E0 | |
754 bsr L0553 | |
755 bcs L050C | |
756 puls y get parent proc desc | |
757 sty <D.Proc | |
758 lda P$ID,x get ID of new process | |
759 sta R$A,u store in caller's A | |
760 ldb P$CID,y get child id of parent | |
761 sta P$CID,y store new proc in parent's CID | |
762 lda P$ID,y get ID of parent | |
763 std P$PID,x store in child proc desc | |
764 ldb P$State,x update state of child | |
765 andb #^SysState | |
766 stb P$State,x | |
767 os9 F$AProc insert child in active Q | |
768 rts | |
769 L050C pshs b | |
770 os9 F$Exit | |
771 comb | |
772 puls x,b | |
773 stx <D.Proc | |
774 rts | |
775 L0517 comb | |
776 ldb #E$PrcFul | |
777 rts | |
778 | |
779 FChain bsr L0543 | |
780 bcs L0531 | |
781 orcc #IntMasks | |
782 ldb $0D,x | |
783 andb #$7F | |
784 stb $0D,x | |
785 L0527 os9 F$AProc | |
786 os9 F$NProc | |
787 | |
788 SFChain bsr L0543 | |
789 bcc L0527 | |
790 L0531 pshs b | |
791 stb <P$Signal,x | |
792 ldb P$State,x | |
793 orb #Condem | |
794 stb P$State,x | |
795 ldb #$FF | |
796 stb P$Prior,x | |
797 comb | |
798 puls pc,b | |
799 L0543 pshs u | |
800 ldx <D.Proc | |
801 ldu <P$PModul,x | |
802 os9 F$UnLink | |
803 ldu ,s | |
804 bsr L0553 | |
805 puls pc,u | |
806 L0553 ldx <D.Proc | |
807 pshs u,x | |
808 ldd <D.UsrSvc | |
809 std <P$SWI,x | |
810 std <P$SWI2,x | |
811 std <P$SWI3,x | |
812 clra | |
813 clrb | |
814 sta <P$Signal,x | |
815 std <P$SigVec,x | |
816 lda R$A,u | |
817 ldx R$X,u | |
818 os9 F$Link | |
819 bcc L0578 | |
820 os9 F$Load | |
821 bcs L05E7 | |
822 L0578 ldy <D.Proc | |
823 stu <P$PModul,y | |
824 cmpa #Prgrm+Objct | |
825 beq L058B | |
826 cmpa #Systm+Objct | |
827 beq L058B | |
828 comb | |
829 ldb #E$NEMod | |
830 bra L05E7 | |
831 L058B leay ,u Y = addr of module | |
832 ldu 2,s get U off stack (caller regs) | |
833 stx R$X,u | |
834 lda R$B,u | |
835 clrb | |
836 cmpd M$Mem,y compare passed mem to module's | |
837 bcc L059B branch if less than | |
838 ldd M$Mem,y | |
839 L059B addd #$0000 | |
840 bne L05A0 | |
841 L05A0 os9 F$Mem | |
842 bcs L05E7 | |
843 subd #R$Size subtract registers | |
844 subd R$Y,u subtract parameter area | |
845 bcs L05E5 | |
846 ldx R$U,u get parameter area | |
847 ldd R$Y,u get parameter size | |
848 pshs b,a | |
849 beq L05BE | |
850 leax d,x point to end of param area | |
851 L05B6 lda ,-x get byte, dec X | |
852 sta ,-y save byte in data area, dec X | |
853 cmpx R$U,u at top of param area? | |
854 bhi L05B6 | |
855 * set up registers for return of F$Fork/F$Chain | |
856 L05BE ldx <D.Proc | |
857 sty -$08,y put in X on caller stack | |
858 leay -R$Size,y back up register size | |
859 sty P$SP,x | |
860 lda P$ADDR,x | |
861 clrb | |
862 std R$U,y lowest address | |
863 sta R$DP,y set direct page | |
864 adda P$PagCnt,x | |
865 std R$Y,y | |
866 puls b,a | |
867 std R$D,y size of param area | |
868 ldb #Entire | |
869 stb R$CC,y | |
870 ldu <P$PModul,x get addr of prim. mod | |
871 ldd M$Exec,u | |
872 leau d,u | |
873 stu R$PC,y put in PC on caller reg | |
874 clrb | |
875 L05E5 ldb #E$IForkP | |
876 L05E7 puls pc,u,x | |
877 | |
2049 | 878 use fsrqmem.asm |
2017
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
879 |
2049 | 880 use fallbit.asm |
1453 | 881 |
2049 | 882 use fprsnam.asm |
1453 | 883 |
2049 | 884 use fcmpnam.asm |
1453 | 885 |
2049 | 886 use fssvc.asm |
2017
f273e28ea8d0
Breaking kernel down into individual files... added comments
boisy
parents:
2012
diff
changeset
|
887 |
1453 | 888 emod |
889 eom equ * | |
890 | |
891 fdb Clock | |
2012 | 892 Vectors fdb SWI3 SWI3 |
893 fdb SWI2 SWI2 | |
894 fdb DUMMY FIRQ | |
895 fdb SVCIRQ IRQ | |
896 fdb SWI SWI | |
897 fdb DUMMY NMI | |
1453 | 898 |
899 end |