diff --git a/arch/risc-v/Kconfig b/arch/risc-v/Kconfig index bd370372ac..a0f5b88146 100644 --- a/arch/risc-v/Kconfig +++ b/arch/risc-v/Kconfig @@ -516,9 +516,9 @@ config RISCV_PERCPU_SCRATCH # config ARCH_USE_S_MODE - bool "Run the NuttX kernel in S-mode" + bool "Run NuttX in S-mode" default n - depends on ARCH_HAVE_S_MODE && BUILD_KERNEL && ARCH_USE_MMU + depends on ARCH_HAVE_S_MODE select RISCV_PERCPU_SCRATCH ---help--- Most of the RISC-V implementations run in M-mode (flat addressing) diff --git a/arch/risc-v/src/common/CMakeLists.txt b/arch/risc-v/src/common/CMakeLists.txt index 82e16738d3..348518a15b 100644 --- a/arch/risc-v/src/common/CMakeLists.txt +++ b/arch/risc-v/src/common/CMakeLists.txt @@ -109,7 +109,7 @@ if(CONFIG_RISCV_PERCPU_SCRATCH) list(APPEND SRCS riscv_percpu.c) endif() -if(CONFIG_BUILD_KERNEL) +if(CONFIG_ARCH_USE_S_MODE) add_subdirectory(supervisor) endif() diff --git a/arch/risc-v/src/common/supervisor/CMakeLists.txt b/arch/risc-v/src/common/supervisor/CMakeLists.txt index 7ae71b030e..376ded80b3 100644 --- a/arch/risc-v/src/common/supervisor/CMakeLists.txt +++ b/arch/risc-v/src/common/supervisor/CMakeLists.txt @@ -18,8 +18,7 @@ # # ############################################################################## -if(CONFIG_BUILD_KERNEL) - +if(CONFIG_ARCH_USE_S_MODE) set(SRCS) list(APPEND SRCS riscv_syscall.S riscv_perform_syscall.c riscv_sbi.c) diff --git a/arch/risc-v/src/k230/k230_head.S b/arch/risc-v/src/k230/k230_head.S index 2673779ceb..901b065d38 100644 --- a/arch/risc-v/src/k230/k230_head.S +++ b/arch/risc-v/src/k230/k230_head.S @@ -59,7 +59,7 @@ __start: /* Preserve a1 by not using it here as it contains DTB */ -#ifndef CONFIG_BUILD_KERNEL +#ifndef CONFIG_ARCH_USE_S_MODE /* Load mhartid (cpuid) */ csrr a0, CSR_MHARTID diff --git a/arch/risc-v/src/k230/k230_start.c b/arch/risc-v/src/k230/k230_start.c index abc378188c..0925352b18 100644 --- a/arch/risc-v/src/k230/k230_start.c +++ b/arch/risc-v/src/k230/k230_start.c @@ -122,7 +122,7 @@ void k230_start(int mhartid, const char *dtb) #endif } -#ifndef CONFIG_BUILD_KERNEL +#ifndef CONFIG_ARCH_USE_S_MODE k230_hart_init(); #endif diff --git a/arch/risc-v/src/qemu-rv/qemu_rv_head.S b/arch/risc-v/src/qemu-rv/qemu_rv_head.S index 9be1ed225f..979fe43536 100644 --- a/arch/risc-v/src/qemu-rv/qemu_rv_head.S +++ b/arch/risc-v/src/qemu-rv/qemu_rv_head.S @@ -45,7 +45,7 @@ __start: /* Preserve a1 as it contains the pointer to DTB */ /* Load mhartid (cpuid) */ -#ifndef CONFIG_BUILD_KERNEL +#ifndef CONFIG_ARCH_USE_S_MODE csrr a0, CSR_MHARTID #endif diff --git a/arch/risc-v/src/qemu-rv/qemu_rv_start.c b/arch/risc-v/src/qemu-rv/qemu_rv_start.c index c9d9bf736b..9381be93bb 100644 --- a/arch/risc-v/src/qemu-rv/qemu_rv_start.c +++ b/arch/risc-v/src/qemu-rv/qemu_rv_start.c @@ -58,7 +58,7 @@ * Extern Function Declarations ****************************************************************************/ -#ifdef CONFIG_BUILD_KERNEL +#ifdef CONFIG_ARCH_USE_S_MODE extern void __start(void); #endif @@ -80,7 +80,7 @@ static void qemu_rv_clear_bss(void) } } -#ifdef CONFIG_BUILD_KERNEL +#ifdef CONFIG_ARCH_USE_S_MODE static void qemu_boot_secondary(int mhartid, uintptr_t dtb) { int i; @@ -101,7 +101,7 @@ static void qemu_boot_secondary(int mhartid, uintptr_t dtb) * Private Data ****************************************************************************/ -#ifdef CONFIG_BUILD_KERNEL +#ifdef CONFIG_ARCH_USE_S_MODE static bool boot_secondary = false; #endif @@ -119,7 +119,7 @@ static bool boot_secondary = false; void qemu_rv_start(int mhartid, const char *dtb) { -#ifdef CONFIG_BUILD_KERNEL +#ifdef CONFIG_ARCH_USE_S_MODE /* Boot other cores */ if (!boot_secondary) diff --git a/boards/risc-v/qemu-rv/rv-virt/scripts/ld.script b/boards/risc-v/qemu-rv/rv-virt/scripts/ld.script index 95d38cf3a9..1b169a37e9 100644 --- a/boards/risc-v/qemu-rv/rv-virt/scripts/ld.script +++ b/boards/risc-v/qemu-rv/rv-virt/scripts/ld.script @@ -18,9 +18,17 @@ * ****************************************************************************/ +#include + +#ifdef CONFIG_ARCH_USE_S_MODE +#define TEXT_ADDR 0x80200000 +#else +#define TEXT_ADDR 0x80000000 +#endif + SECTIONS { - . = 0x80000000; + . = TEXT_ADDR; /* where the global variable out-of-bounds detection information located */ #ifdef CONFIG_MM_KASAN_GLOBAL