Mercurial > hg > Members > kono > nitros9-code
comparison level2/modules/kernel/krnp2.asm @ 1145:ca83286ded5b
Start of new OS-9 L2 Kernel
author | boisy |
---|---|
date | Tue, 22 Apr 2003 19:35:48 +0000 |
parents | |
children | 90bad6d8388c |
comparison
equal
deleted
inserted
replaced
1144:2cdb7acff8aa | 1145:ca83286ded5b |
---|---|
1 ******************************************************************** | |
2 * OS9p2 - NitrOS-9 Kernel Part II | |
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) | |
21 * NitrOS9 V1.09 - Move & optomized F$CpyMem to OS9P1 | |
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 | |
41 * and L0198 and L01B5, also optomized L017C to eliminate a | |
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 * | |
58 | |
59 nam OS9p2 | |
60 ttl NitrOS-9 Kernel Part II | |
61 | |
62 ** If Network I/O ptrs are disabled, F$Fork runs 72 cycles faster | |
63 Network equ 0 Set to 1 to enable network I/O ptrs | |
64 | |
65 ifp1 | |
66 use defsfile | |
67 endc | |
68 | |
69 TC9 set false "true" use TC-9 6309 trap vector | |
70 Edition equ 18 | |
71 Revision equ 5 | |
72 *DAT.Free equ $333E --- remove this def later | |
73 | |
74 mod eom,MName,Systm,ReEnt+Revision,OS9P2,$0100 | |
75 | |
76 MName fcs /OS9p2/ | |
77 fcb Edition | |
78 | |
79 ifeq TC9-1 | |
80 * Entry: None | |
81 * Exit : Process killed & register dump produced for user | |
82 Trap bitmd #%01000000 illegal instruction? | |
83 bne BadIns yes, go process | |
84 bitmd #%10000000 division by 0? | |
85 bne Div0 yes, go process | |
86 jmp [<D.XSWI] act as if nothing happened | |
87 | |
88 * Process illegal instruction trap | |
89 BadIns bsr SetProc move the register stack here | |
90 | |
91 | |
92 | |
93 | |
94 | |
95 ldb #18 get error code for F$Exit | |
96 bra TrapDone | |
97 * Process division by 0 trap | |
98 Div0 bsr SetProc move the register stack | |
99 | |
100 | |
101 | |
102 | |
103 ldb #45 get error code for F$Exit | |
104 | |
105 * Return to system after the trap | |
106 * Entry: B=Error code | |
107 * U=Pointer to register stack | |
108 TrapDone stb R$B,u save the error code to register stack for F$Exit | |
109 lbra FExit enter F$Exit directly | |
110 | |
111 * Set process to system state & copy register stack for trap processing | |
112 SetProc ldd <D.SysSvc set system call processor to system side | |
113 std <D.XSWI2 | |
114 ldd <D.SysIRQ do the same thing for IRQ's | |
115 std <D.XIRQ | |
116 ldx <D.Proc get current process pointer | |
117 IFNE H6309 | |
118 oim #SysState,P$State,x mark process as system state | |
119 ELSE | |
120 ENDC | |
121 * copy register stack to process descriptor | |
122 sts P$SP,x save stack pointer | |
123 leas (P$Stack-R$Size),x point S to register stack destination | |
124 andcc #^IntMasks force interrupts back on | |
125 leau ,s point to destination register stack | |
126 ldb P$Task,x get task # of destination | |
127 ldx P$SP,x get the user/system stack pointer | |
128 pshs b preserve task for a moment | |
129 tfr x,d copy it for easier calcs | |
130 bita #%11100000 offset above block 0? | |
131 beq done yes, no calc needed get out | |
132 anda #%00011111 make it a offset within a block | |
133 tfr d,x copy new offset | |
134 lsra make A an offset into DAT image | |
135 lsra | |
136 lsra | |
137 lsra | |
138 done puls b restore task # | |
139 leax -$6000,x make it a pointer to where I'll map the block | |
140 tfr u,y | |
141 pshs cc,u preserve IRQ status & dest pointer | |
142 ldu <D.TskIPt | |
143 lslb adjust task # to fit table | |
144 ldu b,u get the DAT image pointer | |
145 leau a,u point to the blocks needed | |
146 lda 1,u get 1st block | |
147 ldb 3,u get a second in case of overlap | |
148 orcc #IntMasks shut IRQ's down | |
149 std >$FFA5 map in the blocks | |
150 IFNE H6309 | |
151 ldw #R$Size get size of register stack | |
152 tfm x+,y+ move 'em to process descriptor | |
153 ELSE | |
154 ldb #R$Size | |
155 Uday lda ,x+ | |
156 sta ,y+ | |
157 decb | |
158 bne Uday | |
159 ENDC | |
160 ldx <D.SysDAT get the system DAT image pointer | |
161 lda $0B,x get the original blocks | |
162 ldb $0D,x | |
163 std >$FFA5 map 'em back in | |
164 puls cc,u,pc restore IRQ's, register stack pointer & return | |
165 endc | |
166 | |
167 OS9P2 lda #'2 into OS9p2 | |
168 jsr <D.BtBug | |
169 | |
170 leay SvcTab,pc install system calls | |
171 os9 F$SSvc | |
172 ifeq TC9-1 | |
173 leax Trap,pc | |
174 stx <D.SWI | |
175 endc | |
176 * Change to default directory | |
177 L003A ldu <D.Init get init module pointer | |
178 ldd SysStr,u get pointer to system device name (usually '/dd') | |
179 beq L004F don't exist, open std device | |
180 leax d,u point to name | |
181 | |
182 lda #'x tried chd'ing | |
183 jsr <D.BtBug | |
184 | |
185 lda #(EXEC.+READ.) get file mode | |
186 os9 I$ChgDir change to it | |
187 bcc L004F went ok, go on | |
188 os9 F$Boot try & load boot file | |
189 bcc L003A go try again | |
190 L004F ldu <D.Init get pointer to init | |
191 ldd <StdStr,u point to default device (usually '/term') | |
192 beq L0077 don't exist go do OS9P3 | |
193 leax d,u point to it | |
194 | |
195 lda #'o tried opening output window | |
196 jsr <D.BtBug | |
197 | |
198 lda #UPDAT. get file mode | |
199 os9 I$Open open path to it | |
200 bcc L0066 went ok, save path # | |
201 os9 F$Boot try & re-boot | |
202 bcc L004F go try again | |
203 bra L009B crash machine | |
204 L0066 ldx <D.Proc get current process pointer | |
205 sta <P$Path,x save stdin path | |
206 os9 I$Dup dupe it | |
207 sta <P$Path+1,x save stdout path | |
208 os9 I$Dup dupe it again | |
209 sta <P$Path+2,x save stderr path | |
210 L0077 leax <L0096,pc point to 'OS9P3' | |
211 lda #Systm get type | |
212 os9 F$Link try & link | |
213 bcs L0083 not there, go on | |
214 jsr ,y execute it | |
215 * Execute module listed in Init module | |
216 L0083 ldu <D.Init get init module pointer | |
217 ldd InitStr,u get offset to name of first module | |
218 leax d,u point to it | |
219 | |
220 lda #'C tried to to CC3Go | |
221 jsr <D.BtBug | |
222 | |
223 lda #Objct get module type | |
224 clrb get mem size | |
225 IFNE H6309 | |
226 tfr 0,y Get parameter size | |
227 ELSE | |
228 ldy #$0000 | |
229 ENDC | |
230 os9 F$Fork fork it | |
231 bcc L0093 if no error, go execute it | |
232 jmp <D.Crash otherwise crash the system | |
233 L0093 os9 F$NProc let it take over | |
234 | |
235 L0096 fcs /OS9p3/ | |
236 | |
237 L009B jmp <D.Crash | |
238 | |
239 svctab fcb F$UnLink | |
240 fdb FUnLink-*-2 | |
241 fcb F$Fork | |
242 fdb FFork-*-2 | |
243 fcb F$Wait | |
244 fdb FWait-*-2 | |
245 fcb F$Chain | |
246 fdb FChain-*-2 | |
247 fcb F$Exit | |
248 fdb FExit-*-2 | |
249 fcb F$Mem | |
250 fdb FMem-*-2 | |
251 fcb F$Send | |
252 fdb FSend-*-2 | |
253 fcb F$Icpt | |
254 fdb FIcpt-*-2 | |
255 fcb F$Sleep | |
256 fdb FSleep-*-2 | |
257 fcb F$SPrior | |
258 fdb FSPrior-*-2 | |
259 fcb F$ID | |
260 fdb FID-*-2 | |
261 fcb F$SSWI | |
262 fdb FSSWI-*-2 | |
263 fcb F$STime | |
264 fdb FSTime-*-2 | |
265 fcb F$SchBit | |
266 fdb FSchBit-*-2 | |
267 fcb F$SchBit+$80 | |
268 fdb FSSchBit-*-2 | |
269 fcb F$AllBit | |
270 fdb FAllBit-*-2 | |
271 fcb F$AllBit+$80 | |
272 fdb FSAllBit-*-2 | |
273 fcb F$DelBit | |
274 fdb FDelBit-*-2 | |
275 fcb F$DelBit+$80 | |
276 fdb FSDelBit-*-2 | |
277 fcb F$GPrDsc | |
278 fdb FGPrDsc-*-2 | |
279 fcb F$GBlkMp | |
280 fdb FGBlkMp-*-2 | |
281 fcb F$GModDr | |
282 fdb FGModDr-*-2 | |
283 fcb F$SUser Added back here for room in OS9p1 | |
284 fdb FSUser-*-2 | |
285 fcb F$UnLoad | |
286 fdb FUnLoad-*-2 | |
287 fcb F$Find64+$80 | |
288 fdb FFind64-*-2 | |
289 fcb F$All64+$80 | |
290 fdb FAll64-*-2 | |
291 fcb F$Ret64+$80 | |
292 fdb FRet64-*-2 | |
293 fcb F$GProcP+$80 | |
294 fdb FGProcP-*-2 | |
295 fcb F$DelImg+$80 | |
296 fdb FDelImg-*-2 | |
297 fcb F$AllPrc+$80 | |
298 fdb FAllPrc-*-2 | |
299 fcb F$DelPrc+$80 | |
300 fdb FDelPrc-*-2 | |
301 fcb F$MapBlk | |
302 fdb FMapBlk-*-2 | |
303 fcb F$ClrBlk | |
304 fdb FClrBlk-*-2 | |
305 fcb F$GCMDir+$80 | |
306 fdb FGCMDir-*-2 | |
307 fcb F$CRCMod new system call to change module CRC calcs on/off | |
308 fdb FCRCMod-*-2 | |
309 fcb $7f | |
310 fdb GetIOMan-*-2 | |
311 fcb $80 | |
312 | |
313 use fcrcmod.asm | |
314 | |
315 * Link & execute IOMan | |
316 * Entry: None | |
317 * Exit : I/O handling installed & ready for use | |
318 GetIOMan pshs d,x,y,u preserve regs | |
319 bsr LnkIOMan link to ioman | |
320 bcc GotIOMan no errors, go on | |
321 os9 F$Boot re-load boot file | |
322 bcs IOManErr error loading, return | |
323 bsr LnkIOMan link to ioman | |
324 bcs IOManErr error, save it & return | |
325 GotIOMan jsr ,y execute IOMan's init routine | |
326 puls d,x,y,u restore registers | |
327 jmp [IOEntry,y] Execute I/O vector | |
328 | |
329 IOManErr stb 1,s save error if any | |
330 puls d,x,y,u,pc restore & return | |
331 | |
332 * Link to IOMan | |
333 * Entry: None | |
334 * Exit : U=Pointer to IOMan module header | |
335 * Y=Pointer to IOMan entry point | |
336 LnkIOMan leax <IOMan,pc point to name | |
337 lda #(Systm+Objct) get type | |
338 os9 F$Link link it | |
339 rts return | |
340 | |
341 IOMan fcs /IOMan/ | |
342 | |
343 use funlink.asm | |
344 | |
345 use ffork.asm | |
346 | |
347 use fallprc.asm | |
348 | |
349 use fchain.asm | |
350 | |
351 use fexit.asm | |
352 | |
353 use fmem.asm | |
354 | |
355 use fsend.asm | |
356 | |
357 use ficpt.asm | |
358 | |
359 use fsleep.asm | |
360 | |
361 use fsprior.asm | |
362 | |
363 use fid.asm | |
364 | |
365 use fsswi.asm | |
366 | |
367 use fstime.asm | |
368 | |
369 use fallbit.asm | |
370 | |
371 use fgprdsc.asm | |
372 | |
373 use fgblkmp.asm | |
374 | |
375 use fgmoddr.asm | |
376 | |
377 use fsuser.asm | |
378 | |
379 use funload.asm | |
380 | |
381 use ffind64.asm | |
382 | |
383 use fgprocp.asm | |
384 | |
385 use fdelimg.asm | |
386 | |
387 use fmapblk.asm | |
388 | |
389 use fclrblk.asm | |
390 | |
391 use fgcmdir.asm | |
392 | |
393 emod | |
394 eom equ * | |
395 end | |
396 |