mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 01:21:26 +08:00
arch/risc-v: Add support for S-mode flat build
There is no need to use kernel build for S-mode all the time. As cpu scratch is supported for non kernel mode build, it is possible to use flat build for S-mode. Add flat build support for risc-v S mode. Signed-off-by: Inochi Amaoto <inochiama@outlook.com>
This commit is contained in:
committed by
Xiang Xiao
parent
8ebc3aa9e8
commit
e37348aeba
+2
-2
@@ -516,9 +516,9 @@ config RISCV_PERCPU_SCRATCH
|
|||||||
#
|
#
|
||||||
|
|
||||||
config ARCH_USE_S_MODE
|
config ARCH_USE_S_MODE
|
||||||
bool "Run the NuttX kernel in S-mode"
|
bool "Run NuttX in S-mode"
|
||||||
default n
|
default n
|
||||||
depends on ARCH_HAVE_S_MODE && BUILD_KERNEL && ARCH_USE_MMU
|
depends on ARCH_HAVE_S_MODE
|
||||||
select RISCV_PERCPU_SCRATCH
|
select RISCV_PERCPU_SCRATCH
|
||||||
---help---
|
---help---
|
||||||
Most of the RISC-V implementations run in M-mode (flat addressing)
|
Most of the RISC-V implementations run in M-mode (flat addressing)
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ if(CONFIG_RISCV_PERCPU_SCRATCH)
|
|||||||
list(APPEND SRCS riscv_percpu.c)
|
list(APPEND SRCS riscv_percpu.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_BUILD_KERNEL)
|
if(CONFIG_ARCH_USE_S_MODE)
|
||||||
add_subdirectory(supervisor)
|
add_subdirectory(supervisor)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,7 @@
|
|||||||
#
|
#
|
||||||
# ##############################################################################
|
# ##############################################################################
|
||||||
|
|
||||||
if(CONFIG_BUILD_KERNEL)
|
if(CONFIG_ARCH_USE_S_MODE)
|
||||||
|
|
||||||
set(SRCS)
|
set(SRCS)
|
||||||
|
|
||||||
list(APPEND SRCS riscv_syscall.S riscv_perform_syscall.c riscv_sbi.c)
|
list(APPEND SRCS riscv_syscall.S riscv_perform_syscall.c riscv_sbi.c)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ __start:
|
|||||||
|
|
||||||
/* Preserve a1 by not using it here as it contains DTB */
|
/* Preserve a1 by not using it here as it contains DTB */
|
||||||
|
|
||||||
#ifndef CONFIG_BUILD_KERNEL
|
#ifndef CONFIG_ARCH_USE_S_MODE
|
||||||
/* Load mhartid (cpuid) */
|
/* Load mhartid (cpuid) */
|
||||||
|
|
||||||
csrr a0, CSR_MHARTID
|
csrr a0, CSR_MHARTID
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ void k230_start(int mhartid, const char *dtb)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef CONFIG_BUILD_KERNEL
|
#ifndef CONFIG_ARCH_USE_S_MODE
|
||||||
k230_hart_init();
|
k230_hart_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ __start:
|
|||||||
/* Preserve a1 as it contains the pointer to DTB */
|
/* Preserve a1 as it contains the pointer to DTB */
|
||||||
/* Load mhartid (cpuid) */
|
/* Load mhartid (cpuid) */
|
||||||
|
|
||||||
#ifndef CONFIG_BUILD_KERNEL
|
#ifndef CONFIG_ARCH_USE_S_MODE
|
||||||
csrr a0, CSR_MHARTID
|
csrr a0, CSR_MHARTID
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
* Extern Function Declarations
|
* Extern Function Declarations
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_BUILD_KERNEL
|
#ifdef CONFIG_ARCH_USE_S_MODE
|
||||||
extern void __start(void);
|
extern void __start(void);
|
||||||
#endif
|
#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)
|
static void qemu_boot_secondary(int mhartid, uintptr_t dtb)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -101,7 +101,7 @@ static void qemu_boot_secondary(int mhartid, uintptr_t dtb)
|
|||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_BUILD_KERNEL
|
#ifdef CONFIG_ARCH_USE_S_MODE
|
||||||
static bool boot_secondary = false;
|
static bool boot_secondary = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ static bool boot_secondary = false;
|
|||||||
|
|
||||||
void qemu_rv_start(int mhartid, const char *dtb)
|
void qemu_rv_start(int mhartid, const char *dtb)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_BUILD_KERNEL
|
#ifdef CONFIG_ARCH_USE_S_MODE
|
||||||
/* Boot other cores */
|
/* Boot other cores */
|
||||||
|
|
||||||
if (!boot_secondary)
|
if (!boot_secondary)
|
||||||
|
|||||||
@@ -18,9 +18,17 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_USE_S_MODE
|
||||||
|
#define TEXT_ADDR 0x80200000
|
||||||
|
#else
|
||||||
|
#define TEXT_ADDR 0x80000000
|
||||||
|
#endif
|
||||||
|
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
. = 0x80000000;
|
. = TEXT_ADDR;
|
||||||
|
|
||||||
/* where the global variable out-of-bounds detection information located */
|
/* where the global variable out-of-bounds detection information located */
|
||||||
#ifdef CONFIG_MM_KASAN_GLOBAL
|
#ifdef CONFIG_MM_KASAN_GLOBAL
|
||||||
|
|||||||
Reference in New Issue
Block a user