annotate level2/modules/kernel/falltsk.asm @ 1145:ca83286ded5b

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