From: caiyinyu <caiyinyu@loongson.cn>
To: libc-alpha@sourceware.org
Cc: adhemerval.zanella@linaro.org, xry111@xry111.site,
caiyinyu <caiyinyu@loongson.cn>
Subject: [PATCH] LoongArch: Add Syscall Assembly Implementation
Date: Thu, 23 Mar 2023 20:00:14 +0800 [thread overview]
Message-ID: <20230323120014.1089960-1-caiyinyu@loongson.cn> (raw)
---
sysdeps/unix/sysv/linux/loongarch/syscall.S | 49 +++++++++++++++++++++
1 file changed, 49 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..2b2cce3443
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/syscall.S
@@ -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)
--
2.31.1
next reply other threads:[~2023-03-23 12:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-23 12:00 caiyinyu [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-03-23 8:40 caiyinyu
2023-03-23 9:25 ` Xi Ruoyao
2023-03-23 12:01 ` caiyinyu
2023-03-23 13:12 ` Andreas Schwab
2023-03-23 13:34 ` Xi Ruoyao
2023-03-23 13:43 ` Xi Ruoyao
2023-03-23 17:34 ` Xi Ruoyao
2023-03-23 18:26 ` Xi Ruoyao
2023-03-23 18:40 ` Adhemerval Zanella Netto
2023-03-23 19:08 ` Xi Ruoyao
2023-03-23 13:12 ` Xi Ruoyao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230323120014.1089960-1-caiyinyu@loongson.cn \
--to=caiyinyu@loongson.cn \
--cc=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.org \
--cc=xry111@xry111.site \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).