kernel: add k_panic() and k_oops() APIs
Unlike assertions, these APIs are active at all times. The kernel will treat these errors in the same way as fatal CPU exceptions. Ultimately, the policy of what to do with these errors is implemented in _SysFatalErrorHandler. If the archtecture supports it, a real CPU exception can be triggered which will provide a complete register dump and PC value when the problem occurs. This will provide more helpful information than a fake exception stack frame (_default_esf) passed to the arch-specific exception handling code. Issue: ZEP-843 Change-Id: I8f136905c05bb84772e1c5ed53b8e920d24eb6fd Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
dc91536855
commit
cdb94d6425
19 changed files with 192 additions and 81 deletions
|
@ -3554,6 +3554,51 @@ extern void _sys_power_save_idle_exit(s32_t ticks);
|
|||
|
||||
#include <arch/cpu.h>
|
||||
|
||||
#ifdef _ARCH_EXCEPT
|
||||
/* This archtecture has direct support for triggering a CPU exception */
|
||||
#define _k_except_reason(reason) _ARCH_EXCEPT(reason)
|
||||
#else
|
||||
|
||||
#include <misc/printk.h>
|
||||
|
||||
/* NOTE: This is the implementation for arches that do not implement
|
||||
* _ARCH_EXCEPT() to generate a real CPU exception.
|
||||
*
|
||||
* We won't have a real exception frame to determine the PC value when
|
||||
* the oops occurred, so print file and line number before we jump into
|
||||
* the fatal error handler.
|
||||
*/
|
||||
#define _k_except_reason(reason) do { \
|
||||
printk("@ %s:%d:\n", __FILE__, __LINE__); \
|
||||
_NanoFatalErrorHandler(reason, &_default_esf); \
|
||||
CODE_UNREACHABLE; \
|
||||
} while (0)
|
||||
|
||||
#endif /* _ARCH__EXCEPT */
|
||||
|
||||
/**
|
||||
* @brief Fatally terminate a thread
|
||||
*
|
||||
* This should be called when a thread has encountered an unrecoverable
|
||||
* runtime condition and needs to terminate. What this ultimately
|
||||
* means is determined by the _fatal_error_handler() implementation, which
|
||||
* will be called will reason code _NANO_ERR_KERNEL_OOPS.
|
||||
*
|
||||
* If this is called from ISR context, the default system fatal error handler
|
||||
* will treat it as an unrecoverable system error, just like k_panic().
|
||||
*/
|
||||
#define k_oops() _k_except_reason(_NANO_ERR_KERNEL_OOPS)
|
||||
|
||||
/**
|
||||
* @brief Fatally terminate the system
|
||||
*
|
||||
* This should be called when the Zephyr kernel has encountered an
|
||||
* unrecoverable runtime condition and needs to terminate. What this ultimately
|
||||
* means is determined by the _fatal_error_handler() implementation, which
|
||||
* will be called will reason code _NANO_ERR_KERNEL_PANIC.
|
||||
*/
|
||||
#define k_panic() _k_except_reason(_NANO_ERR_KERNEL_PANIC)
|
||||
|
||||
/*
|
||||
* private APIs that are utilized by one or more public APIs
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue