1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu/native/periph/pm.c

61 lines
1.2 KiB
C
Raw Normal View History

2015-09-29 13:41:33 +02:00
/*
* Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de>
*
2017-01-09 17:41:58 +01:00
* 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.
2015-09-29 13:41:33 +02:00
*/
/**
2017-01-09 17:41:58 +01:00
* @ingroup native_cpu
2015-09-29 13:41:33 +02:00
* @{
2017-01-09 17:41:58 +01:00
*
2015-09-29 13:41:33 +02:00
* @file
2017-01-09 17:41:58 +01:00
* @brief native Power Management implementation
*
2015-09-29 13:41:33 +02:00
* @author Kaspar Schleiser <kaspar@schleiser.de>
*/
#include <err.h>
2017-01-09 17:41:58 +01:00
#include <stdio.h>
2015-09-29 13:41:33 +02:00
#include <stdlib.h>
2017-01-09 17:41:58 +01:00
#include "periph/pm.h"
2015-09-29 13:41:33 +02:00
#include "native_internal.h"
#include "async_read.h"
#include "tty_uart.h"
2015-09-29 13:41:33 +02:00
2017-01-09 17:41:58 +01:00
#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)
2015-09-29 13:41:33 +02:00
{
printf("\n\n\t\t!! REBOOT !!\n\n");
native_async_read_cleanup();
2015-09-29 13:41:33 +02:00
if (real_execve(_native_argv[0], _native_argv, NULL) == -1) {
err(EXIT_FAILURE, "reboot: execve");
}
errx(EXIT_FAILURE, "reboot: this should not have been reached");
}