core: cpu: sys: simplify reboot()
parent
53ccf97de0
commit
938ff5c5e7
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Freie Universität Berlin
|
||||
*
|
||||
* 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 core_arch
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Architecture dependent interface rebooting
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
||||
*/
|
||||
|
||||
#ifndef REBOOT_ARCH_H
|
||||
#define REBOOT_ARCH_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Reboot the system
|
||||
*
|
||||
* @param[in] mode the argument is ignored and only used for conformity
|
||||
* with existing reboot implementations for now.
|
||||
*
|
||||
* @return this call never returns when successful. -1 is returned otherwise.
|
||||
*/
|
||||
int reboot_arch(int mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* REBOOT_ARCH_H */
|
||||
/** @} */
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup core_internal
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Reboot function
|
||||
*
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*/
|
||||
|
||||
#ifndef REBOOT_H_
|
||||
#define REBOOT_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Immediately reboots the system.
|
||||
*
|
||||
* This function is used by core_panic() when the DEVELHELP macro is not defined.
|
||||
*/
|
||||
void reboot(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* REBOOT_H_ */
|
||||
/** @} */
|
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup core_util
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Reboot function
|
||||
*
|
||||
* @author Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "kernel.h"
|
||||
#include "arch/reboot_arch.h"
|
||||
|
||||
int reboot(int mode)
|
||||
{
|
||||
if (mode != RB_AUTOBOOT) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return reboot_arch(mode);
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup native_cpu
|
||||
* @{
|
||||
* @file
|
||||
* @brief native reboot() implementation
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <err.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "native_internal.h"
|
||||
#include "netdev2_tap.h"
|
||||
|
||||
void reboot(void)
|
||||
{
|
||||
printf("\n\n\t\t!! REBOOT !!\n\n");
|
||||
|
||||
#ifdef MODULE_NETDEV2_TAP
|
||||
netdev2_tap_cleanup(&netdev2_tap);
|
||||
#endif
|
||||
|
||||
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");
|
||||
}
|
Loading…
Reference in New Issue