1145
|
1 * F$AllTsk entry point
|
|
2 FAllTsk ldx R$X,u get pointer to process descriptor
|
|
3 L0C58 ldb P$Task,x already have a task #?
|
|
4 bne L0C64 yes, return
|
|
5 bsr L0CA6 find a free task
|
|
6 bcs L0C65 error, couldn't get one, return
|
|
7 stb P$Task,x save task #
|
|
8 bsr L0C79 load MMU with task
|
|
9 L0C64 clrb clear errors
|
|
10 L0C65 rts return
|
|
11
|
|
12 * F$DelTsk entry point
|
|
13 FDelTsk ldx R$X,u
|
|
14 L0C68 ldb P$Task,x grab the current task number
|
|
15 beq L0C64 if system (or released), exit
|
|
16 clr P$Task,x force the task number to be zero
|
|
17 bra L0CC3 do a F$RelTsk
|
|
18
|
|
19 TstImg equ *
|
|
20 IFNE H6309
|
|
21 tim #ImgChg,P$State,x
|
|
22 ELSE
|
|
23 pshs a
|
|
24 lda P$State,x
|
|
25 bita #ImgChg
|
|
26 puls a
|
|
27 ENDC
|
|
28 beq L0C65 if not, exit now: don't clear carry, it's not needed
|
|
29 fcb $8C skip LDX, below
|
|
30
|
|
31 * F$SetTsk entry point
|
|
32 FSetTsk ldx R$X,u get process descriptor pointer
|
|
33 L0C79 equ *
|
|
34 IFNE H6309
|
|
35 aim #^ImgChg,P$State,x flag DAT image change in process descriptor
|
|
36 ELSE
|
1239
|
37 pshs a
|
1145
|
38 lda P$State,x
|
|
39 anda #^ImgChg
|
|
40 sta P$State,x
|
1239
|
41 puls a
|
1145
|
42 ENDC
|
|
43 clr <D.Task1N task 1 DAT image has changed
|
|
44 andcc #^Carry clear carry
|
|
45 pshs cc,d,x,u preserve everything
|
|
46 ldb P$Task,x get task #
|
|
47 leau <P$DATImg,x point to DAT image
|
|
48 ldx <D.TskIPt get task image table pointer
|
|
49 lslb account for 2 bytes/entry
|
|
50 stu b,x save DAT image pointer in task table
|
|
51 cmpb #2 is it either system or GrfDrv?
|
|
52 bhi L0C9F no, return
|
|
53 ldx #$FFA0 update system DAT image
|
|
54 lbsr L0E93 go bash the hardware
|
|
55 L0C9F puls cc,d,x,u,pc
|
|
56
|
|
57 * F$ResTsk entry point
|
|
58 FResTsk bsr L0CA6
|
|
59 stb R$B,u
|
|
60 L0CA5 rts
|
|
61
|
|
62 * Find a free task in task map
|
|
63 * Entry: None
|
|
64 * Exit : B=Task #
|
|
65 L0CA6 pshs x preserve X
|
|
66 ldb #$02 get starting task # (skip System/Grfdrv)
|
|
67 ldx <D.Tasks get task table pointer
|
|
68 L0CAC lda b,x task allocated?
|
|
69 beq L0CBA no, allocate it & return
|
|
70 incb move to next task
|
|
71 cmpb #$20 end of task list?
|
|
72 bne L0CAC no, keep looking
|
|
73 comb set carry for error
|
|
74 ldb #E$NoTask get error code
|
|
75 puls x,pc
|
|
76
|
|
77 L0CBA stb b,x flag task used (1 cycle faster than inc)
|
|
78 * orb <D.SysTsk merge in system task # ??? always 0
|
|
79 clra clear carry
|
|
80 L0CBF puls x,pc restore & return
|
|
81
|
|
82 * F$RelTsk entry point
|
|
83 * no idea why B and X are saved.
|
|
84 FRelTsk ldb R$B,u Get task # to release
|
|
85 L0CC3 pshs b,x Preserve it & X
|
|
86 * ??? No idea why this stuff is done. D.SysTsk is ALWAYS 0.
|
|
87 * Even GrfDrv never changes it.
|
|
88 * ldb <D.SysTsk Get system task #
|
|
89 * comb Invert it
|
|
90 * andb ,s Mask with requested task
|
|
91 tstb check out B
|
|
92 beq L0CD0 If system task, don't bother deleting the task
|
|
93 ldx <D.Tasks Get task table ptr
|
|
94 clr b,x Clear out the task
|
|
95 L0CD0 puls b,x,pc Restore regs & return
|
|
96
|
|
97 * Sleeping process update (Gets executed from clock)
|
|
98 * Could move this code into Clock, but what about the call to F$AProc (L0D11)?
|
|
99 * It probably will be OK... but have to check.
|
|
100 * Possible, move ALL software-clock code into OS9p2, and therefore
|
|
101 * have it auto-initialize? All hardware clocks would then be called
|
|
102 * just once a minute.
|
|
103 L0CD2 ldx <D.SProcQ Get sleeping process Queue ptr
|
|
104 beq L0CFD None (no one sleeping), so exit
|
|
105 IFNE H6309
|
|
106 tim #TimSleep,P$State,x Is it a timed sleep?
|
|
107 ELSE
|
|
108 ldb P$State,x
|
|
109 bitb #TimSleep
|
|
110 ENDC
|
|
111 beq L0CFD No, exit: waiting for signal/interrupt
|
|
112 ldu P$SP,x Yes, get his stack pointer
|
|
113 ldd R$X,u Get his sleep tick count
|
|
114 IFNE H6309
|
|
115 decd decrement sleep count
|
|
116 ELSE
|
|
117 subd #$0001
|
|
118 ENDC
|
|
119 std R$X,u Save it back
|
|
120 bne L0CFD Still more ticks to go, so exit
|
|
121 * Process needs to wake up, update queue pointers
|
|
122 L0CE7 ldu P$Queue,x Get next process in Queue
|
|
123 bsr L0D11 activate it
|
|
124 leax ,u point to new process
|
|
125 beq L0CFB don't exist, go on
|
|
126 IFNE H6309
|
|
127 tim #TimSleep,P$State,x is it in a timed sleep?
|
|
128 ELSE
|
|
129 ldb P$State,x
|
|
130 bitb #TimSleep
|
|
131 ENDC
|
|
132 beq L0CFB no, go update process table
|
|
133 ldu P$SP,x get it's stack pointer
|
|
134 ldd R$X,u any sleep time left?
|
|
135 beq L0CE7 no, go activate next process in queue
|
|
136 L0CFB stx <D.SProcQ Store new sleeping process pointer
|
|
137 L0CFD dec <D.Slice Any time remaining on process?
|
|
138 bne L0D0D Yes, exit
|
|
139 inc <D.Slice reset slice count
|
|
140 ldx <D.Proc Get current process pointer
|
|
141 beq L0D0D none, return
|
|
142 IFNE H6309
|
|
143 oim #TimOut,P$State,x put him in a timeout state
|
|
144 ELSE
|
|
145 ldb P$State,x
|
|
146 orb #TimOut
|
|
147 stb P$State,x
|
|
148 ENDC
|
|
149 L0D0D clrb
|
|
150 rts
|