From ed1010d84b98125a4956af76a305d179ec668d48 Mon Sep 17 00:00:00 2001 From: Wang_Weigen Date: Thu, 13 May 2021 10:59:05 +0800 Subject: [PATCH] add reboot cmd for arm and delete shutcmd --- arch/arm/shared/prepare_ahwstack.c | 8 ++----- arch/risc-v/shared/prepare_rhwstack.c | 11 --------- board/aiit-riscv64-board/board.c | 33 ++++----------------------- board/kd233/board.c | 26 ++------------------- board/maix-go/board.c | 28 +++-------------------- fs/shared/src/iot-vfs.c | 4 ++-- tool/shell/letter-shell/shell.c | 2 +- 7 files changed, 14 insertions(+), 98 deletions(-) diff --git a/arch/arm/shared/prepare_ahwstack.c b/arch/arm/shared/prepare_ahwstack.c index ac690847..64a3f772 100644 --- a/arch/arm/shared/prepare_ahwstack.c +++ b/arch/arm/shared/prepare_ahwstack.c @@ -16,6 +16,7 @@ #include "svc_handle.h" #include "stm32f4xx.h" #include +#include #if (defined ( __GNUC__ ) && defined ( __VFP_FP__ ) && !defined(__SOFTFP__)) #define USE_FPU 1 @@ -410,13 +411,8 @@ void MemFaultHandle(uintptr_t *sp) } -void ShutdownCpu(void) -{ - KPrintf("shutdown...\n"); - CHECK(0); -} - __attribute__((weak)) void HwCpuReset(void) { SCB_AIRCR = SCB_RESET_VALUE; } +SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0), Reboot, HwCpuReset, reset machine ); \ No newline at end of file diff --git a/arch/risc-v/shared/prepare_rhwstack.c b/arch/risc-v/shared/prepare_rhwstack.c index ac2d5837..2d1835ab 100644 --- a/arch/risc-v/shared/prepare_rhwstack.c +++ b/arch/risc-v/shared/prepare_rhwstack.c @@ -96,17 +96,6 @@ uint8 KTaskStackSetup(struct TaskDescriptor *task) return EOK; } - -void ShutdownCpu() -{ - uint32 level; - KPrintf("shutdown...\n"); - - level = DISABLE_INTERRUPT(); - while (level) - CHECK(0); -} - #ifdef TASK_ISOLATION void RestoreMstatus(uintptr_t *sp) { diff --git a/board/aiit-riscv64-board/board.c b/board/aiit-riscv64-board/board.c index c69800df..ac170e5f 100644 --- a/board/aiit-riscv64-board/board.c +++ b/board/aiit-riscv64-board/board.c @@ -53,7 +53,6 @@ Modification: extern x_base cpu2_boot_flag; extern void entry(void); extern void SecondaryCpuCStart(void); -extern void ShutdownCpu(void); extern int IoConfigInit(void); extern int HwCh438Init(void); extern int HwSpiInit(void); @@ -98,7 +97,7 @@ void Kd233Start(uint32_t mhartid) } } -int freq(void) +int Freq(void) { uint64 value = 0; @@ -124,7 +123,7 @@ int freq(void) return 0; } -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),freq, freq, show freq info ); +SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),Freq, Freq, show frequency information ); #ifdef ARCH_SMP extern int EnableHwclintIpi(void); @@ -218,30 +217,6 @@ void HwCpuReset(void) while(RET_TRUE); } -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0), - reboot, HwCpuReset, reset machine ); +SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0), Reboot, HwCpuReset, reset machine ); -static void (*pre_shutdown_action)(void *); -static void *pre_shutdown_action_arg; - -void SetPreShutdownAction(void (*func)(void *), void *arg) -{ - pre_shutdown_action = func; - pre_shutdown_action_arg = arg; -} - -void cmd_shutdown() -{ -#ifdef FS_VFS - SyncOpenedFiles(); -#endif - - if (pre_shutdown_action != NULL) - pre_shutdown_action(pre_shutdown_action_arg); - - ShutdownCpu(); -} - - -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0), - shutdown,cmd_shutdown,shutdown machine); + diff --git a/board/kd233/board.c b/board/kd233/board.c index 2bc030e6..be0bb2e1 100644 --- a/board/kd233/board.c +++ b/board/kd233/board.c @@ -54,7 +54,6 @@ Modification: extern x_base cpu2_boot_flag; extern void entry(void); extern void SecondaryCpuCStart(void); -extern void ShutdownCpu(void); extern int IoConfigInit(void); extern int HwSpiInit(void); extern int HwI2cInit(void); @@ -121,7 +120,7 @@ int Freq(void) return 0; } -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),freq, Freq, show freq info ); +SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),Freq, Freq, show frequency information ); #ifdef ARCH_SMP extern int EnableHwclintIpi(void); @@ -205,27 +204,6 @@ void HwCpuReset(void) while(RET_TRUE); } -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0), - reboot, HwCpuReset, reset machine ); -static void (*pre_shutdown_action)(void *); -static void *pre_shutdown_action_arg; +SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),Reboot, HwCpuReset, reset machine ); -void SetPreShutdownAction(void (*func)(void *), void *arg) -{ - pre_shutdown_action = func; - pre_shutdown_action_arg = arg; -} -void CmdShutdown() -{ -#ifdef FS_VFS - SyncOpenedFiles(); -#endif - if (pre_shutdown_action != NULL) - pre_shutdown_action(pre_shutdown_action_arg); - - ShutdownCpu(); -} - -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0), - shutdown,CmdShutdown,shutdown machine); diff --git a/board/maix-go/board.c b/board/maix-go/board.c index ac89ab79..9d26d1dc 100644 --- a/board/maix-go/board.c +++ b/board/maix-go/board.c @@ -51,7 +51,6 @@ Modification: extern x_base cpu2_boot_flag; extern void entry(void); extern void SecondaryCpuCStart(void); -extern void ShutdownCpu(void); extern int IoConfigInit(void); extern int HwSpiInit(void); extern int HwI2cInit(void); @@ -117,7 +116,7 @@ int Freq(void) return 0; } -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),freq, Freq, show freq info ); +SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),Freq, Freq, show frequency information ); #ifdef ARCH_SMP extern int EnableHwclintIpi(void); @@ -170,27 +169,6 @@ void HwCpuReset(void) while(RET_TRUE); } -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0), - reboot, HwCpuReset, reset machine ); -static void (*pre_shutdown_action)(void *); -static void *pre_shutdown_action_arg; +SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),Reboot, HwCpuReset, reset machine ); -void SetPreShutdownAction(void (*func)(void *), void *arg) -{ - pre_shutdown_action = func; - pre_shutdown_action_arg = arg; -} - -void CmdShutdown() -{ -#ifdef FS_VFS - SyncOpenedFiles(); -#endif - if (pre_shutdown_action != NULL) - pre_shutdown_action(pre_shutdown_action_arg); - - ShutdownCpu(); -} - -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0), - shutdown,CmdShutdown,shutdown machine); + diff --git a/fs/shared/src/iot-vfs.c b/fs/shared/src/iot-vfs.c index c6c14271..520fb66c 100644 --- a/fs/shared/src/iot-vfs.c +++ b/fs/shared/src/iot-vfs.c @@ -1164,7 +1164,7 @@ int VfsInit() return 0; } -int showfd() +int ShowFd() { for (int i = 0; i < FD_MAX - FD_OFFSET; i++) { struct FileDescriptor *fdp = fdtable[i]; @@ -1178,4 +1178,4 @@ int showfd() KPrintf("%s\n", fdp->path); } } -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),showfd, showfd, list file descriptor ); +SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),ShowFd, ShowFd, show file descriptor ); diff --git a/tool/shell/letter-shell/shell.c b/tool/shell/letter-shell/shell.c index 4f3121f7..2cd6e577 100644 --- a/tool/shell/letter-shell/shell.c +++ b/tool/shell/letter-shell/shell.c @@ -1545,7 +1545,7 @@ void shellHelp(int argc, char *argv[]) } SHELL_EXPORT_CMD( SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_DISABLE_RETURN, -help, shellHelp, show command info\r\nhelp [cmd]); +Help, shellHelp, show command info\r\nhelp [cmd]); /** * @brief shell Input processing