annotate level2/modules/kernel/falltsk.asm @ 1239:90bad6d8388c

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