diff --git a/arch/Kconfig b/arch/Kconfig index b34385c708..9286e2ebc7 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -159,6 +159,10 @@ config ARCH_HAVE_POWEROFF bool default n +config ARCH_HAVE_RESET + bool + default n + config ARCH_USE_MMU bool "Enable MMU" default n diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 1cb1da3ce3..f341f3bf2b 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -233,6 +233,7 @@ config ARCH_CORTEXM0 bool default n select ARCH_HAVE_IRQPRIO + select ARCH_HAVE_RESET config ARCH_CORTEXM3 bool @@ -240,6 +241,7 @@ config ARCH_CORTEXM3 select ARCH_HAVE_IRQPRIO select ARCH_HAVE_RAMVECTORS select ARCH_HAVE_HIPRI_INTERRUPT + select ARCH_HAVE_RESET config ARCH_CORTEXM4 bool @@ -247,6 +249,7 @@ config ARCH_CORTEXM4 select ARCH_HAVE_IRQPRIO select ARCH_HAVE_RAMVECTORS select ARCH_HAVE_HIPRI_INTERRUPT + select ARCH_HAVE_RESET config ARCH_CORTEXM7 bool diff --git a/arch/arm/src/armv6-m/up_systemreset.c b/arch/arm/src/armv6-m/up_systemreset.c index b1c70b3e55..6106028615 100644 --- a/arch/arm/src/armv6-m/up_systemreset.c +++ b/arch/arm/src/armv6-m/up_systemreset.c @@ -42,19 +42,21 @@ #include +#include + #include "up_arch.h" #include "nvic.h" /**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - - /**************************************************************************** - * Public Types + * Public functions ****************************************************************************/ /**************************************************************************** - * Public functions + * Name: up_systemreset + * + * Description: + * Internal, Cortex-M0 reset logic. + * ****************************************************************************/ void up_systemreset(void) @@ -76,3 +78,32 @@ void up_systemreset(void) for (;;); } + + +/**************************************************************************** + * Name: board_reset + * + * Description: + * Reset board. This function may or may not be supported by a + * particular board architecture. + * + * Input Parameters: + * status - Status information provided with the reset event. This + * meaning of this status information is board-specific. If not used by + * a board, the value zero may be provided in calls to board_reset. + * + * Returned Value: + * If this function returns, then it was not possible to power-off the + * board due to some constraints. The return value int this case is a + * board-specific reason for the failure to shutdown. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARDCTL_RESET +int board_reset(int status) +{ + up_systemreset(); + return 0; +} +#endif + diff --git a/arch/arm/src/armv7-m/up_systemreset.c b/arch/arm/src/armv7-m/up_systemreset.c index ef6da0b9f7..96f1b92089 100644 --- a/arch/arm/src/armv7-m/up_systemreset.c +++ b/arch/arm/src/armv7-m/up_systemreset.c @@ -42,19 +42,21 @@ #include +#include + #include "up_arch.h" #include "nvic.h" /**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - - /**************************************************************************** - * Public Types + * Public functions ****************************************************************************/ /**************************************************************************** - * Public functions + * Name: up_systemreset + * + * Description: + * Internal, Cortex-M0 reset logic. + * ****************************************************************************/ void up_systemreset(void) @@ -77,3 +79,31 @@ void up_systemreset(void) for (;;); } + + +/**************************************************************************** + * Name: board_reset + * + * Description: + * Reset board. This function may or may not be supported by a + * particular board architecture. + * + * Input Parameters: + * status - Status information provided with the reset event. This + * meaning of this status information is board-specific. If not used by + * a board, the value zero may be provided in calls to board_reset. + * + * Returned Value: + * If this function returns, then it was not possible to power-off the + * board due to some constraints. The return value int this case is a + * board-specific reason for the failure to shutdown. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARDCTL_RESET +int board_reset(int status) +{ + up_systemreset(); + return 0; +} +#endif diff --git a/arch/sim/src/up_head.c b/arch/sim/src/up_head.c index 43bc256b1a..ddc0270974 100644 --- a/arch/sim/src/up_head.c +++ b/arch/sim/src/up_head.c @@ -56,8 +56,8 @@ * Private Data ****************************************************************************/ -static jmp_buf sim_abort; -static int retcode = EXIT_SUCCESS; +static jmp_buf g_simabort; +static int g_exitcode = EXIT_SUCCESS; /**************************************************************************** * Global Functions @@ -83,7 +83,7 @@ int main(int argc, char **argv, char **envp) /* Then start NuttX */ - if (setjmp(sim_abort) == 0) + if (setjmp(g_simabort) == 0) { os_start(); } @@ -91,7 +91,7 @@ int main(int argc, char **argv, char **envp) /* Restore the original terminal mode and return the exit code */ simuart_teriminate(); - return retcode; + return g_exitcode; } /**************************************************************************** @@ -117,8 +117,8 @@ void up_assert(const uint8_t *filename, int line) /* Exit the simulation */ - retcode = EXIT_FAILURE; - longjmp(sim_abort, 1); + g_exitcode = EXIT_FAILURE; + longjmp(g_simabort, 1); } /**************************************************************************** @@ -143,8 +143,8 @@ int board_power_off(int status) { /* Save the return code and exit the simulation */ - retcode = status; - longjmp(sim_abort, 1); + g_exitcode = status; + longjmp(g_simabort, 1); } #endif