From patchwork Thu Mar 23 08:40:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: caiyinyu X-Patchwork-Id: 66789 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 984E3387089E for ; Thu, 23 Mar 2023 08:40:42 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id E87D63870896 for ; Thu, 23 Mar 2023 08:40:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E87D63870896 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [10.2.5.5]) by gateway (Coremail) with SMTP id _____8DxUOV4EBxkA0IQAA--.24545S3; Thu, 23 Mar 2023 16:40:24 +0800 (CST) Received: from 5.5.5 (unknown [10.2.5.5]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cxtrx1EBxkBDkKAA--.1679S2; Thu, 23 Mar 2023 16:40:21 +0800 (CST) From: caiyinyu To: libc-alpha@sourceware.org Cc: adhemerval.zanella@linaro.org, xry111@xry111.site, caiyinyu Subject: [PATCH] LoongArch: Add Syscall Assembly Implementation Date: Thu, 23 Mar 2023 16:40:13 +0800 Message-Id: <20230323084013.1100656-1-caiyinyu@loongson.cn> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Cxtrx1EBxkBDkKAA--.1679S2 X-CM-SenderInfo: 5fdl5xhq1xqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvJXoW7Zr4kWw1rCFyxGF48KF48WFg_yoW8CFy3p3 yruw15Gr48tFyxCr93W3W3X3Z5Cr1f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PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" --- 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 + . */ + +#include + +/* 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)