annotate level2/modules/kernel/fsleep.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 **************************************************
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
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
29 ENDC
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
30 L071B puls cc
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
31 os9 F$AProc activate the process
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
32 bra L0780
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
33 L0722 ldd R$X,u get callers X (contains sleep tick count)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
34 beq L076D done, wake it up
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
35 IFNE H6309
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
36 decd subtract 1 from tick count
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
37 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
38 ENDC
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
39 std R$X,u save it back
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
40 beq L071B zero, wake up process
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
41 pshs x,y
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
42 ldx #(D.SProcQ-P$Queue)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
43 L0732 std R$X,u
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
44 stx 2,s
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
45 ldx P$Queue,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
46 beq L074F
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
47 IFNE H6309
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
48 tim #TimSleep,P$State,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
49 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
50 ENDC
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
51 beq L074F
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
52 ldy P$SP,x get process stack pointer
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
53 ldd R$X,u
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
54 subd R$X,y
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
55 bcc L0732
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
56 IFNE H6309
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
57 negd
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
58 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
59 nega
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
60 negb
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
61 ENDC
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
62 std R$X,y
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
63 L074F puls y,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
64 IFNE H6309
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
65 oim #TimSleep,P$State,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
66 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
67 ENDC
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
68 ldd P$Queue,y
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
69 stx P$Queue,y
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
70 std P$Queue,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
71 ldx R$X,u
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
72 bsr L0780
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
73 stx R$X,u
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
74 ldx <D.Proc
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
75 IFNE H6309
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
76 aim #^TimSleep,P$State,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
77 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
78 ENDC
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
79 SkpSleep puls cc,pc
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
80
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
81 L076D ldx #D.SProcQ-P$Queue
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
82 L0770 leay ,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
83 ldx P$Queue,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
84 bne L0770
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
85 ldx <D.Proc
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
86 clra
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
87 clrb
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
88 stx P$Queue,y
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
89 std P$Queue,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
90 puls cc
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
91
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
92 L0780 pshs dp,x,y,u,pc
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
93 L0782 leax <L079C,pc
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
94 stx 7,s
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
95 ldx <D.Proc
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
96 ldb P$Task,x This is related to the 'one-byte hack'
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
97 cmpb <D.SysTsk that stops OS9p1 from doing an F$AllTsk on
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
98 beq L0792 _every_ system call.
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
99 os9 F$DelTsk
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
100 L0792 ldd P$SP,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
101 IFNE H6309
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
102 pshsw
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
103 ENDC
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
104 pshs cc,d
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
105 sts P$SP,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
106 os9 F$NProc
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
107
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
108 L079C pshs x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
109 ldx <D.Proc
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
110 std P$SP,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
111 clrb
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
112 puls x,pc