Mercurial > hg > Members > kono > nitros9-code
annotate level2/modules/kernel/falltsk.asm @ 1345:1da8ab9ba433
Added consistent comments to each system call
author | boisy |
---|---|
date | Wed, 17 Sep 2003 17:26:37 +0000 |
parents | c90c8b615f8c |
children | 039ddb7c8ad7 |
rev | line source |
---|---|
1345 | 1 ************************************************** |
2 * System Call: F$AllTsk | |
3 * | |
4 * Function: Allocate process task number | |
5 * | |
6 * Input: X = Process descriptor pointer | |
7 * | |
8 * Output: None | |
9 * | |
10 * Error: CC = C bit set; B = error code | |
11 * | |
1145 | 12 FAllTsk ldx R$X,u get pointer to process descriptor |
13 L0C58 ldb P$Task,x already have a task #? | |
14 bne L0C64 yes, return | |
15 bsr L0CA6 find a free task | |
16 bcs L0C65 error, couldn't get one, return | |
17 stb P$Task,x save task # | |
18 bsr L0C79 load MMU with task | |
19 L0C64 clrb clear errors | |
20 L0C65 rts return | |
21 | |
1345 | 22 |
23 ************************************************** | |
24 * System Call: F$DelTsk | |
25 * | |
26 * Function: Deallocate process task number | |
27 * | |
28 * Input: X = Process descriptor pointer | |
29 * | |
30 * Output: None | |
31 * | |
32 * Error: CC = C bit set; B = error code | |
33 * | |
1145 | 34 FDelTsk ldx R$X,u |
35 L0C68 ldb P$Task,x grab the current task number | |
36 beq L0C64 if system (or released), exit | |
37 clr P$Task,x force the task number to be zero | |
38 bra L0CC3 do a F$RelTsk | |
39 | |
40 TstImg equ * | |
41 IFNE H6309 | |
42 tim #ImgChg,P$State,x | |
43 ELSE | |
1246
c90c8b615f8c
Changed register usage from A to B, removed pshs/puls
boisy
parents:
1241
diff
changeset
|
44 * pshs b |
c90c8b615f8c
Changed register usage from A to B, removed pshs/puls
boisy
parents:
1241
diff
changeset
|
45 ldb P$State,x |
c90c8b615f8c
Changed register usage from A to B, removed pshs/puls
boisy
parents:
1241
diff
changeset
|
46 bitb #ImgChg |
c90c8b615f8c
Changed register usage from A to B, removed pshs/puls
boisy
parents:
1241
diff
changeset
|
47 * puls b |
1145 | 48 ENDC |
49 beq L0C65 if not, exit now: don't clear carry, it's not needed | |
50 fcb $8C skip LDX, below | |
51 | |
1345 | 52 |
53 ************************************************** | |
54 * System Call: F$SetTsk | |
55 * | |
56 * Function: Set process task DAT registers | |
57 * | |
58 * Input: X = Process descriptor pointer | |
59 * | |
60 * Output: None | |
61 * | |
62 * Error: CC = C bit set; B = error code | |
63 * | |
1145 | 64 FSetTsk ldx R$X,u get process descriptor pointer |
65 L0C79 equ * | |
66 IFNE H6309 | |
67 aim #^ImgChg,P$State,x flag DAT image change in process descriptor | |
68 ELSE | |
1246
c90c8b615f8c
Changed register usage from A to B, removed pshs/puls
boisy
parents:
1241
diff
changeset
|
69 * pshs b |
c90c8b615f8c
Changed register usage from A to B, removed pshs/puls
boisy
parents:
1241
diff
changeset
|
70 ldb P$State,x |
c90c8b615f8c
Changed register usage from A to B, removed pshs/puls
boisy
parents:
1241
diff
changeset
|
71 andb #^ImgChg |
c90c8b615f8c
Changed register usage from A to B, removed pshs/puls
boisy
parents:
1241
diff
changeset
|
72 stb P$State,x |
c90c8b615f8c
Changed register usage from A to B, removed pshs/puls
boisy
parents:
1241
diff
changeset
|
73 * puls b |
1145 | 74 ENDC |
75 clr <D.Task1N task 1 DAT image has changed | |
76 andcc #^Carry clear carry | |
77 pshs cc,d,x,u preserve everything | |
78 ldb P$Task,x get task # | |
79 leau <P$DATImg,x point to DAT image | |
80 ldx <D.TskIPt get task image table pointer | |
81 lslb account for 2 bytes/entry | |
82 stu b,x save DAT image pointer in task table | |
83 cmpb #2 is it either system or GrfDrv? | |
84 bhi L0C9F no, return | |
1241 | 85 ldx #DAT.Regs update system DAT image |
1145 | 86 lbsr L0E93 go bash the hardware |
87 L0C9F puls cc,d,x,u,pc | |
88 | |
1345 | 89 |
90 ************************************************** | |
91 * System Call: F$ResTsk | |
92 * | |
93 * Function: Reserve task number | |
94 * | |
95 * Input: None | |
96 * | |
97 * Output: B = Task number | |
98 * | |
99 * Error: CC = C bit set; B = error code | |
100 * | |
1145 | 101 FResTsk bsr L0CA6 |
102 stb R$B,u | |
103 L0CA5 rts | |
104 | |
1345 | 105 |
1145 | 106 * Find a free task in task map |
107 * Entry: None | |
108 * Exit : B=Task # | |
109 L0CA6 pshs x preserve X | |
110 ldb #$02 get starting task # (skip System/Grfdrv) | |
111 ldx <D.Tasks get task table pointer | |
112 L0CAC lda b,x task allocated? | |
113 beq L0CBA no, allocate it & return | |
114 incb move to next task | |
115 cmpb #$20 end of task list? | |
116 bne L0CAC no, keep looking | |
117 comb set carry for error | |
118 ldb #E$NoTask get error code | |
119 puls x,pc | |
120 | |
121 L0CBA stb b,x flag task used (1 cycle faster than inc) | |
122 * orb <D.SysTsk merge in system task # ??? always 0 | |
123 clra clear carry | |
124 L0CBF puls x,pc restore & return | |
125 | |
1345 | 126 |
127 ************************************************** | |
128 * System Call: F$RelTsk | |
129 * | |
130 * Function: Release task number | |
131 * | |
132 * Input: B = Task number | |
133 * | |
134 * Output: None | |
135 * | |
136 * Error: CC = C bit set; B = error code | |
137 * | |
1145 | 138 FRelTsk ldb R$B,u Get task # to release |
139 L0CC3 pshs b,x Preserve it & X | |
140 * ??? No idea why this stuff is done. D.SysTsk is ALWAYS 0. | |
141 * Even GrfDrv never changes it. | |
142 * ldb <D.SysTsk Get system task # | |
143 * comb Invert it | |
144 * andb ,s Mask with requested task | |
145 tstb check out B | |
146 beq L0CD0 If system task, don't bother deleting the task | |
147 ldx <D.Tasks Get task table ptr | |
148 clr b,x Clear out the task | |
149 L0CD0 puls b,x,pc Restore regs & return | |
150 | |
151 * Sleeping process update (Gets executed from clock) | |
152 * Could move this code into Clock, but what about the call to F$AProc (L0D11)? | |
153 * It probably will be OK... but have to check. | |
154 * Possible, move ALL software-clock code into OS9p2, and therefore | |
155 * have it auto-initialize? All hardware clocks would then be called | |
156 * just once a minute. | |
157 L0CD2 ldx <D.SProcQ Get sleeping process Queue ptr | |
158 beq L0CFD None (no one sleeping), so exit | |
159 IFNE H6309 | |
160 tim #TimSleep,P$State,x Is it a timed sleep? | |
161 ELSE | |
162 ldb P$State,x | |
163 bitb #TimSleep | |
164 ENDC | |
165 beq L0CFD No, exit: waiting for signal/interrupt | |
166 ldu P$SP,x Yes, get his stack pointer | |
167 ldd R$X,u Get his sleep tick count | |
168 IFNE H6309 | |
169 decd decrement sleep count | |
170 ELSE | |
171 subd #$0001 | |
172 ENDC | |
173 std R$X,u Save it back | |
174 bne L0CFD Still more ticks to go, so exit | |
175 * Process needs to wake up, update queue pointers | |
176 L0CE7 ldu P$Queue,x Get next process in Queue | |
177 bsr L0D11 activate it | |
178 leax ,u point to new process | |
179 beq L0CFB don't exist, go on | |
180 IFNE H6309 | |
181 tim #TimSleep,P$State,x is it in a timed sleep? | |
182 ELSE | |
183 ldb P$State,x | |
184 bitb #TimSleep | |
185 ENDC | |
186 beq L0CFB no, go update process table | |
187 ldu P$SP,x get it's stack pointer | |
188 ldd R$X,u any sleep time left? | |
189 beq L0CE7 no, go activate next process in queue | |
190 L0CFB stx <D.SProcQ Store new sleeping process pointer | |
191 L0CFD dec <D.Slice Any time remaining on process? | |
192 bne L0D0D Yes, exit | |
193 inc <D.Slice reset slice count | |
194 ldx <D.Proc Get current process pointer | |
195 beq L0D0D none, return | |
196 IFNE H6309 | |
197 oim #TimOut,P$State,x put him in a timeout state | |
198 ELSE | |
199 ldb P$State,x | |
200 orb #TimOut | |
201 stb P$State,x | |
202 ENDC | |
203 L0D0D clrb | |
204 rts |