github.com/likebike/go--@v0.0.0-20190911215757-0bd925d16e96/go/src/syscall/asm_linux_arm.s (about) 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 #include "textflag.h" 6 #include "funcdata.h" 7 8 // 9 // System calls for arm, Linux 10 // 11 12 // TODO(kaib): handle error returns 13 14 // func Syscall(syscall uintptr, a1, a2, a3 uintptr) (r1, r2, err uintptr); 15 16 TEXT ·Syscall(SB),NOSPLIT,$0-28 17 BL runtime·entersyscall(SB) 18 MOVW trap+0(FP), R7 19 MOVW a1+4(FP), R0 20 MOVW a2+8(FP), R1 21 MOVW a3+12(FP), R2 22 MOVW $0, R3 23 MOVW $0, R4 24 MOVW $0, R5 25 SWI $0 26 MOVW $0xfffff001, R1 27 CMP R1, R0 28 BLS ok 29 MOVW $-1, R1 30 MOVW R1, r1+16(FP) 31 MOVW $0, R2 32 MOVW R2, r2+20(FP) 33 RSB $0, R0, R0 34 MOVW R0, err+24(FP) 35 BL runtime·exitsyscall(SB) 36 RET 37 ok: 38 MOVW R0, r1+16(FP) 39 MOVW $0, R0 40 MOVW R0, r2+20(FP) 41 MOVW R0, err+24(FP) 42 BL runtime·exitsyscall(SB) 43 RET 44 45 // func Syscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr); 46 // Actually Syscall5 but the rest of the code expects it to be named Syscall6. 47 TEXT ·Syscall6(SB),NOSPLIT,$0-40 48 BL runtime·entersyscall(SB) 49 MOVW trap+0(FP), R7 // syscall entry 50 MOVW a1+4(FP), R0 51 MOVW a2+8(FP), R1 52 MOVW a3+12(FP), R2 53 MOVW a4+16(FP), R3 54 MOVW a5+20(FP), R4 55 MOVW a6+24(FP), R5 56 SWI $0 57 MOVW $0xfffff001, R6 58 CMP R6, R0 59 BLS ok6 60 MOVW $-1, R1 61 MOVW R1, r1+28(FP) 62 MOVW $0, R2 63 MOVW R2, r2+32(FP) 64 RSB $0, R0, R0 65 MOVW R0, err+36(FP) 66 BL runtime·exitsyscall(SB) 67 RET 68 ok6: 69 MOVW R0, r1+28(FP) 70 MOVW R1, r2+32(FP) 71 MOVW $0, R0 72 MOVW R0, err+36(FP) 73 BL runtime·exitsyscall(SB) 74 RET 75 76 // func RawSyscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr); 77 // Actually RawSyscall5 but the rest of the code expects it to be named RawSyscall6. 78 TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 79 MOVW trap+0(FP), R7 // syscall entry 80 MOVW a1+4(FP), R0 81 MOVW a2+8(FP), R1 82 MOVW a3+12(FP), R2 83 MOVW a4+16(FP), R3 84 MOVW a5+20(FP), R4 85 MOVW a6+24(FP), R5 86 SWI $0 87 MOVW $0xfffff001, R6 88 CMP R6, R0 89 BLS ok2 90 MOVW $-1, R1 91 MOVW R1, r1+28(FP) 92 MOVW $0, R2 93 MOVW R2, r2+32(FP) 94 RSB $0, R0, R0 95 MOVW R0, err+36(FP) 96 RET 97 ok2: 98 MOVW R0, r1+28(FP) 99 MOVW R1, r2+32(FP) 100 MOVW $0, R0 101 MOVW R0, err+36(FP) 102 RET 103 104 #define SYS__LLSEEK 140 /* from zsysnum_linux_arm.go */ 105 // func seek(fd int, offset int64, whence int) (newoffset int64, errno int) 106 // Implemented in assembly to avoid allocation when 107 // taking the address of the return value newoffset. 108 // Underlying system call is 109 // llseek(int fd, int offhi, int offlo, int64 *result, int whence) 110 TEXT ·seek(SB),NOSPLIT,$0-28 111 BL runtime·entersyscall(SB) 112 MOVW $SYS__LLSEEK, R7 // syscall entry 113 MOVW fd+0(FP), R0 114 MOVW offset_hi+8(FP), R1 115 MOVW offset_lo+4(FP), R2 116 MOVW $newoffset_lo+16(FP), R3 117 MOVW whence+12(FP), R4 118 SWI $0 119 MOVW $0xfffff001, R6 120 CMP R6, R0 121 BLS okseek 122 MOVW $0, R1 123 MOVW R1, newoffset_lo+16(FP) 124 MOVW R1, newoffset_hi+20(FP) 125 RSB $0, R0, R0 126 MOVW R0, err+24(FP) 127 BL runtime·exitsyscall(SB) 128 RET 129 okseek: 130 // system call filled in newoffset already 131 MOVW $0, R0 132 MOVW R0, err+24(FP) 133 BL runtime·exitsyscall(SB) 134 RET 135 136 // func RawSyscall(trap uintptr, a1, a2, a3 uintptr) (r1, r2, err uintptr); 137 TEXT ·RawSyscall(SB),NOSPLIT,$0-28 138 MOVW trap+0(FP), R7 // syscall entry 139 MOVW a1+4(FP), R0 140 MOVW a2+8(FP), R1 141 MOVW a3+12(FP), R2 142 SWI $0 143 MOVW $0xfffff001, R1 144 CMP R1, R0 145 BLS ok1 146 MOVW $-1, R1 147 MOVW R1, r1+16(FP) 148 MOVW $0, R2 149 MOVW R2, r2+20(FP) 150 RSB $0, R0, R0 151 MOVW R0, err+24(FP) 152 RET 153 ok1: 154 MOVW R0, r1+16(FP) 155 MOVW $0, R0 156 MOVW R0, r2+20(FP) 157 MOVW R0, err+24(FP) 158 RET 159