OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // System calls and other sys.stuff for 386, Darwin | 5 // System calls and other sys.stuff for 386, Darwin |
6 // See http://fxr.watson.org/fxr/source/bsd/kern/syscalls.c?v=xnu-1228 | 6 // See http://fxr.watson.org/fxr/source/bsd/kern/syscalls.c?v=xnu-1228 |
7 // or /usr/include/sys/syscall.h (on a Mac) for system call numbers. | 7 // or /usr/include/sys/syscall.h (on a Mac) for system call numbers. |
8 | 8 |
9 #include "zasm_GOOS_GOARCH.h" | 9 #include "zasm_GOOS_GOARCH.h" |
10 | 10 |
11 TEXT runtime·notok(SB),7,$0 | |
12 MOVL $0xf1, 0xf1 | |
13 RET | |
14 | |
15 // Exit the entire program (like C exit) | 11 // Exit the entire program (like C exit) |
16 TEXT runtime·exit(SB),7,$0 | 12 TEXT runtime·exit(SB),7,$0 |
17 MOVL $1, AX | 13 MOVL $1, AX |
18 INT $0x80 | 14 INT $0x80 |
19 » CALL» runtime·notok(SB) | 15 » MOVL» $0xf1, 0xf1 // crash |
20 RET | 16 RET |
21 | 17 |
22 // Exit this OS thread (like pthread_exit, which eventually | 18 // Exit this OS thread (like pthread_exit, which eventually |
23 // calls __bsdthread_terminate). | 19 // calls __bsdthread_terminate). |
24 TEXT runtime·exit1(SB),7,$0 | 20 TEXT runtime·exit1(SB),7,$0 |
25 MOVL $361, AX | 21 MOVL $361, AX |
26 INT $0x80 | 22 INT $0x80 |
27 JAE 2(PC) | 23 JAE 2(PC) |
28 » CALL» runtime·notok(SB) | 24 » MOVL» $0xf1, 0xf1 // crash |
29 RET | 25 RET |
30 | 26 |
31 TEXT runtime·write(SB),7,$0 | 27 TEXT runtime·write(SB),7,$0 |
32 MOVL $4, AX | 28 MOVL $4, AX |
33 INT $0x80 | 29 INT $0x80 |
34 RET | 30 RET |
35 | 31 |
36 TEXT runtime·raisesigpipe(SB),7,$8 | 32 TEXT runtime·raisesigpipe(SB),7,$8 |
37 get_tls(CX) | 33 get_tls(CX) |
38 MOVL m(CX), DX | 34 MOVL m(CX), DX |
39 MOVL m_procid(DX), DX | 35 MOVL m_procid(DX), DX |
40 MOVL DX, 0(SP) // thread_port | 36 MOVL DX, 0(SP) // thread_port |
41 MOVL $13, 4(SP) // signal: SIGPIPE | 37 MOVL $13, 4(SP) // signal: SIGPIPE |
42 MOVL $328, AX // __pthread_kill | 38 MOVL $328, AX // __pthread_kill |
43 INT $0x80 | 39 INT $0x80 |
44 RET | 40 RET |
45 | 41 |
46 TEXT runtime·mmap(SB),7,$0 | 42 TEXT runtime·mmap(SB),7,$0 |
47 MOVL $197, AX | 43 MOVL $197, AX |
48 INT $0x80 | 44 INT $0x80 |
49 RET | 45 RET |
50 | 46 |
51 TEXT runtime·madvise(SB),7,$0 | 47 TEXT runtime·madvise(SB),7,$0 |
52 MOVL $75, AX | 48 MOVL $75, AX |
53 INT $0x80 | 49 INT $0x80 |
54 JAE 2(PC) | 50 JAE 2(PC) |
55 » CALL» runtime·notok(SB) | 51 » MOVL» $0xf1, 0xf1 // crash |
56 RET | 52 RET |
57 | 53 |
58 TEXT runtime·munmap(SB),7,$0 | 54 TEXT runtime·munmap(SB),7,$0 |
59 MOVL $73, AX | 55 MOVL $73, AX |
60 INT $0x80 | 56 INT $0x80 |
61 JAE 2(PC) | 57 JAE 2(PC) |
62 » CALL» runtime·notok(SB) | 58 » MOVL» $0xf1, 0xf1 // crash |
63 RET | 59 RET |
64 | 60 |
65 TEXT runtime·setitimer(SB),7,$0 | 61 TEXT runtime·setitimer(SB),7,$0 |
66 MOVL $83, AX | 62 MOVL $83, AX |
67 INT $0x80 | 63 INT $0x80 |
68 RET | 64 RET |
69 | 65 |
70 // func now() (sec int64, nsec int32) | 66 // func now() (sec int64, nsec int32) |
71 TEXT time·now(SB), 7, $32 | 67 TEXT time·now(SB), 7, $32 |
72 LEAL 12(SP), AX // must be non-nil, unused | 68 LEAL 12(SP), AX // must be non-nil, unused |
(...skipping 30 matching lines...) Expand all Loading... |
103 | 99 |
104 MOVL ret+0(FP), DI | 100 MOVL ret+0(FP), DI |
105 MOVL AX, 0(DI) | 101 MOVL AX, 0(DI) |
106 MOVL DX, 4(DI) | 102 MOVL DX, 4(DI) |
107 RET | 103 RET |
108 | 104 |
109 TEXT runtime·sigprocmask(SB),7,$0 | 105 TEXT runtime·sigprocmask(SB),7,$0 |
110 MOVL $329, AX // pthread_sigmask (on OS X, sigprocmask==entire proce
ss) | 106 MOVL $329, AX // pthread_sigmask (on OS X, sigprocmask==entire proce
ss) |
111 INT $0x80 | 107 INT $0x80 |
112 JAE 2(PC) | 108 JAE 2(PC) |
113 » CALL» runtime·notok(SB) | 109 » MOVL» $0xf1, 0xf1 // crash |
114 RET | 110 RET |
115 | 111 |
116 TEXT runtime·sigaction(SB),7,$0 | 112 TEXT runtime·sigaction(SB),7,$0 |
117 MOVL $46, AX | 113 MOVL $46, AX |
118 INT $0x80 | 114 INT $0x80 |
119 JAE 2(PC) | 115 JAE 2(PC) |
120 » CALL» runtime·notok(SB) | 116 » MOVL» $0xf1, 0xf1 // crash |
121 RET | 117 RET |
122 | 118 |
123 // Sigtramp's job is to call the actual signal handler. | 119 // Sigtramp's job is to call the actual signal handler. |
124 // It is called with the following arguments on the stack: | 120 // It is called with the following arguments on the stack: |
125 // 0(FP) "return address" - ignored | 121 // 0(FP) "return address" - ignored |
126 // 4(FP) actual handler | 122 // 4(FP) actual handler |
127 // 8(FP) siginfo style - ignored | 123 // 8(FP) siginfo style - ignored |
128 // 12(FP) signal number | 124 // 12(FP) signal number |
129 // 16(FP) siginfo | 125 // 16(FP) siginfo |
130 // 20(FP) context | 126 // 20(FP) context |
(...skipping 27 matching lines...) Expand all Loading... |
158 MOVL DI, g(CX) | 154 MOVL DI, g(CX) |
159 | 155 |
160 // call sigreturn | 156 // call sigreturn |
161 MOVL context+16(FP), CX | 157 MOVL context+16(FP), CX |
162 MOVL style+4(FP), BX | 158 MOVL style+4(FP), BX |
163 MOVL $0, 0(SP) // "caller PC" - ignored | 159 MOVL $0, 0(SP) // "caller PC" - ignored |
164 MOVL CX, 4(SP) | 160 MOVL CX, 4(SP) |
165 MOVL BX, 8(SP) | 161 MOVL BX, 8(SP) |
166 MOVL $184, AX // sigreturn(ucontext, infostyle) | 162 MOVL $184, AX // sigreturn(ucontext, infostyle) |
167 INT $0x80 | 163 INT $0x80 |
168 » CALL» runtime·notok(SB) | 164 » MOVL» $0xf1, 0xf1 // crash |
169 RET | 165 RET |
170 | 166 |
171 TEXT runtime·sigaltstack(SB),7,$0 | 167 TEXT runtime·sigaltstack(SB),7,$0 |
172 MOVL $53, AX | 168 MOVL $53, AX |
173 INT $0x80 | 169 INT $0x80 |
174 JAE 2(PC) | 170 JAE 2(PC) |
175 » CALL» runtime·notok(SB) | 171 » MOVL» $0xf1, 0xf1 // crash |
176 RET | 172 RET |
177 | 173 |
178 TEXT runtime·usleep(SB),7,$32 | 174 TEXT runtime·usleep(SB),7,$32 |
179 MOVL $0, DX | 175 MOVL $0, DX |
180 MOVL usec+0(FP), AX | 176 MOVL usec+0(FP), AX |
181 MOVL $1000000, CX | 177 MOVL $1000000, CX |
182 DIVL CX | 178 DIVL CX |
183 MOVL AX, 24(SP) // sec | 179 MOVL AX, 24(SP) // sec |
184 MOVL DX, 28(SP) // usec | 180 MOVL DX, 28(SP) // usec |
185 | 181 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 MOVL $366, AX | 257 MOVL $366, AX |
262 // 0(SP) is where kernel expects caller PC; ignored | 258 // 0(SP) is where kernel expects caller PC; ignored |
263 MOVL $runtime·bsdthread_start(SB), 4(SP) // threadstart | 259 MOVL $runtime·bsdthread_start(SB), 4(SP) // threadstart |
264 MOVL $0, 8(SP) // wqthread, not used by us | 260 MOVL $0, 8(SP) // wqthread, not used by us |
265 MOVL $0, 12(SP) // pthsize, not used by us | 261 MOVL $0, 12(SP) // pthsize, not used by us |
266 MOVL $0, 16(SP) // dummy_value [sic] | 262 MOVL $0, 16(SP) // dummy_value [sic] |
267 MOVL $0, 20(SP) // targetconc_ptr | 263 MOVL $0, 20(SP) // targetconc_ptr |
268 MOVL $0, 24(SP) // dispatchqueue_offset | 264 MOVL $0, 24(SP) // dispatchqueue_offset |
269 INT $0x80 | 265 INT $0x80 |
270 JAE 2(PC) | 266 JAE 2(PC) |
271 » CALL» runtime·notok(SB) | 267 » MOVL» $0xf1, 0xf1 // crash |
272 RET | 268 RET |
273 | 269 |
274 // Invoke Mach system call. | 270 // Invoke Mach system call. |
275 // Assumes system call number in AX, | 271 // Assumes system call number in AX, |
276 // caller PC on stack, caller's caller PC next, | 272 // caller PC on stack, caller's caller PC next, |
277 // and then the system call arguments. | 273 // and then the system call arguments. |
278 // | 274 // |
279 // Can be used for BSD too, but we don't, | 275 // Can be used for BSD too, but we don't, |
280 // because if you use this interface the BSD | 276 // because if you use this interface the BSD |
281 // system call numbers need an extra field | 277 // system call numbers need an extra field |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 RET | 364 RET |
369 | 365 |
370 TEXT runtime·sysctl(SB),7,$0 | 366 TEXT runtime·sysctl(SB),7,$0 |
371 MOVL $202, AX | 367 MOVL $202, AX |
372 INT $0x80 | 368 INT $0x80 |
373 JAE 3(PC) | 369 JAE 3(PC) |
374 NEGL AX | 370 NEGL AX |
375 RET | 371 RET |
376 MOVL $0, AX | 372 MOVL $0, AX |
377 RET | 373 RET |
OLD | NEW |