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