Mercurial > hg > Members > kono > nitros9-code
annotate level2/modules/kernel/krnp2.asm @ 1631:ec6fb5543b22
Robert Gault's modifications for correcting timing errors
author | boisy |
---|---|
date | Mon, 12 Jul 2004 01:38:08 +0000 |
parents | 5f18094d961d |
children | 5ecf6e023a64 |
rev | line source |
---|---|
1145 | 1 ******************************************************************** |
1587
5f18094d961d
kernel modules renamed to krn, updated makefiles, clock2_tc3 now clock2_cloud9...
boisy
parents:
1482
diff
changeset
|
2 * krnp2 - NitrOS-9 Level 2 Kernel Part 2 |
1145 | 3 * |
4 * $Id$ | |
5 * | |
6 * Copyright (c) 1982 Microware Corporation | |
7 * | |
8 * Modified for 6309 Native mode by: | |
9 * | |
10 * Bill Nobel, L. Curtis Boyle & Wes Gale - Gale Force Enterprises | |
11 * | |
12 * Ed. Comments Who YY/MM/DD | |
13 * ------------------------------------------------------------------ | |
14 * | |
15 * 17.2 08/02/92 - Active in 6309 Native mode, No apparent bugs (BN) | |
16 * - Optimized F$Fork (BN) | |
17 * - Optimized F$Chain (BN) | |
18 * 18.4 92/12/15 - Cut initial memory allocation routine - unnecessary | |
19 * 18.5 93/01/18 - Fixed bug in F$Sleep (LCB) | |
20 * - Optimized F$All64 to use tfm (BN) | |
1239 | 21 * NitrOS9 V1.09 - Move & optimized F$CpyMem to OS9P1 |
1145 | 22 * V1.10 93/05/23 - Slight opt to UnLink |
23 * V1.11 93/07/26 - Slight opt in F$Icpt | |
24 * - Slight opt in F$Wait alarm clearing | |
25 * - Slight opt to speed up path table full errors | |
26 * - Changed LBEQ to BEQ in F$Unlink | |
27 * V1.16 93/09/03 - Moved F$SUser to OS9P1 (WG) | |
28 * 93/09/08 - Moved F$SUser back to OS9P2 for room in OS9P1 (LCB) | |
29 * 93/09/10 - F$Find64 (L0A50) - Took out BSR to L0A5C, merged routine | |
30 * in (only called from here), and took out PSHS/PULS D | |
31 * Also modified error structure a bit to shorten it | |
32 * 93/10/06 - Added conditional assembly to skip Network I/O ptrs since | |
33 * Coco network never released by Tandy/Microware (in F$Fork) | |
34 * - @ GotNProc (in F$Fork), saved 1 byte/cycle when inheriting | |
35 * User # & priority | |
36 * - Changed routine @ L01FB to use U instead of Y (slightly | |
37 * smaller & slightly faster), and also used CLRB with STB | |
38 * instead of CLR for clearing DAT block #'s (F$UnLink) | |
39 * 93/12/17 - Moved F$CRCMod code here to give some room in OS9P1 | |
40 * 94/05/15 - Attempted opts in Unlink: Changed usage of W to D @ L0185 | |
1239 | 41 * and L0198 and L01B5, also optimized L017C to eliminate a |
1145 | 42 * branch (speeds up module dir search by 3 cycles/module |
43 * checked) | |
44 * - Changed BRA L032F @ L02EC (AllProc error) to RTS | |
45 * - Changed BRA L0629 @ L05DF to RTS | |
46 * - Changed L066A & L067B from BRA L06F4 to PULS CC,A,Y,U,PC | |
47 * (F$Send errors) | |
48 * - Changed L0A2B from BRA L0A4F to RTS (F$UnLoad error) | |
49 * - Changed L0C53 & L0C81 BRA L0C93 to CLRB/RTS (F$GCMDir) | |
50 * -- Alan DeKok | |
51 * 94/10/28 - added boot debug calls | |
52 * - Changed code at ~L0D47 to allow F$Fork/F$Chain of Obj6309 | |
53 * 94/10/30 - Added error checking on F$Fork of CC3Go | |
54 * - Minor mods to F$SSWI call | |
55 * - Minor mods to F$STime | |
56 * - Changed F$GModDr to BRA to similar code in F$GBlkMp | |
57 * | |
1251
411c88ed62f6
Fixed bug in os9p1, now boots in Level Two! Also inc'ed rev (and in os9p2)
boisy
parents:
1250
diff
changeset
|
58 * 18r6 Back-ported to OS-9 Level Two from NitrOS-9 Level Two |
1145 | 59 |
1587
5f18094d961d
kernel modules renamed to krn, updated makefiles, clock2_tc3 now clock2_cloud9...
boisy
parents:
1482
diff
changeset
|
60 nam krnp2 |
1378 | 61 ttl NitrOS-9 Level 2 Kernel Part 2 |
1145 | 62 |
63 ** If Network I/O ptrs are disabled, F$Fork runs 72 cycles faster | |
64 Network equ 0 Set to 1 to enable network I/O ptrs | |
65 | |
66 ifp1 | |
67 use defsfile | |
68 endc | |
69 | |
70 TC9 set false "true" use TC-9 6309 trap vector | |
71 Edition equ 18 | |
1251
411c88ed62f6
Fixed bug in os9p1, now boots in Level Two! Also inc'ed rev (and in os9p2)
boisy
parents:
1250
diff
changeset
|
72 Revision equ 6 |
1145 | 73 *DAT.Free equ $333E --- remove this def later |
74 | |
1587
5f18094d961d
kernel modules renamed to krn, updated makefiles, clock2_tc3 now clock2_cloud9...
boisy
parents:
1482
diff
changeset
|
75 mod eom,MName,Systm,ReEnt+Revision,krnp2,$0100 |
1145 | 76 |
1587
5f18094d961d
kernel modules renamed to krn, updated makefiles, clock2_tc3 now clock2_cloud9...
boisy
parents:
1482
diff
changeset
|
77 MName fcs /krnp2/ |
1145 | 78 fcb Edition |
79 | |
80 ifeq TC9-1 | |
81 * Entry: None | |
82 * Exit : Process killed & register dump produced for user | |
83 Trap bitmd #%01000000 illegal instruction? | |
84 bne BadIns yes, go process | |
85 bitmd #%10000000 division by 0? | |
86 bne Div0 yes, go process | |
87 jmp [<D.XSWI] act as if nothing happened | |
88 | |
89 * Process illegal instruction trap | |
90 BadIns bsr SetProc move the register stack here | |
91 | |
92 | |
93 | |
94 | |
95 | |
96 ldb #18 get error code for F$Exit | |
97 bra TrapDone | |
98 * Process division by 0 trap | |
99 Div0 bsr SetProc move the register stack | |
100 | |
101 | |
102 | |
103 | |
104 ldb #45 get error code for F$Exit | |
105 | |
106 * Return to system after the trap | |
107 * Entry: B=Error code | |
108 * U=Pointer to register stack | |
109 TrapDone stb R$B,u save the error code to register stack for F$Exit | |
110 lbra FExit enter F$Exit directly | |
111 | |
112 * Set process to system state & copy register stack for trap processing | |
113 SetProc ldd <D.SysSvc set system call processor to system side | |
114 std <D.XSWI2 | |
115 ldd <D.SysIRQ do the same thing for IRQ's | |
116 std <D.XIRQ | |
117 ldx <D.Proc get current process pointer | |
118 IFNE H6309 | |
119 oim #SysState,P$State,x mark process as system state | |
120 ELSE | |
1239 | 121 ldb P$State,x |
122 orb #SysState | |
123 stb P$State,x | |
1145 | 124 ENDC |
125 * copy register stack to process descriptor | |
126 sts P$SP,x save stack pointer | |
127 leas (P$Stack-R$Size),x point S to register stack destination | |
128 andcc #^IntMasks force interrupts back on | |
129 leau ,s point to destination register stack | |
130 ldb P$Task,x get task # of destination | |
131 ldx P$SP,x get the user/system stack pointer | |
132 pshs b preserve task for a moment | |
133 tfr x,d copy it for easier calcs | |
134 bita #%11100000 offset above block 0? | |
135 beq done yes, no calc needed get out | |
136 anda #%00011111 make it a offset within a block | |
137 tfr d,x copy new offset | |
138 lsra make A an offset into DAT image | |
139 lsra | |
140 lsra | |
141 lsra | |
142 done puls b restore task # | |
143 leax -$6000,x make it a pointer to where I'll map the block | |
144 tfr u,y | |
145 pshs cc,u preserve IRQ status & dest pointer | |
146 ldu <D.TskIPt | |
147 lslb adjust task # to fit table | |
148 ldu b,u get the DAT image pointer | |
149 leau a,u point to the blocks needed | |
150 lda 1,u get 1st block | |
151 ldb 3,u get a second in case of overlap | |
152 orcc #IntMasks shut IRQ's down | |
153 std >$FFA5 map in the blocks | |
154 IFNE H6309 | |
155 ldw #R$Size get size of register stack | |
156 tfm x+,y+ move 'em to process descriptor | |
157 ELSE | |
158 ldb #R$Size | |
159 Uday lda ,x+ | |
160 sta ,y+ | |
161 decb | |
162 bne Uday | |
163 ENDC | |
164 ldx <D.SysDAT get the system DAT image pointer | |
165 lda $0B,x get the original blocks | |
166 ldb $0D,x | |
167 std >$FFA5 map 'em back in | |
168 puls cc,u,pc restore IRQ's, register stack pointer & return | |
169 endc | |
170 | |
1587
5f18094d961d
kernel modules renamed to krn, updated makefiles, clock2_tc3 now clock2_cloud9...
boisy
parents:
1482
diff
changeset
|
171 krnp2 lda #'2 into krnp2 |
1145 | 172 jsr <D.BtBug |
173 | |
174 leay SvcTab,pc install system calls | |
175 os9 F$SSvc | |
176 ifeq TC9-1 | |
177 leax Trap,pc | |
178 stx <D.SWI | |
179 endc | |
180 * Change to default directory | |
181 L003A ldu <D.Init get init module pointer | |
182 ldd SysStr,u get pointer to system device name (usually '/dd') | |
183 beq L004F don't exist, open std device | |
184 leax d,u point to name | |
185 | |
186 lda #'x tried chd'ing | |
187 jsr <D.BtBug | |
188 | |
189 lda #(EXEC.+READ.) get file mode | |
190 os9 I$ChgDir change to it | |
191 bcc L004F went ok, go on | |
192 os9 F$Boot try & load boot file | |
193 bcc L003A go try again | |
194 L004F ldu <D.Init get pointer to init | |
195 ldd <StdStr,u point to default device (usually '/term') | |
196 beq L0077 don't exist go do OS9P3 | |
197 leax d,u point to it | |
198 | |
199 lda #'o tried opening output window | |
200 jsr <D.BtBug | |
201 | |
202 lda #UPDAT. get file mode | |
203 os9 I$Open open path to it | |
204 bcc L0066 went ok, save path # | |
205 os9 F$Boot try & re-boot | |
206 bcc L004F go try again | |
207 bra L009B crash machine | |
208 L0066 ldx <D.Proc get current process pointer | |
209 sta <P$Path,x save stdin path | |
210 os9 I$Dup dupe it | |
211 sta <P$Path+1,x save stdout path | |
212 os9 I$Dup dupe it again | |
213 sta <P$Path+2,x save stderr path | |
214 L0077 leax <L0096,pc point to 'OS9P3' | |
215 lda #Systm get type | |
216 os9 F$Link try & link | |
217 bcs L0083 not there, go on | |
218 jsr ,y execute it | |
219 * Execute module listed in Init module | |
220 L0083 ldu <D.Init get init module pointer | |
221 ldd InitStr,u get offset to name of first module | |
222 leax d,u point to it | |
223 | |
224 lda #'C tried to to CC3Go | |
225 jsr <D.BtBug | |
226 | |
227 lda #Objct get module type | |
228 clrb get mem size | |
229 IFNE H6309 | |
230 tfr 0,y Get parameter size | |
231 ELSE | |
232 ldy #$0000 | |
233 ENDC | |
234 os9 F$Fork fork it | |
1241 | 235 bcc L0093 if no error, go execute it |
1258 | 236 * jmp <D.Crash otherwise crash the system |
237 bra L009B crash machine | |
1145 | 238 L0093 os9 F$NProc let it take over |
239 | |
1587
5f18094d961d
kernel modules renamed to krn, updated makefiles, clock2_tc3 now clock2_cloud9...
boisy
parents:
1482
diff
changeset
|
240 L0096 fcs /krnp3/ |
1145 | 241 |
242 L009B jmp <D.Crash | |
243 | |
244 svctab fcb F$UnLink | |
245 fdb FUnLink-*-2 | |
246 fcb F$Fork | |
247 fdb FFork-*-2 | |
248 fcb F$Wait | |
249 fdb FWait-*-2 | |
250 fcb F$Chain | |
251 fdb FChain-*-2 | |
252 fcb F$Exit | |
253 fdb FExit-*-2 | |
254 fcb F$Mem | |
255 fdb FMem-*-2 | |
256 fcb F$Send | |
257 fdb FSend-*-2 | |
258 fcb F$Icpt | |
259 fdb FIcpt-*-2 | |
260 fcb F$Sleep | |
261 fdb FSleep-*-2 | |
262 fcb F$SPrior | |
263 fdb FSPrior-*-2 | |
264 fcb F$ID | |
265 fdb FID-*-2 | |
266 fcb F$SSWI | |
267 fdb FSSWI-*-2 | |
268 fcb F$STime | |
269 fdb FSTime-*-2 | |
270 fcb F$SchBit | |
271 fdb FSchBit-*-2 | |
1258 | 272 fcb F$SchBit+SysState |
1145 | 273 fdb FSSchBit-*-2 |
274 fcb F$AllBit | |
275 fdb FAllBit-*-2 | |
1258 | 276 fcb F$AllBit+SysState |
1145 | 277 fdb FSAllBit-*-2 |
278 fcb F$DelBit | |
279 fdb FDelBit-*-2 | |
1258 | 280 fcb F$DelBit+SysState |
1145 | 281 fdb FSDelBit-*-2 |
282 fcb F$GPrDsc | |
283 fdb FGPrDsc-*-2 | |
284 fcb F$GBlkMp | |
285 fdb FGBlkMp-*-2 | |
286 fcb F$GModDr | |
287 fdb FGModDr-*-2 | |
1258 | 288 IFEQ H6309 |
1250 | 289 fcb F$CpyMem |
290 fdb FCpyMem-*-2 | |
291 fcb F$DelRAM | |
292 fdb FDelRAM-*-2 | |
293 ENDC | |
1145 | 294 fcb F$SUser Added back here for room in OS9p1 |
295 fdb FSUser-*-2 | |
296 fcb F$UnLoad | |
297 fdb FUnLoad-*-2 | |
298 fcb F$Find64+$80 | |
299 fdb FFind64-*-2 | |
300 fcb F$All64+$80 | |
301 fdb FAll64-*-2 | |
302 fcb F$Ret64+$80 | |
303 fdb FRet64-*-2 | |
304 fcb F$GProcP+$80 | |
305 fdb FGProcP-*-2 | |
306 fcb F$DelImg+$80 | |
307 fdb FDelImg-*-2 | |
308 fcb F$AllPrc+$80 | |
309 fdb FAllPrc-*-2 | |
310 fcb F$DelPrc+$80 | |
311 fdb FDelPrc-*-2 | |
312 fcb F$MapBlk | |
313 fdb FMapBlk-*-2 | |
314 fcb F$ClrBlk | |
315 fdb FClrBlk-*-2 | |
316 fcb F$GCMDir+$80 | |
317 fdb FGCMDir-*-2 | |
318 fcb F$CRCMod new system call to change module CRC calcs on/off | |
319 fdb FCRCMod-*-2 | |
320 fcb $7f | |
321 fdb GetIOMan-*-2 | |
322 fcb $80 | |
323 | |
324 use fcrcmod.asm | |
325 | |
326 * Link & execute IOMan | |
327 * Entry: None | |
328 * Exit : I/O handling installed & ready for use | |
329 GetIOMan pshs d,x,y,u preserve regs | |
330 bsr LnkIOMan link to ioman | |
331 bcc GotIOMan no errors, go on | |
332 os9 F$Boot re-load boot file | |
333 bcs IOManErr error loading, return | |
334 bsr LnkIOMan link to ioman | |
335 bcs IOManErr error, save it & return | |
336 GotIOMan jsr ,y execute IOMan's init routine | |
337 puls d,x,y,u restore registers | |
338 jmp [IOEntry,y] Execute I/O vector | |
339 | |
340 IOManErr stb 1,s save error if any | |
341 puls d,x,y,u,pc restore & return | |
342 | |
343 * Link to IOMan | |
344 * Entry: None | |
345 * Exit : U=Pointer to IOMan module header | |
346 * Y=Pointer to IOMan entry point | |
347 LnkIOMan leax <IOMan,pc point to name | |
348 lda #(Systm+Objct) get type | |
349 os9 F$Link link it | |
350 rts return | |
351 | |
352 IOMan fcs /IOMan/ | |
353 | |
354 use funlink.asm | |
355 | |
356 use ffork.asm | |
357 | |
358 use fallprc.asm | |
359 | |
360 use fchain.asm | |
361 | |
362 use fexit.asm | |
363 | |
364 use fmem.asm | |
365 | |
366 use fsend.asm | |
367 | |
368 use ficpt.asm | |
369 | |
370 use fsleep.asm | |
371 | |
372 use fsprior.asm | |
373 | |
374 use fid.asm | |
375 | |
1363 | 376 IFEQ H6309 |
1250 | 377 use fcpymem.asm |
378 | |
379 use fdelram.asm | |
380 ENDC | |
381 | |
1145 | 382 use fsswi.asm |
383 | |
384 use fstime.asm | |
385 | |
386 use fallbit.asm | |
387 | |
388 use fgprdsc.asm | |
389 | |
390 use fgblkmp.asm | |
391 | |
392 use fgmoddr.asm | |
393 | |
394 use fsuser.asm | |
395 | |
396 use funload.asm | |
397 | |
398 use ffind64.asm | |
399 | |
400 use fgprocp.asm | |
401 | |
402 use fdelimg.asm | |
403 | |
404 use fmapblk.asm | |
405 | |
406 use fclrblk.asm | |
407 | |
408 use fgcmdir.asm | |
409 | |
410 emod | |
411 eom equ * | |
412 end | |
413 |