提交 10d0268c 编写于 作者: R Rich Felker

switch to using trap number 31 for syscalls on sh

nominally the low bits of the trap number on sh are the number of
syscall arguments, but they have never been used by the kernel, and
some code making syscalls does not even know the number of arguments
and needs to pass an arbitrary high number anyway.

sh3/sh4 traditionally used the trap range 16-31 for syscalls, but part
of this range overlapped with hardware exceptions/interrupts on sh2
hardware, so an incompatible range 32-47 was chosen for sh2.

using trap number 31 everywhere, since it's in the existing sh3/sh4
range and does not conflict with sh2 hardware, is a proposed
unification of the kernel syscall convention that will allow binaries
to be shared between sh2 and sh3/sh4. if this is not accepted into the
kernel, we can refit the sh2 target with runtime selection mechanisms
for the trap number, but doing so would be invasive and would entail
non-trivial overhead.
上级 3366a99b
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
*/ */
#define __asm_syscall(trapno, ...) do { \ #define __asm_syscall(trapno, ...) do { \
__asm__ __volatile__ ( \ __asm__ __volatile__ ( \
"trapa #" #trapno "\n" \ "trapa #31\n" \
"or r0, r0\n" \ "or r0, r0\n" \
"or r0, r0\n" \ "or r0, r0\n" \
"or r0, r0\n" \ "or r0, r0\n" \
......
...@@ -13,7 +13,7 @@ __syscall: ...@@ -13,7 +13,7 @@ __syscall:
mov.l @r15, r7 mov.l @r15, r7
mov.l @(4,r15), r0 mov.l @(4,r15), r0
mov.l @(8,r15), r1 mov.l @(8,r15), r1
trapa #22 trapa #31
or r0, r0 or r0, r0
or r0, r0 or r0, r0
or r0, r0 or r0, r0
......
...@@ -7,7 +7,7 @@ vfork: ...@@ -7,7 +7,7 @@ vfork:
mov #95, r3 mov #95, r3
add r3, r3 add r3, r3
trapa #16 trapa #31
or r0, r0 or r0, r0
or r0, r0 or r0, r0
or r0, r0 or r0, r0
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
.type __restore, @function .type __restore, @function
__restore: __restore:
mov #119, r3 !__NR_sigreturn mov #119, r3 !__NR_sigreturn
trapa #16 trapa #31
or r0, r0 or r0, r0
or r0, r0 or r0, r0
...@@ -15,7 +15,7 @@ __restore: ...@@ -15,7 +15,7 @@ __restore:
__restore_rt: __restore_rt:
mov #100, r3 !__NR_rt_sigreturn mov #100, r3 !__NR_rt_sigreturn
add #73, r3 add #73, r3
trapa #16 trapa #31
or r0, r0 or r0, r0
or r0, r0 or r0, r0
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
.type __unmapself_sh_mmu, @function .type __unmapself_sh_mmu, @function
__unmapself_sh_mmu: __unmapself_sh_mmu:
mov #91, r3 ! SYS_munmap mov #91, r3 ! SYS_munmap
trapa #18 trapa #31
or r0, r0 or r0, r0
or r0, r0 or r0, r0
...@@ -13,7 +13,7 @@ __unmapself_sh_mmu: ...@@ -13,7 +13,7 @@ __unmapself_sh_mmu:
mov #1, r3 ! SYS_exit mov #1, r3 ! SYS_exit
mov #0, r4 mov #0, r4
trapa #17 trapa #31
or r0, r0 or r0, r0
or r0, r0 or r0, r0
......
...@@ -17,7 +17,7 @@ __clone: ...@@ -17,7 +17,7 @@ __clone:
mov.l @r15, r6 ! r6 = ptid mov.l @r15, r6 ! r6 = ptid
mov.l @(8,r15), r7 ! r7 = ctid mov.l @(8,r15), r7 ! r7 = ctid
mov.l @(4,r15), r0 ! r0 = tls mov.l @(4,r15), r0 ! r0 = tls
trapa #21 trapa #31
or r0, r0 or r0, r0
or r0, r0 or r0, r0
...@@ -38,7 +38,7 @@ __clone: ...@@ -38,7 +38,7 @@ __clone:
mov #1, r3 ! __NR_exit mov #1, r3 ! __NR_exit
mov r0, r4 mov r0, r4
trapa #17 trapa #31
or r0, r0 or r0, r0
or r0, r0 or r0, r0
......
...@@ -31,7 +31,7 @@ L1: .long __cancel@PLT-(1b-.) ...@@ -31,7 +31,7 @@ L1: .long __cancel@PLT-(1b-.)
mov.l @(4,r15), r7 mov.l @(4,r15), r7
mov.l @(8,r15), r0 mov.l @(8,r15), r0
mov.l @(12,r15), r1 mov.l @(12,r15), r1
trapa #22 trapa #31
__cp_end: __cp_end:
! work around hardware bug ! work around hardware bug
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
.type pipe, @function .type pipe, @function
pipe: pipe:
mov #42, r3 mov #42, r3
trapa #17 trapa #31
! work around hardware bug ! work around hardware bug
or r0, r0 or r0, r0
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册