LoongArch: Add Syscall Assembly Implementation
Checks
Context |
Check |
Description |
dj/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
dj/TryBot-32bit |
success
|
Build for i686
|
Commit Message
---
sysdeps/unix/sysv/linux/loongarch/syscall.S | 49 +++++++++++++++++++++
1 file changed, 49 insertions(+)
create mode 100644 sysdeps/unix/sysv/linux/loongarch/syscall.S
new file mode 100644
@@ -0,0 +1,49 @@
+/* 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 a0 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. */
+
+ LI t0, -4096
+ bltu t0, a0, L (error)
+
+ jirl zero, ra, 0 /* Return to caller. */
+
+L (error):
+ b __syscall_error
+
+PSEUDO_END (syscall)