From d007207f3e5c11744d612786df9e7c35887de2b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Roussel?= Date: Wed, 12 Feb 2014 11:10:38 +0100 Subject: [PATCH] Add a mechanism for handling fatal errors (and reboots) --- core/include/crash.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 core/include/crash.h diff --git a/core/include/crash.h b/core/include/crash.h new file mode 100644 index 0000000000..1265232e15 --- /dev/null +++ b/core/include/crash.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2014 INRIA + * + * This file is subject to the terms and conditions of the GNU Lesser General + * Public License. See the file LICENSE in the top level directory for more + * details. + */ + +/** + * @addtogroup core_util + * @{ + * + * @file crash.h + * @brief Crash handling header + * + * Define a panic() function that allows to stop/reboot the system + * when an unrecoverable problem has occured. + * + * @author Kévin Roussel + */ + +#ifndef __CRASH_H +#define __CRASH_H + +#include "kernel.h" + +/** Handle an unrecoverable error by halting or rebooting the system. + A numeric code indicating the failure reason can be given + as the ::crash_code parameter. + Detailing the failure is possible using the ::message parameter. + This function should serve a similar purpose than the panic() + function of Unix/Linux kernels. + + if DEVELHELP macro is defined, system will be halted; + system will be rebooted otherwise. + + WARNING: this function NEVER returns! */ +NORETURN void core_panic(int crash_code, const char *message); + +/** @} */ +#endif /* __CRASH_H */