Kai Backman | ee31157 | 2009-08-28 07:23:24 -0700 | [diff] [blame] | 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 | |
Rob Pike | 8bca148 | 2014-08-12 17:04:45 -0700 | [diff] [blame] | 5 | #include "textflag.h" |
Russ Cox | 860a645 | 2014-09-12 00:55:24 -0400 | [diff] [blame] | 6 | #include "funcdata.h" |
Keith Randall | db324cc | 2013-08-12 10:24:30 -0700 | [diff] [blame] | 7 | |
Kai Backman | e5c884f | 2009-10-01 06:55:01 -0700 | [diff] [blame] | 8 | // |
| 9 | // System calls for arm, Linux |
| 10 | // |
| 11 | |
Kai Backman | e5c884f | 2009-10-01 06:55:01 -0700 | [diff] [blame] | 12 | // TODO(kaib): handle error returns |
| 13 | |
| 14 | // func Syscall(syscall uintptr, a1, a2, a3 uintptr) (r1, r2, err uintptr); |
| 15 | |
Keith Randall | db324cc | 2013-08-12 10:24:30 -0700 | [diff] [blame] | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 |
Russ Cox | 22a5c78 | 2009-10-15 23:10:49 -0700 | [diff] [blame] | 17 | BL runtime·entersyscall(SB) |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 18 | MOVW trap+0(FP), R7 |
| 19 | MOVW a1+4(FP), R0 |
| 20 | MOVW a2+8(FP), R1 |
| 21 | MOVW a3+12(FP), R2 |
Russ Cox | 8382463 | 2014-09-04 23:12:10 -0400 | [diff] [blame] | 22 | MOVW $0, R3 |
| 23 | MOVW $0, R4 |
| 24 | MOVW $0, R5 |
Kai Backman | 6f91ba1 | 2009-10-25 11:51:16 -0700 | [diff] [blame] | 25 | SWI $0 |
Kai Backman | df88fc6 | 2010-08-06 16:57:49 -0700 | [diff] [blame] | 26 | MOVW $0xfffff001, R1 |
| 27 | CMP R1, R0 |
| 28 | BLS ok |
| 29 | MOVW $-1, R1 |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 30 | MOVW R1, r1+16(FP) |
Kai Backman | df88fc6 | 2010-08-06 16:57:49 -0700 | [diff] [blame] | 31 | MOVW $0, R2 |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 32 | MOVW R2, r2+20(FP) |
Kai Backman | df88fc6 | 2010-08-06 16:57:49 -0700 | [diff] [blame] | 33 | RSB $0, R0, R0 |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 34 | MOVW R0, err+24(FP) |
Kai Backman | df88fc6 | 2010-08-06 16:57:49 -0700 | [diff] [blame] | 35 | BL runtime·exitsyscall(SB) |
| 36 | RET |
| 37 | ok: |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 38 | MOVW R0, r1+16(FP) |
Kai Backman | 98fff8f | 2009-10-08 22:16:08 -0700 | [diff] [blame] | 39 | MOVW $0, R0 |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 40 | MOVW R0, r2+20(FP) |
| 41 | MOVW R0, err+24(FP) |
Russ Cox | 22a5c78 | 2009-10-15 23:10:49 -0700 | [diff] [blame] | 42 | BL runtime·exitsyscall(SB) |
Kai Backman | e5c884f | 2009-10-01 06:55:01 -0700 | [diff] [blame] | 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. |
Keith Randall | db324cc | 2013-08-12 10:24:30 -0700 | [diff] [blame] | 47 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 |
Russ Cox | 22a5c78 | 2009-10-15 23:10:49 -0700 | [diff] [blame] | 48 | BL runtime·entersyscall(SB) |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 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 |
Kai Backman | 6f91ba1 | 2009-10-25 11:51:16 -0700 | [diff] [blame] | 56 | SWI $0 |
Russ Cox | 1142b60 | 2010-10-20 10:39:46 -0400 | [diff] [blame] | 57 | MOVW $0xfffff001, R6 |
| 58 | CMP R6, R0 |
Kai Backman | df88fc6 | 2010-08-06 16:57:49 -0700 | [diff] [blame] | 59 | BLS ok6 |
| 60 | MOVW $-1, R1 |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 61 | MOVW R1, r1+28(FP) |
Kai Backman | df88fc6 | 2010-08-06 16:57:49 -0700 | [diff] [blame] | 62 | MOVW $0, R2 |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 63 | MOVW R2, r2+32(FP) |
Kai Backman | df88fc6 | 2010-08-06 16:57:49 -0700 | [diff] [blame] | 64 | RSB $0, R0, R0 |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 65 | MOVW R0, err+36(FP) |
Kai Backman | df88fc6 | 2010-08-06 16:57:49 -0700 | [diff] [blame] | 66 | BL runtime·exitsyscall(SB) |
| 67 | RET |
| 68 | ok6: |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 69 | MOVW R0, r1+28(FP) |
| 70 | MOVW R1, r2+32(FP) |
Kai Backman | 98fff8f | 2009-10-08 22:16:08 -0700 | [diff] [blame] | 71 | MOVW $0, R0 |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 72 | MOVW R0, err+36(FP) |
Russ Cox | 22a5c78 | 2009-10-15 23:10:49 -0700 | [diff] [blame] | 73 | BL runtime·exitsyscall(SB) |
Kai Backman | e5c884f | 2009-10-01 06:55:01 -0700 | [diff] [blame] | 74 | RET |
| 75 | |
Ian Lance Taylor | 4fd41e4 | 2011-03-16 19:03:01 -0700 | [diff] [blame] | 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. |
Keith Randall | db324cc | 2013-08-12 10:24:30 -0700 | [diff] [blame] | 78 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 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 |
Ian Lance Taylor | 4fd41e4 | 2011-03-16 19:03:01 -0700 | [diff] [blame] | 86 | SWI $0 |
| 87 | MOVW $0xfffff001, R6 |
| 88 | CMP R6, R0 |
| 89 | BLS ok2 |
| 90 | MOVW $-1, R1 |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 91 | MOVW R1, r1+28(FP) |
Ian Lance Taylor | 4fd41e4 | 2011-03-16 19:03:01 -0700 | [diff] [blame] | 92 | MOVW $0, R2 |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 93 | MOVW R2, r2+32(FP) |
Ian Lance Taylor | 4fd41e4 | 2011-03-16 19:03:01 -0700 | [diff] [blame] | 94 | RSB $0, R0, R0 |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 95 | MOVW R0, err+36(FP) |
Ian Lance Taylor | 4fd41e4 | 2011-03-16 19:03:01 -0700 | [diff] [blame] | 96 | RET |
| 97 | ok2: |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 98 | MOVW R0, r1+28(FP) |
| 99 | MOVW R1, r2+32(FP) |
Ian Lance Taylor | 4fd41e4 | 2011-03-16 19:03:01 -0700 | [diff] [blame] | 100 | MOVW $0, R0 |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 101 | MOVW R0, err+36(FP) |
Ian Lance Taylor | 4fd41e4 | 2011-03-16 19:03:01 -0700 | [diff] [blame] | 102 | RET |
| 103 | |
Russ Cox | 1142b60 | 2010-10-20 10:39:46 -0400 | [diff] [blame] | 104 | #define SYS__LLSEEK 140 /* from zsysnum_linux_arm.go */ |
Russ Cox | bf68f66 | 2014-05-16 12:15:32 -0400 | [diff] [blame] | 105 | // func seek(fd int, offset int64, whence int) (newoffset int64, errno int) |
Russ Cox | 1142b60 | 2010-10-20 10:39:46 -0400 | [diff] [blame] | 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) |
David Crawshaw | 094a054 | 2015-01-14 10:20:58 -0500 | [diff] [blame] | 110 | TEXT ·seek(SB),NOSPLIT,$0-28 |
Russ Cox | 1142b60 | 2010-10-20 10:39:46 -0400 | [diff] [blame] | 111 | BL runtime·entersyscall(SB) |
| 112 | MOVW $SYS__LLSEEK, R7 // syscall entry |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 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 |
Russ Cox | 1142b60 | 2010-10-20 10:39:46 -0400 | [diff] [blame] | 118 | SWI $0 |
| 119 | MOVW $0xfffff001, R6 |
| 120 | CMP R6, R0 |
| 121 | BLS okseek |
| 122 | MOVW $0, R1 |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 123 | MOVW R1, newoffset_lo+16(FP) |
| 124 | MOVW R1, newoffset_hi+20(FP) |
Russ Cox | 1142b60 | 2010-10-20 10:39:46 -0400 | [diff] [blame] | 125 | RSB $0, R0, R0 |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 126 | MOVW R0, err+24(FP) |
Russ Cox | 1142b60 | 2010-10-20 10:39:46 -0400 | [diff] [blame] | 127 | BL runtime·exitsyscall(SB) |
| 128 | RET |
| 129 | okseek: |
| 130 | // system call filled in newoffset already |
| 131 | MOVW $0, R0 |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 132 | MOVW R0, err+24(FP) |
Russ Cox | 1142b60 | 2010-10-20 10:39:46 -0400 | [diff] [blame] | 133 | BL runtime·exitsyscall(SB) |
| 134 | RET |
| 135 | |
Kai Backman | e5c884f | 2009-10-01 06:55:01 -0700 | [diff] [blame] | 136 | // func RawSyscall(trap uintptr, a1, a2, a3 uintptr) (r1, r2, err uintptr); |
Keith Randall | db324cc | 2013-08-12 10:24:30 -0700 | [diff] [blame] | 137 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 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 |
Kai Backman | 6f91ba1 | 2009-10-25 11:51:16 -0700 | [diff] [blame] | 142 | SWI $0 |
Kai Backman | df88fc6 | 2010-08-06 16:57:49 -0700 | [diff] [blame] | 143 | MOVW $0xfffff001, R1 |
| 144 | CMP R1, R0 |
| 145 | BLS ok1 |
| 146 | MOVW $-1, R1 |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 147 | MOVW R1, r1+16(FP) |
Kai Backman | df88fc6 | 2010-08-06 16:57:49 -0700 | [diff] [blame] | 148 | MOVW $0, R2 |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 149 | MOVW R2, r2+20(FP) |
Kai Backman | df88fc6 | 2010-08-06 16:57:49 -0700 | [diff] [blame] | 150 | RSB $0, R0, R0 |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 151 | MOVW R0, err+24(FP) |
Kai Backman | df88fc6 | 2010-08-06 16:57:49 -0700 | [diff] [blame] | 152 | RET |
| 153 | ok1: |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 154 | MOVW R0, r1+16(FP) |
Kai Backman | 98fff8f | 2009-10-08 22:16:08 -0700 | [diff] [blame] | 155 | MOVW $0, R0 |
David Crawshaw | e10e913 | 2015-01-14 14:36:17 -0500 | [diff] [blame] | 156 | MOVW R0, r2+20(FP) |
| 157 | MOVW R0, err+24(FP) |
Kai Backman | e5c884f | 2009-10-01 06:55:01 -0700 | [diff] [blame] | 158 | RET |
Russ Cox | 1142b60 | 2010-10-20 10:39:46 -0400 | [diff] [blame] | 159 | |