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 #define SYS_SEEK 39 /* from zsysnum_plan9.go */ 9 10 // System call support for plan9 on arm 11 12 TEXT sysresult<>(SB),NOSPLIT,$12 13 MOVW $runtimeemptystring+0(SB), R2 14 CMP $-1, R0 15 B.NE ok 16 MOVW R1, save-4(SP) 17 BL runtimeerrstr(SB) 18 MOVW save-4(SP), R1 19 MOVW $err-12(SP), R2 20 ok: 21 MOVM.IA (R2), [R3-R4] 22 MOVM.IA [R3-R4], (R1) 23 RET 24 25 //func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err ErrorString) 26 TEXT Syscall(SB),NOSPLIT,$0-32 27 BL runtimeentersyscall(SB) 28 MOVW trap+0(FP), R0 // syscall num 29 MOVM.IA.W (R13),[R1-R2] // pop LR and caller's LR 30 SWI 0 31 MOVM.DB.W [R1-R2],(R13) // push LR and caller's LR 32 MOVW $0, R2 33 MOVW $r1+16(FP), R1 34 MOVM.IA.W [R0,R2], (R1) 35 BL sysresult<>(SB) 36 BL runtimeexitsyscall(SB) 37 RET 38 39 //func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err ErrorString) 40 // Actually Syscall5 but the rest of the code expects it to be named Syscall6. 41 TEXT Syscall6(SB),NOSPLIT,$0-44 42 BL runtimeentersyscall(SB) 43 MOVW trap+0(FP), R0 // syscall num 44 MOVM.IA.W (R13),[R1-R2] // pop LR and caller's LR 45 SWI 0 46 MOVM.DB.W [R1-R2],(R13) // push LR and caller's LR 47 MOVW $0, R1 48 MOVW $r1+28(FP), R1 49 MOVM.IA.W [R0,R2], (R1) 50 BL sysresult<>(SB) 51 BL runtimeexitsyscall(SB) 52 RET 53 54 //func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) 55 TEXT RawSyscall(SB),NOSPLIT,$0-28 56 MOVW trap+0(FP), R0 // syscall num 57 MOVM.IA.W (R13),[R1] // pop caller's LR 58 SWI 0 59 MOVM.DB.W [R1],(R13) // push caller's LR 60 MOVW R0, r1+16(FP) 61 MOVW R0, r2+20(FP) 62 MOVW R0, err+24(FP) 63 RET 64 65 //func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) 66 // Actually RawSyscall5 but the rest of the code expects it to be named RawSyscall6. 67 TEXT RawSyscall6(SB),NOSPLIT,$0-40 68 MOVW trap+0(FP), R0 // syscall num 69 MOVM.IA.W (R13),[R1] // pop caller's LR 70 SWI 0 71 MOVM.DB.W [R1],(R13) // push caller's LR 72 MOVW R0, r1+28(FP) 73 MOVW R0, r2+32(FP) 74 MOVW R0, err+36(FP) 75 RET 76 77 //func seek(placeholder uintptr, fd int, offset int64, whence int) (newoffset int64, err string) 78 TEXT seek(SB),NOSPLIT,$0-36 79 MOVW $newoffset_lo+20(FP), R5 80 MOVW R5, placeholder+0(FP) //placeholder = dest for return value 81 MOVW $SYS_SEEK, R0 // syscall num 82 MOVM.IA.W (R13),[R1] // pop LR 83 SWI 0 84 MOVM.DB.W [R1],(R13) // push LR 85 CMP $-1, R0 86 MOVW.EQ R0, 0(R5) 87 MOVW.EQ R0, 4(R5) 88 MOVW $err+28(FP), R1 89 BL sysresult<>(SB) 90 RET 91 92 //func exit(code int) 93 // Import runtimeexit for cleanly exiting. 94 TEXT exit(SB),NOSPLIT,$4-4 95 NO_LOCAL_POINTERS 96 MOVW code+0(FP), R0 97 MOVW R0, e-4(SP) 98 BL runtimeexit(SB) 99 RET 100