nios2: fatal: add _SysFatalErrorHandler and _Fault stub

ZEP-252 will handle implementation of the code here.

Change-Id: I3e9a6c7cdf2d5a3b0240317b772628fead528095
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2016-05-03 11:49:50 -07:00 committed by Benjamin Walsh
parent 2d5645e57a
commit 7f7337a0fe
2 changed files with 65 additions and 3 deletions

View file

@ -17,18 +17,77 @@
#include <nanokernel.h>
#include <arch/cpu.h>
#include <nano_private.h>
#include <misc/printk.h>
/* TODO initialize with sentinel values */
const NANO_ESF _default_esf;
/**
*
* @brief Nanokernel fatal error handler
*
* This routine is called when a fatal error condition is detected by either
* hardware or software.
*
* The caller is expected to always provide a usable ESF. In the event that the
* fatal error does not have a hardware generated ESF, the caller should either
* create its own or call _Fault instead.
*
* @param reason the reason that the handler was called
* @param pEsf pointer to the exception stack frame
*
* @return This function does not return.
*/
FUNC_NORETURN void _NanoFatalErrorHandler(unsigned int reason,
const NANO_ESF *esf)
{
ARG_UNUSED(reason);
ARG_UNUSED(esf);
/* STUB TODO: dump out reason for the error and any interesting
* info in esf
*/
_SysFatalErrorHandler(reason, esf);
}
FUNC_NORETURN void _Fault(void)
{
/* STUB TODO dump out reason for this exception */
_NanoFatalErrorHandler(_NANO_ERR_HW_EXCEPTION, &_default_esf);
}
/**
*
* @brief Fatal error handler
*
* This routine implements the corrective action to be taken when the system
* detects a fatal error.
*
* This sample implementation attempts to abort the current thread and allow
* the system to continue executing, which may permit the system to continue
* functioning with degraded capabilities.
*
* System designers may wish to enhance or substitute this sample
* implementation to take other actions, such as logging error (or debug)
* information to a persistent repository and/or rebooting the system.
*
* @param reason the fatal error reason
* @param pEsf the pointer to the exception stack frame
*
* @return This function does not return.
*/
FUNC_NORETURN void _SysFatalErrorHandler(unsigned int reason,
const NANO_ESF *esf)
{
/* STUB TODO try to abort task/fibers like in the x86 implementation */
printk("Fatal error!\n");
/* STUB */
while (1) {
/* whee! */
}
}

View file

@ -70,6 +70,9 @@ struct __esf {
typedef struct __esf NANO_ESF;
extern const NANO_ESF _default_esf;
FUNC_NORETURN void _SysFatalErrorHandler(unsigned int reason,
const NANO_ESF *esf);
#endif /* _ASMLANGUAGE */
#ifdef __cplusplus