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>) {
if ($+{$code} ne "!") {
print CODESOUT "#define $code_macro $+{$code}\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";
print ASMOUT "syscall $sys_name, $code_macro\n";
} else {
$need_aux = 1;
......
ENTRY(sys_mmap)
push { %r4, %r5, %r7 }
ldr %r4, [%sp, #12]
ldr %r5, [%sp, #16]
lsr %r5, #12
do_sys 192
pop { %r4, %r5, %r7 }
bx %lr
END(sys_mmap)
\ No newline at end of file
nr_sys_mmap:
.long 192
ENTRY(sys_mmap)
push {%r4, %r5, %r7, %lr}
ldr %r4, [%sp, #16]
ldr %r5, [%sp, #20]
lsr %r5, #12
adr %r7, nr_sys_mmap
ldr %r7, [%r7]
svc 0x00000000
pop {%r4, %r5, %r7, %pc}
END(sys_mmap)
#include "asm/linkage.h"
.macro mov_r7 imm
mov %r7, #\imm
.endm
syscall_common:
ldr %r7, [%r7]
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
movw %r7, #\opcode
svc #0
.endm
ENTRY(\name)
push {%r4, %r5, %r6, %r7}
adr %r7, .nr_\name
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)
do_sys __NR_rt_sigreturn
b sys_rt_sigreturn
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