You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/12/30 03:47:50 UTC
[incubator-nuttx] branch master updated: arch/risc-v: Refine syscall interface
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 2de2298 arch/risc-v: Refine syscall interface
2de2298 is described below
commit 2de22980e59f53a9bd4c54db9c70cacb813c2cfa
Author: Huang Qi <hu...@xiaomi.com>
AuthorDate: Wed Dec 29 23:49:31 2021 +0800
arch/risc-v: Refine syscall interface
Signed-off-by: Huang Qi <hu...@xiaomi.com>
---
arch/risc-v/include/rv32im/syscall.h | 204 -------------------
arch/risc-v/include/rv64gc/syscall.h | 349 ---------------------------------
arch/risc-v/include/syscall.h | 290 ++++++++++++++++++++++++++-
arch/risc-v/src/bl602/Make.defs | 2 +-
arch/risc-v/src/esp32c3/Make.defs | 2 +-
arch/risc-v/src/fe310/Make.defs | 2 +-
arch/risc-v/src/litex/Make.defs | 2 +-
arch/risc-v/src/qemu-rv32/Make.defs | 2 +-
arch/risc-v/src/rv32im/riscv_syscall.S | 91 ---------
arch/risc-v/src/rv32m1/Make.defs | 2 +-
10 files changed, 287 insertions(+), 659 deletions(-)
diff --git a/arch/risc-v/include/rv32im/syscall.h b/arch/risc-v/include/rv32im/syscall.h
deleted file mode 100644
index c884bf2..0000000
--- a/arch/risc-v/include/rv32im/syscall.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/****************************************************************************
- * arch/risc-v/include/rv32im/syscall.h
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership. The
- * ASF licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- *
- ****************************************************************************/
-
-/* This file should never be included directly but, rather, only indirectly
- * through include/syscall.h or include/sys/sycall.h
- */
-
-#ifndef __ARCH_RISCV_INCLUDE_RV32IM_SYSCALL_H
-#define __ARCH_RISCV_INCLUDE_RV32IM_SYSCALL_H
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#ifndef __ASSEMBLY__
-# include <stdint.h>
-#endif
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define SYS_syscall 0x00
-
-/* Configuration ************************************************************/
-
-/* SYS call 1 and 2 are defined for internal use by the RISC-V port (see
- * arch/riscv/include/mips32/syscall.h). In addition, SYS call 3 is the
- * return from a SYS call in kernel mode. The first four syscall values
- * must, therefore, be reserved (0 is not used).
- */
-
-#ifdef CONFIG_BUILD_KERNEL
-# ifndef CONFIG_SYS_RESERVED
-# error "CONFIG_SYS_RESERVED must be defined to the value 4"
-# elif CONFIG_SYS_RESERVED != 4
-# error "CONFIG_SYS_RESERVED must have the value 4"
-# endif
-#endif
-
-/* sys_call macros **********************************************************/
-
-#ifndef __ASSEMBLY__
-
-/* Context switching system calls *******************************************/
-
-/* SYS call 0:
- *
- * int riscv_saveusercontext(uint32_t *saveregs);
- *
- * Return:
- * 0: Normal Return
- * 1: Context Switch Return
- */
-
-#define SYS_save_context (0)
-#define riscv_saveusercontext(saveregs) \
- (int)sys_call1(SYS_save_context, (uintptr_t)saveregs)
-
-/* SYS call 1:
- *
- * void riscv_fullcontextrestore(uint32_t *restoreregs) noreturn_function;
- */
-
-#define SYS_restore_context (1)
-#define riscv_fullcontextrestore(restoreregs) \
- sys_call1(SYS_restore_context, (uintptr_t)restoreregs)
-
-/* SYS call 2:
- *
- * void riscv_switchcontext(uint32_t *saveregs, uint32_t *restoreregs);
- */
-
-#define SYS_switch_context (2)
-#define riscv_switchcontext(saveregs, restoreregs) \
- sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs)
-
-#ifdef CONFIG_BUILD_KERNEL
-/* SYS call 3:
- *
- * void riscv_syscall_return(void);
- */
-
-#define SYS_syscall_return (3)
-#define riscv_syscall_return() (void)sys_call0(SYS_syscall_return)
-
-#endif
-#endif /* __ASSEMBLY__ */
-
-/****************************************************************************
- * Public Types
- ****************************************************************************/
-
-/****************************************************************************
- * Inline functions
- ****************************************************************************/
-
-#ifndef __ASSEMBLY__
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-/****************************************************************************
- * Public Function Prototypes
- ****************************************************************************/
-
-#ifdef __cplusplus
-#define EXTERN extern "C"
-extern "C"
-{
-#else
-#define EXTERN extern
-#endif
-
-/****************************************************************************
- * Name: sys_call0
- *
- * Description:
- * System call SYS_ argument and no additional parameters.
- *
- ****************************************************************************/
-
-uintptr_t sys_call0(unsigned int nbr);
-
-/****************************************************************************
- * Name: sys_call1
- *
- * Description:
- * System call SYS_ argument and one additional parameter.
- *
- ****************************************************************************/
-
-uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1);
-
-/****************************************************************************
- * Name: sys_call2
- *
- * Description:
- * System call SYS_ argument and two additional parameters.
- *
- ****************************************************************************/
-
-uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, uintptr_t parm2);
-
-/****************************************************************************
- * Name: sys_call3
- *
- * Description:
- * System call SYS_ argument and three additional parameters.
- *
- ****************************************************************************/
-
-uintptr_t sys_call3(unsigned int nbr, uintptr_t parm1, uintptr_t parm2,
- uintptr_t parm3);
-
-/****************************************************************************
- * Name: sys_call4
- *
- * Description:
- * System call SYS_ argument and four additional parameters.
- *
- ****************************************************************************/
-
-uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1, uintptr_t parm2,
- uintptr_t parm3, uintptr_t parm4);
-
-/****************************************************************************
- * Name: sys_call5
- *
- * Description:
- * System call SYS_ argument and five additional parameters.
- *
- ****************************************************************************/
-
-uintptr_t sys_call5(unsigned int nbr, uintptr_t parm1, uintptr_t parm2,
- uintptr_t parm3, uintptr_t parm4, uintptr_t parm5);
-
-#undef EXTERN
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __ASSEMBLY__ */
-#endif /* __ARCH_RISCV_INCLUDE_RV32IM_SYSCALL_H */
diff --git a/arch/risc-v/include/rv64gc/syscall.h b/arch/risc-v/include/rv64gc/syscall.h
deleted file mode 100644
index d352809..0000000
--- a/arch/risc-v/include/rv64gc/syscall.h
+++ /dev/null
@@ -1,349 +0,0 @@
-/****************************************************************************
- * arch/risc-v/include/rv64gc/syscall.h
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership. The
- * ASF licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- *
- ****************************************************************************/
-
-/* This file should never be included directly but, rather, only indirectly
- * through include/syscall.h or include/sys/sycall.h
- */
-
-#ifndef __ARCH_RISCV_INCLUDE_RV64GC_SYSCALL_H
-#define __ARCH_RISCV_INCLUDE_RV64GC_SYSCALL_H
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#ifndef __ASSEMBLY__
-# include <stdint.h>
-#endif
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define SYS_syscall 0x00
-
-/* The SYS_signal_handler_return is executed here... its value is not always
- * available in this context and so is assumed to be 7.
- */
-
-#ifndef SYS_signal_handler_return
-# define SYS_signal_handler_return (7)
-#elif SYS_signal_handler_return != 7
-# error "SYS_signal_handler_return was assumed to be 7"
-#endif
-
-/* Configuration ************************************************************/
-
-/* SYS call 1 and 2 are defined for internal use by the RISC-V port (see
- * arch/risc-v/include/rv64gc/syscall.h). In addition, SYS call 3 is the
- * return from a SYS call in kernel mode. The first four syscall values must,
- * therefore, be reserved (0 is not used).
- */
-
-#ifdef CONFIG_BUILD_KERNEL
-# ifndef CONFIG_SYS_RESERVED
-# error "CONFIG_SYS_RESERVED must be defined to the value 4"
-# elif CONFIG_SYS_RESERVED != 4
-# error "CONFIG_SYS_RESERVED must have the value 4"
-# endif
-#endif
-
-/* sys_call macros **********************************************************/
-
-#ifndef __ASSEMBLY__
-
-/* Context switching system calls *******************************************/
-
-/* SYS call 0:
- *
- * int riscv_saveusercontext(uint64_t *saveregs);
- *
- * Return:
- * 0: Normal Return
- * 1: Context Switch Return
- */
-
-#define SYS_save_context (0)
-#define riscv_saveusercontext(saveregs) \
- (int)sys_call1(SYS_save_context, (uintptr_t)saveregs)
-
-/* SYS call 1:
- *
- * void riscv_fullcontextrestore(uint32_t *restoreregs) noreturn_function;
- */
-
-#define SYS_restore_context (1)
-#define riscv_fullcontextrestore(restoreregs) \
- sys_call1(SYS_restore_context, (uintptr_t)restoreregs)
-
-/* SYS call 2:
- *
- * void riscv_switchcontext(uint32_t *saveregs, uint32_t *restoreregs);
- */
-
-#define SYS_switch_context (2)
-#define riscv_switchcontext(saveregs, restoreregs) \
- sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs)
-
-#ifdef CONFIG_BUILD_KERNEL
-/* SYS call 3:
- *
- * void riscv_syscall_return(void);
- */
-
-#define SYS_syscall_return (3)
-#define riscv_syscall_return() sys_call0(SYS_syscall_return)
-
-#endif
-#endif /* __ASSEMBLY__ */
-
-/****************************************************************************
- * Public Types
- ****************************************************************************/
-
-/****************************************************************************
- * Inline functions
- ****************************************************************************/
-
-#ifndef __ASSEMBLY__
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-/****************************************************************************
- * Public Function Prototypes
- ****************************************************************************/
-
-#ifdef __cplusplus
-#define EXTERN extern "C"
-extern "C"
-{
-#else
-#define EXTERN extern
-#endif
-
-/****************************************************************************
- * Name: sys_call0
- *
- * Description:
- * System call SYS_ argument and no additional parameters.
- *
- ****************************************************************************/
-
-static inline uintptr_t sys_call0(unsigned int nbr)
-{
- register long r0 asm("a0") = (long)(nbr);
-
- asm volatile
- (
- "ecall"
- :: "r"(r0)
- : "memory"
- );
-
- asm volatile("nop" : "=r"(r0));
-
- return r0;
-}
-
-/****************************************************************************
- * Name: sys_call1
- *
- * Description:
- * System call SYS_ argument and one additional parameter.
- *
- ****************************************************************************/
-
-static inline uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1)
-{
- register long r0 asm("a0") = (long)(nbr);
- register long r1 asm("a1") = (long)(parm1);
-
- asm volatile
- (
- "ecall"
- :: "r"(r0), "r"(r1)
- : "memory"
- );
-
- asm volatile("nop" : "=r"(r0));
-
- return r0;
-}
-
-/****************************************************************************
- * Name: sys_call2
- *
- * Description:
- * System call SYS_ argument and two additional parameters.
- *
- ****************************************************************************/
-
-static inline uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1,
- uintptr_t parm2)
-{
- register long r0 asm("a0") = (long)(nbr);
- register long r1 asm("a1") = (long)(parm1);
- register long r2 asm("a2") = (long)(parm2);
-
- asm volatile
- (
- "ecall"
- :: "r"(r0), "r"(r1), "r"(r2)
- : "memory"
- );
-
- asm volatile("nop" : "=r"(r0));
-
- return r0;
-}
-
-/****************************************************************************
- * Name: sys_call3
- *
- * Description:
- * System call SYS_ argument and three additional parameters.
- *
- ****************************************************************************/
-
-static inline uintptr_t sys_call3(unsigned int nbr, uintptr_t parm1,
- uintptr_t parm2, uintptr_t parm3)
-{
- register long r0 asm("a0") = (long)(nbr);
- register long r1 asm("a1") = (long)(parm1);
- register long r2 asm("a2") = (long)(parm2);
- register long r3 asm("a3") = (long)(parm3);
-
- asm volatile
- (
- "ecall"
- :: "r"(r0), "r"(r1), "r"(r2), "r"(r3)
- : "memory"
- );
-
- asm volatile("nop" : "=r"(r0));
-
- return r0;
-}
-
-/****************************************************************************
- * Name: sys_call4
- *
- * Description:
- * System call SYS_ argument and four additional parameters.
- *
- ****************************************************************************/
-
-static inline uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1,
- uintptr_t parm2, uintptr_t parm3,
- uintptr_t parm4)
-{
- register long r0 asm("a0") = (long)(nbr);
- register long r1 asm("a1") = (long)(parm1);
- register long r2 asm("a2") = (long)(parm2);
- register long r3 asm("a3") = (long)(parm3);
- register long r4 asm("a4") = (long)(parm4);
-
- asm volatile
- (
- "ecall"
- :: "r"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r4)
- : "memory"
- );
-
- asm volatile("nop" : "=r"(r0));
-
- return r0;
-}
-
-/****************************************************************************
- * Name: sys_call5
- *
- * Description:
- * System call SYS_ argument and five additional parameters.
- *
- ****************************************************************************/
-
-static inline uintptr_t sys_call5(unsigned int nbr, uintptr_t parm1,
- uintptr_t parm2, uintptr_t parm3,
- uintptr_t parm4, uintptr_t parm5)
-{
- register long r0 asm("a0") = (long)(nbr);
- register long r1 asm("a1") = (long)(parm1);
- register long r2 asm("a2") = (long)(parm2);
- register long r3 asm("a3") = (long)(parm3);
- register long r4 asm("a4") = (long)(parm4);
- register long r5 asm("a5") = (long)(parm5);
-
- asm volatile
- (
- "ecall"
- :: "r"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r4), "r"(r5)
- : "memory"
- );
-
- asm volatile("nop" : "=r"(r0));
-
- return r0;
-}
-
-/****************************************************************************
- * Name: sys_call6
- *
- * Description:
- * System call SYS_ argument and six additional parameters.
- *
- ****************************************************************************/
-
-static inline uintptr_t sys_call6(unsigned int nbr, uintptr_t parm1,
- uintptr_t parm2, uintptr_t parm3,
- uintptr_t parm4, uintptr_t parm5,
- uintptr_t parm6)
-{
- register long r0 asm("a0") = (long)(nbr);
- register long r1 asm("a1") = (long)(parm1);
- register long r2 asm("a2") = (long)(parm2);
- register long r3 asm("a3") = (long)(parm3);
- register long r4 asm("a4") = (long)(parm4);
- register long r5 asm("a5") = (long)(parm5);
- register long r6 asm("a6") = (long)(parm6);
-
- asm volatile
- (
- "ecall"
- :: "r"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r4), "r"(r5), "r"(r6)
- : "memory"
- );
-
- asm volatile("nop" : "=r"(r0));
-
- return r0;
-}
-
-#undef EXTERN
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __ASSEMBLY__ */
-#endif /* __ARCH_RISCV_INCLUDE_RV64GC_SYSCALL_H */
diff --git a/arch/risc-v/include/syscall.h b/arch/risc-v/include/syscall.h
index 1a912e5..e5e15a1 100644
--- a/arch/risc-v/include/syscall.h
+++ b/arch/risc-v/include/syscall.h
@@ -29,20 +29,93 @@
* Included Files
****************************************************************************/
-/* Include RISC-V architecture-specific syscall macros */
+#include <nuttx/config.h>
-#ifdef CONFIG_ARCH_RV32
-# include <arch/rv32im/syscall.h>
-#endif
-
-#ifdef CONFIG_ARCH_RV64
-# include <arch/rv64gc/syscall.h>
+#ifndef __ASSEMBLY__
+# include <stdint.h>
#endif
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+#define SYS_syscall 0x00
+
+/* The SYS_signal_handler_return is executed here... its value is not always
+ * available in this context and so is assumed to be 7.
+ */
+
+#ifndef SYS_signal_handler_return
+# define SYS_signal_handler_return (7)
+#elif SYS_signal_handler_return != 7
+# error "SYS_signal_handler_return was assumed to be 7"
+#endif
+
+/* Configuration ************************************************************/
+
+/* SYS call 1 and 2 are defined for internal use by the RISC-V port (see
+ * arch/risc-v/include/rv64gc/syscall.h). In addition, SYS call 3 is the
+ * return from a SYS call in kernel mode. The first four syscall values must,
+ * therefore, be reserved (0 is not used).
+ */
+
+#ifdef CONFIG_BUILD_KERNEL
+# ifndef CONFIG_SYS_RESERVED
+# error "CONFIG_SYS_RESERVED must be defined to the value 4"
+# elif CONFIG_SYS_RESERVED != 4
+# error "CONFIG_SYS_RESERVED must have the value 4"
+# endif
+#endif
+
+/* sys_call macros **********************************************************/
+
+#ifndef __ASSEMBLY__
+
+/* Context switching system calls *******************************************/
+
+/* SYS call 0:
+ *
+ * int riscv_saveusercontext(uint64_t *saveregs);
+ *
+ * Return:
+ * 0: Normal Return
+ * 1: Context Switch Return
+ */
+
+#define SYS_save_context (0)
+#define riscv_saveusercontext(saveregs) \
+ (int)sys_call1(SYS_save_context, (uintptr_t)saveregs)
+
+/* SYS call 1:
+ *
+ * void riscv_fullcontextrestore(uint32_t *restoreregs) noreturn_function;
+ */
+
+#define SYS_restore_context (1)
+#define riscv_fullcontextrestore(restoreregs) \
+ sys_call1(SYS_restore_context, (uintptr_t)restoreregs)
+
+/* SYS call 2:
+ *
+ * void riscv_switchcontext(uint32_t *saveregs, uint32_t *restoreregs);
+ */
+
+#define SYS_switch_context (2)
+#define riscv_switchcontext(saveregs, restoreregs) \
+ sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs)
+
+#ifdef CONFIG_BUILD_KERNEL
+/* SYS call 3:
+ *
+ * void riscv_syscall_return(void);
+ */
+
+#define SYS_syscall_return (3)
+#define riscv_syscall_return() sys_call0(SYS_syscall_return)
+
+#endif
+#endif /* __ASSEMBLY__ */
+
/****************************************************************************
* Public Types
****************************************************************************/
@@ -51,6 +124,8 @@
* Inline functions
****************************************************************************/
+#ifndef __ASSEMBLY__
+
/****************************************************************************
* Public Data
****************************************************************************/
@@ -59,7 +134,6 @@
* Public Function Prototypes
****************************************************************************/
-#ifndef __ASSEMBLY__
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
@@ -68,10 +142,208 @@ extern "C"
#define EXTERN extern
#endif
+/****************************************************************************
+ * Name: sys_call0
+ *
+ * Description:
+ * System call SYS_ argument and no additional parameters.
+ *
+ ****************************************************************************/
+
+static inline uintptr_t sys_call0(unsigned int nbr)
+{
+ register long r0 asm("a0") = (long)(nbr);
+
+ asm volatile
+ (
+ "ecall"
+ :: "r"(r0)
+ : "memory"
+ );
+
+ asm volatile("nop" : "=r"(r0));
+
+ return r0;
+}
+
+/****************************************************************************
+ * Name: sys_call1
+ *
+ * Description:
+ * System call SYS_ argument and one additional parameter.
+ *
+ ****************************************************************************/
+
+static inline uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1)
+{
+ register long r0 asm("a0") = (long)(nbr);
+ register long r1 asm("a1") = (long)(parm1);
+
+ asm volatile
+ (
+ "ecall"
+ :: "r"(r0), "r"(r1)
+ : "memory"
+ );
+
+ asm volatile("nop" : "=r"(r0));
+
+ return r0;
+}
+
+/****************************************************************************
+ * Name: sys_call2
+ *
+ * Description:
+ * System call SYS_ argument and two additional parameters.
+ *
+ ****************************************************************************/
+
+static inline uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1,
+ uintptr_t parm2)
+{
+ register long r0 asm("a0") = (long)(nbr);
+ register long r1 asm("a1") = (long)(parm1);
+ register long r2 asm("a2") = (long)(parm2);
+
+ asm volatile
+ (
+ "ecall"
+ :: "r"(r0), "r"(r1), "r"(r2)
+ : "memory"
+ );
+
+ asm volatile("nop" : "=r"(r0));
+
+ return r0;
+}
+
+/****************************************************************************
+ * Name: sys_call3
+ *
+ * Description:
+ * System call SYS_ argument and three additional parameters.
+ *
+ ****************************************************************************/
+
+static inline uintptr_t sys_call3(unsigned int nbr, uintptr_t parm1,
+ uintptr_t parm2, uintptr_t parm3)
+{
+ register long r0 asm("a0") = (long)(nbr);
+ register long r1 asm("a1") = (long)(parm1);
+ register long r2 asm("a2") = (long)(parm2);
+ register long r3 asm("a3") = (long)(parm3);
+
+ asm volatile
+ (
+ "ecall"
+ :: "r"(r0), "r"(r1), "r"(r2), "r"(r3)
+ : "memory"
+ );
+
+ asm volatile("nop" : "=r"(r0));
+
+ return r0;
+}
+
+/****************************************************************************
+ * Name: sys_call4
+ *
+ * Description:
+ * System call SYS_ argument and four additional parameters.
+ *
+ ****************************************************************************/
+
+static inline uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1,
+ uintptr_t parm2, uintptr_t parm3,
+ uintptr_t parm4)
+{
+ register long r0 asm("a0") = (long)(nbr);
+ register long r1 asm("a1") = (long)(parm1);
+ register long r2 asm("a2") = (long)(parm2);
+ register long r3 asm("a3") = (long)(parm3);
+ register long r4 asm("a4") = (long)(parm4);
+
+ asm volatile
+ (
+ "ecall"
+ :: "r"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r4)
+ : "memory"
+ );
+
+ asm volatile("nop" : "=r"(r0));
+
+ return r0;
+}
+
+/****************************************************************************
+ * Name: sys_call5
+ *
+ * Description:
+ * System call SYS_ argument and five additional parameters.
+ *
+ ****************************************************************************/
+
+static inline uintptr_t sys_call5(unsigned int nbr, uintptr_t parm1,
+ uintptr_t parm2, uintptr_t parm3,
+ uintptr_t parm4, uintptr_t parm5)
+{
+ register long r0 asm("a0") = (long)(nbr);
+ register long r1 asm("a1") = (long)(parm1);
+ register long r2 asm("a2") = (long)(parm2);
+ register long r3 asm("a3") = (long)(parm3);
+ register long r4 asm("a4") = (long)(parm4);
+ register long r5 asm("a5") = (long)(parm5);
+
+ asm volatile
+ (
+ "ecall"
+ :: "r"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r4), "r"(r5)
+ : "memory"
+ );
+
+ asm volatile("nop" : "=r"(r0));
+
+ return r0;
+}
+
+/****************************************************************************
+ * Name: sys_call6
+ *
+ * Description:
+ * System call SYS_ argument and six additional parameters.
+ *
+ ****************************************************************************/
+
+static inline uintptr_t sys_call6(unsigned int nbr, uintptr_t parm1,
+ uintptr_t parm2, uintptr_t parm3,
+ uintptr_t parm4, uintptr_t parm5,
+ uintptr_t parm6)
+{
+ register long r0 asm("a0") = (long)(nbr);
+ register long r1 asm("a1") = (long)(parm1);
+ register long r2 asm("a2") = (long)(parm2);
+ register long r3 asm("a3") = (long)(parm3);
+ register long r4 asm("a4") = (long)(parm4);
+ register long r5 asm("a5") = (long)(parm5);
+ register long r6 asm("a6") = (long)(parm6);
+
+ asm volatile
+ (
+ "ecall"
+ :: "r"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r4), "r"(r5), "r"(r6)
+ : "memory"
+ );
+
+ asm volatile("nop" : "=r"(r0));
+
+ return r0;
+}
+
#undef EXTERN
#ifdef __cplusplus
}
#endif
-#endif
+#endif /* __ASSEMBLY__ */
#endif /* __ARCH_RISCV_INCLUDE_SYSCALL_H */
diff --git a/arch/risc-v/src/bl602/Make.defs b/arch/risc-v/src/bl602/Make.defs
index cd1a8c7..4196ba7 100644
--- a/arch/risc-v/src/bl602/Make.defs
+++ b/arch/risc-v/src/bl602/Make.defs
@@ -23,7 +23,7 @@
HEAD_ASRC = bl602_vectors.S
# Specify our general Assembly files
-CHIP_ASRCS = bl602_head.S riscv_syscall.S bl602_entry.S
+CHIP_ASRCS = bl602_head.S bl602_entry.S
CMN_ASRCS += riscv_testset.S
diff --git a/arch/risc-v/src/esp32c3/Make.defs b/arch/risc-v/src/esp32c3/Make.defs
index 5e8e843..91d65f1 100644
--- a/arch/risc-v/src/esp32c3/Make.defs
+++ b/arch/risc-v/src/esp32c3/Make.defs
@@ -25,7 +25,7 @@ include chip/Bootloader.mk
HEAD_ASRC = esp32c3_head.S
-CHIP_ASRCS = esp32c3_vectors.S esp32c3_interrupt.S riscv_syscall.S
+CHIP_ASRCS = esp32c3_vectors.S esp32c3_interrupt.S
# Specify C code within the common directory to be included
diff --git a/arch/risc-v/src/fe310/Make.defs b/arch/risc-v/src/fe310/Make.defs
index c70ff62..241bcce 100644
--- a/arch/risc-v/src/fe310/Make.defs
+++ b/arch/risc-v/src/fe310/Make.defs
@@ -23,7 +23,7 @@
HEAD_ASRC = fe310_vectors.S
# Specify our general Assembly files
-CHIP_ASRCS = fe310_head.S riscv_syscall.S
+CHIP_ASRCS = fe310_head.S
CMN_ASRCS += riscv_testset.S
diff --git a/arch/risc-v/src/litex/Make.defs b/arch/risc-v/src/litex/Make.defs
index 04f1850..05eb9ae 100644
--- a/arch/risc-v/src/litex/Make.defs
+++ b/arch/risc-v/src/litex/Make.defs
@@ -23,7 +23,7 @@
HEAD_ASRC = litex_vectors.S
# Specify our general Assembly files
-CHIP_ASRCS = litex_head.S riscv_syscall.S
+CHIP_ASRCS = litex_head.S
CMN_ASRCS += riscv_testset.S
diff --git a/arch/risc-v/src/qemu-rv32/Make.defs b/arch/risc-v/src/qemu-rv32/Make.defs
index 01bfb18..23d53bd 100644
--- a/arch/risc-v/src/qemu-rv32/Make.defs
+++ b/arch/risc-v/src/qemu-rv32/Make.defs
@@ -23,7 +23,7 @@
HEAD_ASRC = qemu_rv32_head.S
# Specify our general Assembly files
-CHIP_ASRCS = qemu_rv32_vectors.S riscv_syscall.S
+CHIP_ASRCS = qemu_rv32_vectors.S
CMN_ASRCS += riscv_testset.S
diff --git a/arch/risc-v/src/rv32im/riscv_syscall.S b/arch/risc-v/src/rv32im/riscv_syscall.S
deleted file mode 100644
index aca1930..0000000
--- a/arch/risc-v/src/rv32im/riscv_syscall.S
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
- * arch/riscv/src/rv32im/riscv_syscall.S
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership. The
- * ASF licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-/****************************************************************************
- * Public Symbols
- ****************************************************************************/
-
- .file "up_syscall0.S"
- .global sys_call0
- .global sys_call1
- .global sys_call2
- .global sys_call3
- .global sys_call4
- .global sys_call5
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: up_syscall0, up_syscall1, up_syscall2, up_syscall3
- *
- * Description:
- * up_syscall0 - System call SYS_ argument and no additional parameters.
- * up_syscall1 - System call SYS_ argument and one additional parameter.
- * up_syscall2 - System call SYS_ argument and two additional parameters.
- * up_syscall3 - System call SYS_ argument and three additional parameters.
- * up_syscall4 - System call SYS_ argument and four additional parameters.
- * up_syscall5 - System call SYS_ argument and five additional parameters.
- *
- * Assumption:
- * All interrupts are disabled except for the software interrupts.
- *
- ****************************************************************************/
-
- .text
-
-sys_call0: /* a0 holds the syscall number */
-sys_call1: /* a0 holds the syscall number, argument in a1 */
-sys_call2: /* a0 holds the syscall number, arguments in a1 and a2 */
-sys_call3: /* a0 holds the syscall number, arguments in a1, a2, and a3 */
-sys_call4: /* a0 holds the syscall number, arguments in a1, a2, a3 and a4 */
-sys_call5: /* a0 holds the syscall number, arguments in a1, a2, a3, a4 and a5 */
-
- /* Issue the ECALL opcode to perform a SW interrupt to the OS */
-
- ecall
-
- /* The actual interrupt may not a occur for a few more cycles. Let's
- * put a few nop's here in hope that the SW interrupt occurs during
- * the sequence of nops.
- */
-
- nop
- nop
-
- /* Then return with the result of the software interrupt in v0 */
-
- ret
- nop
diff --git a/arch/risc-v/src/rv32m1/Make.defs b/arch/risc-v/src/rv32m1/Make.defs
index cab15a6..e777e99 100644
--- a/arch/risc-v/src/rv32m1/Make.defs
+++ b/arch/risc-v/src/rv32m1/Make.defs
@@ -23,7 +23,7 @@
HEAD_ASRC = rv32m1_vectors.S
# Specify our general Assembly files
-CHIP_ASRCS = rv32m1_head.S riscv_syscall.S
+CHIP_ASRCS = rv32m1_head.S
# Specify C code within the common directory to be included
CMN_CSRCS += riscv_initialize.c riscv_swint.c