diff --git a/cpu/native/Makefile.features b/cpu/native/Makefile.features new file mode 100644 index 0000000000000000000000000000000000000000..7a418ea511cb94cb5a2daed61773d99257e33013 --- /dev/null +++ b/cpu/native/Makefile.features @@ -0,0 +1 @@ +FEATURES_PROVIDED += periph_pm diff --git a/cpu/native/irq_cpu.c b/cpu/native/irq_cpu.c index 7833b5005784fef1db61478ba3a2ce94d177b9d3..645c3bf6978036411e0d756538cb61e7510fe0d9 100644 --- a/cpu/native/irq_cpu.c +++ b/cpu/native/irq_cpu.c @@ -37,6 +37,7 @@ #include "irq.h" #include "cpu.h" +#include "periph/pm.h" #include "native_internal.h" @@ -446,7 +447,7 @@ static void native_shutdown(int sig, siginfo_t *info, void *context) (void)info; (void)context; - // TODO: poweroff + pm_off(); } /** diff --git a/cpu/native/reboot.c b/cpu/native/periph/pm.c similarity index 51% rename from cpu/native/reboot.c rename to cpu/native/periph/pm.c index c54bec1328ffdb8a2abe22f03a9040a31824b53a..032abc005e56494b05905a0783ef12d368130f06 100644 --- a/cpu/native/reboot.c +++ b/cpu/native/periph/pm.c @@ -1,28 +1,52 @@ /* * Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de> * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. + * This file is subject to the terms and conditions of the GNU Lesser General + * Public License v2.1. See the file LICENSE in the top level directory for + * more details. */ /** - * @ingroup native_cpu + * @ingroup native_cpu * @{ + * * @file - * @brief native reboot() implementation + * @brief native Power Management implementation + * * @author Kaspar Schleiser <kaspar@schleiser.de> - * @} */ #include <err.h> +#include <stdio.h> #include <stdlib.h> +#include "periph/pm.h" #include "native_internal.h" #include "netdev2_tap.h" #include "tty_uart.h" -void reboot(void) +#define ENABLE_DEBUG (0) +#include "debug.h" + +void pm_set_lowest(void) +{ + _native_in_syscall++; // no switching here + real_pause(); + _native_in_syscall--; + + if (_native_sigpend > 0) { + _native_in_syscall++; + _native_syscall_leave(); + } +} + +void pm_off(void) +{ + puts("\nnative: exiting"); + real_exit(EXIT_SUCCESS); +} + +void pm_reboot(void) { printf("\n\n\t\t!! REBOOT !!\n\n");