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