[PATCH] LoongArch: Add Syscall Assembly Implementation
caiyinyu
caiyinyu@loongson.cn
Thu Mar 23 08:40:13 GMT 2023
---
sysdeps/unix/sysv/linux/loongarch/syscall.S | 48 +++++++++++++++++++++
1 file changed, 48 insertions(+)
create mode 100644 sysdeps/unix/sysv/linux/loongarch/syscall.S
diff --git a/sysdeps/unix/sysv/linux/loongarch/syscall.S b/sysdeps/unix/sysv/linux/loongarch/syscall.S
new file mode 100644
index 0000000000..de2d5e9fb8
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/syscall.S
@@ -0,0 +1,48 @@
+/* Copyright (C) 2023 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+
+/* syscall (int nr, ...)
+
+ LoongArch system calls take between 0 and 7 arguments. On entry here nr
+ is in a0 and any other system call arguments are in register a1..a7.
+
+ For kernel entry we need to move the system call nr to a7 then
+ load the remaining arguments to register. */
+
+ ENTRY (syscall)
+ move t0, a7
+ move a7, a0 /* Syscall number -> a0. */
+ move a0, a1 /* shift arg1 - arg6. */
+ move a1, a2
+ move a2, a3
+ move a3, a4
+ move a4, a5
+ move a5, a6
+ move a6, t0 /* arg7 is saved in t0. */
+ syscall 0 /* Do the system call. */
+
+ lu12i.w t0, -1
+ bltu t0, a0, L (error)
+ ret /* Return to caller. */
+
+L (error):
+ b __syscall_error
+
+PSEUDO_END (syscall)
--
2.31.1
More information about the Libc-alpha
mailing list