bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/9] aarch64: Add public syscall ABI


From: Sergey Bugaev
Subject: [PATCH 3/9] aarch64: Add public syscall ABI
Date: Mon, 15 Apr 2024 12:01:43 +0300

We use largely the same ABI as Linux: a syscall is invoked with the
"svc #0" instruction, passing arguments the same way as for a regular
function call.  Specifically, up to 8 arguments are passed in the x0-x7
registers, and the rest are placed on the stack (this is only necessary
for the vm_map() syscall).  w8 should contain the (negative) Mach trap
number.  A syscall preserves all registers except for x0, which upon
returning contains the return value.
---
 aarch64/Makefrag.am                       |  2 ++
 aarch64/include/mach/aarch64/asm.h        | 39 +++++++++++++++++++++++
 aarch64/include/mach/aarch64/syscall_sw.h | 32 +++++++++++++++++++
 3 files changed, 73 insertions(+)
 create mode 100644 aarch64/include/mach/aarch64/asm.h
 create mode 100644 aarch64/include/mach/aarch64/syscall_sw.h

diff --git a/aarch64/Makefrag.am b/aarch64/Makefrag.am
index 15ce3f49..7949d7ba 100644
--- a/aarch64/Makefrag.am
+++ b/aarch64/Makefrag.am
@@ -27,9 +27,11 @@ if HOST_aarch64
 
 include_mach_aarch64dir = $(includedir)/mach/aarch64
 include_mach_aarch64_HEADERS = \
+       aarch64/include/mach/aarch64/asm.h \
        aarch64/include/mach/aarch64/boolean.h \
        aarch64/include/mach/aarch64/kern_return.h \
        aarch64/include/mach/aarch64/machine_types.defs \
+       aarch64/include/mach/aarch64/syscall_sw.h \
        aarch64/include/mach/aarch64/vm_types.h
 
 endif # HOST_aarch64
diff --git a/aarch64/include/mach/aarch64/asm.h 
b/aarch64/include/mach/aarch64/asm.h
new file mode 100644
index 00000000..ae94e637
--- /dev/null
+++ b/aarch64/include/mach/aarch64/asm.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2023-2024 Free Software Foundation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef _MACH_AARCH64_ASM_H_
+#define _MACH_AARCH64_ASM_H_
+
+#define EXT(x)         x
+#define LEXT(x)                x ## :
+#define SEXT(x)                #x
+
+#define TEXT_ALIGN     4
+#define DATA_ALIGN     4
+
+#define SVC            svc # (0)
+#define ENTRY(x)       .globl EXT(x); .type EXT(x), @function; .p2align 
TEXT_ALIGN; LEXT(x)
+#define END(x)         .size x,.-x
+
+#ifdef __ARM_FEATURE_BTI_DEFAULT
+#define MACH_BTI_C     bti c
+#else
+#define MACH_BTI_C
+#endif
+
+#endif /* _MACH_AARCH64_ASM_H_ */
diff --git a/aarch64/include/mach/aarch64/syscall_sw.h 
b/aarch64/include/mach/aarch64/syscall_sw.h
new file mode 100644
index 00000000..cf13dd7e
--- /dev/null
+++ b/aarch64/include/mach/aarch64/syscall_sw.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2023-2024 Free Software Foundation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef        _MACH_AARCH64_SYSCALL_SW_H_
+#define _MACH_AARCH64_SYSCALL_SW_H_
+
+#include <mach/machine/asm.h>
+
+#define kernel_trap(trap_name,trap_number,number_args)  \
+ENTRY(trap_name)  \
+       MACH_BTI_C; \
+       mov w8, #(trap_number);  \
+       SVC;  \
+       ret;  \
+END(trap_name)
+
+#endif /* _MACH_AARCH64_SYSCALL_SW_H_ */
-- 
2.44.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]