Commit b0db7e87 authored by Mikio Hara's avatar Mikio Hara

syscall: fix system calls with misaligned arguments on freebsd/arm

This CL enables the current tree to work with FreeBSD 10-STABLE
on ARM EABI platforms, though there are still a few test fails.

Also updates documentation.

LGTM=iant
R=iant, dave
CC=golang-codereviews
https://golang.org/cl/61060044
parent 2277e8d3
...@@ -8,13 +8,13 @@ ...@@ -8,13 +8,13 @@
// System call support for ARM, FreeBSD // System call support for ARM, FreeBSD
// //
// func Syscall(trap int32, a1, a2, a3 int32) (r1, r2, err int32); // func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, errno uintptr);
// func Syscall6(trap int32, a1, a2, a3, a4, a5, a6 int32) (r1, r2, err int32); // func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr);
// func Syscall9(trap int32, a1, a2, a3, a4, a5, a6, a7, a8, a9 int64) (r1, r2, err int32) // func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2, errno uintptr)
TEXT ·Syscall(SB),NOSPLIT,$0-28 TEXT ·Syscall(SB),NOSPLIT,$0-28
BL runtime·entersyscall(SB) BL runtime·entersyscall(SB)
MOVW 0(FP), R7 // sigcall num MOVW 0(FP), R7 // syscall number
MOVW 4(FP), R0 // a1 MOVW 4(FP), R0 // a1
MOVW 8(FP), R1 // a2 MOVW 8(FP), R1 // a2
MOVW 12(FP), R2 // a3 MOVW 12(FP), R2 // a3
...@@ -23,69 +23,71 @@ TEXT ·Syscall(SB),NOSPLIT,$0-28 ...@@ -23,69 +23,71 @@ TEXT ·Syscall(SB),NOSPLIT,$0-28
BCS error BCS error
MOVW R0, 16(FP) // r1 MOVW R0, 16(FP) // r1
MOVW R1, 20(FP) // r2 MOVW R1, 20(FP) // r2
MOVW R2, 24(FP) // err MOVW R2, 24(FP) // errno
BL runtime·exitsyscall(SB) BL runtime·exitsyscall(SB)
RET RET
error: error:
MOVW $-1, R3 MOVW $-1, R3
MOVW R3, 16(FP) // r1 MOVW R3, 16(FP) // r1
MOVW R2, 20(FP) // r2 MOVW R2, 20(FP) // r2
MOVW R0, 24(FP) // err MOVW R0, 24(FP) // errno
BL runtime·exitsyscall(SB) BL runtime·exitsyscall(SB)
RET RET
TEXT ·Syscall6(SB),NOSPLIT,$0-40 TEXT ·Syscall6(SB),NOSPLIT,$0-40
BL runtime·entersyscall(SB) BL runtime·entersyscall(SB)
MOVW 0(FP), R7 // sigcall num MOVW 0(FP), R7 // syscall number
MOVW 4(FP), R0 // a1 MOVW 4(FP), R0 // a1
MOVW 8(FP), R1 // a2 MOVW 8(FP), R1 // a2
MOVW 12(FP), R2 // a3 MOVW 12(FP), R2 // a3
MOVW 16(FP), R3 // a4 MOVW 16(FP), R3 // a4
ADD $24, R13 // a5 to a6 are passed on stack MOVW R13, R4
MOVW $20(FP), R13 // a5 to a6 are passed on stack
SWI $0 // syscall SWI $0 // syscall
SUB $24, R13 MOVW R4, R13
MOVW $0, R2 MOVW $0, R2
BCS error6 BCS error6
MOVW R0, 28(FP) // r1 MOVW R0, 28(FP) // r1
MOVW R1, 32(FP) // r2 MOVW R1, 32(FP) // r2
MOVW R2, 36(FP) // err MOVW R2, 36(FP) // errno
BL runtime·exitsyscall(SB) BL runtime·exitsyscall(SB)
RET RET
error6: error6:
MOVW $-1, R3 MOVW $-1, R3
MOVW R3, 28(FP) // r1 MOVW R3, 28(FP) // r1
MOVW R2, 32(FP) // r2 MOVW R2, 32(FP) // r2
MOVW R0, 36(FP) // err MOVW R0, 36(FP) // errno
BL runtime·exitsyscall(SB) BL runtime·exitsyscall(SB)
RET RET
TEXT ·Syscall9(SB),NOSPLIT,$0-52 TEXT ·Syscall9(SB),NOSPLIT,$0-52
BL runtime·entersyscall(SB) BL runtime·entersyscall(SB)
MOVW 0(FP), R7 // sigcall num MOVW 0(FP), R7 // syscall number
MOVW 4(FP), R0 // a1 MOVW 4(FP), R0 // a1
MOVW 8(FP), R1 // a2 MOVW 8(FP), R1 // a2
MOVW 12(FP), R2 // a3 MOVW 12(FP), R2 // a3
MOVW 16(FP), R3 // a4 MOVW 16(FP), R3 // a4
ADD $24, R13 // a5 to a9 are passed on stack MOVW R13, R4
MOVW $20(FP), R13 // a5 to a9 are passed on stack
SWI $0 // syscall SWI $0 // syscall
SUB $24, R13 MOVW R4, R13
MOVW $0, R2 MOVW $0, R2
BCS error9 BCS error9
MOVW R0, 40(FP) // r1 MOVW R0, 40(FP) // r1
MOVW R1, 44(FP) // r2 MOVW R1, 44(FP) // r2
MOVW R2, 48(FP) // err MOVW R2, 48(FP) // errno
BL runtime·exitsyscall(SB) BL runtime·exitsyscall(SB)
RET RET
error9: error9:
MOVW $-1, R3 MOVW $-1, R3
MOVW R3, 40(FP) // r1 MOVW R3, 40(FP) // r1
MOVW R2, 44(FP) // r2 MOVW R2, 44(FP) // r2
MOVW R0, 48(FP) // err MOVW R0, 48(FP) // errno
BL runtime·exitsyscall(SB) BL runtime·exitsyscall(SB)
RET RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-28 TEXT ·RawSyscall(SB),NOSPLIT,$0-28
MOVW 0(FP), R7 // sigcall num MOVW 0(FP), R7 // syscall number
MOVW 4(FP), R0 // a1 MOVW 4(FP), R0 // a1
MOVW 8(FP), R1 // a2 MOVW 8(FP), R1 // a2
MOVW 12(FP), R2 // a3 MOVW 12(FP), R2 // a3
...@@ -94,33 +96,34 @@ TEXT ·RawSyscall(SB),NOSPLIT,$0-28 ...@@ -94,33 +96,34 @@ TEXT ·RawSyscall(SB),NOSPLIT,$0-28
BCS errorr BCS errorr
MOVW R0, 16(FP) // r1 MOVW R0, 16(FP) // r1
MOVW R1, 20(FP) // r2 MOVW R1, 20(FP) // r2
MOVW R2, 24(FP) // err MOVW R2, 24(FP) // errno
RET RET
errorr: errorr:
MOVW $-1, R3 MOVW $-1, R3
MOVW R3, 16(FP) // r1 MOVW R3, 16(FP) // r1
MOVW R2, 20(FP) // r2 MOVW R2, 20(FP) // r2
MOVW R0, 24(FP) // err MOVW R0, 24(FP) // errno
RET RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
MOVW 0(FP), R7 // sigcall num MOVW 0(FP), R7 // syscall number
MOVW 4(FP), R0 // a1 MOVW 4(FP), R0 // a1
MOVW 8(FP), R1 // a2 MOVW 8(FP), R1 // a2
MOVW 12(FP), R2 // a3 MOVW 12(FP), R2 // a3
MOVW 16(FP), R3 // a4 MOVW 16(FP), R3 // a4
ADD $24, R13 // a5 to a6 are passed on stack MOVW R13, R4
MOVW $20(FP), R13 // a5 to a6 are passed on stack
SWI $0 // syscall SWI $0 // syscall
SUB $24, R13 MOVW R4, R13
MOVW $0, R2 MOVW $0, R2
BCS errorr6 BCS errorr6
MOVW R0, 28(FP) // r1 MOVW R0, 28(FP) // r1
MOVW R1, 32(FP) // r2 MOVW R1, 32(FP) // r2
MOVW R2, 36(FP) // err MOVW R2, 36(FP) // errno
RET RET
errorr6: errorr6:
MOVW $-1, R3 MOVW $-1, R3
MOVW R3, 28(FP) // r1 MOVW R3, 28(FP) // r1
MOVW R2, 32(FP) // r2 MOVW R2, 32(FP) // r2
MOVW R0, 36(FP) // err MOVW R0, 36(FP) // errno
RET RET
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment