diff --git a/lib/console/include/lib/console.h b/lib/console/include/lib/console.h index f72e7d85..177d6f22 100644 --- a/lib/console/include/lib/console.h +++ b/lib/console/include/lib/console.h @@ -29,3 +29,9 @@ void panic_shell_start(void); extern int lastresult; +/* enable the panic shell if we're being built */ +#if !defined(ENABLE_PANIC_SHELL) && PLATFORM_SUPPORTS_PANIC_SHELL +#define ENABLE_PANIC_SHELL 1 +#endif + + diff --git a/platform/power.c b/platform/power.c index 1e190851..691b44fb 100644 --- a/platform/power.c +++ b/platform/power.c @@ -8,11 +8,11 @@ #include #include #include +#include #include #include #include #include -#include #if WITH_LIB_CONSOLE #include @@ -24,19 +24,18 @@ */ __WEAK void platform_halt(platform_halt_action suggested_action, platform_halt_reason reason) { -#if WITH_LIB_CONSOLE && ENABLE_PANIC_SHELL - +#if ENABLE_PANIC_SHELL if (reason == HALT_REASON_SW_PANIC) { dprintf(ALWAYS, "CRASH: starting debug shell... (reason = %d)\n", reason); arch_disable_ints(); panic_shell_start(); } - #endif // ENABLE_PANIC_SHELL dprintf(ALWAYS, "HALT: spinning forever... (reason = %d)\n", reason); arch_disable_ints(); - for (;;); + for (;;) + arch_idle(); } static int cmd_reboot(int argc, const cmd_args *argv) { diff --git a/platform/stm32/power.c b/platform/stm32/power.c index 3e5e3f62..b58331f4 100644 --- a/platform/stm32/power.c +++ b/platform/stm32/power.c @@ -8,12 +8,17 @@ #include #include #include +#include #include #include #include #include #include +#if WITH_LIB_CONSOLE +#include +#endif + void platform_halt(platform_halt_action suggested_action, platform_halt_reason reason) { #if ENABLE_PANIC_SHELL diff --git a/top/include/lk/console_cmd.h b/top/include/lk/console_cmd.h index fe06540b..dccdc92b 100644 --- a/top/include/lk/console_cmd.h +++ b/top/include/lk/console_cmd.h @@ -47,16 +47,12 @@ typedef struct _cmd_block { */ #if WITH_LIB_CONSOLE -/* enable the panic shell if we're being built */ -#if !defined(ENABLE_PANIC_SHELL) && PLATFORM_SUPPORTS_PANIC_SHELL -#define ENABLE_PANIC_SHELL 1 -#endif - #define STATIC_COMMAND_START static const cmd _cmd_list[] = { #define STATIC_COMMAND_END(name) }; cmd_block _cmd_block_##name __ALIGNED(sizeof(void *)) __SECTION(".commands") = \ { NULL, sizeof(_cmd_list) / sizeof(_cmd_list[0]), _cmd_list } +/* same as above but with a suffixed name to make the list unique within the file */ #define STATIC_COMMAND_START_NAMED(name) static const cmd _cmd_list_##name[] = { #define STATIC_COMMAND_END_NAMED(name) }; cmd_block _cmd_block_##name __ALIGNED(sizeof(void *)) __SECTION(".commands") = \