Text file
src/runtime/sys_plan9_386.s
1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 #include "go_asm.h"
6 #include "go_tls.h"
7 #include "textflag.h"
8
9 // setldt(int entry, int address, int limit)
10 TEXT runtime·setldt(SB),NOSPLIT,$0
11 RET
12
13 TEXT runtime·open(SB),NOSPLIT,$0
14 MOVL $14, AX
15 INT $64
16 MOVL AX, ret+12(FP)
17 RET
18
19 TEXT runtime·pread(SB),NOSPLIT,$0
20 MOVL $50, AX
21 INT $64
22 MOVL AX, ret+20(FP)
23 RET
24
25 TEXT runtime·pwrite(SB),NOSPLIT,$0
26 MOVL $51, AX
27 INT $64
28 MOVL AX, ret+20(FP)
29 RET
30
31 // int32 _seek(int64*, int32, int64, int32)
32 TEXT _seek<>(SB),NOSPLIT,$0
33 MOVL $39, AX
34 INT $64
35 RET
36
37 TEXT runtime·seek(SB),NOSPLIT,$24
38 LEAL ret+16(FP), AX
39 MOVL fd+0(FP), BX
40 MOVL offset_lo+4(FP), CX
41 MOVL offset_hi+8(FP), DX
42 MOVL whence+12(FP), SI
43 MOVL AX, 0(SP)
44 MOVL BX, 4(SP)
45 MOVL CX, 8(SP)
46 MOVL DX, 12(SP)
47 MOVL SI, 16(SP)
48 CALL _seek<>(SB)
49 CMPL AX, $0
50 JGE 3(PC)
51 MOVL $-1, ret_lo+16(FP)
52 MOVL $-1, ret_hi+20(FP)
53 RET
54
55 TEXT runtime·closefd(SB),NOSPLIT,$0
56 MOVL $4, AX
57 INT $64
58 MOVL AX, ret+4(FP)
59 RET
60
61 TEXT runtime·dupfd(SB),NOSPLIT,$0
62 MOVL $5, AX
63 INT $64
64 MOVL AX, ret+8(FP)
65 RET
66
67 TEXT runtime·exits(SB),NOSPLIT,$0
68 MOVL $8, AX
69 INT $64
70 RET
71
72 TEXT runtime·brk_(SB),NOSPLIT,$0
73 MOVL $24, AX
74 INT $64
75 MOVL AX, ret+4(FP)
76 RET
77
78 TEXT runtime·sleep(SB),NOSPLIT,$0
79 MOVL $17, AX
80 INT $64
81 MOVL AX, ret+4(FP)
82 RET
83
84 TEXT runtime·plan9_semacquire(SB),NOSPLIT,$0
85 MOVL $37, AX
86 INT $64
87 MOVL AX, ret+8(FP)
88 RET
89
90 TEXT runtime·plan9_tsemacquire(SB),NOSPLIT,$0
91 MOVL $52, AX
92 INT $64
93 MOVL AX, ret+8(FP)
94 RET
95
96 // func timesplit(u uint64) (sec int64, nsec int32)
97 TEXT runtime·timesplit(SB),NOSPLIT,$0
98 MOVL u_lo+0(FP), AX
99 MOVL u_hi+4(FP), DX
100 MOVL $1000000000, CX
101 DIVL CX
102 MOVL AX, sec_lo+8(FP)
103 MOVL $0, sec_hi+12(FP)
104 MOVL DX, nsec+16(FP)
105 RET
106
107 TEXT runtime·notify(SB),NOSPLIT,$0
108 MOVL $28, AX
109 INT $64
110 MOVL AX, ret+4(FP)
111 RET
112
113 TEXT runtime·noted(SB),NOSPLIT,$0
114 MOVL $29, AX
115 INT $64
116 MOVL AX, ret+4(FP)
117 RET
118
119 TEXT runtime·plan9_semrelease(SB),NOSPLIT,$0
120 MOVL $38, AX
121 INT $64
122 MOVL AX, ret+8(FP)
123 RET
124
125 TEXT runtime·rfork(SB),NOSPLIT,$0
126 MOVL $19, AX
127 INT $64
128 MOVL AX, ret+4(FP)
129 RET
130
131 TEXT runtime·tstart_plan9(SB),NOSPLIT,$4
132 MOVL newm+0(FP), CX
133 MOVL m_g0(CX), DX
134
135 // Layout new m scheduler stack on os stack.
136 MOVL SP, AX
137 MOVL AX, (g_stack+stack_hi)(DX)
138 SUBL $(64*1024), AX // stack size
139 MOVL AX, (g_stack+stack_lo)(DX)
140 MOVL AX, g_stackguard0(DX)
141 MOVL AX, g_stackguard1(DX)
142
143 // Initialize procid from TOS struct.
144 MOVL _tos(SB), AX
145 MOVL 48(AX), AX
146 MOVL AX, m_procid(CX) // save pid as m->procid
147
148 // Finally, initialize g.
149 get_tls(BX)
150 MOVL DX, g(BX)
151
152 CALL runtime·stackcheck(SB) // smashes AX, CX
153 CALL runtime·mstart(SB)
154
155 // Exit the thread.
156 MOVL $0, 0(SP)
157 CALL runtime·exits(SB)
158 JMP 0(PC)
159
160 // void sigtramp(void *ureg, int8 *note)
161 TEXT runtime·sigtramp(SB),NOSPLIT,$0
162 get_tls(AX)
163
164 // check that g exists
165 MOVL g(AX), BX
166 CMPL BX, $0
167 JNE 3(PC)
168 CALL runtime·badsignal2(SB) // will exit
169 RET
170
171 // save args
172 MOVL ureg+0(FP), CX
173 MOVL note+4(FP), DX
174
175 // change stack
176 MOVL g_m(BX), BX
177 MOVL m_gsignal(BX), BP
178 MOVL (g_stack+stack_hi)(BP), BP
179 MOVL BP, SP
180
181 // make room for args and g
182 SUBL $24, SP
183
184 // save g
185 MOVL g(AX), BP
186 MOVL BP, 20(SP)
187
188 // g = m->gsignal
189 MOVL m_gsignal(BX), DI
190 MOVL DI, g(AX)
191
192 // load args and call sighandler
193 MOVL CX, 0(SP)
194 MOVL DX, 4(SP)
195 MOVL BP, 8(SP)
196
197 CALL runtime·sighandler(SB)
198 MOVL 12(SP), AX
199
200 // restore g
201 get_tls(BX)
202 MOVL 20(SP), BP
203 MOVL BP, g(BX)
204
205 // call noted(AX)
206 MOVL AX, 0(SP)
207 CALL runtime·noted(SB)
208 RET
209
210 // Only used by the 64-bit runtime.
211 TEXT runtime·setfpmasks(SB),NOSPLIT,$0
212 RET
213
214 #define ERRMAX 128 /* from os_plan9.h */
215
216 // void errstr(int8 *buf, int32 len)
217 TEXT errstr<>(SB),NOSPLIT,$0
218 MOVL $41, AX
219 INT $64
220 RET
221
222 // func errstr() string
223 // Only used by package syscall.
224 // Grab error string due to a syscall made
225 // in entersyscall mode, without going
226 // through the allocator (issue 4994).
227 // See ../syscall/asm_plan9_386.s:/·Syscall/
228 TEXT runtime·errstr(SB),NOSPLIT,$8-8
229 get_tls(AX)
230 MOVL g(AX), BX
231 MOVL g_m(BX), BX
232 MOVL (m_mOS+mOS_errstr)(BX), CX
233 MOVL CX, 0(SP)
234 MOVL $ERRMAX, 4(SP)
235 CALL errstr<>(SB)
236 CALL runtime·findnull(SB)
237 MOVL 4(SP), AX
238 MOVL AX, ret_len+4(FP)
239 MOVL 0(SP), AX
240 MOVL AX, ret_base+0(FP)
241 RET
242
243 // never called on this platform
244 TEXT ·sigpanictramp(SB),NOSPLIT,$0-0
245 UNDEF
246
View as plain text