diff --git a/arch/risc-v/include/syscall.h b/arch/risc-v/include/syscall.h index 9d220067608..ed49fa5c2f6 100644 --- a/arch/risc-v/include/syscall.h +++ b/arch/risc-v/include/syscall.h @@ -139,7 +139,8 @@ extern "C" long smh_call(unsigned int nbr, void *parm); -#if defined(CONFIG_ARCH_USE_S_MODE) && defined(__KERNEL__) +#if defined(__KERNEL__) + uintptr_t sys_call0(unsigned int nbr); uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1); uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, uintptr_t parm2); diff --git a/arch/risc-v/src/common/CMakeLists.txt b/arch/risc-v/src/common/CMakeLists.txt index b1dd33db887..74b270e4c52 100644 --- a/arch/risc-v/src/common/CMakeLists.txt +++ b/arch/risc-v/src/common/CMakeLists.txt @@ -33,6 +33,7 @@ list(APPEND SRCS riscv_releasestack.c riscv_schedulesigaction.c riscv_sigdeliver.c) list(APPEND SRCS riscv_stackframe.c riscv_tcbinfo.c riscv_swint.c) list(APPEND SRCS riscv_switchcontext.c riscv_usestack.c) +list(APPEND SRCS riscv_syscall.S riscv_perform_syscall.c) if(NOT CONFIG_ALARM_ARCH) if(NOT CONFIG_TIMER_ARCH) @@ -122,7 +123,7 @@ if(CONFIG_RISCV_PERCPU_SCRATCH) endif() if(CONFIG_ARCH_USE_S_MODE) - add_subdirectory(supervisor) + list(APPEND SRCS riscv_sbi.c) endif() target_sources(arch PRIVATE ${SRCS}) diff --git a/arch/risc-v/src/common/Make.defs b/arch/risc-v/src/common/Make.defs index e3c46f6fcaa..bcd03e26924 100644 --- a/arch/risc-v/src/common/Make.defs +++ b/arch/risc-v/src/common/Make.defs @@ -25,6 +25,7 @@ endif # Specify our general Assembly files CMN_ASRCS += riscv_vectors.S riscv_exception_common.S riscv_mhartid.S CMN_ASRCS += riscv_saveusercontext.S +CMN_ASRCS += riscv_syscall.S # Specify C code within the common directory to be included CMN_CSRCS += riscv_initialize.c riscv_swint.c riscv_mtimer.c @@ -35,6 +36,7 @@ CMN_CSRCS += riscv_idle.c riscv_modifyreg32.c riscv_nputs.c riscv_releasestack.c CMN_CSRCS += riscv_registerdump.c riscv_stackframe.c riscv_schedulesigaction.c CMN_CSRCS += riscv_sigdeliver.c riscv_switchcontext.c CMN_CSRCS += riscv_usestack.c riscv_tcbinfo.c +CMN_CSRCS += riscv_perform_syscall.c ifneq ($(CONFIG_ALARM_ARCH),y) ifneq ($(CONFIG_TIMER_ARCH),y) @@ -121,8 +123,6 @@ ifeq ($(CONFIG_RISCV_PERCPU_SCRATCH),y) CMN_CSRCS += riscv_percpu.c endif -# Kernel runs in supervisor mode or machine mode ? - ifeq ($(CONFIG_ARCH_USE_S_MODE),y) -include common/supervisor/Make.defs +CMN_CSRCS += riscv_sbi.c endif diff --git a/arch/risc-v/src/common/riscv_exception.c b/arch/risc-v/src/common/riscv_exception.c index cefa6c03f99..0ff9af828a4 100644 --- a/arch/risc-v/src/common/riscv_exception.c +++ b/arch/risc-v/src/common/riscv_exception.c @@ -287,12 +287,7 @@ void riscv_exception_attach(void) irq_attach(RISCV_IRQ_ECALLS, riscv_exception, NULL); irq_attach(RISCV_IRQ_ECALLH, riscv_exception, NULL); - -#ifndef CONFIG_ARCH_USE_S_MODE - irq_attach(RISCV_IRQ_ECALLM, riscv_swint, NULL); -#else irq_attach(RISCV_IRQ_ECALLM, riscv_exception, NULL); -#endif irq_attach(RISCV_IRQ_INSTRUCTIONPF, riscv_exception, NULL); diff --git a/arch/risc-v/src/common/supervisor/riscv_perform_syscall.c b/arch/risc-v/src/common/riscv_perform_syscall.c similarity index 97% rename from arch/risc-v/src/common/supervisor/riscv_perform_syscall.c rename to arch/risc-v/src/common/riscv_perform_syscall.c index cd134fb4e1b..c687ebdec49 100644 --- a/arch/risc-v/src/common/supervisor/riscv_perform_syscall.c +++ b/arch/risc-v/src/common/riscv_perform_syscall.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/risc-v/src/common/supervisor/riscv_perform_syscall.c + * arch/risc-v/src/common/riscv_perform_syscall.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/arch/risc-v/src/common/supervisor/riscv_sbi.c b/arch/risc-v/src/common/riscv_sbi.c similarity index 98% rename from arch/risc-v/src/common/supervisor/riscv_sbi.c rename to arch/risc-v/src/common/riscv_sbi.c index 626e2d068ff..4eff3c167c0 100644 --- a/arch/risc-v/src/common/supervisor/riscv_sbi.c +++ b/arch/risc-v/src/common/riscv_sbi.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/risc-v/src/common/supervisor/riscv_sbi.c + * arch/risc-v/src/common/riscv_sbi.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/arch/risc-v/src/common/supervisor/riscv_syscall.S b/arch/risc-v/src/common/riscv_syscall.S similarity index 98% rename from arch/risc-v/src/common/supervisor/riscv_syscall.S rename to arch/risc-v/src/common/riscv_syscall.S index bda64d3de2c..802037ed3b6 100644 --- a/arch/risc-v/src/common/supervisor/riscv_syscall.S +++ b/arch/risc-v/src/common/riscv_syscall.S @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/risc-v/src/common/supervisor/riscv_syscall.S + * arch/risc-v/src/common/riscv_syscall.S * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/arch/risc-v/src/common/supervisor/CMakeLists.txt b/arch/risc-v/src/common/supervisor/CMakeLists.txt deleted file mode 100644 index 376ded80b30..00000000000 --- a/arch/risc-v/src/common/supervisor/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# ############################################################################## -# arch/risc-v/src/common/supervisor/CMakeLists.txt -# -# 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. -# -# ############################################################################## - -if(CONFIG_ARCH_USE_S_MODE) - set(SRCS) - - list(APPEND SRCS riscv_syscall.S riscv_perform_syscall.c riscv_sbi.c) - - target_sources(arch PRIVATE ${SRCS}) - -endif() diff --git a/arch/risc-v/src/common/supervisor/Make.defs b/arch/risc-v/src/common/supervisor/Make.defs deleted file mode 100644 index 65375a3f097..00000000000 --- a/arch/risc-v/src/common/supervisor/Make.defs +++ /dev/null @@ -1,28 +0,0 @@ -############################################################################ -# arch/risc-v/src/common/supervisor/Make.defs -# -# 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. -# -############################################################################ - -# If the NuttX kernel runs in S-mode - -CMN_ASRCS += riscv_syscall.S -CMN_CSRCS += riscv_perform_syscall.c -CMN_CSRCS += riscv_sbi.c - -INCLUDES += ${INCDIR_PREFIX}$(ARCH_SRCDIR)$(DELIM)common$(DELIM)supervisor -VPATH += common$(DELIM)supervisor