riscv/virt: M-mode poweroff support

This adds poweroff support to `rv-virt/nsh` and `rv-virt/nsh64`.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
This commit is contained in:
Yanfeng Liu 2024-05-08 11:09:46 +08:00 committed by Xiang Xiao
parent 5b3ef20629
commit ef15b5296d
5 changed files with 17 additions and 3 deletions

View File

@ -31,4 +31,6 @@
#define QEMU_RV_ACLINT_BASE 0x02f00000
#define QEMU_RV_PLIC_BASE 0x0c000000
#define QEMU_RV_RESET_BASE 0x100000
#endif /* __ARCH_RISCV_SRC_QEMU_RV_HARDWARE_QEMU_RV_MEMORYMAP_H */

View File

@ -39,4 +39,12 @@
#define QEMU_RV_IDLESTACK_BASE _ebss
#endif
#ifndef CONFIG_BUILD_KERNEL
/* QEMU reset chocies */
#define QEMU_RV_RESET_DONE 0x5555
#define QEMU_RV_RESET_FAIL 0x3333
#define QEMU_RV_RESET_REBOOT 0x7777
#endif
#endif /* __ARCH_RISCV_SRC_QEMU_RV_QEMU_RV_MEMORYMAP_H */

View File

@ -26,6 +26,7 @@ CONFIG_ARCH_CHIP_QEMU_RV_ISA_M=y
CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ARCH_RISCV=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_BOARDCTL_POWEROFF=y
CONFIG_BOARD_LOOPSPERMSEC=6366
CONFIG_BUILTIN=y
CONFIG_DEBUG_FULLOPT=y
@ -37,7 +38,6 @@ CONFIG_FS_HOSTFS=y
CONFIG_FS_PROCFS=y
CONFIG_IDLETHREAD_STACKSIZE=2048
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INTELHEX_BINARY=y
CONFIG_LIBC_ENVPATH=y
CONFIG_LIBC_EXECFUNCS=y
CONFIG_LIBC_PERROR_STDOUT=y

View File

@ -27,6 +27,7 @@ CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ARCH_RISCV=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_BCH=y
CONFIG_BOARDCTL_POWEROFF=y
CONFIG_BOARD_LOOPSPERMSEC=6366
CONFIG_BUILTIN=y
CONFIG_DEBUG_FULLOPT=y
@ -40,7 +41,6 @@ CONFIG_FS_PROCFS=y
CONFIG_IDLETHREAD_STACKSIZE=2048
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INIT_STACKSIZE=3072
CONFIG_INTELHEX_BINARY=y
CONFIG_LIBC_ENVPATH=y
CONFIG_LIBC_EXECFUNCS=y
CONFIG_LIBC_PERROR_STDOUT=y

View File

@ -36,6 +36,10 @@
#include <sys/mount.h>
#ifndef CONFIG_BUILD_KERNEL
#include "hardware/qemu_rv_memorymap.h"
#include "qemu_rv_memorymap.h"
#endif
#include "riscv_internal.h"
#include "romfs.h"
@ -185,7 +189,7 @@ int board_power_off(int status)
#ifdef CONFIG_BUILD_KERNEL
riscv_sbi_system_reset(SBI_SRST_TYPE_SHUTDOWN, SBI_SRST_REASON_NONE);
#else
#warning "to be done"
*(FAR volatile uint32_t *)QEMU_RV_RESET_BASE = QEMU_RV_RESET_DONE;
#endif
UNUSED(status);