Skip to content

Commit

Permalink
bsp: qemu-virt64-riscv: remove config RISCV_S_MODE
Browse files Browse the repository at this point in the history
RISCV_S_MODE configuration only affects the code in
libcpu/risc-v/virt64, and the only bsp using this
libcpu is qemu-virt64-riscv.

Considering s-mode is the default mode RT-Thread
running on virt64 machine, it seems unnecessary to
make RISCV_S_MODE a Kconfig option.

Solution: Remove RISCV_S_MODE from Kconfig and define
it as a macro in the code in libcpu/risc-v/virt64.

Plus, due to this macro is only related to virt64, rename
RISCV_S_MODE to RISCV_VIRT64_S_MODE.

Update the .config/rtconfig.h in this patch.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
  • Loading branch information
unicornx authored and Rbb666 committed Jan 10, 2025
1 parent bdd9447 commit 123ed1b
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 10 deletions.
2 changes: 0 additions & 2 deletions bsp/qemu-virt64-riscv/.config
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000

CONFIG_RT_USING_DFS_DEVFS=y
CONFIG_RT_USING_DFS_ROMFS=y
# CONFIG_RT_USING_DFS_ROMFS_USER_ROOT is not set
# CONFIG_RT_USING_DFS_CROMFS is not set
# CONFIG_RT_USING_DFS_TMPFS is not set
# CONFIG_RT_USING_DFS_MQUEUE is not set
Expand Down Expand Up @@ -1434,7 +1433,6 @@ CONFIG_RT_USING_ADT_REF=y
#
# RISC-V QEMU virt64 configs
#
CONFIG_RISCV_S_MODE=y
CONFIG_BSP_USING_VIRTIO=y
CONFIG_BSP_USING_VIRTIO_BLK=y
CONFIG_BSP_USING_VIRTIO_NET=y
Expand Down
4 changes: 0 additions & 4 deletions bsp/qemu-virt64-riscv/driver/Kconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
menu "RISC-V QEMU virt64 configs"

config RISCV_S_MODE
bool "RT-Thread run in RISC-V S-Mode(supervisor mode)"
default y

config BSP_USING_VIRTIO
bool "Using VirtIO"
default y
Expand Down
1 change: 0 additions & 1 deletion bsp/qemu-virt64-riscv/rtconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,6 @@

/* RISC-V QEMU virt64 configs */

#define RISCV_S_MODE
#define BSP_USING_VIRTIO
#define BSP_USING_VIRTIO_BLK
#define BSP_USING_VIRTIO_NET
Expand Down
2 changes: 1 addition & 1 deletion libcpu/risc-v/common64/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

| 选项 | 默认值 | 说明 |
| --------------- | --- | ---------------------------------------------------------------------------------------------------- |
| RISCV_S_MODE | 打开 | 系统启动后是否运行在S态,关闭时系统将运行在M态;目前系统存在bug尚不可直接运行在M态,故此开关必须打开 |
| RISCV_VIRT64_S_MODE | 打开 | 系统启动后是否运行在S态,关闭时系统将运行在M态;目前系统存在bug尚不可直接运行在M态,故此开关必须打开 |
| RT_USING_SMART | 关闭 | 是否开启RTThread SMART版本,开启后系统运行在S+U态,且会开启MMU页表(satp);关闭时系统仅运行在S态,MMU关闭(satp为bare translation) |
| ARCH_USING_ASID | 关闭 | MMU是否支持asid |

Expand Down
2 changes: 1 addition & 1 deletion libcpu/risc-v/virt64/plic.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void plic_irq_enable(int irq)
{
int hart = __raw_hartid();
*(uint32_t *)PLIC_ENABLE(hart) = ((*(uint32_t *)PLIC_ENABLE(hart)) | (1 << irq));
#ifdef RISCV_S_MODE
#ifdef RISCV_VIRT64_S_MODE
set_csr(sie, read_csr(sie) | MIP_SEIP);
#else
set_csr(mie, read_csr(mie) | MIP_MEIP);
Expand Down
5 changes: 4 additions & 1 deletion libcpu/risc-v/virt64/plic.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ extern size_t plic_base;
#define PLIC_ENABLE_STRIDE 0x80
#define PLIC_CONTEXT_STRIDE 0x1000

#ifndef RISCV_S_MODE
/* RT-Thread runs in S-mode on virt64 by default */
#define RISCV_VIRT64_S_MODE

#ifndef RISCV_VIRT64_S_MODE
#define PLIC_MENABLE_OFFSET (0x2000)
#define PLIC_MTHRESHOLD_OFFSET (0x200000)
#define PLIC_MCLAIM_OFFSET (0x200004)
Expand Down

0 comments on commit 123ed1b

Please sign in to comment.