Commit d305fb13 authored by Alexander Kartashov's avatar Alexander Kartashov Committed by Pavel Emelyanov

arm: refactor the syscall glue to support ARMv6

This patch modifies the ARM syscall glue as follows:

* the macros syscallX that produce different code
  for syscalls with different number of arguments
  are replaced by the generic syscall thunk copied
  from libc;

* the syscall tables generation script is simplified
  since the syscall argument number analysis is redundant;

* the ARMv7 specific instruction MOVW is eliminated.
Signed-off-by: 's avatarAlexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 6ee9ad5b
...@@ -72,21 +72,7 @@ for (<IN>) { ...@@ -72,21 +72,7 @@ for (<IN>) {
if ($+{$code} ne "!") { if ($+{$code} ne "!") {
print CODESOUT "#define $code_macro $+{$code}\n"; print CODESOUT "#define $code_macro $+{$code}\n";
print ASMOUT "syscall $sys_name, $code_macro\n";
my $nargs;
if ($+{args} eq "void") {
$nargs = 0;
} else {
my $tmp = $+{args};
$nargs = 1 + ($tmp =~ tr/\,/\,/);
if ($nargs <= 4) {
$nargs = 0;
}
}
print ASMOUT "syscall$nargs $sys_name, $code_macro\n";
} else { } else {
$need_aux = 1; $need_aux = 1;
......
ENTRY(sys_mmap) nr_sys_mmap:
push { %r4, %r5, %r7 } .long 192
ldr %r4, [%sp, #12]
ldr %r5, [%sp, #16] ENTRY(sys_mmap)
lsr %r5, #12 push {%r4, %r5, %r7, %lr}
do_sys 192 ldr %r4, [%sp, #16]
pop { %r4, %r5, %r7 } ldr %r5, [%sp, #20]
bx %lr lsr %r5, #12
END(sys_mmap) adr %r7, nr_sys_mmap
\ No newline at end of file ldr %r7, [%r7]
svc 0x00000000
pop {%r4, %r5, %r7, %pc}
END(sys_mmap)
#include "asm/linkage.h" #include "asm/linkage.h"
.macro mov_r7 imm syscall_common:
mov %r7, #\imm ldr %r7, [%r7]
.endm add %ip, %sp, #16
ldm %ip, {%r4, %r5, %r6}
svc 0x00000000
pop {%r4, %r5, %r6, %r7}
bx %lr
// Call the kernel .macro syscall name, nr
.nr_\name :
.long \nr
.macro do_sys opcode ENTRY(\name)
movw %r7, #\opcode push {%r4, %r5, %r6, %r7}
svc #0 adr %r7, .nr_\name
.endm b syscall_common
END(\name)
.endm
// a syscall with 0-4 arguments
.macro syscall0 name, opcode
ENTRY(\name)
push { %r7 }
do_sys \opcode
pop { %r7 }
bx %lr
END(\name)
.endm
// a syscall with 5 arguments
.macro syscall5 name, opcode
ENTRY(\name)
push { %r4, %r7 }
ldr %r4, [%sp, #8]
do_sys \opcode
pop { %r4, %r7 }
bx %lr
END(\name)
.endm
// a syscall with 6 arguments
.macro syscall6 name, opcode
ENTRY(\name)
push { %r4, %r5, %r7 }
ldr %r4, [%sp, #12]
ldr %r5, [%sp, #16]
do_sys \opcode
pop { %r4, %r5, %r7 }
bx %lr
END(\name)
.endm
ENTRY(__cr_restore_rt) ENTRY(__cr_restore_rt)
do_sys __NR_rt_sigreturn b sys_rt_sigreturn
END(__cr_restore_rt) END(__cr_restore_rt)
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