blob: 99a21caf00da08de5be92702e77e0caa73599f5e [file] [log] [blame]
/*
* Copyright (c) 2016 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#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)
{
/* 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");
while (1) {
/* whee! */
}
}