core: optimize panic.c
This commit is contained in:
parent
9ecaea4038
commit
f953ae8187
22
core/panic.c
22
core/panic.c
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015 INRIA
|
* Copyright (C) 2015 INRIA
|
||||||
* Copyright (C) 2015 Eistec AB
|
* Copyright (C) 2015 Eistec AB
|
||||||
|
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
|
||||||
*
|
*
|
||||||
* This file is subject to the terms and conditions of the GNU Lesser General
|
* 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
|
* Public License v2.1. See the file LICENSE in the top level directory for more
|
||||||
@ -17,6 +18,7 @@
|
|||||||
* @author Kévin Roussel <Kevin.Roussel@inria.fr>
|
* @author Kévin Roussel <Kevin.Roussel@inria.fr>
|
||||||
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
||||||
* @author Joakim Gebart <joakim.gebart@eistec.se>
|
* @author Joakim Gebart <joakim.gebart@eistec.se>
|
||||||
|
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -32,27 +34,16 @@
|
|||||||
#include "ps.h"
|
#include "ps.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#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" */
|
/* flag preventing "recursive crash printing loop" */
|
||||||
static int crashed = 0;
|
static int crashed = 0;
|
||||||
|
|
||||||
/* WARNING: this function NEVER returns! */
|
/* WARNING: this function NEVER returns! */
|
||||||
NORETURN void core_panic(int crash_code, const char *message)
|
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) {
|
if (crashed == 0) {
|
||||||
|
/* print panic message to console (if possible) */
|
||||||
crashed = 1;
|
crashed = 1;
|
||||||
puts("******** SYSTEM FAILURE ********\n");
|
puts("*** RIOT kernel panic");
|
||||||
puts(message);
|
puts(message);
|
||||||
#if DEVELHELP
|
#if DEVELHELP
|
||||||
#ifdef MODULE_PS
|
#ifdef MODULE_PS
|
||||||
@ -60,11 +51,10 @@ NORETURN void core_panic(int crash_code, const char *message)
|
|||||||
puts("");
|
puts("");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
puts("******** RIOT HALTS HERE ********\n");
|
puts("*** halted.\n");
|
||||||
#else
|
#else
|
||||||
puts("******** RIOT WILL REBOOT ********\n");
|
puts("*** rebooting...\n\n");
|
||||||
#endif
|
#endif
|
||||||
puts("\n\n");
|
|
||||||
}
|
}
|
||||||
/* disable watchdog and all possible sources of interrupts */
|
/* disable watchdog and all possible sources of interrupts */
|
||||||
disableIRQ();
|
disableIRQ();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user