annotate level2/modules/kernel/fsleep.asm @ 1249:6f0cffb3ab74

Added sbca #0
author boisy
date Sat, 16 Aug 2003 11:22:34 +0000
parents 90bad6d8388c
children 1aae5bde55a0
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 **************************************************
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
2 * System Call: F$Sleep
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
3 *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
4 * Function: Put the calling process to sleep
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
5 *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
6 * Input: X = Sleep time in ticks (0 = forever)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
7 *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
8 * Output: X = Decremented by the number of ticks that the process slept
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
9 *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
10 * Error: CC = C bit set; B = error code
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 FSleep pshs cc preserve interupt status
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
13 ldx <D.Proc Get current process pointer
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
14
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
15 * F$Sleep bug fix. Check if we're in system state. If so return because you
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
16 * should never sleep in system state.
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
17 cmpx <D.SysPrc is it system process?
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
18 beq SkpSleep skip sleep call
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
19 orcc #IntMasks disable interupts
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
20 lda P$Signal,x get pending signal
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
21 beq L0722 none there, skip ahead
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
22 deca wakeup signal?
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
23 bne L0715 no, skip ahead
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
24 sta P$Signal,x clear pending signal so we can wake up process
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
25 L0715
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
26 IFNE H6309
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
27 aim #^Suspend,P$State,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
28 ELSE
1239
90bad6d8388c Major changes to bring kernel closer to L2 port
boisy
parents: 1145
diff changeset
29 lda P$State,x
90bad6d8388c Major changes to bring kernel closer to L2 port
boisy
parents: 1145
diff changeset
30 anda #^Suspend
90bad6d8388c Major changes to bring kernel closer to L2 port
boisy
parents: 1145
diff changeset
31 sta P$State,x
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
32 ENDC
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
33 L071B puls cc
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
34 os9 F$AProc activate the process
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
35 bra L0780
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
36 L0722 ldd R$X,u get callers X (contains sleep tick count)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
37 beq L076D done, wake it up
1239
90bad6d8388c Major changes to bring kernel closer to L2 port
boisy
parents: 1145
diff changeset
38 IFNE H6309
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
39 decd subtract 1 from tick count
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
40 ELSE
1239
90bad6d8388c Major changes to bring kernel closer to L2 port
boisy
parents: 1145
diff changeset
41 subd #$0001
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 std R$X,u save it back
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
44 beq L071B zero, wake up process
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
45 pshs x,y
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
46 ldx #(D.SProcQ-P$Queue)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
47 L0732 std R$X,u
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
48 stx 2,s
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
49 ldx P$Queue,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
50 beq L074F
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
51 IFNE H6309
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
52 tim #TimSleep,P$State,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
53 ELSE
1239
90bad6d8388c Major changes to bring kernel closer to L2 port
boisy
parents: 1145
diff changeset
54 lda P$State,x
90bad6d8388c Major changes to bring kernel closer to L2 port
boisy
parents: 1145
diff changeset
55 bita #TimSleep
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
56 ENDC
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
57 beq L074F
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
58 ldy P$SP,x get process stack pointer
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
59 ldd R$X,u
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
60 subd R$X,y
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
61 bcc L0732
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
62 IFNE H6309
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
63 negd
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
64 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
65 nega
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
66 negb
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
67 ENDC
1249
6f0cffb3ab74 Added sbca #0
boisy
parents: 1239
diff changeset
68 sbca #0
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
69 std R$X,y
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
70 L074F puls y,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
71 IFNE H6309
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
72 oim #TimSleep,P$State,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
73 ELSE
1239
90bad6d8388c Major changes to bring kernel closer to L2 port
boisy
parents: 1145
diff changeset
74 lda P$State,x
90bad6d8388c Major changes to bring kernel closer to L2 port
boisy
parents: 1145
diff changeset
75 ora #TimSleep
90bad6d8388c Major changes to bring kernel closer to L2 port
boisy
parents: 1145
diff changeset
76 sta P$State,x
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
77 ENDC
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
78 ldd P$Queue,y
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
79 stx P$Queue,y
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
80 std P$Queue,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
81 ldx R$X,u
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
82 bsr L0780
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
83 stx R$X,u
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
84 ldx <D.Proc
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
85 IFNE H6309
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
86 aim #^TimSleep,P$State,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
87 ELSE
1239
90bad6d8388c Major changes to bring kernel closer to L2 port
boisy
parents: 1145
diff changeset
88 lda P$State,x
90bad6d8388c Major changes to bring kernel closer to L2 port
boisy
parents: 1145
diff changeset
89 anda #^TimSleep
90bad6d8388c Major changes to bring kernel closer to L2 port
boisy
parents: 1145
diff changeset
90 sta P$State,x
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
91 ENDC
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
92 SkpSleep puls cc,pc
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
93
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
94 L076D ldx #D.SProcQ-P$Queue
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
95 L0770 leay ,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
96 ldx P$Queue,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
97 bne L0770
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
98 ldx <D.Proc
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
99 clra
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
100 clrb
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
101 stx P$Queue,y
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
102 std P$Queue,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
103 puls cc
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
104
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
105 L0780 pshs dp,x,y,u,pc
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
106 L0782 leax <L079C,pc
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
107 stx 7,s
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
108 ldx <D.Proc
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
109 ldb P$Task,x This is related to the 'one-byte hack'
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
110 cmpb <D.SysTsk that stops OS9p1 from doing an F$AllTsk on
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
111 beq L0792 _every_ system call.
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
112 os9 F$DelTsk
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
113 L0792 ldd P$SP,x
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 pshsw
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 pshs cc,d
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
118 sts P$SP,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
119 os9 F$NProc
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
120
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
121 L079C pshs x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
122 ldx <D.Proc
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
123 std P$SP,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
124 clrb
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
125 puls x,pc