diff --git a/core/include/arch/reboot_arch.h b/core/include/arch/reboot_arch.h deleted file mode 100644 index 83f760083..000000000 --- a/core/include/arch/reboot_arch.h +++ /dev/null @@ -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 - * @author Oliver Hahm - */ - -#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 */ -/** @} */ diff --git a/core/include/kernel.h b/core/include/kernel.h index 4b22c3971..7ead76272 100644 --- a/core/include/kernel.h +++ b/core/include/kernel.h @@ -64,23 +64,6 @@ extern config_t sysconfig; /* ------------------------------------------------------------------------- */ -/** - * @brief Immediately reboots the system. - * - * This function is used by core_panic() when the DEVELHELP macro is not defined. - * - * @param mode The reboot mode (unused for now) - * - * @return This call never returns when successful. -1 is returned otherwise. - */ -int reboot(int mode); - -/** - * @def RB_AUTOBOOT - * @brief Reboot the system in the usual fashion - */ -#define RB_AUTOBOOT 0 - #ifdef __cplusplus } #endif diff --git a/core/include/reboot.h b/core/include/reboot.h new file mode 100644 index 000000000..f0aa28200 --- /dev/null +++ b/core/include/reboot.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2016 Kaspar Schleiser + * + * 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 + */ + +#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_ */ +/** @} */ diff --git a/core/panic.c b/core/panic.c index 257904765..998be10e4 100644 --- a/core/panic.c +++ b/core/panic.c @@ -30,6 +30,7 @@ #include "lpm.h" #include "panic.h" #include "arch/panic_arch.h" +#include "reboot.h" #if defined(DEVELHELP) && defined(MODULE_PS) #include "ps.h" @@ -72,7 +73,7 @@ NORETURN void core_panic(core_panic_t crash_code, const char *message) panic_arch(); #ifndef DEVELHELP /* DEVELHELP not set => reboot system */ - (void) reboot(RB_AUTOBOOT); + reboot(); #endif /* tell the compiler that we won't return from this function diff --git a/core/reboot.c b/core/reboot.c deleted file mode 100644 index de0b154a4..000000000 --- a/core/reboot.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2014 Ludwig Knüpfer - * - * 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 + * 2014 Freie Universität Berlin, Hinnerk van Bruinehsen * * 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 @@ -14,27 +15,22 @@ * @brief Implementation of the kernels reboot interface * * @author Hinnerk van Bruinehsen + * @author Kaspar Schleiser * * @} */ -#include #include -#include "arch/reboot_arch.h" +#include "kernel.h" #include "cpu.h" - -int reboot_arch(int mode) +void reboot(void) { - printf("Going into reboot, mode %i\n", mode); - /* * Since the AVR doesn't support a real software reset, we set the Watchdog * Timer on a 250ms timeout. Consider this a kludge. */ wdt_enable(WDTO_250MS); - - - return 0; + while(1); } diff --git a/cpu/cortexm_common/reboot_arch.c b/cpu/cortexm_common/reboot_arch.c index 338f2ba38..a12a94322 100644 --- a/cpu/cortexm_common/reboot_arch.c +++ b/cpu/cortexm_common/reboot_arch.c @@ -22,15 +22,10 @@ #include -#include "arch/reboot_arch.h" +#include "kernel.h" #include "cpu.h" -int reboot_arch(int mode) +void reboot(void) { - printf("Going into reboot, mode %i\n", mode); - /* wait a while to make sure the printf is finished */ - volatile int n = 100000; - while(n--); NVIC_SystemReset(); - return -1; } diff --git a/cpu/lpc11u34/reboot_arch.c b/cpu/lpc11u34/reboot_arch.c index 643c2a3ee..123707195 100644 --- a/cpu/lpc11u34/reboot_arch.c +++ b/cpu/lpc11u34/reboot_arch.c @@ -1,5 +1,6 @@ /* - * Copyright (C) 2015 Freie Universität Berlin + * Copyright (C) 2016 Kaspar Schleiser + * 2015 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 @@ -14,20 +15,17 @@ * @brief Implementation of the kernels reboot interface * * @author Paul RATHGEB + * @author Kaspar Schleiser * * @} */ -#include - -#include "arch/reboot_arch.h" +#include "reboot.h" #include "cpu.h" +#include "log.h" -int reboot_arch(int mode) +void reboot(void) { - printf("Going into reboot, mode %i\n", mode); - + LOG_INFO("RIOT rebooting...\n"); NVIC_SystemReset(); - - return 0; } diff --git a/cpu/lpc1768/reboot_arch.c b/cpu/lpc1768/reboot_arch.c index ca12bb1b5..455e613c6 100644 --- a/cpu/lpc1768/reboot_arch.c +++ b/cpu/lpc1768/reboot_arch.c @@ -1,5 +1,6 @@ /* - * Copyright (C) 2014 Freie Universität Berlin + * Copyright (C) 2016 Kaspar Schleiser + * 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 @@ -15,20 +16,17 @@ * * @author Oliver Hahm * @author Hauke Petersen + * @author Kaspar Schleiser * * @} */ #include -#include "arch/reboot_arch.h" +#include "kernel.h" #include "cpu.h" -int reboot_arch(int mode) +void reboot(void) { - printf("Going into reboot, mode %i\n", mode); - NVIC_SystemReset(); - - return 0; } diff --git a/cpu/msp430-common/cpu.c b/cpu/msp430-common/cpu.c index c5707114a..278d341df 100644 --- a/cpu/msp430-common/cpu.c +++ b/cpu/msp430-common/cpu.c @@ -1,5 +1,6 @@ /* - * Copyright (C) 2014, Freie Universitaet Berlin (FUB) & INRIA. + * Copyright (C) 2016 Kaspar Schleiser + * 2014, Freie Universitaet Berlin (FUB) & INRIA. * All rights reserved. * * This file is subject to the terms and conditions of the GNU Lesser @@ -93,15 +94,11 @@ char *thread_stack_init(thread_task_func_t task_func, void *arg, void *stack_sta /******************************************************************************/ /* System reboot */ -int reboot_arch(int mode) +void reboot(void) { - (void) mode; - /* force an hardware reboot ("Power-Up Clear"), by writing an illegal value to the watchdog control register */ while (1) { WDTCTL = 0x0000; } - - return -1; } diff --git a/cpu/native/native_cpu.c b/cpu/native/native_cpu.c index 44ab42808..41c4d2656 100644 --- a/cpu/native/native_cpu.c +++ b/cpu/native/native_cpu.c @@ -1,19 +1,24 @@ -/** - * Native CPU kernel_intern.h and sched.h implementation - * - * in-process preemptive context switching utilizes POSIX ucontexts. - * (ucontext provides for architecture independent stack handling) - * - * Copyright (C) 2013 Ludwig Knüpfer +/* + * Copyright (C) 2016 Kaspar Schleiser + * 2013 Ludwig Knüpfer * * 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 CPU kernel_intern.h and sched.h implementation + * + * in-process preemptive context switching utilizes POSIX ucontexts. + * (ucontext provides for architecture independent stack handling) + * * @author Ludwig Knüpfer + * @author Kaspar Schleiser */ #include @@ -62,23 +67,6 @@ extern netdev2_tap_t netdev2_tap; ucontext_t end_context; char __end_stack[SIGSTKSZ]; -int reboot_arch(int mode) -{ - (void) mode; - - 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"); -} - /** * TODO: implement */ diff --git a/cpu/native/reboot.c b/cpu/native/reboot.c new file mode 100644 index 000000000..6641a9ed9 --- /dev/null +++ b/cpu/native/reboot.c @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2016 Kaspar Schleiser + * + * 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 + * @} + */ + +#include +#include + +#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"); +} diff --git a/cpu/x86/x86_reboot.c b/cpu/x86/x86_reboot.c index 90d2eef50..65bd83a3e 100644 --- a/cpu/x86/x86_reboot.c +++ b/cpu/x86/x86_reboot.c @@ -1,5 +1,6 @@ /* - * Copyright (C) 2014 René Kijewski + * Copyright (C) 2016 Kaspar Schleiser + * 2014 René Kijewski * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -24,6 +25,7 @@ * @brief Configurable reboot handler for x86. * * @author René Kijewski + * @author Kaspar Schleiser * * @} */ @@ -84,22 +86,16 @@ void NORETURN x86_kbc_reboot(void) static x86_reboot_t reboot_fun; static bool reboot_twice; -int reboot_arch(int mode) +void reboot(void) { - switch (mode) { - case RB_AUTOBOOT: - asm volatile ("cli"); - if (!reboot_twice) { - reboot_twice = true; - if (reboot_fun) { - reboot_fun(); - } - } - x86_kbc_reboot(); - - default: - return -1; + asm volatile ("cli"); + if (!reboot_twice) { + reboot_twice = true; + if (reboot_fun) { + reboot_fun(); + } } + x86_kbc_reboot(); } void x86_set_reboot_fun(x86_reboot_t fun) diff --git a/sys/newlib/syscalls.c b/sys/newlib/syscalls.c index d0679481d..09610e590 100644 --- a/sys/newlib/syscalls.c +++ b/sys/newlib/syscalls.c @@ -33,8 +33,9 @@ #include "cpu.h" #include "board.h" #include "thread.h" -#include "kernel.h" +#include "reboot.h" #include "irq.h" +#include "log.h" #include "uart_stdio.h" @@ -77,8 +78,8 @@ void _fini(void) */ void _exit(int n) { - printf("#! exit %i: resetting\n", n); - reboot(n); + LOG_INFO("#! exit %i: resetting\n", n); + reboot(); while(1); } diff --git a/sys/shell/commands/sc_sys.c b/sys/shell/commands/sc_sys.c index 25d166b27..1aa02b3ce 100644 --- a/sys/shell/commands/sc_sys.c +++ b/sys/shell/commands/sc_sys.c @@ -18,14 +18,14 @@ * @} */ -#include "kernel.h" +#include "reboot.h" int _reboot_handler(int argc, char **argv) { (void) argc; (void) argv; - (void) reboot(RB_AUTOBOOT); + reboot(); return 0; }