diff --git a/arch/sim/src/up_head.c b/arch/sim/src/up_head.c index e1d8c943ba..431d417de6 100644 --- a/arch/sim/src/up_head.c +++ b/arch/sim/src/up_head.c @@ -47,6 +47,7 @@ #include #include +#include /**************************************************************************** * Private Data @@ -60,6 +61,16 @@ static jmp_buf sim_abort; int main(int argc, char **argv, char **envp) { + /* Power management should be initialized early in the (simulated) boot + * sequence. + */ + +#ifdef CONFIG_PM + pm_initialize(); +#endif + + /* Then start NuttX */ + if (setjmp(sim_abort) == 0) { os_start(); diff --git a/arch/sim/src/up_idle.c b/arch/sim/src/up_idle.c index 32efaa11b8..f1d9974d23 100644 --- a/arch/sim/src/up_idle.c +++ b/arch/sim/src/up_idle.c @@ -40,7 +40,10 @@ #include #include + #include +#include + #include "up_internal.h" /**************************************************************************** @@ -103,6 +106,24 @@ void up_idle(void) uipdriver_loop(); #endif + /* Fake some power management stuff for testing purposes */ + +#ifdef CONFIG_PM + { + static enum pm_state_e state = PM_NORMAL; + enum pm_state_e newstate; + + newstate = pm_checkstate(); + if (newstate != state) + { + if (pm_changestate(newstate) == OK) + { + state = newstate; + } + } + } +#endif + /* Wait a bit so that the sched_process_timer() is called close to the * correct rate. */