AArch64: Add support for AArch64 to the syscall interface
This patch adds support for AArch64 to the syscall interface. The kernel
implementation exports a set of canonical syscalls, therefore some of
the userspace exported syscalls are implemented as stubs based on the
canonical set.
Change-Id: Ia965d71e97769b8be9d7655193fc40303964c4df
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
diff --git a/libc/tools/gensyscalls.py b/libc/tools/gensyscalls.py
index 5595cd7..bf44b70 100755
--- a/libc/tools/gensyscalls.py
+++ b/libc/tools/gensyscalls.py
@@ -56,6 +56,29 @@
#
+# AArch64 assembler templates for each syscall stub
+#
+
+aarch64_call = syscall_stub_header + """\
+ stp x29, x30, [sp, #-16]!
+ mov x29, sp
+ str x8, [sp, #-16]!
+
+ mov x8, %(__NR_name)s
+ svc #0
+
+ ldr x8, [sp], #16
+ ldp x29, x30, [sp], #16
+
+ cmn x0, #(MAX_ERRNO + 1)
+ cneg x0, x0, hi
+ b.hi __set_errno
+
+ ret
+END(%(func)s)
+"""
+
+#
# ARM assembler templates for each syscall stub
#
@@ -246,6 +269,10 @@
return stub
+def aarch64_genstub(syscall):
+ return aarch64_call % syscall
+
+
def arm_eabi_genstub(syscall):
num_regs = count_arm_param_registers(syscall["params"])
if num_regs > 4:
@@ -277,6 +304,7 @@
result += x86_return % syscall
return result
+
def x86_genstub_socketcall(syscall):
# %ebx <--- Argument 1 - The call id of the needed vectored
# syscall (socket, bind, recv, etc)
@@ -339,6 +367,9 @@
for syscall in self.syscalls:
syscall["__NR_name"] = make__NR_name(syscall["name"])
+ if syscall.has_key("aarch64"):
+ syscall["asm-aarch64"] = add_footer(64, aarch64_genstub(syscall), syscall)
+
if syscall.has_key("arm"):
syscall["asm-arm"] = add_footer(32, arm_eabi_genstub(syscall), syscall)
@@ -357,7 +388,6 @@
if syscall.has_key("x86_64"):
syscall["asm-x86_64"] = add_footer(64, x86_64_genstub(syscall), syscall)
-
# Scan a Linux kernel asm/unistd.h file containing __NR_* constants
# and write out equivalent SYS_* constants for glibc source compatibility.
def scan_linux_unistd_h(self, fp, path):
@@ -380,7 +410,9 @@
glibc_fp.write("#ifndef _BIONIC_GLIBC_SYSCALLS_H_\n")
glibc_fp.write("#define _BIONIC_GLIBC_SYSCALLS_H_\n")
- glibc_fp.write("#if defined(__arm__)\n")
+ glibc_fp.write("#if defined(__aarch64__)\n")
+ self.scan_linux_unistd_h(glibc_fp, bionic_libc_root + "/kernel/uapi/asm-generic/unistd.h")
+ glibc_fp.write("#elif defined(__arm__)\n")
self.scan_linux_unistd_h(glibc_fp, bionic_libc_root + "/kernel/arch-arm/asm/unistd.h")
glibc_fp.write("#elif defined(__mips__)\n")
self.scan_linux_unistd_h(glibc_fp, bionic_libc_root + "/kernel/arch-mips/asm/unistd.h")