1 // Copyright 2015 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 "textflag.h" 6 7 // 8 // System call support for ARM64, Darwin 9 // 10 11 // func Syscall(syscall uintptr, a1, a2, a3 uintptr) (r1, r2, err uintptr) 12 TEXT Syscall(SB),NOSPLIT,$0-56 13 BL runtimeentersyscall(SB) 14 MOVD syscall+0(FP), R16 15 MOVD a1+8(FP), R0 16 MOVD a2+16(FP), R1 17 MOVD a3+24(FP), R2 18 SVC $0x80 19 BCC ok 20 MOVD $-1, R1 21 MOVD R1, r1+32(FP) // r1 22 MOVD ZR, r2+40(FP) // r2 23 MOVD R0, errno+48(FP) // errno 24 BL runtimeexitsyscall(SB) 25 RET 26 ok: 27 MOVD R0, r1+32(FP) // r1 28 MOVD R1, r2+40(FP) // r2 29 MOVD ZR, errno+48(FP) // errno 30 BL runtimeexitsyscall(SB) 31 RET 32 33 // func RawSyscall(trap uintptr, a1, a2, a3 uintptr) (r1, r2, err uintptr) 34 TEXT RawSyscall(SB),NOSPLIT,$0-56 35 MOVD syscall+0(FP), R16 // syscall entry 36 MOVD a1+8(FP), R0 37 MOVD a2+16(FP), R1 38 MOVD a3+24(FP), R2 39 SVC $0x80 40 BCC ok 41 MOVD $-1, R1 42 MOVD R1, r1+32(FP) // r1 43 MOVD ZR, r2+40(FP) // r2 44 MOVD R0, errno+48(FP) // errno 45 RET 46 ok: 47 MOVD R0, r1+32(FP) // r1 48 MOVD R1, r2+40(FP) // r2 49 MOVD ZR, errno+48(FP) // errno 50 RET 51 52 // func Syscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) 53 TEXT Syscall6(SB),NOSPLIT,$0-80 54 BL runtimeentersyscall(SB) 55 MOVD syscall+0(FP), R16 // syscall entry 56 MOVD a1+8(FP), R0 57 MOVD a2+16(FP), R1 58 MOVD a3+24(FP), R2 59 MOVD a4+32(FP), R3 60 MOVD a5+40(FP), R4 61 MOVD a6+48(FP), R5 62 SVC $0x80 63 BCC ok 64 MOVD $-1, R1 65 MOVD R1, r1+56(FP) // r1 66 MOVD ZR, r2+64(FP) // r2 67 MOVD R0, errno+72(FP) // errno 68 BL runtimeexitsyscall(SB) 69 RET 70 ok: 71 MOVD R0, r1+56(FP) // r1 72 MOVD R1, r2+64(FP) // r2 73 MOVD ZR, errno+72(FP) // errno 74 BL runtimeexitsyscall(SB) 75 RET 76 77 // func RawSyscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) 78 TEXT RawSyscall6(SB),NOSPLIT,$0-80 79 MOVD trap+0(FP), R16 // syscall entry 80 MOVD a1+8(FP), R0 81 MOVD a2+16(FP), R1 82 MOVD a3+24(FP), R2 83 MOVD a4+32(FP), R3 84 MOVD a5+40(FP), R4 85 MOVD a6+48(FP), R5 86 SVC $0x80 87 BCC ok 88 MOVD $-1, R1 89 MOVD R1, r1+56(FP) // r1 90 MOVD ZR, r2+64(FP) // r2 91 MOVD R0, errno+72(FP) // errno 92 RET 93 ok: 94 MOVD R0, r1+56(FP) // r1 95 MOVD R1, r2+64(FP) // r2 96 MOVD ZR, R0 97 MOVD R0, errno+72(FP) // errno 98 RET 99 100 // Actually Syscall7 101 TEXT Syscall9(SB),NOSPLIT,$0-104 102 BL runtimeentersyscall(SB) 103 MOVD syscall+0(FP), R16 // syscall entry 104 MOVD a1+8(FP), R0 105 MOVD a2+16(FP), R1 106 MOVD a3+24(FP), R2 107 MOVD a4+32(FP), R3 108 MOVD a5+40(FP), R4 109 MOVD a6+48(FP), R5 110 MOVD a7+56(FP), R6 111 //MOVD a8+64(FP), R7 112 //MOVD a9+72(FP), R8 113 SVC $0x80 114 BCC ok 115 MOVD $-1, R1 116 MOVD R1, r1+80(FP) // r1 117 MOVD ZR, r2+88(FP) // r2 118 MOVD R0, errno+96(FP) // errno 119 BL runtimeexitsyscall(SB) 120 RET 121 ok: 122 MOVD R0, r1+80(FP) // r1 123 MOVD R1, r2+88(FP) // r2 124 MOVD ZR, errno+96(FP) // errno 125 BL runtimeexitsyscall(SB) 126 RET 127 128