1 // Copyright 2009 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 // TODO(rsc): Rewrite all nn(SP) references into name+(nn-8)(FP) 6 // so that go vet can check that they are correct. 7 8 #include "textflag.h" 9 #include "funcdata.h" 10 11 // 12 // System call support for 386, Plan 9 13 // 14 15 //func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err string) 16 //func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err string) 17 //func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) 18 //func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) 19 20 // Trap # in AX, args on stack above caller pc. 21 TEXT Syscall(SB),NOSPLIT,$0-32 22 CALL runtimeentersyscall(SB) 23 MOVL 4(SP), AX // syscall entry 24 // slide args down on top of system call number 25 LEAL 8(SP), SI 26 LEAL 4(SP), DI 27 CLD 28 MOVSL 29 MOVSL 30 MOVSL 31 INT $64 32 MOVL AX, r1+20(SP) 33 MOVL $0, r2+24(SP) 34 CMPL AX, $-1 35 JNE ok3 36 37 SUBL $8, SP 38 CALL runtimeerrstr(SB) 39 MOVL SP, SI 40 ADDL $8, SP 41 JMP copyresult3 42 43 ok3: 44 LEAL runtimeemptystring(SB), SI 45 46 copyresult3: 47 LEAL err+28(SP), DI 48 49 CLD 50 MOVSL 51 MOVSL 52 53 CALL runtimeexitsyscall(SB) 54 RET 55 56 TEXT Syscall6(SB),NOSPLIT,$0-44 57 CALL runtimeentersyscall(SB) 58 MOVL 4(SP), AX // syscall entry 59 // slide args down on top of system call number 60 LEAL 8(SP), SI 61 LEAL 4(SP), DI 62 CLD 63 MOVSL 64 MOVSL 65 MOVSL 66 MOVSL 67 MOVSL 68 MOVSL 69 INT $64 70 MOVL AX, r1+32(SP) 71 MOVL $0, r2+36(SP) 72 CMPL AX, $-1 73 JNE ok4 74 75 SUBL $8, SP 76 CALL runtimeerrstr(SB) 77 MOVL SP, SI 78 ADDL $8, SP 79 JMP copyresult4 80 81 ok4: 82 LEAL runtimeemptystring(SB), SI 83 84 copyresult4: 85 LEAL err+40(SP), DI 86 87 CLD 88 MOVSL 89 MOVSL 90 91 CALL runtimeexitsyscall(SB) 92 RET 93 94 TEXT RawSyscall(SB),NOSPLIT,$0-28 95 MOVL 4(SP), AX // syscall entry 96 // slide args down on top of system call number 97 LEAL 8(SP), SI 98 LEAL 4(SP), DI 99 CLD 100 MOVSL 101 MOVSL 102 MOVSL 103 INT $64 104 MOVL AX, r1+20(SP) 105 MOVL AX, r2+24(SP) 106 MOVL AX, err+28(SP) 107 RET 108 109 TEXT RawSyscall6(SB),NOSPLIT,$0-40 110 MOVL 4(SP), AX // syscall entry 111 // slide args down on top of system call number 112 LEAL 8(SP), SI 113 LEAL 4(SP), DI 114 CLD 115 MOVSL 116 MOVSL 117 MOVSL 118 MOVSL 119 MOVSL 120 MOVSL 121 INT $64 122 MOVL AX, r1+32(SP) 123 MOVL AX, r2+36(SP) 124 MOVL AX, err+40(SP) 125 RET 126 127 #define SYS_SEEK 39 /* from zsysnum_plan9_386.go */ 128 129 //func seek(placeholder uintptr, fd int, offset int64, whence int) (newoffset int64, err string) 130 TEXT seek(SB),NOSPLIT,$0-36 131 LEAL newoffset+24(SP), AX 132 MOVL AX, placeholder+4(SP) 133 134 MOVL $SYS_SEEK, AX // syscall entry 135 INT $64 136 137 CMPL AX, $-1 138 JNE ok6 139 MOVL AX, 24(SP) // newoffset low 140 MOVL AX, 28(SP) // newoffset high 141 142 SUBL $8, SP 143 CALL syscallerrstr(SB) 144 MOVL SP, SI 145 ADDL $8, SP 146 JMP copyresult6 147 148 ok6: 149 LEAL runtimeemptystring(SB), SI 150 151 copyresult6: 152 LEAL err+32(SP), DI 153 154 CLD 155 MOVSL 156 MOVSL 157 RET 158 159 //func exit(code int) 160 // Import runtimeexit for cleanly exiting. 161 TEXT exit(SB),NOSPLIT,$4-4 162 NO_LOCAL_POINTERS 163 MOVL code+0(FP), AX 164 MOVL AX, 0(SP) 165 CALL runtimeexit(SB) 166 RET 167