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