Mercurial > hg > Members > kono > nitros9-code
annotate level2/modules/kernel/fnproc.asm @ 2639:283433fa565c
Added notes to atari.d
author | Boisy Pitre <boisy.pitre@nuance.com> |
---|---|
date | Tue, 28 Feb 2012 09:26:09 -0600 |
parents | 530759e9f289 |
children | ead54d2c06d4 |
rev | line source |
---|---|
1145 | 1 ************************************************** |
2 * System Call: F$NProc | |
3 * | |
4 * Function: Start the next process in the active queue | |
5 * | |
6 * Input: None | |
7 * | |
8 * Output: Control does not return to the caller | |
9 * | |
1387 | 10 FNProc |
11 IFGT Level-1 | |
12 ldx <D.SysPrc get system process descriptor | |
1145 | 13 stx <D.Proc save it as current |
14 lds <D.SysStk get system stack pointer | |
15 andcc #^IntMasks re-enable IRQ's (to allow pending one through) | |
1387 | 16 ELSE |
17 clra | |
18 clrb | |
19 std <D.Proc | |
20 ENDC | |
1145 | 21 fcb $8C skip the next 2 bytes |
22 | |
23 L0D91 cwai #^IntMasks re-enable IRQ's and wait for one | |
24 L0D93 orcc #IntMasks Shut off interrupts again | |
25 lda #Suspend get suspend suspend state flag | |
26 ldx #D.AProcQ-P$Queue For start of loop, setup to point to current process | |
27 | |
28 * Loop to find next active process that is not Suspended | |
29 L0D9A leay ,x Point y to previous link (process dsc. ptr) | |
30 ldx P$Queue,y Get process dsc. ptr for next active process | |
31 beq L0D91 None, allow any pending IRQ thru & try again | |
32 bita P$State,x There is one, is it Suspended? | |
33 bne L0D9A Yes, skip it & try next one | |
34 | |
35 * Found a process in line ready to be started | |
36 ldd P$Queue,x Get next process dsc. ptr in line after found one | |
37 std P$Queue,y Save the next one in line in previous' next ptr | |
38 stx <D.Proc Make new process dsc. the current one | |
39 lbsr L0C58 Go check or make a task # for the found process | |
40 bcs L0D83 Couldn't get one, go to next process in line | |
41 lda <D.TSlice Reload # ticks this process can run | |
42 sta <D.Slice Save as new tick counter for process | |
43 ldu P$SP,x get the process stack pointer | |
44 lda P$State,x get it's state | |
45 lbmi L0E29 If in System State, switch to system task (0) | |
46 L0DB9 bita #Condem Was it condemned by a deadly signal? | |
47 bne L0DFD Yes, go exit with Error=the signal code # | |
48 lbsr TstImg do a F$SetTsk if the ImgChg flag is set | |
49 L0DBD ldb <P$Signal,x any signals? | |
50 beq L0DF7 no, go on | |
51 decb is it a wake up signal? | |
52 beq L0DEF yes, go wake it up | |
53 leas -R$Size,s make a register buffer on stack | |
54 leau ,s point to it | |
55 lbsr L02CB copy the stack from process to our copy of it | |
56 lda <P$Signal,x get last signal | |
57 sta R$B,u save it to process' B | |
58 | |
59 ldd <P$SigVec,x any intercept trap? | |
60 beq L0DFD no, go force the process to F$Exit | |
61 std R$PC,u save vector to it's PC | |
62 ldd <P$SigDat,x get pointer to intercept data area | |
63 std R$U,u save it to it's U | |
64 ldd P$SP,x get it's stack pointer | |
65 subd #R$Size take off register stack | |
66 std P$SP,x save updated SP | |
67 lbsr L02DA Copy modified stack back overtop process' stack | |
68 leas R$Size,s purge temporary stack | |
69 L0DEF clr <P$Signal,x clear the signal | |
70 | |
71 * No signals go here | |
72 L0DF7 equ * | |
73 IFNE H6309 | |
74 oim #$01,<D.Quick | |
75 ELSE | |
76 ldb <D.Quick | |
77 orb #$01 | |
78 stb <D.Quick | |
79 ENDC | |
80 BackTo1 equ * | |
81 L0DF2 ldu <D.UsrSvc Get current User's system call service routine ptr | |
82 stu <D.XSWI2 Save as SWI2 service routine ptr | |
83 ldu <D.UsrIRQ Get IRQ entry point for user state | |
84 stu <D.XIRQ Save as IRQ service routine ptr | |
85 | |
86 ldb P$Task,x get task number | |
87 lslb 2 bytes per entry in D.TskIpt | |
88 ldy P$SP,x get stack pointer | |
89 lbsr L0E8D re-map the DAT image, if necessary | |
90 | |
91 ldb <D.Quick get quick return flag | |
2615
530759e9f289
Added ccbkrn from Brett Gordon (level 2 only for now)
Boisy Pitre <boisy.pitre@nuance.com>
parents:
1387
diff
changeset
|
92 lbra L0E4C Go switch GIME over to new process & run |
1145 | 93 |
94 * Process a signal (process had no signal trap) | |
95 L0DFD equ * | |
96 IFNE H6309 | |
97 oim #SysState,P$State,x Put process into system state | |
98 ELSE | |
99 ldb P$State,x | |
100 orb #SysState | |
101 stb P$State,x | |
102 ENDC | |
103 leas >P$Stack,x Point SP to process' stack | |
104 andcc #^IntMasks Turn interrupts on | |
105 ldb <P$Signal,x Get signal that process received | |
106 clr <P$Signal,x Clear out the one in process dsc. | |
107 os9 F$Exit Exit with signal # being error code | |
108 | |
1239 | 109 S.SvcIRQ jmp [>D.Poll] Call IOMAN for IRQ polling |