From 828839316b47a0f42dbe2f56e017b062b64c86b5 Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Sat, 9 May 2015 18:02:39 +0200 Subject: [PATCH 1/2] core: renamed crash.h to panic.h --- boards/telosb/driver_cc2420.c | 2 +- boards/wsn430-v1_4/driver_cc2420.c | 2 +- boards/z1/driver_cc2420.c | 2 +- core/include/{crash.h => panic.h} | 12 ++++++------ cpu/arm7_common/{crash.c => panic.c} | 4 ++-- cpu/cortex-m0_common/{crash.c => panic.c} | 2 +- cpu/cortex-m3_common/{crash.c => panic.c} | 2 +- cpu/cortex-m4_common/{crash.c => panic.c} | 2 +- cpu/kinetis_common/fault_handlers.c | 2 +- cpu/msp430-common/hwtimer_cpu.c | 2 +- cpu/msp430-common/{crash.c => panic.c} | 4 ++-- cpu/native/{crash.c => panic.c} | 4 ++-- cpu/nrf51822/startup.c | 2 +- cpu/sam3x8e/startup.c | 2 +- cpu/stm32f0/startup.c | 2 +- cpu/stm32f1/startup.c | 2 +- cpu/stm32l1/startup.c | 2 +- drivers/cc2420/cc2420.c | 2 +- 18 files changed, 26 insertions(+), 26 deletions(-) rename core/include/{crash.h => panic.h} (88%) rename cpu/arm7_common/{crash.c => panic.c} (97%) rename cpu/cortex-m0_common/{crash.c => panic.c} (99%) rename cpu/cortex-m3_common/{crash.c => panic.c} (99%) rename cpu/cortex-m4_common/{crash.c => panic.c} (99%) rename cpu/msp430-common/{crash.c => panic.c} (97%) rename cpu/native/{crash.c => panic.c} (97%) diff --git a/boards/telosb/driver_cc2420.c b/boards/telosb/driver_cc2420.c index 638c8f6c1..eb0f27555 100644 --- a/boards/telosb/driver_cc2420.c +++ b/boards/telosb/driver_cc2420.c @@ -14,7 +14,7 @@ #include "cpu.h" #include "irq.h" #include "hwtimer.h" -#include "crash.h" +#include "panic.h" #include "cc2420.h" #include "cc2420_arch.h" diff --git a/boards/wsn430-v1_4/driver_cc2420.c b/boards/wsn430-v1_4/driver_cc2420.c index fbe0da06e..15407f5ef 100644 --- a/boards/wsn430-v1_4/driver_cc2420.c +++ b/boards/wsn430-v1_4/driver_cc2420.c @@ -14,7 +14,7 @@ #include "cpu.h" #include "irq.h" #include "hwtimer.h" -#include "crash.h" +#include "panic.h" #include "cc2420.h" #include "cc2420_arch.h" diff --git a/boards/z1/driver_cc2420.c b/boards/z1/driver_cc2420.c index f8e0fe13b..d912da685 100644 --- a/boards/z1/driver_cc2420.c +++ b/boards/z1/driver_cc2420.c @@ -28,7 +28,7 @@ #include "cpu.h" #include "irq.h" #include "hwtimer.h" -#include "crash.h" +#include "panic.h" #include "cc2420.h" #include "cc2420_arch.h" diff --git a/core/include/crash.h b/core/include/panic.h similarity index 88% rename from core/include/crash.h rename to core/include/panic.h index bbb422109..60c8e0199 100644 --- a/core/include/crash.h +++ b/core/include/panic.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014 INRIA + * Copyright (C) 2014, 2015 INRIA * * 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 @@ -10,17 +10,17 @@ * @addtogroup core_util * @{ * - * @file crash.h + * @file * @brief Crash handling header * - * Define a core_panic() function that allows to stop/reboot the system + * Define a ::core_panic function that allows to stop/reboot the system * when an unrecoverable problem has occurred. * * @author Kévin Roussel */ -#ifndef CRASH_H -#define CRASH_H +#ifndef PANIC_H +#define PANIC_H #include "kernel.h" @@ -54,5 +54,5 @@ NORETURN void core_panic(int crash_code, const char *message); } #endif -#endif /* CRASH_H */ +#endif /* PANIC_H */ /** @} */ diff --git a/cpu/arm7_common/crash.c b/cpu/arm7_common/panic.c similarity index 97% rename from cpu/arm7_common/crash.c rename to cpu/arm7_common/panic.c index 1899c6310..e93ff05d7 100644 --- a/cpu/arm7_common/crash.c +++ b/cpu/arm7_common/panic.c @@ -10,7 +10,7 @@ * @ingroup core_util * @{ * - * @file crash.c + * @file panic.c * @brief Crash handling functions implementation for ARM-based MCUs * * @author Kévin Roussel @@ -18,7 +18,7 @@ #include "cpu.h" #include "lpm.h" -#include "crash.h" +#include "panic.h" #include #include diff --git a/cpu/cortex-m0_common/crash.c b/cpu/cortex-m0_common/panic.c similarity index 99% rename from cpu/cortex-m0_common/crash.c rename to cpu/cortex-m0_common/panic.c index 03d71cba8..e660de4e4 100644 --- a/cpu/cortex-m0_common/crash.c +++ b/cpu/cortex-m0_common/panic.c @@ -24,7 +24,7 @@ #include "cpu.h" #include "irq.h" #include "lpm.h" -#include "crash.h" +#include "panic.h" #define PANIC_STR_SIZE 80 diff --git a/cpu/cortex-m3_common/crash.c b/cpu/cortex-m3_common/panic.c similarity index 99% rename from cpu/cortex-m3_common/crash.c rename to cpu/cortex-m3_common/panic.c index 93e7ce471..76db9bdea 100644 --- a/cpu/cortex-m3_common/crash.c +++ b/cpu/cortex-m3_common/panic.c @@ -24,7 +24,7 @@ #include "cpu.h" #include "irq.h" #include "lpm.h" -#include "crash.h" +#include "panic.h" #define PANIC_STR_SIZE 80 diff --git a/cpu/cortex-m4_common/crash.c b/cpu/cortex-m4_common/panic.c similarity index 99% rename from cpu/cortex-m4_common/crash.c rename to cpu/cortex-m4_common/panic.c index f10541300..ec5dbe902 100644 --- a/cpu/cortex-m4_common/crash.c +++ b/cpu/cortex-m4_common/panic.c @@ -24,7 +24,7 @@ #include "cpu.h" #include "irq.h" #include "lpm.h" -#include "crash.h" +#include "panic.h" #define PANIC_STR_SIZE 80 diff --git a/cpu/kinetis_common/fault_handlers.c b/cpu/kinetis_common/fault_handlers.c index 9b98d54d9..10126c261 100644 --- a/cpu/kinetis_common/fault_handlers.c +++ b/cpu/kinetis_common/fault_handlers.c @@ -21,7 +21,7 @@ */ #include -#include "crash.h" +#include "panic.h" #include "fault_handlers.h" void isr_nmi(void) diff --git a/cpu/msp430-common/hwtimer_cpu.c b/cpu/msp430-common/hwtimer_cpu.c index 511d34181..f9875d940 100644 --- a/cpu/msp430-common/hwtimer_cpu.c +++ b/cpu/msp430-common/hwtimer_cpu.c @@ -24,7 +24,7 @@ #include #include "cpu.h" -#include "crash.h" +#include "panic.h" #include "hwtimer.h" #include "arch/hwtimer_arch.h" diff --git a/cpu/msp430-common/crash.c b/cpu/msp430-common/panic.c similarity index 97% rename from cpu/msp430-common/crash.c rename to cpu/msp430-common/panic.c index 4784f910b..5e3b71b4a 100644 --- a/cpu/msp430-common/crash.c +++ b/cpu/msp430-common/panic.c @@ -10,7 +10,7 @@ * @ingroup core_util * @{ * - * @file crash.c + * @file panic.c * @brief Crash handling functions implementation for MSP430 MCUs * * @author Kévin Roussel @@ -18,7 +18,7 @@ #include "cpu.h" #include "lpm.h" -#include "crash.h" +#include "panic.h" #include #include diff --git a/cpu/native/crash.c b/cpu/native/panic.c similarity index 97% rename from cpu/native/crash.c rename to cpu/native/panic.c index 40b9c6d1b..55fc2d918 100644 --- a/cpu/native/crash.c +++ b/cpu/native/panic.c @@ -10,7 +10,7 @@ * @ingroup core_util * @{ * - * @file crash.c + * @file panic.c * @brief Crash handling functions implementation for 'native' port * * @author Ludwig Ortmann @@ -22,7 +22,7 @@ #include #include -#include "crash.h" +#include "panic.h" #include "native_internal.h" /* "public" variables holding the crash data (look for them in your debugger) */ diff --git a/cpu/nrf51822/startup.c b/cpu/nrf51822/startup.c index 4c58873c2..87676eb4a 100644 --- a/cpu/nrf51822/startup.c +++ b/cpu/nrf51822/startup.c @@ -22,7 +22,7 @@ #include "board.h" #include "cpu.h" -#include "crash.h" +#include "panic.h" /** * memory markers as defined in the linker script diff --git a/cpu/sam3x8e/startup.c b/cpu/sam3x8e/startup.c index 0df580f59..52278ccde 100644 --- a/cpu/sam3x8e/startup.c +++ b/cpu/sam3x8e/startup.c @@ -20,7 +20,7 @@ #include -#include "crash.h" +#include "panic.h" /** * memory markers as defined in the linker script diff --git a/cpu/stm32f0/startup.c b/cpu/stm32f0/startup.c index f4b4004c2..9dbe6497c 100644 --- a/cpu/stm32f0/startup.c +++ b/cpu/stm32f0/startup.c @@ -20,7 +20,7 @@ #include -#include "crash.h" +#include "panic.h" /** * memory markers as defined in the linker script diff --git a/cpu/stm32f1/startup.c b/cpu/stm32f1/startup.c index 0e1358359..612ade611 100644 --- a/cpu/stm32f1/startup.c +++ b/cpu/stm32f1/startup.c @@ -20,7 +20,7 @@ */ #include -#include "crash.h" +#include "panic.h" /** diff --git a/cpu/stm32l1/startup.c b/cpu/stm32l1/startup.c index 83f453bad..9802555c6 100644 --- a/cpu/stm32l1/startup.c +++ b/cpu/stm32l1/startup.c @@ -20,7 +20,7 @@ */ #include -#include "crash.h" +#include "panic.h" /** diff --git a/drivers/cc2420/cc2420.c b/drivers/cc2420/cc2420.c index 9adf0b18a..3190f051e 100644 --- a/drivers/cc2420/cc2420.c +++ b/drivers/cc2420/cc2420.c @@ -8,7 +8,7 @@ * directory for more details. */ -#include "crash.h" +#include "panic.h" #include "cc2420.h" #include "cc2420_spi.h" #include "cc2420_settings.h" From cb1f047f59374f19668faed0f38d3ac587627307 Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Sat, 9 May 2015 18:12:18 +0200 Subject: [PATCH 2/2] core: unified core_panic implementation --- core/include/arch/panic_arch.h | 39 +++++++++++++++++++ core/panic.c | 71 ++++++++++++++++++++++++++++++++++ cpu/arm7_common/panic.c | 51 ++++-------------------- cpu/cortex-m0_common/panic.c | 43 +------------------- cpu/cortex-m3_common/panic.c | 43 +------------------- cpu/cortex-m4_common/panic.c | 43 +------------------- cpu/msp430-common/panic.c | 43 +++----------------- cpu/native/panic.c | 42 +++----------------- 8 files changed, 130 insertions(+), 245 deletions(-) create mode 100644 core/include/arch/panic_arch.h create mode 100644 core/panic.c diff --git a/core/include/arch/panic_arch.h b/core/include/arch/panic_arch.h new file mode 100644 index 000000000..715d3877a --- /dev/null +++ b/core/include/arch/panic_arch.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2015 INRIA + * + * 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 panic function + * + * @author Oliver Hahm + */ + +#ifndef PANIC_ARCH_H +#define PANIC_ARCH_H + +#ifdef __cplusplus + extern "C" { +#endif + + /** + * @brief architecture dependent handling of an panic case + * + * This function gives the CPU the possibility to execute architecture + * dependent code in case of an severe error. + */ +void panic_arch(void); + +#ifdef __cplusplus +} +#endif + +#endif /* REBOOT_ARCH_H */ +/** @} */ diff --git a/core/panic.c b/core/panic.c new file mode 100644 index 000000000..91afac6e4 --- /dev/null +++ b/core/panic.c @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2015 INRIA + * Copyright (C) 2015 Eistec AB + * + * 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 Crash handling functions + * + * @author Kévin Roussel + * @author Oliver Hahm + * @author Joakim Gebart + */ + +#include +#include + +#include "cpu.h" +#include "irq.h" +#include "lpm.h" +#include "panic.h" +#include "arch/panic_arch.h" + +#define PANIC_STR_SIZE 80 + +/* "public" variables holding the crash data */ +char panic_str[PANIC_STR_SIZE]; +int panic_code; + +/* flag preventing "recursive crash printing loop" */ +static int crashed = 0; + +/* WARNING: this function NEVER returns! */ +NORETURN void core_panic(int crash_code, const char *message) +{ + /* copy panic datas to "public" global variables */ + panic_code = crash_code; + strncpy(panic_str, message, sizeof(panic_str)); + /* strncpy does not add any null-termination. */ + panic_str[sizeof(panic_str)-1] = '\0'; + /* print panic message to console (if possible) */ + if (crashed == 0) { + crashed = 1; + puts("******** SYSTEM FAILURE ********\n"); + puts(message); +#if DEVELHELP + puts("******** RIOT HALTS HERE ********\n"); +#else + puts("******** RIOT WILL REBOOT ********\n"); +#endif + puts("\n\n"); + } + /* disable watchdog and all possible sources of interrupts */ + disableIRQ(); + panic_arch(); +#ifndef DEVELHELP + /* DEVELHELP not set => reboot system */ + (void) reboot(RB_AUTOBOOT); +#endif + + /* tell the compiler that we won't return from this function + (even if we actually won't even get here...) */ + UNREACHABLE(); +} diff --git a/cpu/arm7_common/panic.c b/cpu/arm7_common/panic.c index e93ff05d7..3f99c50f4 100644 --- a/cpu/arm7_common/panic.c +++ b/cpu/arm7_common/panic.c @@ -1,67 +1,30 @@ /* * Copyright (C) 2014 INRIA * - * 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 core_util + * @ingroup arm7_common * @{ * - * @file panic.c + * @file * @brief Crash handling functions implementation for ARM-based MCUs * * @author Kévin Roussel + * @author Oliver Hahm */ -#include "cpu.h" #include "lpm.h" -#include "panic.h" -#include -#include - -/* "public" variables holding the crash data */ -char panic_str[80]; -int panic_code; - -/* flag preventing "recursive crash printing loop" */ -static int crashed = 0; - -/* WARNING: this function NEVER returns! */ -NORETURN void core_panic(int crash_code, const char *message) +void panic_arch(void) { - /* copy panic datas to "public" global variables */ - panic_code = crash_code; - strncpy(panic_str, message, 80); - /* print panic message to console (if possible) */ - if (crashed == 0) { - crashed = 1; - puts("******** SYSTEM FAILURE ********\n"); - puts(message); -#if DEVELHELP - puts("******** RIOT HALTS HERE ********\n"); -#else - puts("******** RIOT WILL REBOOT ********\n"); -#endif - puts("\n\n"); - } - /* disable watchdog and all possible sources of interrupts */ - //TODO - dINT(); #if DEVELHELP /* enter infinite loop, into deepest possible sleep mode */ while (1) { lpm_set(LPM_OFF); } -#else - /* DEVELHELP not set => reboot system */ - (void) reboot(RB_AUTOBOOT); #endif - - /* tell the compiler that we won't return from this function - (even if we actually won't even get here...) */ - UNREACHABLE(); } diff --git a/cpu/cortex-m0_common/panic.c b/cpu/cortex-m0_common/panic.c index e660de4e4..ddcbdc635 100644 --- a/cpu/cortex-m0_common/panic.c +++ b/cpu/cortex-m0_common/panic.c @@ -18,45 +18,11 @@ * @author Joakim Gebart */ -#include -#include - #include "cpu.h" -#include "irq.h" #include "lpm.h" -#include "panic.h" - -#define PANIC_STR_SIZE 80 - -/* "public" variables holding the crash data */ -char panic_str[PANIC_STR_SIZE]; -int panic_code; - -/* flag preventing "recursive crash printing loop" */ -static int crashed = 0; -/* WARNING: this function NEVER returns! */ -NORETURN void core_panic(int crash_code, const char *message) +void panic_arch(void) { - /* copy panic datas to "public" global variables */ - panic_code = crash_code; - strncpy(panic_str, message, sizeof(panic_str)); - /* strncpy does not add any null-termination. */ - panic_str[sizeof(panic_str)-1] = '\0'; - /* print panic message to console (if possible) */ - if (crashed == 0) { - crashed = 1; - puts("******** SYSTEM FAILURE ********\n"); - puts(message); -#if DEVELHELP - puts("******** RIOT HALTS HERE ********\n"); -#else - puts("******** RIOT WILL REBOOT ********\n"); -#endif - puts("\n\n"); - } - /* disable watchdog and all possible sources of interrupts */ - disableIRQ(); #if DEVELHELP /* The bkpt instruction will signal to the debugger to break here. */ __ASM("bkpt #0"); @@ -64,12 +30,5 @@ NORETURN void core_panic(int crash_code, const char *message) while (1) { lpm_set(LPM_OFF); } -#else - /* DEVELHELP not set => reboot system */ - (void) reboot(RB_AUTOBOOT); #endif - - /* tell the compiler that we won't return from this function - (even if we actually won't even get here...) */ - UNREACHABLE(); } diff --git a/cpu/cortex-m3_common/panic.c b/cpu/cortex-m3_common/panic.c index 76db9bdea..4f9aef455 100644 --- a/cpu/cortex-m3_common/panic.c +++ b/cpu/cortex-m3_common/panic.c @@ -18,45 +18,11 @@ * @author Joakim Gebart */ -#include -#include - #include "cpu.h" -#include "irq.h" #include "lpm.h" -#include "panic.h" - -#define PANIC_STR_SIZE 80 - -/* "public" variables holding the crash data */ -char panic_str[PANIC_STR_SIZE]; -int panic_code; - -/* flag preventing "recursive crash printing loop" */ -static int crashed = 0; -/* WARNING: this function NEVER returns! */ -NORETURN void core_panic(int crash_code, const char *message) +void panic_arch(void) { - /* copy panic datas to "public" global variables */ - panic_code = crash_code; - strncpy(panic_str, message, sizeof(panic_str)); - /* strncpy does not add any null-termination. */ - panic_str[sizeof(panic_str)-1] = '\0'; - /* print panic message to console (if possible) */ - if (crashed == 0) { - crashed = 1; - puts("******** SYSTEM FAILURE ********\n"); - puts(message); -#if DEVELHELP - puts("******** RIOT HALTS HERE ********\n"); -#else - puts("******** RIOT WILL REBOOT ********\n"); -#endif - puts("\n\n"); - } - /* disable watchdog and all possible sources of interrupts */ - disableIRQ(); #if DEVELHELP /* The bkpt instruction will signal to the debugger to break here. */ __ASM("bkpt #0"); @@ -64,12 +30,5 @@ NORETURN void core_panic(int crash_code, const char *message) while (1) { lpm_set(LPM_OFF); } -#else - /* DEVELHELP not set => reboot system */ - (void) reboot(RB_AUTOBOOT); #endif - - /* tell the compiler that we won't return from this function - (even if we actually won't even get here...) */ - UNREACHABLE(); } diff --git a/cpu/cortex-m4_common/panic.c b/cpu/cortex-m4_common/panic.c index ec5dbe902..61a923eb5 100644 --- a/cpu/cortex-m4_common/panic.c +++ b/cpu/cortex-m4_common/panic.c @@ -18,45 +18,11 @@ * @author Joakim Gebart */ -#include -#include - #include "cpu.h" -#include "irq.h" #include "lpm.h" -#include "panic.h" - -#define PANIC_STR_SIZE 80 - -/* "public" variables holding the crash data */ -char panic_str[PANIC_STR_SIZE]; -int panic_code; - -/* flag preventing "recursive crash printing loop" */ -static int crashed = 0; -/* WARNING: this function NEVER returns! */ -NORETURN void core_panic(int crash_code, const char *message) +void panic_arch(void) { - /* copy panic datas to "public" global variables */ - panic_code = crash_code; - strncpy(panic_str, message, sizeof(panic_str)); - /* strncpy does not add any null-termination. */ - panic_str[sizeof(panic_str)-1] = '\0'; - /* print panic message to console (if possible) */ - if (crashed == 0) { - crashed = 1; - puts("******** SYSTEM FAILURE ********\n"); - puts(message); -#if DEVELHELP - puts("******** RIOT HALTS HERE ********\n"); -#else - puts("******** RIOT WILL REBOOT ********\n"); -#endif - puts("\n\n"); - } - /* disable watchdog and all possible sources of interrupts */ - disableIRQ(); #if DEVELHELP /* The bkpt instruction will signal to the debugger to break here. */ __ASM("bkpt #0"); @@ -64,12 +30,5 @@ NORETURN void core_panic(int crash_code, const char *message) while (1) { lpm_set(LPM_OFF); } -#else - /* DEVELHELP not set => reboot system */ - (void) reboot(RB_AUTOBOOT); #endif - - /* tell the compiler that we won't return from this function - (even if we actually won't even get here...) */ - UNREACHABLE(); } diff --git a/cpu/msp430-common/panic.c b/cpu/msp430-common/panic.c index 5e3b71b4a..9f461ab19 100644 --- a/cpu/msp430-common/panic.c +++ b/cpu/msp430-common/panic.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014 INRIA + * Copyright (C) 2014, 2015 INRIA * * 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 @@ -7,61 +7,28 @@ */ /** - * @ingroup core_util + * @ingroup msp430 * @{ * - * @file panic.c + * @file * @brief Crash handling functions implementation for MSP430 MCUs * * @author Kévin Roussel + * @author Oliver Hahm */ #include "cpu.h" #include "lpm.h" -#include "panic.h" -#include -#include - -/* "public" variables holding the crash data */ -char panic_str[80]; -int panic_code; - -/* flag preventing "recursive crash printing loop" */ -static int crashed = 0; - -/* WARNING: this function NEVER returns! */ -NORETURN void core_panic(int crash_code, const char *message) +void panic_arch(void) { - /* copy panic datas to "public" global variables */ - panic_code = crash_code; - strncpy(panic_str, message, 80); - /* (try to) print panic message to console */ - if (crashed == 0) { - crashed = 1; - puts("******** SYSTEM FAILURE ********\n"); - puts(message); -#if DEVELHELP - puts("******** RIOT HALTS HERE ********\n"); -#else - puts("******** RIOT WILL REBOOT ********\n"); -#endif - puts("\n\n"); - } /* disable watchdog and all possible sources of interrupts */ WDTCTL = WDTPW | WDTHOLD; - dINT(); #if DEVELHELP /* enter infinite loop, into deepest possible sleep mode */ while (1) { lpm_set(LPM_OFF); } -#else - /* DEVELHELP not set => reboot system */ - (void) reboot(RB_AUTOBOOT); #endif - /* tell the compiler that we won't return from this function - (even if we actually won't even get here...) */ - UNREACHABLE(); } diff --git a/cpu/native/panic.c b/cpu/native/panic.c index 55fc2d918..357106691 100644 --- a/cpu/native/panic.c +++ b/cpu/native/panic.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014 Freie Universitaet Berlin (FUB) and INRIA + * Copyright (C) 2014, 2015 Freie Universitaet Berlin (FUB) and INRIA * * 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 @@ -7,59 +7,27 @@ */ /** - * @ingroup core_util + * @ingroup native_cpu * @{ * - * @file panic.c + * @file * @brief Crash handling functions implementation for 'native' port * * @author Ludwig Ortmann * @author Kévin Roussel + * @author Oliver Hahm */ #include #include -#include -#include -#include "panic.h" #include "native_internal.h" -/* "public" variables holding the crash data (look for them in your debugger) */ -char panic_str[80]; -int panic_code; - -/* flag preventing "recursive crash printing loop" */ -static int crashed = 0; - -NORETURN void core_panic(int crash_code, const char *message) +void panic_arch(void) { - if (crashed == 0) { - crashed = 1; - /* copy the crash data to "long-lived" global variables */ - panic_code = crash_code; - strncpy(panic_str, message, 80); - /* try to print panic message to console (if possible) */ - puts("******** SYSTEM FAILURE ********\n"); - puts(message); -#if DEVELHELP - puts("******** RIOT HALTS HERE ********\n"); -#else - puts("******** RIOT WILL REBOOT ********\n"); -#endif - puts("\n\n"); - } - - dINT(); #if DEVELHELP /* since we're atop an Unix-like platform, just use the (developer-)friendly core-dump feature */ kill(_native_pid, SIGTRAP); -#else - (void) reboot(RB_AUTOBOOT); #endif - - /* tell the compiler that we won't return from this function - (even if we actually won't even get here...) */ - UNREACHABLE(); }