This is an automated email from the ASF dual-hosted git repository. archer pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 0c7517e57940abecfa720eaa5ad757561c98e093 Author: Xiang Xiao <[email protected]> AuthorDate: Fri Feb 25 01:49:58 2022 +0800 arch: Remove the duplicated syscall.h in each arch Signed-off-by: Xiang Xiao <[email protected]> --- arch/arm/include/arm/syscall.h | 252 ------------------------------- arch/arm/include/armv6-m/syscall.h | 270 ---------------------------------- arch/arm/include/armv7-a/syscall.h | 252 ------------------------------- arch/arm/include/armv7-m/syscall.h | 248 ------------------------------- arch/arm/include/armv7-r/syscall.h | 252 ------------------------------- arch/arm/include/armv8-m/syscall.h | 248 ------------------------------- arch/arm/include/syscall.h | 217 +++++++++++++++++++++++++-- arch/avr/include/avr/syscall.h | 122 --------------- arch/avr/include/avr32/syscall.h | 122 --------------- arch/avr/include/syscall.h | 69 +++++++-- arch/mips/include/mips32/syscall.h | 246 ------------------------------- arch/mips/include/syscall.h | 183 ++++++++++++++++++++++- arch/misoc/include/lm32/syscall.h | 193 ------------------------ arch/misoc/include/minerva/syscall.h | 192 ------------------------ arch/misoc/include/syscall.h | 160 +++++++++++++++++++- arch/sparc/include/sparc_v8/syscall.h | 195 ------------------------ arch/sparc/include/syscall.h | 131 ++++++++++++++++- arch/x86/include/i486/syscall.h | 122 --------------- arch/x86/include/syscall.h | 67 +++++++-- arch/x86_64/include/intel64/syscall.h | 156 -------------------- arch/x86_64/include/syscall.h | 100 +++++++++++-- 21 files changed, 867 insertions(+), 2930 deletions(-) diff --git a/arch/arm/include/arm/syscall.h b/arch/arm/include/arm/syscall.h deleted file mode 100644 index f7be3c1..0000000 --- a/arch/arm/include/arm/syscall.h +++ /dev/null @@ -1,252 +0,0 @@ -/**************************************************************************** - * arch/arm/include/arm/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_ARM_INCLUDE_ARM_SYSCALL_H -#define __ARCH_ARM_INCLUDE_ARM_SYSCALL_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#ifndef __ASSEMBLY__ -# include <stdint.h> -#endif - -/**************************************************************************** - * Pre-processor Prototypes - ****************************************************************************/ - -#define SYS_syscall 0x00 - -#if defined(__thumb__) || defined(__thumb2__) -# define SYS_smhcall 0xab -#else -# define SYS_smhcall 0x123456 -#endif - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Inline functions - ****************************************************************************/ - -#ifndef __ASSEMBLY__ - -/* SWI with SYS_ call number and no parameters */ - -static inline uintptr_t sys_call0(unsigned int nbr) -{ - register long reg0 __asm__("r0") = (long)(nbr); - - __asm__ __volatile__ - ( - "swi %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0) - : "memory", "r14" - ); - - return reg0; -} - -/* SWI with SYS_ call number and one parameter */ - -static inline uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "swi %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1) - : "memory", "r14" - ); - - return reg0; -} - -/* SWI with SYS_ call number and two parameters */ - -static inline uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "swi %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2) - : "memory", "r14" - ); - - return reg0; -} - -/* SWI with SYS_ call number and three parameters */ - -static inline uintptr_t sys_call3(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg3 __asm__("r3") = (long)(parm3); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "swi %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), "r"(reg3) - : "memory", "r14" - ); - - return reg0; -} - -/* SWI with SYS_ call number and four parameters */ - -static inline uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3, - uintptr_t parm4) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg4 __asm__("r4") = (long)(parm4); - register long reg3 __asm__("r3") = (long)(parm3); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "swi %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), - "r"(reg3), "r"(reg4) - : "memory", "r14" - ); - - return reg0; -} - -/* SWI with SYS_ call number and five 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 reg0 __asm__("r0") = (long)(nbr); - register long reg5 __asm__("r5") = (long)(parm5); - register long reg4 __asm__("r4") = (long)(parm4); - register long reg3 __asm__("r3") = (long)(parm3); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "swi %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), - "r"(reg3), "r"(reg4), "r"(reg5) - : "memory", "r14" - ); - - return reg0; -} - -/* SWI with SYS_ call number and six 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 reg0 __asm__("r0") = (long)(nbr); - register long reg6 __asm__("r6") = (long)(parm6); - register long reg5 __asm__("r5") = (long)(parm5); - register long reg4 __asm__("r4") = (long)(parm4); - register long reg3 __asm__("r3") = (long)(parm3); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "swi %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), - "r"(reg3), "r"(reg4), "r"(reg5), "r"(reg6) - : "memory", "r14" - ); - - return reg0; -} - -/* semihosting(SMH) call with call number and one parameter */ - -static inline long smh_call(unsigned int nbr, void *parm) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg1 __asm__("r1") = (long)(parm); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_smhcall), "r"(reg0), "r"(reg1) - : "memory", "r14" - ); - - return reg0; -} - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#ifdef __cplusplus -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif - -#undef EXTERN -#ifdef __cplusplus -} -#endif - -#endif /* __ASSEMBLY__ */ -#endif /* __ARCH_ARM_INCLUDE_ARM_SYSCALL_H */ diff --git a/arch/arm/include/armv6-m/syscall.h b/arch/arm/include/armv6-m/syscall.h deleted file mode 100644 index da96e1f..0000000 --- a/arch/arm/include/armv6-m/syscall.h +++ /dev/null @@ -1,270 +0,0 @@ -/**************************************************************************** - * arch/arm/include/armv6-m/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_ARM_INCLUDE_ARMV6_M_SYSCALL_H -#define __ARCH_ARM_INCLUDE_ARMV6_M_SYSCALL_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#ifndef __ASSEMBLY__ -# include <stdint.h> -#endif - -/**************************************************************************** - * Pre-processor Prototypes - ****************************************************************************/ - -/* This is the value used as the argument to the SVC instruction. It is not - * used. - */ - -#define SYS_syscall 0x00 -#define SYS_smhcall 0xab - -/* 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 - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Inline functions - ****************************************************************************/ - -#ifndef __ASSEMBLY__ - -/* SVC call with SYS_ call number and no parameters */ - -static inline uintptr_t sys_call0(unsigned int nbr) -{ - register long reg0 __asm__("r0") = (long)(nbr); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0) - : "memory" - ); - - return reg0; -} - -/* SVC call with SYS_ call number and one parameter */ - -static inline uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1) - : "memory" - ); - - return reg0; -} - -/* SVC call with SYS_ call number and two parameters */ - -static inline uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2) - : "memory" - ); - - return reg0; -} - -/* SVC call with SYS_ call number and three parameters */ - -static inline uintptr_t sys_call3(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg3 __asm__("r3") = (long)(parm3); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), "r"(reg3) - : "memory" - ); - - return reg0; -} - -/* SVC call with SYS_ call number and four parameters. - * - * NOTE the nonstandard parameter passing: parm4 is in R4 - */ - -static inline uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3, - uintptr_t parm4) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg4 __asm__("r4") = (long)(parm4); - register long reg3 __asm__("r3") = (long)(parm3); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), - "r"(reg3), "r"(reg4) - : "memory" - ); - - return reg0; -} - -/* SVC call with SYS_ call number and five parameters. - * - * NOTE the nonstandard parameter passing: parm4 and parm5 are in R4 and R5 - */ - -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 reg0 __asm__("r0") = (long)(nbr); - register long reg5 __asm__("r5") = (long)(parm5); - register long reg4 __asm__("r4") = (long)(parm4); - register long reg3 __asm__("r3") = (long)(parm3); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), - "r"(reg3), "r"(reg4), "r"(reg5) - : "memory" - ); - - return reg0; -} - -/* SVC call with SYS_ call number and six parameters. - * - * NOTE the nonstandard parameter passing: parm4-parm6 are in R4-R6 - */ - -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 reg0 __asm__("r0") = (long)(nbr); - register long reg6 __asm__("r6") = (long)(parm6); - register long reg5 __asm__("r5") = (long)(parm5); - register long reg4 __asm__("r4") = (long)(parm4); - register long reg3 __asm__("r3") = (long)(parm3); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), - "r"(reg3), "r"(reg4), "r"(reg5), "r"(reg6) - : "memory" - ); - - return reg0; -} - -/* semihosting(SMH) call with call number and one parameter */ - -static inline long smh_call(unsigned int nbr, void *parm) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg1 __asm__("r1") = (long)(parm); - - __asm__ __volatile__ - ( - "bkpt %1" - : "=r"(reg0) - : "i"(SYS_smhcall), "r"(reg0), "r"(reg1) - : "memory" - ); - - return reg0; -} - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#ifdef __cplusplus -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif - -#undef EXTERN -#ifdef __cplusplus -} -#endif - -#endif /* __ASSEMBLY__ */ -#endif /* __ARCH_ARM_INCLUDE_ARMV6_M_SYSCALL_H */ diff --git a/arch/arm/include/armv7-a/syscall.h b/arch/arm/include/armv7-a/syscall.h deleted file mode 100644 index a235a04..0000000 --- a/arch/arm/include/armv7-a/syscall.h +++ /dev/null @@ -1,252 +0,0 @@ -/**************************************************************************** - * arch/arm/include/armv7-a/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_ARM_INCLUDE_ARMV7_A_SYSCALL_H -#define __ARCH_ARM_INCLUDE_ARMV7_A_SYSCALL_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#ifndef __ASSEMBLY__ -# include <stdint.h> -#endif - -/**************************************************************************** - * Pre-processor Prototypes - ****************************************************************************/ - -#define SYS_syscall 0x00 - -#if defined(__thumb__) || defined(__thumb2__) -# define SYS_smhcall 0xab -#else -# define SYS_smhcall 0x123456 -#endif - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Inline functions - ****************************************************************************/ - -#ifndef __ASSEMBLY__ - -/* SVC with SYS_ call number and no parameters */ - -static inline uintptr_t sys_call0(unsigned int nbr) -{ - register long reg0 __asm__("r0") = (long)(nbr); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0) - : "memory", "r14" - ); - - return reg0; -} - -/* SVC with SYS_ call number and one parameter */ - -static inline uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1) - : "memory", "r14" - ); - - return reg0; -} - -/* SVC with SYS_ call number and two parameters */ - -static inline uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2) - : "memory", "r14" - ); - - return reg0; -} - -/* SVC with SYS_ call number and three parameters */ - -static inline uintptr_t sys_call3(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg3 __asm__("r3") = (long)(parm3); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), "r"(reg3) - : "memory", "r14" - ); - - return reg0; -} - -/* SVC with SYS_ call number and four parameters */ - -static inline uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3, - uintptr_t parm4) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg4 __asm__("r4") = (long)(parm4); - register long reg3 __asm__("r3") = (long)(parm3); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), - "r"(reg3), "r"(reg4) - : "memory", "r14" - ); - - return reg0; -} - -/* SVC with SYS_ call number and five 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 reg0 __asm__("r0") = (long)(nbr); - register long reg5 __asm__("r5") = (long)(parm5); - register long reg4 __asm__("r4") = (long)(parm4); - register long reg3 __asm__("r3") = (long)(parm3); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), - "r"(reg3), "r"(reg4), "r"(reg5) - : "memory", "r14" - ); - - return reg0; -} - -/* SVC with SYS_ call number and six 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 reg0 __asm__("r0") = (long)(nbr); - register long reg6 __asm__("r6") = (long)(parm6); - register long reg5 __asm__("r5") = (long)(parm5); - register long reg4 __asm__("r4") = (long)(parm4); - register long reg3 __asm__("r3") = (long)(parm3); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), - "r"(reg3), "r"(reg4), "r"(reg5), "r"(reg6) - : "memory", "r14" - ); - - return reg0; -} - -/* semihosting(SMH) call with call number and one parameter */ - -static inline long smh_call(unsigned int nbr, void *parm) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg1 __asm__("r1") = (long)(parm); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_smhcall), "r"(reg0), "r"(reg1) - : "memory", "r14" - ); - - return reg0; -} - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#ifdef __cplusplus -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif - -#undef EXTERN -#ifdef __cplusplus -} -#endif - -#endif /* __ASSEMBLY__ */ -#endif /* __ARCH_ARM_INCLUDE_ARMV7_A_SYSCALL_H */ diff --git a/arch/arm/include/armv7-m/syscall.h b/arch/arm/include/armv7-m/syscall.h deleted file mode 100644 index 83e809f..0000000 --- a/arch/arm/include/armv7-m/syscall.h +++ /dev/null @@ -1,248 +0,0 @@ -/**************************************************************************** - * arch/arm/include/armv7-m/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_ARM_INCLUDE_ARMV7_M_SYSCALL_H -#define __ARCH_ARM_INCLUDE_ARMV7_M_SYSCALL_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#ifndef __ASSEMBLY__ -# include <stdint.h> -#endif - -/**************************************************************************** - * Pre-processor Prototypes - ****************************************************************************/ - -/* This is the value used as the argument to the SVC instruction. It is not - * used. - */ - -#define SYS_syscall 0x00 -#define SYS_smhcall 0xab - -/* 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 - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Inline functions - ****************************************************************************/ - -#ifndef __ASSEMBLY__ - -/* SVC call with SYS_ call number and no parameters */ - -static inline uintptr_t sys_call0(unsigned int nbr) -{ - register long reg0 __asm__("r0") = (long)(nbr); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0) - : "memory" - ); - - return reg0; -} - -/* SVC call with SYS_ call number and one parameter */ - -static inline uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1) - : "memory" - ); - - return reg0; -} - -/* SVC call with SYS_ call number and two parameters */ - -static inline uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2) - : "memory" - ); - - return reg0; -} - -/* SVC call with SYS_ call number and three parameters */ - -static inline uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3, - uintptr_t parm4); -static inline uintptr_t sys_call3(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3) -{ - return sys_call4(nbr, parm1, parm2, parm3, 0); -} - -/* SVC call with SYS_ call number and four parameters. - * - * NOTE the nonstandard parameter passing: parm4 is in R4 - */ - -static inline uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3, - uintptr_t parm4) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg4 __asm__("r4") = (long)(parm4); - register long reg3 __asm__("r3") = (long)(parm3); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), - "r"(reg3), "r"(reg4) - : "memory" - ); - - return reg0; -} - -/* SVC call with SYS_ call number and five parameters. - * - * NOTE the nonstandard parameter passing: parm4 and parm5 are in R4 and R5 - */ - -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); -static inline uintptr_t sys_call5(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3, - uintptr_t parm4, uintptr_t parm5) -{ - return sys_call6(nbr, parm1, parm2, parm3, parm4, parm5, 0); -} - -/* SVC call with SYS_ call number and six parameters. - * - * NOTE the nonstandard parameter passing: parm4-parm6 are in R4-R6 - */ - -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 reg0 __asm__("r0") = (long)(nbr); - register long reg6 __asm__("r6") = (long)(parm6); - register long reg5 __asm__("r5") = (long)(parm5); - register long reg4 __asm__("r4") = (long)(parm4); - register long reg3 __asm__("r3") = (long)(parm3); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), - "r"(reg3), "r"(reg4), "r"(reg5), "r"(reg6) - : "memory" - ); - - return reg0; -} - -/* semihosting(SMH) call with call number and one parameter */ - -static inline long smh_call(unsigned int nbr, void *parm) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg1 __asm__("r1") = (long)(parm); - - __asm__ __volatile__ - ( - "bkpt %1" - : "=r"(reg0) - : "i"(SYS_smhcall), "r"(reg0), "r"(reg1) - : "memory" - ); - - return reg0; -} - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#ifdef __cplusplus -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif - -#undef EXTERN -#ifdef __cplusplus -} -#endif - -#endif /* __ASSEMBLY__ */ -#endif /* __ARCH_ARM_INCLUDE_ARMV7_M_SYSCALL_H */ diff --git a/arch/arm/include/armv7-r/syscall.h b/arch/arm/include/armv7-r/syscall.h deleted file mode 100644 index e86170f..0000000 --- a/arch/arm/include/armv7-r/syscall.h +++ /dev/null @@ -1,252 +0,0 @@ -/**************************************************************************** - * arch/arm/include/armv7-r/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_ARM_INCLUDE_ARMV7_R_SYSCALL_H -#define __ARCH_ARM_INCLUDE_ARMV7_R_SYSCALL_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#ifndef __ASSEMBLY__ -# include <stdint.h> -#endif - -/**************************************************************************** - * Pre-processor Prototypes - ****************************************************************************/ - -#define SYS_syscall 0x00 - -#if defined(__thumb__) || defined(__thumb2__) -# define SYS_smhcall 0xab -#else -# define SYS_smhcall 0x123456 -#endif - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Inline functions - ****************************************************************************/ - -#ifndef __ASSEMBLY__ - -/* SVC with SYS_ call number and no parameters */ - -static inline uintptr_t sys_call0(unsigned int nbr) -{ - register long reg0 __asm__("r0") = (long)(nbr); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0) - : "memory", "r14" - ); - - return reg0; -} - -/* SVC with SYS_ call number and one parameter */ - -static inline uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1) - : "memory", "r14" - ); - - return reg0; -} - -/* SVC with SYS_ call number and two parameters */ - -static inline uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2) - : "memory", "r14" - ); - - return reg0; -} - -/* SVC with SYS_ call number and three parameters */ - -static inline uintptr_t sys_call3(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg3 __asm__("r3") = (long)(parm3); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), "r"(reg3) - : "memory", "r14" - ); - - return reg0; -} - -/* SVC with SYS_ call number and four parameters */ - -static inline uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3, - uintptr_t parm4) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg4 __asm__("r4") = (long)(parm4); - register long reg3 __asm__("r3") = (long)(parm3); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), - "r"(reg3), "r"(reg4) - : "memory", "r14" - ); - - return reg0; -} - -/* SVC with SYS_ call number and five 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 reg0 __asm__("r0") = (long)(nbr); - register long reg5 __asm__("r5") = (long)(parm5); - register long reg4 __asm__("r4") = (long)(parm4); - register long reg3 __asm__("r3") = (long)(parm3); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), - "r"(reg3), "r"(reg4), "r"(reg5) - : "memory", "r14" - ); - - return reg0; -} - -/* SVC with SYS_ call number and six 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 reg0 __asm__("r0") = (long)(nbr); - register long reg6 __asm__("r6") = (long)(parm6); - register long reg5 __asm__("r5") = (long)(parm5); - register long reg4 __asm__("r4") = (long)(parm4); - register long reg3 __asm__("r3") = (long)(parm3); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), - "r"(reg3), "r"(reg4), "r"(reg5), "r"(reg6) - : "memory", "r14" - ); - - return reg0; -} - -/* semihosting(SMH) call with call number and one parameter */ - -static inline long smh_call(unsigned int nbr, void *parm) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg1 __asm__("r1") = (long)(parm); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_smhcall), "r"(reg0), "r"(reg1) - : "memory", "r14" - ); - - return reg0; -} - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#ifdef __cplusplus -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif - -#undef EXTERN -#ifdef __cplusplus -} -#endif - -#endif /* __ASSEMBLY__ */ -#endif /* __ARCH_ARM_INCLUDE_ARMV7_R_SYSCALL_H */ diff --git a/arch/arm/include/armv8-m/syscall.h b/arch/arm/include/armv8-m/syscall.h deleted file mode 100644 index 458c33a..0000000 --- a/arch/arm/include/armv8-m/syscall.h +++ /dev/null @@ -1,248 +0,0 @@ -/**************************************************************************** - * arch/arm/include/armv8-m/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_ARM_INCLUDE_ARMV8_M_SYSCALL_H -#define __ARCH_ARM_INCLUDE_ARMV8_M_SYSCALL_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#ifndef __ASSEMBLY__ -# include <stdint.h> -#endif - -/**************************************************************************** - * Pre-processor Prototypes - ****************************************************************************/ - -/* This is the value used as the argument to the SVC instruction. It is not - * used. - */ - -#define SYS_syscall 0x00 -#define SYS_smhcall 0xab - -/* 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 - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Inline functions - ****************************************************************************/ - -#ifndef __ASSEMBLY__ - -/* SVC call with SYS_ call number and no parameters */ - -static inline uintptr_t sys_call0(unsigned int nbr) -{ - register long reg0 __asm__("r0") = (long)(nbr); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0) - : "memory" - ); - - return reg0; -} - -/* SVC call with SYS_ call number and one parameter */ - -static inline uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1) - : "memory" - ); - - return reg0; -} - -/* SVC call with SYS_ call number and two parameters */ - -static inline uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2) - : "memory" - ); - - return reg0; -} - -/* SVC call with SYS_ call number and three parameters */ - -static inline uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3, - uintptr_t parm4); -static inline uintptr_t sys_call3(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3) -{ - return sys_call4(nbr, parm1, parm2, parm3, 0); -} - -/* SVC call with SYS_ call number and four parameters. - * - * NOTE the nonstandard parameter passing: parm4 is in R4 - */ - -static inline uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3, - uintptr_t parm4) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg4 __asm__("r4") = (long)(parm4); - register long reg3 __asm__("r3") = (long)(parm3); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), - "r"(reg3), "r"(reg4) - : "memory" - ); - - return reg0; -} - -/* SVC call with SYS_ call number and five parameters. - * - * NOTE the nonstandard parameter passing: parm4 and parm5 are in R4 and R5 - */ - -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); -static inline uintptr_t sys_call5(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3, - uintptr_t parm4, uintptr_t parm5) -{ - return sys_call6(nbr, parm1, parm2, parm3, parm4, parm5, 0); -} - -/* SVC call with SYS_ call number and six parameters. - * - * NOTE the nonstandard parameter passing: parm4-parm6 are in R4-R6 - */ - -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 reg0 __asm__("r0") = (long)(nbr); - register long reg6 __asm__("r6") = (long)(parm6); - register long reg5 __asm__("r5") = (long)(parm5); - register long reg4 __asm__("r4") = (long)(parm4); - register long reg3 __asm__("r3") = (long)(parm3); - register long reg2 __asm__("r2") = (long)(parm2); - register long reg1 __asm__("r1") = (long)(parm1); - - __asm__ __volatile__ - ( - "svc %1" - : "=r"(reg0) - : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), - "r"(reg3), "r"(reg4), "r"(reg5), "r"(reg6) - : "memory" - ); - - return reg0; -} - -/* semihosting(SMH) call with call number and one parameter */ - -static inline long smh_call(unsigned int nbr, void *parm) -{ - register long reg0 __asm__("r0") = (long)(nbr); - register long reg1 __asm__("r1") = (long)(parm); - - __asm__ __volatile__ - ( - "bkpt %1" - : "=r"(reg0) - : "i"(SYS_smhcall), "r"(reg0), "r"(reg1) - : "memory" - ); - - return reg0; -} - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#ifdef __cplusplus -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif - -#undef EXTERN -#ifdef __cplusplus -} -#endif - -#endif /* __ASSEMBLY__ */ -#endif /* __ARCH_ARM_INCLUDE_ARMV8_M_SYSCALL_H */ diff --git a/arch/arm/include/syscall.h b/arch/arm/include/syscall.h index ea1ee2e..033be91 100644 --- a/arch/arm/include/syscall.h +++ b/arch/arm/include/syscall.h @@ -29,26 +29,34 @@ * Included Files ****************************************************************************/ -/* Include ARM architecture-specific syscall macros */ - -#if defined(CONFIG_ARCH_ARMV7A) -# include <arch/armv7-a/syscall.h> -#elif defined(CONFIG_ARCH_ARMV7R) -# include <arch/armv7-r/syscall.h> -#elif defined(CONFIG_ARCH_ARMV7M) -# include <arch/armv7-m/syscall.h> -#elif defined(CONFIG_ARCH_ARMV8M) -# include <arch/armv8-m/syscall.h> -#elif defined(CONFIG_ARCH_ARMV6M) -# include <arch/armv6-m/syscall.h> -#else -# include <arch/arm/syscall.h> +#include <nuttx/config.h> + +#ifndef __ASSEMBLY__ +# include <stdint.h> #endif /**************************************************************************** * Pre-processor Prototypes ****************************************************************************/ +#define SYS_syscall 0x00 + +#if defined(__thumb__) || defined(__thumb2__) +# define SYS_smhcall 0xab +#else +# define SYS_smhcall 0x123456 +#endif + +/* 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 + /**************************************************************************** * Public Types ****************************************************************************/ @@ -57,6 +65,184 @@ * Inline functions ****************************************************************************/ +#ifndef __ASSEMBLY__ + +/* SVC with SYS_ call number and no parameters */ + +static inline uintptr_t sys_call0(unsigned int nbr) +{ + register long reg0 __asm__("r0") = (long)(nbr); + + __asm__ __volatile__ + ( + "svc %1" + : "=r"(reg0) + : "i"(SYS_syscall), "r"(reg0) + : "memory", "r14" + ); + + return reg0; +} + +/* SVC with SYS_ call number and one parameter */ + +static inline uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1) +{ + register long reg0 __asm__("r0") = (long)(nbr); + register long reg1 __asm__("r1") = (long)(parm1); + + __asm__ __volatile__ + ( + "svc %1" + : "=r"(reg0) + : "i"(SYS_syscall), "r"(reg0), "r"(reg1) + : "memory", "r14" + ); + + return reg0; +} + +/* SVC with SYS_ call number and two parameters */ + +static inline uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, + uintptr_t parm2) +{ + register long reg0 __asm__("r0") = (long)(nbr); + register long reg2 __asm__("r2") = (long)(parm2); + register long reg1 __asm__("r1") = (long)(parm1); + + __asm__ __volatile__ + ( + "svc %1" + : "=r"(reg0) + : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2) + : "memory", "r14" + ); + + return reg0; +} + +/* SVC with SYS_ call number and three parameters */ + +static inline uintptr_t sys_call3(unsigned int nbr, uintptr_t parm1, + uintptr_t parm2, uintptr_t parm3) +{ + register long reg0 __asm__("r0") = (long)(nbr); + register long reg3 __asm__("r3") = (long)(parm3); + register long reg2 __asm__("r2") = (long)(parm2); + register long reg1 __asm__("r1") = (long)(parm1); + + __asm__ __volatile__ + ( + "svc %1" + : "=r"(reg0) + : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), "r"(reg3) + : "memory", "r14" + ); + + return reg0; +} + +/* SVC with SYS_ call number and four parameters */ + +static inline uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1, + uintptr_t parm2, uintptr_t parm3, + uintptr_t parm4) +{ + register long reg0 __asm__("r0") = (long)(nbr); + register long reg4 __asm__("r4") = (long)(parm4); + register long reg3 __asm__("r3") = (long)(parm3); + register long reg2 __asm__("r2") = (long)(parm2); + register long reg1 __asm__("r1") = (long)(parm1); + + __asm__ __volatile__ + ( + "svc %1" + : "=r"(reg0) + : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), + "r"(reg3), "r"(reg4) + : "memory", "r14" + ); + + return reg0; +} + +/* SVC with SYS_ call number and five 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 reg0 __asm__("r0") = (long)(nbr); + register long reg5 __asm__("r5") = (long)(parm5); + register long reg4 __asm__("r4") = (long)(parm4); + register long reg3 __asm__("r3") = (long)(parm3); + register long reg2 __asm__("r2") = (long)(parm2); + register long reg1 __asm__("r1") = (long)(parm1); + + __asm__ __volatile__ + ( + "svc %1" + : "=r"(reg0) + : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), + "r"(reg3), "r"(reg4), "r"(reg5) + : "memory", "r14" + ); + + return reg0; +} + +/* SVC with SYS_ call number and six 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 reg0 __asm__("r0") = (long)(nbr); + register long reg6 __asm__("r6") = (long)(parm6); + register long reg5 __asm__("r5") = (long)(parm5); + register long reg4 __asm__("r4") = (long)(parm4); + register long reg3 __asm__("r3") = (long)(parm3); + register long reg2 __asm__("r2") = (long)(parm2); + register long reg1 __asm__("r1") = (long)(parm1); + + __asm__ __volatile__ + ( + "svc %1" + : "=r"(reg0) + : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), + "r"(reg3), "r"(reg4), "r"(reg5), "r"(reg6) + : "memory", "r14" + ); + + return reg0; +} + +/* semihosting(SMH) call with call number and one parameter */ + +static inline long smh_call(unsigned int nbr, void *parm) +{ + register long reg0 __asm__("r0") = (long)(nbr); + register long reg1 __asm__("r1") = (long)(parm); + + __asm__ __volatile__ + ( +#if defined(CONFIG_ARCH_ARMV6M) || \ + defined(CONFIG_ARCH_ARMV7M) || \ + defined(CONFIG_ARCH_ARMV8M) + "bkpt %1" +#else + "svc %1" +#endif + : "=r"(reg0) + : "i"(SYS_smhcall), "r"(reg0), "r"(reg1) + : "memory", "r14" + ); + + return reg0; +} + /**************************************************************************** * Public Data ****************************************************************************/ @@ -65,7 +251,6 @@ * Public Function Prototypes ****************************************************************************/ -#ifndef __ASSEMBLY__ #ifdef __cplusplus #define EXTERN extern "C" extern "C" @@ -78,6 +263,6 @@ extern "C" #ifdef __cplusplus } #endif -#endif +#endif /* __ASSEMBLY__ */ #endif /* __ARCH_ARM_INCLUDE_SYSCALL_H */ diff --git a/arch/avr/include/avr/syscall.h b/arch/avr/include/avr/syscall.h deleted file mode 100644 index 177c210..0000000 --- a/arch/avr/include/avr/syscall.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** - * arch/avr/include/avr/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_AVR_INCLUDE_AVR_SYSCALL_H -#define __ARCH_AVR_INCLUDE_AVR_SYSCALL_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> -#include <stdint.h> - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define SYS_syscall 0x80 - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#ifndef __ASSEMBLY__ -#ifdef __cplusplus -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif - -/* SWI with SYS_ call number and six parameters */ -#warning "REVISIT" -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); - -/* SWI with SYS_ call number and no parameters */ - -static inline uintptr_t sys_call0(unsigned int nbr) -{ - return sys_call6(nbr, 0, 0, 0, 0, 0, 0); -} - -/* SWI with SYS_ call number and one parameter */ - -static inline uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1) -{ - return sys_call6(nbr, parm1, 0, 0, 0, 0, 0); -} - -/* SWI with SYS_ call number and two parameters */ - -static inline uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2) -{ - return sys_call6(nbr, parm1, parm2, 0, 0, 0, 0); -} - -/* SWI with SYS_ call number and three parameters */ - -static inline uintptr_t sys_call3(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3) -{ - return sys_call6(nbr, parm1, parm2, parm3, 0, 0, 0); -} - -/* SWI with SYS_ call number and four parameters */ - -static inline uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3, - uintptr_t parm4) -{ - return sys_call6(nbr, parm1, parm2, parm3, parm4, 0, 0); -} - -/* SWI with SYS_ call number and five 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) -{ - return sys_call6(nbr, parm1, parm2, parm3, parm4, parm5, 0); -} - -#undef EXTERN -#ifdef __cplusplus -} -#endif -#endif - -#endif /* __ARCH_AVR_INCLUDE_AVR_SYSCALL_H */ diff --git a/arch/avr/include/avr32/syscall.h b/arch/avr/include/avr32/syscall.h deleted file mode 100644 index bde8698..0000000 --- a/arch/avr/include/avr32/syscall.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** - * arch/avr/include/avr32/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_AVR_INCLUDE_AVR32_SYSCALL_H -#define __ARCH_AVR_INCLUDE_AVR32_SYSCALL_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> -#include <stdint.h> - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define SYS_syscall 0x80 - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#ifndef __ASSEMBLY__ -#ifdef __cplusplus -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif - -/* SWI with SYS_ call number and six parameters */ - -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); - -/* SWI with SYS_ call number and no parameters */ - -static inline uintptr_t sys_call0(unsigned int nbr) -{ - return sys_call6(nbr, 0, 0, 0, 0, 0, 0); -} - -/* SWI with SYS_ call number and one parameter */ - -static inline uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1) -{ - return sys_call6(nbr, parm1, 0, 0, 0, 0, 0); -} - -/* SWI with SYS_ call number and two parameters */ - -static inline uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2) -{ - return sys_call6(nbr, parm1, parm2, 0, 0, 0, 0); -} - -/* SWI with SYS_ call number and three parameters */ - -static inline uintptr_t sys_call3(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3) -{ - return sys_call6(nbr, parm1, parm2, parm3, 0, 0, 0); -} - -/* SWI with SYS_ call number and four parameters */ - -static inline uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3, - uintptr_t parm4) -{ - return sys_call6(nbr, parm1, parm2, parm3, parm4, 0, 0); -} - -/* SWI with SYS_ call number and five 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) -{ - return sys_call6(nbr, parm1, parm2, parm3, parm4, parm5, 0); -} - -#undef EXTERN -#ifdef __cplusplus -} -#endif -#endif - -#endif /* __ARCH_AVR_INCLUDE_AVR32_SYSCALL_H */ diff --git a/arch/avr/include/syscall.h b/arch/avr/include/syscall.h index 2a975be..e88fcf9 100644 --- a/arch/avr/include/syscall.h +++ b/arch/avr/include/syscall.h @@ -29,24 +29,17 @@ * Included Files ****************************************************************************/ -/* Include AVR architecture-specific syscall macros */ - -#ifdef CONFIG_ARCH_FAMILY_AVR32 -# include <arch/avr32/syscall.h> -#else -# include <arch/avr/syscall.h> -#endif +#include <nuttx/config.h> +#include <stdint.h> /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ -/**************************************************************************** - * Public Types - ****************************************************************************/ +#define SYS_syscall 0x80 /**************************************************************************** - * Inline functions + * Public Types ****************************************************************************/ /**************************************************************************** @@ -66,6 +59,60 @@ extern "C" #define EXTERN extern #endif +/* SWI with SYS_ call number and six parameters */ + +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); + +/* SWI with SYS_ call number and no parameters */ + +static inline uintptr_t sys_call0(unsigned int nbr) +{ + return sys_call6(nbr, 0, 0, 0, 0, 0, 0); +} + +/* SWI with SYS_ call number and one parameter */ + +static inline uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1) +{ + return sys_call6(nbr, parm1, 0, 0, 0, 0, 0); +} + +/* SWI with SYS_ call number and two parameters */ + +static inline uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, + uintptr_t parm2) +{ + return sys_call6(nbr, parm1, parm2, 0, 0, 0, 0); +} + +/* SWI with SYS_ call number and three parameters */ + +static inline uintptr_t sys_call3(unsigned int nbr, uintptr_t parm1, + uintptr_t parm2, uintptr_t parm3) +{ + return sys_call6(nbr, parm1, parm2, parm3, 0, 0, 0); +} + +/* SWI with SYS_ call number and four parameters */ + +static inline uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1, + uintptr_t parm2, uintptr_t parm3, + uintptr_t parm4) +{ + return sys_call6(nbr, parm1, parm2, parm3, parm4, 0, 0); +} + +/* SWI with SYS_ call number and five 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) +{ + return sys_call6(nbr, parm1, parm2, parm3, parm4, parm5, 0); +} + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/mips/include/mips32/syscall.h b/arch/mips/include/mips32/syscall.h deleted file mode 100644 index db4b563..0000000 --- a/arch/mips/include/mips32/syscall.h +++ /dev/null @@ -1,246 +0,0 @@ -/**************************************************************************** - * arch/mips/include/mips32/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_MIPS_INCLUDE_MIPS32_SYSCALL_H -#define __ARCH_MIPS_INCLUDE_MIPS32_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 PIC32MX port (see - * arch/mips/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 **********************************************************/ - -/* System calls with 3 parameters and fewer are handled by sys_call0 - * (sys_call1, sys_call2, and sys_call3 are aliases for sys_call0). - * This is because the parameters are passed in a0-a3. a0 is reserved for - * the syscall number leaving up to three additional parameters that can be - * passed in registers. The remainder would have to be pushed onto the - * stack. - * - * Instead, these macros are provided which handle parameters four, five and - * six in a non-standard way: The use s0 ($7), s1 ($8), and s2 ($9) to pass - * the additional parameters. - */ - -#ifndef __ASSEMBLY__ - -/* System call SYS_ argument and four additional parameters. */ - -#define sys_call4(nbr,parm1,parm2,parm3,parm4) __extension__({ \ - uintptr_t __result; \ - __asm__ __volatile__ (\ - "\tmove $4, %0\n" \ - "\tmove $5, %1\n" \ - "\tmove $6, %2\n" \ - "\tmove $7, %3\n" \ - "\tmove $8, %4\n" \ - "\la $12, sys_call3\n" \ - "\jalr $12, $31\n" \ - "\tmove %5, $r2\n" \ - : "=r" (nbr) "=r" (parm1) "=r" (parm2) "=r" (parm3) "=r" (parm4) \ - : " "r"(__result)\ - : "memory"\ - ); \ - __result; \ -}) - -/* System call SYS_ argument and five additional parameters. */ - -#define sys_call5(nbr,parm1,parm2,parm3,parm4,parm5) __extension__({ \ - uintptr_t __result; \ - __asm__ __volatile__ (\ - "\tmove $4, %0\n" \ - "\tmove $5, %1\n" \ - "\tmove $6, %2\n" \ - "\tmove $7, %3\n" \ - "\tmove $8, %4\n" \ - "\tmove $9, %5\n" \ - "\la $12, sys_call3\n" \ - "\jalr $12, $31\n" \ - "\tmove %6, $r2\n" \ - : "=r" (nbr) "=r" (parm1) "=r" (parm2) "=r" (parm3) "=r" (parm4) "=r" (parm5) \ - : " "r"(__result)\ - : "memory"\ - ); \ - __result; \ -}) - -/* System call SYS_ argument and six additional parameters. */ - -#define sys_call5(nbr,parm1,parm2,parm3,parm4,parm5,parm6) __extension__({ \ - uintptr_t __result; \ - __asm__ __volatile__ (\ - "\tmove $4, %0\n" \ - "\tmove $5, %1\n" \ - "\tmove $6, %2\n" \ - "\tmove $7, %3\n" \ - "\tmove $8, %4\n" \ - "\tmove $9, %5\n" \ - "\tmove $10, %5\n" \ - "\la $12, sys_call3\n" \ - "\jalr $12, $31\n" \ - "\tmove %6, $r2\n" \ - : "=r" (nbr) "=r" (parm1) "=r" (parm2) "=r" (parm3) "=r" (parm4) "=r" (parm5) \ - : " "r"(__result)\ - : "memory"\ - ); \ - __result; \ -}) - -/* Context switching system calls *******************************************/ - -/* SYS call 0: (not used) */ - -/* SYS call 1: - * - * void up_fullcontextrestore(uint32_t *restoreregs) noreturn_function; - */ - -#define SYS_restore_context (1) -#define up_fullcontextrestore(restoreregs) \ - sys_call1(SYS_restore_context, (uintptr_t)restoreregs) - -/* SYS call 2: - * - * void up_switchcontext(uint32_t *saveregs, uint32_t *restoreregs); - */ - -#define SYS_switch_context (2) -#define up_switchcontext(saveregs, restoreregs) \ - sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs) - -#ifdef CONFIG_BUILD_KERNEL -/* SYS call 3: - * - * void up_syscall_return(void); - */ - -#define SYS_syscall_return (3) -#define up_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: up_syscall0 - * - * Description: - * System call SYS_ argument and no additional parameters. - * - ****************************************************************************/ - -uintptr_t sys_call0(unsigned int nbr); - -/**************************************************************************** - * Name: up_syscall1 - * - * Description: - * System call SYS_ argument and one additional parameter. - * - ****************************************************************************/ - -uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1); - -/**************************************************************************** - * Name: up_syscall2 - * - * Description: - * System call SYS_ argument and two additional parameters. - * - ****************************************************************************/ - -uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, uintptr_t parm2); - -/**************************************************************************** - * Name: up_syscall3 - * - * 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); - -#undef EXTERN -#ifdef __cplusplus -} -#endif - -#endif /* __ASSEMBLY__ */ -#endif /* __ARCH_MIPS_INCLUDE_MIPS32_SYSCALL_H */ diff --git a/arch/mips/include/syscall.h b/arch/mips/include/syscall.h index 5a4f8b6..8fbb624 100644 --- a/arch/mips/include/syscall.h +++ b/arch/mips/include/syscall.h @@ -29,16 +29,147 @@ * Included Files ****************************************************************************/ -/* Include MIPS architecture-specific syscall macros */ +#include <nuttx/config.h> -#ifdef CONFIG_ARCH_MIPS32 -# include <arch/mips32/syscall.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 PIC32MX port (see + * arch/mips/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 **********************************************************/ + +/* System calls with 3 parameters and fewer are handled by sys_call0 + * (sys_call1, sys_call2, and sys_call3 are aliases for sys_call0). + * This is because the parameters are passed in a0-a3. a0 is reserved for + * the syscall number leaving up to three additional parameters that can be + * passed in registers. The remainder would have to be pushed onto the + * stack. + * + * Instead, these macros are provided which handle parameters four, five and + * six in a non-standard way: The use s0 ($7), s1 ($8), and s2 ($9) to pass + * the additional parameters. + */ + +#ifndef __ASSEMBLY__ + +/* System call SYS_ argument and four additional parameters. */ + +#define sys_call4(nbr,parm1,parm2,parm3,parm4) __extension__({ \ + uintptr_t __result; \ + __asm__ __volatile__ (\ + "\tmove $4, %0\n" \ + "\tmove $5, %1\n" \ + "\tmove $6, %2\n" \ + "\tmove $7, %3\n" \ + "\tmove $8, %4\n" \ + "\la $12, sys_call3\n" \ + "\jalr $12, $31\n" \ + "\tmove %5, $r2\n" \ + : "=r" (nbr) "=r" (parm1) "=r" (parm2) "=r" (parm3) "=r" (parm4) \ + : " "r"(__result)\ + : "memory"\ + ); \ + __result; \ +}) + +/* System call SYS_ argument and five additional parameters. */ + +#define sys_call5(nbr,parm1,parm2,parm3,parm4,parm5) __extension__({ \ + uintptr_t __result; \ + __asm__ __volatile__ (\ + "\tmove $4, %0\n" \ + "\tmove $5, %1\n" \ + "\tmove $6, %2\n" \ + "\tmove $7, %3\n" \ + "\tmove $8, %4\n" \ + "\tmove $9, %5\n" \ + "\la $12, sys_call3\n" \ + "\jalr $12, $31\n" \ + "\tmove %6, $r2\n" \ + : "=r" (nbr) "=r" (parm1) "=r" (parm2) "=r" (parm3) "=r" (parm4) "=r" (parm5) \ + : " "r"(__result)\ + : "memory"\ + ); \ + __result; \ +}) + +/* System call SYS_ argument and six additional parameters. */ + +#define sys_call5(nbr,parm1,parm2,parm3,parm4,parm5,parm6) __extension__({ \ + uintptr_t __result; \ + __asm__ __volatile__ (\ + "\tmove $4, %0\n" \ + "\tmove $5, %1\n" \ + "\tmove $6, %2\n" \ + "\tmove $7, %3\n" \ + "\tmove $8, %4\n" \ + "\tmove $9, %5\n" \ + "\tmove $10, %5\n" \ + "\la $12, sys_call3\n" \ + "\jalr $12, $31\n" \ + "\tmove %6, $r2\n" \ + : "=r" (nbr) "=r" (parm1) "=r" (parm2) "=r" (parm3) "=r" (parm4) "=r" (parm5) \ + : " "r"(__result)\ + : "memory"\ + ); \ + __result; \ +}) + +/* Context switching system calls *******************************************/ + +/* SYS call 0: (not used) */ + +/* SYS call 1: + * + * void up_fullcontextrestore(uint32_t *restoreregs) noreturn_function; + */ + +#define SYS_restore_context (1) +#define up_fullcontextrestore(restoreregs) \ + sys_call1(SYS_restore_context, (uintptr_t)restoreregs) + +/* SYS call 2: + * + * void up_switchcontext(uint32_t *saveregs, uint32_t *restoreregs); + */ + +#define SYS_switch_context (2) +#define up_switchcontext(saveregs, restoreregs) \ + sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs) + +#ifdef CONFIG_BUILD_KERNEL +/* SYS call 3: + * + * void up_syscall_return(void); + */ + +#define SYS_syscall_return (3) +#define up_syscall_return() (void)sys_call0(SYS_syscall_return) + +#endif +#endif /* __ASSEMBLY__ */ + /**************************************************************************** * Public Types ****************************************************************************/ @@ -47,6 +178,8 @@ * Inline functions ****************************************************************************/ +#ifndef __ASSEMBLY__ + /**************************************************************************** * Public Data ****************************************************************************/ @@ -55,7 +188,6 @@ * Public Function Prototypes ****************************************************************************/ -#ifndef __ASSEMBLY__ #ifdef __cplusplus #define EXTERN extern "C" extern "C" @@ -64,10 +196,51 @@ extern "C" #define EXTERN extern #endif +/**************************************************************************** + * Name: up_syscall0 + * + * Description: + * System call SYS_ argument and no additional parameters. + * + ****************************************************************************/ + +uintptr_t sys_call0(unsigned int nbr); + +/**************************************************************************** + * Name: up_syscall1 + * + * Description: + * System call SYS_ argument and one additional parameter. + * + ****************************************************************************/ + +uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1); + +/**************************************************************************** + * Name: up_syscall2 + * + * Description: + * System call SYS_ argument and two additional parameters. + * + ****************************************************************************/ + +uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, uintptr_t parm2); + +/**************************************************************************** + * Name: up_syscall3 + * + * 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); + #undef EXTERN #ifdef __cplusplus } #endif -#endif +#endif /* __ASSEMBLY__ */ #endif /* __ARCH_MIPS_INCLUDE_SYSCALL_H */ diff --git a/arch/misoc/include/lm32/syscall.h b/arch/misoc/include/lm32/syscall.h deleted file mode 100644 index a7a549c..0000000 --- a/arch/misoc/include/lm32/syscall.h +++ /dev/null @@ -1,193 +0,0 @@ -/**************************************************************************** - * arch/misoc/include/lm32/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_MISOC_INCLUDE_LM32_SYSCALL_H -#define __ARCH_MISOC_INCLUDE_LM32_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 LM32 port (see - * arch/miscoc/include/lm32/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: (not used) */ - -/* SYS call 1: - * - * void up_fullcontextrestore(uint32_t *restoreregs) noreturn_function; - */ - -#define SYS_restore_context (1) -#define up_fullcontextrestore(restoreregs) \ - sys_call1(SYS_restore_context, (uintptr_t)restoreregs) - -/* SYS call 2: - * - * void up_switchcontext(uint32_t *saveregs, uint32_t *restoreregs); - */ - -#define SYS_switch_context (2) -#define up_switchcontext(saveregs, restoreregs) \ - sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs) - -#ifdef CONFIG_BUILD_KERNEL -/* SYS call 3: - * - * void up_syscall_return(void); - */ - -#define SYS_syscall_return (3) -#define up_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: up_syscall0 - * - * Description: - * System call SYS_ argument and no additional parameters. - * - ****************************************************************************/ - -uintptr_t sys_call0(unsigned int nbr); - -/**************************************************************************** - * Name: up_syscall1 - * - * Description: - * System call SYS_ argument and one additional parameter. - * - ****************************************************************************/ - -uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1); - -/**************************************************************************** - * Name: up_syscall2 - * - * Description: - * System call SYS_ argument and two additional parameters. - * - ****************************************************************************/ - -uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, uintptr_t parm2); - -/**************************************************************************** - * Name: up_syscall3 - * - * 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: up_syscall4 - * - * 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: up_syscall5 - * - * 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_MISOC_INCLUDE_LM32_SYSCALL_H */ diff --git a/arch/misoc/include/minerva/syscall.h b/arch/misoc/include/minerva/syscall.h deleted file mode 100644 index 7e27993..0000000 --- a/arch/misoc/include/minerva/syscall.h +++ /dev/null @@ -1,192 +0,0 @@ -/**************************************************************************** - * arch/misoc/include/minerva/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_MISOC_INCLUDE_MINERVA_SYSCALL_H -#define __ARCH_MISOC_INCLUDE_MINERVA_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 MINERVA port (see - * arch/miscoc/include/minerva/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: (not used) */ - -/* SYS call 1: - * - * void up_fullcontextrestore(uint32_t *restoreregs) noreturn_function; - */ - -#define SYS_restore_context (1) -#define up_fullcontextrestore(restoreregs) \ - sys_call1(SYS_restore_context, (uintptr_t)restoreregs) - -/* SYS call 2: - * - * void up_switchcontext(uint32_t *saveregs, uint32_t *restoreregs); - */ - -#define SYS_switch_context (2) -#define up_switchcontext(saveregs, restoreregs) \ - sys_call2(SYS_switch_context, (uintptr_t)saveregs, \ - (uintptr_t)restoreregs) - -#ifdef CONFIG_BUILD_KERNEL - -/* SYS call 3: - * - * void up_syscall_return(void); - */ - -#define SYS_syscall_return (3) -#define up_syscall_return() (void)sys_call0(SYS_syscall_return) - -#endif - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Inline functions - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#ifdef __cplusplus -# define EXTERN extern "C" -extern "C" -{ -#else -# define EXTERN extern -#endif - -/**************************************************************************** - * Name: up_syscall0 - * - * Description: - * System call SYS_ argument and no additional parameters. - * - ****************************************************************************/ - -uintptr_t sys_call0(unsigned int nbr); - -/**************************************************************************** - * Name: up_syscall1 - * - * Description: - * System call SYS_ argument and one additional parameter. - * - ****************************************************************************/ - -uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1); - -/**************************************************************************** - * Name: up_syscall2 - * - * Description: - * System call SYS_ argument and two additional parameters. - * - ****************************************************************************/ - -uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, uintptr_t parm2); - -/**************************************************************************** - * Name: up_syscall3 - * - * 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: up_syscall4 - * - * 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: up_syscall5 - * - * 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_MISOC_INCLUDE_MINERVA_SYSCALL_H */ diff --git a/arch/misoc/include/syscall.h b/arch/misoc/include/syscall.h index 5d02b94..564c200 100644 --- a/arch/misoc/include/syscall.h +++ b/arch/misoc/include/syscall.h @@ -29,14 +29,164 @@ * Included Files ****************************************************************************/ -/* Include LM32 architecture-specific syscall macros */ +#include <nuttx/config.h> -#ifdef CONFIG_ARCH_CHIP_LM32 -# include <arch/lm32/syscall.h> +#ifndef __ASSEMBLY__ +#include <stdint.h> #endif -#ifdef CONFIG_ARCH_CHIP_MINERVA -# include <arch/minerva/syscall.h> +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define SYS_syscall 0x00 + +/* Configuration ************************************************************/ + +/* SYS call 1 and 2 are defined for internal use by the MINERVA port (see + * arch/miscoc/include/minerva/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: (not used) */ + +/* SYS call 1: + * + * void up_fullcontextrestore(uint32_t *restoreregs) noreturn_function; + */ + +#define SYS_restore_context (1) +#define up_fullcontextrestore(restoreregs) \ + sys_call1(SYS_restore_context, (uintptr_t)restoreregs) + +/* SYS call 2: + * + * void up_switchcontext(uint32_t *saveregs, uint32_t *restoreregs); + */ + +#define SYS_switch_context (2) +#define up_switchcontext(saveregs, restoreregs) \ + sys_call2(SYS_switch_context, (uintptr_t)saveregs, \ + (uintptr_t)restoreregs) + +#ifdef CONFIG_BUILD_KERNEL + +/* SYS call 3: + * + * void up_syscall_return(void); + */ + +#define SYS_syscall_return (3) +#define up_syscall_return() (void)sys_call0(SYS_syscall_return) + +#endif + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Inline functions + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef __cplusplus +# define EXTERN extern "C" +extern "C" +{ +#else +# define EXTERN extern +#endif + +/**************************************************************************** + * Name: up_syscall0 + * + * Description: + * System call SYS_ argument and no additional parameters. + * + ****************************************************************************/ + +uintptr_t sys_call0(unsigned int nbr); + +/**************************************************************************** + * Name: up_syscall1 + * + * Description: + * System call SYS_ argument and one additional parameter. + * + ****************************************************************************/ + +uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1); + +/**************************************************************************** + * Name: up_syscall2 + * + * Description: + * System call SYS_ argument and two additional parameters. + * + ****************************************************************************/ + +uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, uintptr_t parm2); + +/**************************************************************************** + * Name: up_syscall3 + * + * 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: up_syscall4 + * + * 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: up_syscall5 + * + * 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_MISOC_INCLUDE_SYSCALL_H */ diff --git a/arch/sparc/include/sparc_v8/syscall.h b/arch/sparc/include/sparc_v8/syscall.h deleted file mode 100644 index 37eef48..0000000 --- a/arch/sparc/include/sparc_v8/syscall.h +++ /dev/null @@ -1,195 +0,0 @@ -/**************************************************************************** - * arch/sparc/include/sparc_v8/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 directed but, rather, only indirectly - * through include/syscall.h or include/sys/sycall.h - */ - -#ifndef __ARCH_SPARC_INCLUDE_SPARC_V8_SYSCALL_H -#define __ARCH_SPARC_INCLUDE_SPARC_V8_SYSCALL_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#ifndef __ASSEMBLY__ -# include <stdint.h> -#endif - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define SYS_syscall 0x80 - -/* 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: (not used) */ - -/* SYS call 1: - * - * void up_fullcontextrestore(uint32_t *restoreregs) noreturn_function; - */ - -#define SYS_restore_context (1) -#define up_fullcontextrestore(restoreregs) \ - (void)sys_call1(SYS_restore_context, (uintptr_t)restoreregs) - -/* SYS call 2: - * - * void up_switchcontext(uint32_t *saveregs, uint32_t *restoreregs); - */ - -#define SYS_switch_context (2) -#define up_switchcontext(saveregs, restoreregs) \ - (void)sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs) - -#ifdef CONFIG_BUILD_KERNEL -/* SYS call 3: - * - * void up_syscall_return(void); - */ - -#define SYS_syscall_return (3) -#define up_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: up_syscall0 - * - * Description: - * System call SYS_ argument and no additional parameters. - * - ****************************************************************************/ - -uintptr_t sys_call0(unsigned int nbr); - -/**************************************************************************** - * Name: up_syscall1 - * - * Description: - * System call SYS_ argument and one additional parameter. - * - ****************************************************************************/ - -uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1); - -/**************************************************************************** - * Name: up_syscall2 - * - * Description: - * System call SYS_ argument and two additional parameters. - * - ****************************************************************************/ - -uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, uintptr_t parm2); - -/**************************************************************************** - * Name: up_syscall3 - * - * 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: up_syscall4 - * - * 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: up_syscall5 - * - * 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_SPARC_INCLUDE_SPARC_V8_SYSCALL_H */ - diff --git a/arch/sparc/include/syscall.h b/arch/sparc/include/syscall.h index d45d462..279f3bf 100644 --- a/arch/sparc/include/syscall.h +++ b/arch/sparc/include/syscall.h @@ -29,16 +29,72 @@ * Included Files ****************************************************************************/ -/* Include ARM architecture-specific syscall macros */ +#include <nuttx/config.h> -#ifdef CONFIG_ARCH_SPARC_V8 -# include <arch/sparc_v8/syscall.h> +#ifndef __ASSEMBLY__ +# include <stdint.h> #endif /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ +#define SYS_syscall 0x80 + +/* 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: (not used) */ + +/* SYS call 1: + * + * void up_fullcontextrestore(uint32_t *restoreregs) noreturn_function; + */ + +#define SYS_restore_context (1) +#define up_fullcontextrestore(restoreregs) \ + (void)sys_call1(SYS_restore_context, (uintptr_t)restoreregs) + +/* SYS call 2: + * + * void up_switchcontext(uint32_t *saveregs, uint32_t *restoreregs); + */ + +#define SYS_switch_context (2) +#define up_switchcontext(saveregs, restoreregs) \ + (void)sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs) + +#ifdef CONFIG_BUILD_KERNEL +/* SYS call 3: + * + * void up_syscall_return(void); + */ + +#define SYS_syscall_return (3) +#define up_syscall_return() (void)sys_call0(SYS_syscall_return) + +#endif +#endif /* __ASSEMBLY__ */ + /**************************************************************************** * Public Types ****************************************************************************/ @@ -47,6 +103,8 @@ * Inline functions ****************************************************************************/ +#ifndef __ASSEMBLY__ + /**************************************************************************** * Public Data ****************************************************************************/ @@ -55,7 +113,6 @@ * Public Function Prototypes ****************************************************************************/ -#ifndef __ASSEMBLY__ #ifdef __cplusplus #define EXTERN extern "C" extern "C" @@ -64,11 +121,75 @@ extern "C" #define EXTERN extern #endif +/**************************************************************************** + * Name: up_syscall0 + * + * Description: + * System call SYS_ argument and no additional parameters. + * + ****************************************************************************/ + +uintptr_t sys_call0(unsigned int nbr); + +/**************************************************************************** + * Name: up_syscall1 + * + * Description: + * System call SYS_ argument and one additional parameter. + * + ****************************************************************************/ + +uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1); + +/**************************************************************************** + * Name: up_syscall2 + * + * Description: + * System call SYS_ argument and two additional parameters. + * + ****************************************************************************/ + +uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, uintptr_t parm2); + +/**************************************************************************** + * Name: up_syscall3 + * + * 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: up_syscall4 + * + * 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: up_syscall5 + * + * 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 + +#endif /* __ASSEMBLY__ */ #endif /* __ARCH_SPARC_INCLUDE_SYSCALL_H */ diff --git a/arch/x86/include/i486/syscall.h b/arch/x86/include/i486/syscall.h deleted file mode 100644 index 994f2c0..0000000 --- a/arch/x86/include/i486/syscall.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** - * arch/x86/include/i486/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_X86_INCLUDE_I486_SYSCALL_H -#define __ARCH_X86_INCLUDE_I486_SYSCALL_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> -#include <stdint.h> - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define SYS_syscall 0x80 - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#ifndef __ASSEMBLY__ -#ifdef __cplusplus -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif - -/* SWI with SYS_ call number and six parameters */ - -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); - -/* SWI with SYS_ call number and no parameters */ - -static inline uintptr_t sys_call0(unsigned int nbr) -{ - return sys_call6(nbr, 0, 0, 0, 0, 0, 0); -} - -/* SWI with SYS_ call number and one parameter */ - -static inline uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1) -{ - return sys_call6(nbr, parm1, 0, 0, 0, 0, 0); -} - -/* SWI with SYS_ call number and two parameters */ - -static inline uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2) -{ - return sys_call6(nbr, parm1, parm2, 0, 0, 0, 0); -} - -/* SWI with SYS_ call number and three parameters */ - -static inline uintptr_t sys_call3(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3) -{ - return sys_call6(nbr, parm1, parm2, parm3, 0, 0, 0); -} - -/* SWI with SYS_ call number and four parameters */ - -static inline uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3, - uintptr_t parm4) -{ - return sys_call6(nbr, parm1, parm2, parm3, parm4, 0, 0); -} - -/* SWI with SYS_ call number and five 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) -{ - return sys_call6(nbr, parm1, parm2, parm3, parm4, parm5, 0); -} - -#undef EXTERN -#ifdef __cplusplus -} -#endif -#endif - -#endif /* __ARCH_X86_INCLUDE_I486_SYSCALL_H */ diff --git a/arch/x86/include/syscall.h b/arch/x86/include/syscall.h index 9a4d20a..ea1b814 100644 --- a/arch/x86/include/syscall.h +++ b/arch/x86/include/syscall.h @@ -29,22 +29,17 @@ * Included Files ****************************************************************************/ -/* Include x86 architecture-specific syscall macros */ - -#ifdef CONFIG_ARCH_I486 -# include <arch/i486/syscall.h> -#endif +#include <nuttx/config.h> +#include <stdint.h> /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ -/**************************************************************************** - * Public Types - ****************************************************************************/ +#define SYS_syscall 0x80 /**************************************************************************** - * Inline functions + * Public Types ****************************************************************************/ /**************************************************************************** @@ -64,6 +59,60 @@ extern "C" #define EXTERN extern #endif +/* SWI with SYS_ call number and six parameters */ + +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); + +/* SWI with SYS_ call number and no parameters */ + +static inline uintptr_t sys_call0(unsigned int nbr) +{ + return sys_call6(nbr, 0, 0, 0, 0, 0, 0); +} + +/* SWI with SYS_ call number and one parameter */ + +static inline uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1) +{ + return sys_call6(nbr, parm1, 0, 0, 0, 0, 0); +} + +/* SWI with SYS_ call number and two parameters */ + +static inline uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, + uintptr_t parm2) +{ + return sys_call6(nbr, parm1, parm2, 0, 0, 0, 0); +} + +/* SWI with SYS_ call number and three parameters */ + +static inline uintptr_t sys_call3(unsigned int nbr, uintptr_t parm1, + uintptr_t parm2, uintptr_t parm3) +{ + return sys_call6(nbr, parm1, parm2, parm3, 0, 0, 0); +} + +/* SWI with SYS_ call number and four parameters */ + +static inline uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1, + uintptr_t parm2, uintptr_t parm3, + uintptr_t parm4) +{ + return sys_call6(nbr, parm1, parm2, parm3, parm4, 0, 0); +} + +/* SWI with SYS_ call number and five 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) +{ + return sys_call6(nbr, parm1, parm2, parm3, parm4, parm5, 0); +} + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/x86_64/include/intel64/syscall.h b/arch/x86_64/include/intel64/syscall.h deleted file mode 100644 index 1c4befa..0000000 --- a/arch/x86_64/include/intel64/syscall.h +++ /dev/null @@ -1,156 +0,0 @@ -/**************************************************************************** - * arch/x86_64/include/intel64/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_X86_64_INCLUDE_INTEL64_SYSCALL_H -#define __ARCH_X86_64_INCLUDE_INTEL64_SYSCALL_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> -#include <stdint.h> - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#ifndef __ASSEMBLY__ -#ifdef __cplusplus -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif - -void enable_syscall(void); -void syscall_entry(void); -uint64_t syscall_handler(unsigned long nbr, uintptr_t parm1, uintptr_t parm2, - uintptr_t parm3, uintptr_t parm4, uintptr_t parm5, - uintptr_t parm6); -uint64_t linux_interface(unsigned long nbr, uintptr_t parm1, uintptr_t parm2, - uintptr_t parm3, uintptr_t parm4, uintptr_t parm5, - uintptr_t parm6); - -/* SWI with SYS_ call number and six 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); - -/* SWI with SYS_ call number and no parameters */ - -static inline uintptr_t sys_call0(unsigned int nbr) -{ - return sys_call6(nbr, 0, 0, 0, 0, 0, 0); -} - -/* SWI with SYS_ call number and one parameter */ - -static inline uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1) -{ - return sys_call6(nbr, parm1, 0, 0, 0, 0, 0); -} - -/* SWI with SYS_ call number and two parameters */ - -static inline uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2) -{ - return sys_call6(nbr, parm1, parm2, 0, 0, 0, 0); -} - -/* SWI with SYS_ call number and three parameters */ - -static inline uintptr_t sys_call3(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3) -{ - return sys_call6(nbr, parm1, parm2, parm3, 0, 0, 0); -} - -/* SWI with SYS_ call number and four parameters */ - -static inline uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1, - uintptr_t parm2, uintptr_t parm3, - uintptr_t parm4) -{ - return sys_call6(nbr, parm1, parm2, parm3, parm4, 0, 0); -} - -/* SWI with SYS_ call number and five 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) -{ - return sys_call6(nbr, parm1, parm2, parm3, parm4, parm5, 0); -} - -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 uint64_t reg0 __asm__("rax") = (uint64_t)(nbr); - register uint64_t reg1 __asm__("rdi") = (uint64_t)(parm1); - register uint64_t reg2 __asm__("rsi") = (uint64_t)(parm2); - register uint64_t reg3 __asm__("rdx") = (uint64_t)(parm3); - register uint64_t reg4 __asm__("r10") = (uint64_t)(parm4); - register uint64_t reg5 __asm__("r8") = (uint64_t)(parm5); - register uint64_t reg6 __asm__("r9") = (uint64_t)(parm6); - - __asm__ __volatile__ - ( - "syscall" - : "=r"(reg0) - : "r"(reg0), "r"(reg1), "r"(reg2), - "r"(reg3), "r"(reg4), "r"(reg5), "r"(reg6) - : "memory" - ); - - return reg0; -} - -#undef EXTERN -#ifdef __cplusplus -} -#endif -#endif - -#endif /* __ARCH_X86_64_INCLUDE_INTEL64_SYSCALL_H */ - diff --git a/arch/x86_64/include/syscall.h b/arch/x86_64/include/syscall.h index ec9ac4d..6e35fc0 100644 --- a/arch/x86_64/include/syscall.h +++ b/arch/x86_64/include/syscall.h @@ -29,11 +29,8 @@ * Included Files ****************************************************************************/ -/* Include x86 architecture-specific syscall macros */ - -#ifdef CONFIG_ARCH_INTEL64 -# include <arch/intel64/syscall.h> -#endif +#include <nuttx/config.h> +#include <stdint.h> /**************************************************************************** * Pre-processor Definitions @@ -44,10 +41,6 @@ ****************************************************************************/ /**************************************************************************** - * Inline functions - ****************************************************************************/ - -/**************************************************************************** * Public Data ****************************************************************************/ @@ -64,6 +57,95 @@ extern "C" #define EXTERN extern #endif +void enable_syscall(void); +void syscall_entry(void); +uint64_t syscall_handler(unsigned long nbr, uintptr_t parm1, uintptr_t parm2, + uintptr_t parm3, uintptr_t parm4, uintptr_t parm5, + uintptr_t parm6); +uint64_t linux_interface(unsigned long nbr, uintptr_t parm1, uintptr_t parm2, + uintptr_t parm3, uintptr_t parm4, uintptr_t parm5, + uintptr_t parm6); + +/* SWI with SYS_ call number and six 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); + +/* SWI with SYS_ call number and no parameters */ + +static inline uintptr_t sys_call0(unsigned int nbr) +{ + return sys_call6(nbr, 0, 0, 0, 0, 0, 0); +} + +/* SWI with SYS_ call number and one parameter */ + +static inline uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1) +{ + return sys_call6(nbr, parm1, 0, 0, 0, 0, 0); +} + +/* SWI with SYS_ call number and two parameters */ + +static inline uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, + uintptr_t parm2) +{ + return sys_call6(nbr, parm1, parm2, 0, 0, 0, 0); +} + +/* SWI with SYS_ call number and three parameters */ + +static inline uintptr_t sys_call3(unsigned int nbr, uintptr_t parm1, + uintptr_t parm2, uintptr_t parm3) +{ + return sys_call6(nbr, parm1, parm2, parm3, 0, 0, 0); +} + +/* SWI with SYS_ call number and four parameters */ + +static inline uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1, + uintptr_t parm2, uintptr_t parm3, + uintptr_t parm4) +{ + return sys_call6(nbr, parm1, parm2, parm3, parm4, 0, 0); +} + +/* SWI with SYS_ call number and five 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) +{ + return sys_call6(nbr, parm1, parm2, parm3, parm4, parm5, 0); +} + +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 uint64_t reg0 __asm__("rax") = (uint64_t)(nbr); + register uint64_t reg1 __asm__("rdi") = (uint64_t)(parm1); + register uint64_t reg2 __asm__("rsi") = (uint64_t)(parm2); + register uint64_t reg3 __asm__("rdx") = (uint64_t)(parm3); + register uint64_t reg4 __asm__("r10") = (uint64_t)(parm4); + register uint64_t reg5 __asm__("r8") = (uint64_t)(parm5); + register uint64_t reg6 __asm__("r9") = (uint64_t)(parm6); + + __asm__ __volatile__ + ( + "syscall" + : "=r"(reg0) + : "r"(reg0), "r"(reg1), "r"(reg2), + "r"(reg3), "r"(reg4), "r"(reg5), "r"(reg6) + : "memory" + ); + + return reg0; +} + #undef EXTERN #ifdef __cplusplus }
