Joel Sing | 550149f | 2015-02-16 02:28:39 +1100 | [diff] [blame] | 1 | // Copyright 2013 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 call support for ARM, OpenBSD |
| 10 | // |
| 11 | |
| 12 | // func Syscall(trap int32, a1, a2, a3 int32) (r1, r2, err int32); |
| 13 | // func Syscall6(trap int32, a1, a2, a3, a4, a5, a6 int32) (r1, r2, err int32); |
| 14 | // func Syscall9(trap int32, a1, a2, a3, a4, a5, a6, a7, a8, a9 int64) (r1, r2, err int32) |
| 15 | // func RawSyscall(trap int32, a1, a2, a3 int32) (r1, r2, err int32); |
| 16 | // func RawSyscall6(trap int32, a1, a2, a3, a4, a5, a6 int32) (r1, r2, err int32); |
| 17 | |
| 18 | TEXT ·Syscall(SB),NOSPLIT,$0-28 |
| 19 | BL runtime·entersyscall(SB) |
Josh Bleecher Snyder | 71ab9fa | 2016-07-11 16:05:57 -0700 | [diff] [blame] | 20 | MOVW trap+0(FP), R12 // syscall number |
Joel Sing | 550149f | 2015-02-16 02:28:39 +1100 | [diff] [blame] | 21 | MOVW a1+4(FP), R0 // arg 1 |
| 22 | MOVW a2+8(FP), R1 // arg 2 |
| 23 | MOVW a3+12(FP), R2 // arg 3 |
| 24 | SWI $0 |
| 25 | MOVW $0, R2 |
| 26 | BCS error |
| 27 | MOVW R0, r1+16(FP) // ret 1 |
| 28 | MOVW R1, r2+20(FP) // ret 2 |
| 29 | MOVW R2, err+24(FP) // err |
| 30 | BL runtime·exitsyscall(SB) |
| 31 | RET |
| 32 | error: |
| 33 | MOVW $-1, R3 |
| 34 | MOVW R3, r1+16(FP) // ret 1 |
| 35 | MOVW R2, r2+20(FP) // ret 2 |
| 36 | MOVW R0, err+24(FP) // err |
| 37 | BL runtime·exitsyscall(SB) |
| 38 | RET |
| 39 | |
| 40 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 |
| 41 | BL runtime·entersyscall(SB) |
Josh Bleecher Snyder | 71ab9fa | 2016-07-11 16:05:57 -0700 | [diff] [blame] | 42 | MOVW trap+0(FP), R12 // syscall number |
Joel Sing | 550149f | 2015-02-16 02:28:39 +1100 | [diff] [blame] | 43 | MOVW a1+4(FP), R0 // arg 1 |
| 44 | MOVW a2+8(FP), R1 // arg 2 |
| 45 | MOVW a3+12(FP), R2 // arg 3 |
| 46 | MOVW a4+16(FP), R3 // arg 4 |
| 47 | MOVW R13, R4 |
| 48 | MOVW $a5+20(FP), R13 // arg 5 to arg 6 are passed on stack |
| 49 | SWI $0 |
| 50 | MOVW R4, R13 |
| 51 | MOVW $0, R2 |
| 52 | BCS error6 |
| 53 | MOVW R0, r1+28(FP) // ret 1 |
| 54 | MOVW R1, r2+32(FP) // ret 2 |
| 55 | MOVW R2, err+36(FP) // err |
| 56 | BL runtime·exitsyscall(SB) |
| 57 | RET |
| 58 | error6: |
| 59 | MOVW $-1, R3 |
| 60 | MOVW R3, r1+28(FP) // ret 1 |
| 61 | MOVW R2, r2+32(FP) // ret 2 |
| 62 | MOVW R0, err+36(FP) // err |
| 63 | BL runtime·exitsyscall(SB) |
| 64 | RET |
| 65 | |
| 66 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 |
| 67 | BL runtime·entersyscall(SB) |
Josh Bleecher Snyder | 71ab9fa | 2016-07-11 16:05:57 -0700 | [diff] [blame] | 68 | MOVW num+0(FP), R12 // syscall number |
Joel Sing | 550149f | 2015-02-16 02:28:39 +1100 | [diff] [blame] | 69 | MOVW a1+4(FP), R0 // arg 1 |
| 70 | MOVW a2+8(FP), R1 // arg 2 |
| 71 | MOVW a3+12(FP), R2 // arg 3 |
| 72 | MOVW a4+16(FP), R3 // arg 4 |
| 73 | MOVW R13, R4 |
| 74 | MOVW $a5+20(FP), R13 // arg 5 to arg 9 are passed on stack |
| 75 | SWI $0 |
| 76 | MOVW R4, R13 |
| 77 | MOVW $0, R2 |
| 78 | BCS error9 |
| 79 | MOVW R0, r1+40(FP) // ret 1 |
| 80 | MOVW R1, r2+44(FP) // ret 2 |
| 81 | MOVW R2, err+48(FP) // err |
| 82 | BL runtime·exitsyscall(SB) |
| 83 | RET |
| 84 | error9: |
| 85 | MOVW $-1, R3 |
| 86 | MOVW R3, r1+40(FP) // ret 1 |
| 87 | MOVW R2, r2+44(FP) // ret 2 |
| 88 | MOVW R0, err+48(FP) // err |
| 89 | BL runtime·exitsyscall(SB) |
| 90 | RET |
| 91 | |
| 92 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 |
Josh Bleecher Snyder | 71ab9fa | 2016-07-11 16:05:57 -0700 | [diff] [blame] | 93 | MOVW trap+0(FP), R12 // syscall number |
Joel Sing | 550149f | 2015-02-16 02:28:39 +1100 | [diff] [blame] | 94 | MOVW a1+4(FP), R0 // arg 1 |
| 95 | MOVW a2+8(FP), R1 // arg 2 |
| 96 | MOVW a3+12(FP), R2 // arg 3 |
| 97 | SWI $0 |
| 98 | MOVW $0, R2 |
| 99 | BCS errorr |
| 100 | MOVW R0, r1+16(FP) // ret 1 |
| 101 | MOVW R1, r2+20(FP) // ret 2 |
| 102 | MOVW R2, err+24(FP) // err |
| 103 | RET |
| 104 | errorr: |
| 105 | MOVW $-1, R3 |
| 106 | MOVW R3, r1+16(FP) // ret 1 |
| 107 | MOVW R2, r2+20(FP) // ret 2 |
| 108 | MOVW R0, err+24(FP) // err |
| 109 | RET |
| 110 | |
| 111 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 |
Josh Bleecher Snyder | 71ab9fa | 2016-07-11 16:05:57 -0700 | [diff] [blame] | 112 | MOVW trap+0(FP), R12 // syscall number |
Joel Sing | 550149f | 2015-02-16 02:28:39 +1100 | [diff] [blame] | 113 | MOVW a1+4(FP), R0 // arg 1 |
| 114 | MOVW a2+8(FP), R1 // arg 2 |
| 115 | MOVW a3+12(FP), R2 // arg 3 |
| 116 | MOVW a4+16(FP), R3 // arg 4 |
| 117 | MOVW R13, R4 |
| 118 | MOVW $a5+20(FP), R13 // arg 5 to arg 6 are passed on stack |
| 119 | SWI $0 |
| 120 | MOVW R4, R13 |
| 121 | MOVW $0, R2 |
| 122 | BCS errorr6 |
| 123 | MOVW R0, r1+28(FP) // ret 1 |
| 124 | MOVW R1, r2+32(FP) // ret 2 |
| 125 | MOVW R2, err+36(FP) // err |
| 126 | RET |
| 127 | errorr6: |
| 128 | MOVW $-1, R3 |
| 129 | MOVW R3, r1+28(FP) // ret 1 |
| 130 | MOVW R2, r2+32(FP) // ret 2 |
| 131 | MOVW R0, err+36(FP) // err |
| 132 | RET |