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