github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/src/pkg/runtime/sys_plan9_amd64.s (about) 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 "zasm_GOOS_GOARCH.h" 6 7 // setldt(int entry, int address, int limit) 8 TEXT runtime·setldt(SB),7,$0 9 RET 10 11 TEXT runtime·open(SB),7,$0 12 MOVQ $0x8000, AX 13 MOVQ $14, BP 14 SYSCALL 15 RET 16 17 TEXT runtime·pread(SB),7,$0 18 MOVQ $0x8000, AX 19 MOVQ $50, BP 20 SYSCALL 21 RET 22 23 TEXT runtime·pwrite(SB),7,$0 24 MOVQ $0x8000, AX 25 MOVQ $51, BP 26 SYSCALL 27 RET 28 29 // int32 _seek(int64*, int32, int64, int32) 30 TEXT _seek<>(SB),7,$0 31 MOVQ $0x8000, AX 32 MOVQ $39, BP 33 SYSCALL 34 RET 35 36 // int64 seek(int32, int64, int32) 37 TEXT runtime·seek(SB),7,$56 38 LEAQ new+48(SP), CX 39 MOVQ CX, 0(SP) 40 MOVQ fd+0(FP), CX 41 MOVQ CX, 8(SP) 42 MOVQ off+8(FP), CX 43 MOVQ CX, 16(SP) 44 MOVQ whence+16(FP), CX 45 MOVQ CX, 24(SP) 46 CALL _seek<>(SB) 47 CMPL AX, $0 48 JGE 2(PC) 49 MOVQ $-1, new+48(SP) 50 MOVQ new+48(SP), AX 51 RET 52 53 TEXT runtime·close(SB),7,$0 54 MOVQ $0x8000, AX 55 MOVQ $4, BP 56 SYSCALL 57 RET 58 59 TEXT runtime·exits(SB),7,$0 60 MOVQ $0x8000, AX 61 MOVQ $8, BP 62 SYSCALL 63 RET 64 65 TEXT runtime·brk_(SB),7,$0 66 MOVQ $0x8000, AX 67 MOVQ $24, BP 68 SYSCALL 69 RET 70 71 TEXT runtime·sleep(SB),7,$0 72 MOVQ $0x8000, AX 73 MOVQ $17, BP 74 SYSCALL 75 RET 76 77 TEXT runtime·plan9_semacquire(SB),7,$0 78 MOVQ $0x8000, AX 79 MOVQ $37, BP 80 SYSCALL 81 RET 82 83 TEXT runtime·plan9_tsemacquire(SB),7,$0 84 MOVQ $0x8000, AX 85 MOVQ $52, BP 86 SYSCALL 87 RET 88 89 TEXT runtime·notify(SB),7,$0 90 MOVQ $0x8000, AX 91 MOVQ $28, BP 92 SYSCALL 93 RET 94 95 TEXT runtime·noted(SB),7,$0 96 MOVQ $0x8000, AX 97 MOVQ $29, BP 98 SYSCALL 99 RET 100 101 TEXT runtime·plan9_semrelease(SB),7,$0 102 MOVQ $0x8000, AX 103 MOVQ $38, BP 104 SYSCALL 105 RET 106 107 TEXT runtime·nanotime(SB),7,$0 108 MOVQ $0x8000, AX 109 MOVQ $60, BP 110 SYSCALL 111 RET 112 113 TEXT runtime·rfork(SB),7,$0 114 MOVQ $0x8000, AX 115 MOVQ $19, BP // rfork 116 SYSCALL 117 118 // In parent, return. 119 CMPQ AX, $0 120 JEQ 2(PC) 121 RET 122 123 // In child on forked stack. 124 MOVQ mm+24(SP), BX // m 125 MOVQ gg+32(SP), DX // g 126 MOVQ fn+40(SP), SI // fn 127 128 // set SP to be on the new child stack 129 MOVQ stack+16(SP), CX 130 MOVQ CX, SP 131 132 // Initialize m, g. 133 get_tls(AX) 134 MOVQ DX, g(AX) 135 MOVQ BX, m(AX) 136 137 // Initialize AX from pid in TLS. 138 MOVQ procid(AX), AX 139 MOVQ AX, m_procid(BX) // save pid as m->procid 140 141 CALL runtime·stackcheck(SB) // smashes AX, CX 142 143 MOVQ 0(DX), DX // paranoia; check they are not nil 144 MOVQ 0(BX), BX 145 146 CALL SI // fn() 147 CALL runtime·exit(SB) 148 RET 149 150 // This is needed by asm_amd64.s 151 TEXT runtime·settls(SB),7,$0 152 RET 153 154 // void sigtramp(void *ureg, int8 *note) 155 TEXT runtime·sigtramp(SB),7,$0 156 get_tls(AX) 157 158 // check that m exists 159 MOVQ m(AX), BX 160 CMPQ BX, $0 161 JNE 3(PC) 162 CALL runtime·badsignal(SB) // will exit 163 RET 164 165 // save args 166 MOVQ ureg+8(SP), CX 167 MOVQ note+16(SP), DX 168 169 // change stack 170 MOVQ m_gsignal(BX), R10 171 MOVQ g_stackbase(R10), BP 172 MOVQ BP, SP 173 174 // make room for args and g 175 SUBQ $32, SP 176 177 // save g 178 MOVQ g(AX), BP 179 MOVQ BP, 24(SP) 180 181 // g = m->gsignal 182 MOVQ R10, g(AX) 183 184 // load args and call sighandler 185 MOVQ CX, 0(SP) 186 MOVQ DX, 8(SP) 187 MOVQ BP, 16(SP) 188 189 CALL runtime·sighandler(SB) 190 191 // restore g 192 get_tls(BX) 193 MOVQ 24(SP), R10 194 MOVQ R10, g(BX) 195 196 // call noted(AX) 197 MOVQ AX, 0(SP) 198 CALL runtime·noted(SB) 199 RET 200 201 TEXT runtime·setfpmasks(SB),7,$8 202 STMXCSR 0(SP) 203 MOVL 0(SP), AX 204 ANDL $~0x3F, AX 205 ORL $(0x3F<<7), AX 206 MOVL AX, 0(SP) 207 LDMXCSR 0(SP) 208 RET 209 210 #define ERRMAX 128 /* from os_plan9.h */ 211 212 // func errstr() String 213 // Only used by package syscall. 214 // Grab error string due to a syscall made 215 // in entersyscall mode, without going 216 // through the allocator (issue 4994). 217 // See ../syscall/asm_plan9_386.s:/·Syscall/ 218 TEXT runtime·errstr(SB),7,$0 219 get_tls(AX) 220 MOVQ m(AX), BX 221 MOVQ m_errstr(BX), CX 222 MOVQ CX, 8(SP) 223 MOVQ $ERRMAX, 16(SP) 224 MOVQ $0x8000, AX 225 MOVQ $41, BP 226 SYSCALL 227 228 // syscall requires caller-save 229 MOVQ 8(SP), CX 230 231 // push the argument 232 PUSHQ CX 233 CALL runtime·findnull(SB) 234 POPQ CX 235 MOVQ AX, 16(SP) 236 RET