Implementment board_power_off() for the simulation platform.

This commit is contained in:
Gregory Nutt
2015-07-04 07:22:38 -06:00
parent f235144989
commit 4c54db68bd
3 changed files with 59 additions and 1 deletions
+2
View File
@@ -10663,3 +10663,5 @@
* sched/sched/sched_waitpid.c: Implement WNOHANG for waitpid() only and * sched/sched/sched_waitpid.c: Implement WNOHANG for waitpid() only and
for the case of CONFIG_SCHED_HAVE_PARENT not selected. From Max for the case of CONFIG_SCHED_HAVE_PARENT not selected. From Max
Neklyudov (2015-07-02). Neklyudov (2015-07-02).
* arch/sim/src/up_head.S: Implement board_power_off() for the simulation
platform (2015-07-04).
+1
View File
@@ -54,6 +54,7 @@ config ARCH_SH
config ARCH_SIM config ARCH_SIM
bool "Simulation" bool "Simulation"
select ARCH_HAVE_TICKLESS select ARCH_HAVE_TICKLESS
select ARCH_HAVE_POWEROFF
---help--- ---help---
Linux/Cywgin user-mode simulation. Linux/Cywgin user-mode simulation.
+56 -1
View File
@@ -47,6 +47,7 @@
#include <nuttx/init.h> #include <nuttx/init.h>
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include <nuttx/board.h>
#include <nuttx/power/pm.h> #include <nuttx/power/pm.h>
/**************************************************************************** /****************************************************************************
@@ -54,11 +55,20 @@
****************************************************************************/ ****************************************************************************/
static jmp_buf sim_abort; static jmp_buf sim_abort;
static int retcode = 0;
/**************************************************************************** /****************************************************************************
* Global Functions * Global Functions
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Name: main
*
* Description:
* This is the main entry point into the simulation.
*
****************************************************************************/
int main(int argc, char **argv, char **envp) int main(int argc, char **argv, char **envp)
{ {
/* Power management should be initialized early in the (simulated) boot /* Power management should be initialized early in the (simulated) boot
@@ -75,16 +85,61 @@ int main(int argc, char **argv, char **envp)
{ {
os_start(); os_start();
} }
return 0;
return retcode;
} }
/****************************************************************************
* Name: up_assert
*
* Description:
* Called to terminate the simulation abnormally in the event of a failed
* assertion.
*
****************************************************************************/
void up_assert(const uint8_t *filename, int line) void up_assert(const uint8_t *filename, int line)
{ {
/* Show the location of the failed assertion */
fprintf(stderr, "Assertion failed at file:%s line: %d\n", filename, line); fprintf(stderr, "Assertion failed at file:%s line: %d\n", filename, line);
/* Allow for any board/configuration specific crash information */
#ifdef CONFIG_BOARD_CRASHDUMP #ifdef CONFIG_BOARD_CRASHDUMP
board_crashdump(up_getsp(), g_readytorun.head, filename, line); board_crashdump(up_getsp(), g_readytorun.head, filename, line);
#endif #endif
/* Exit the simulation */
retcode = EXIT_FAILURE;
longjmp(sim_abort, 1); longjmp(sim_abort, 1);
} }
/****************************************************************************
* Name: board_power_off
*
* Description:
* Power off the board. This function may or may not be supported by a
* particular board architecture.
*
* Input Parameters:
* status - Status information provided with the power off event.
*
* 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_POWEROFF
int board_power_off(int status)
{
/* Save the return code and exit the simulation */
retcode = status;
longjmp(sim_abort, 1);
}
#endif