2015-04-10 16:44:37 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014 Wind River Systems, Inc.
|
|
|
|
*
|
2017-01-18 17:01:01 -08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-04-10 16:44:37 -07:00
|
|
|
*/
|
|
|
|
|
2015-12-04 10:09:39 -05:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief Common fault handler for ARCv2
|
|
|
|
*
|
2015-04-10 16:44:37 -07:00
|
|
|
* Common fault handler for ARCv2 processors.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <toolchain.h>
|
|
|
|
#include <sections.h>
|
2016-08-18 13:04:06 -07:00
|
|
|
#include <inttypes.h>
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2016-12-23 08:35:34 -05:00
|
|
|
#include <kernel.h>
|
2016-11-08 10:36:50 -05:00
|
|
|
#include <kernel_structs.h>
|
2015-04-10 16:44:37 -07:00
|
|
|
|
|
|
|
#ifdef CONFIG_PRINTK
|
|
|
|
#include <misc/printk.h>
|
|
|
|
#define PR_EXC(...) printk(__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define PR_EXC(...)
|
|
|
|
#endif /* CONFIG_PRINTK */
|
|
|
|
|
|
|
|
#if (CONFIG_FAULT_DUMP > 0)
|
|
|
|
#define FAULT_DUMP(esf, fault) _FaultDump(esf, fault)
|
|
|
|
#else
|
|
|
|
#define FAULT_DUMP(esf, fault) \
|
|
|
|
do { \
|
|
|
|
(void) esf; \
|
|
|
|
(void) fault; \
|
|
|
|
} while ((0))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (CONFIG_FAULT_DUMP > 0)
|
|
|
|
/*
|
2015-07-01 17:51:40 -04:00
|
|
|
* @brief Dump information regarding fault (FAULT_DUMP > 0)
|
2015-04-10 16:44:37 -07:00
|
|
|
*
|
|
|
|
* Dump information regarding the fault when CONFIG_FAULT_DUMP is set to 1
|
|
|
|
* (short form).
|
|
|
|
*
|
2015-07-01 17:29:04 -04:00
|
|
|
* @return N/A
|
2015-04-10 16:44:37 -07:00
|
|
|
*/
|
|
|
|
void _FaultDump(const NANO_ESF *esf, int fault)
|
|
|
|
{
|
|
|
|
ARG_UNUSED(esf);
|
2016-12-21 00:25:52 -06:00
|
|
|
ARG_UNUSED(fault);
|
|
|
|
|
2015-09-17 22:51:21 -04:00
|
|
|
#ifdef CONFIG_PRINTK
|
2017-04-20 13:30:33 -05:00
|
|
|
u32_t exc_addr = _arc_v2_aux_reg_read(_ARC_V2_EFA);
|
|
|
|
u32_t ecr = _arc_v2_aux_reg_read(_ARC_V2_ECR);
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2017-04-20 13:30:33 -05:00
|
|
|
PR_EXC("Exception vector: 0x%x, cause code: 0x%x, parameter 0x%xn",
|
2015-04-10 16:44:37 -07:00
|
|
|
_ARC_V2_ECR_VECTOR(ecr),
|
|
|
|
_ARC_V2_ECR_CODE(ecr),
|
|
|
|
_ARC_V2_ECR_PARAMETER(ecr));
|
2017-04-20 13:30:33 -05:00
|
|
|
PR_EXC("Address 0x%x\n", exc_addr);
|
2015-09-17 22:51:21 -04:00
|
|
|
#endif
|
2015-04-10 16:44:37 -07:00
|
|
|
}
|
|
|
|
#endif /* CONFIG_FAULT_DUMP */
|
|
|
|
|
|
|
|
/*
|
2015-07-01 17:51:40 -04:00
|
|
|
* @brief Fault handler
|
2015-04-10 16:44:37 -07:00
|
|
|
*
|
|
|
|
* This routine is called when fatal error conditions are detected by hardware
|
|
|
|
* and is responsible only for reporting the error. Once reported, it then
|
|
|
|
* invokes the user provided routine _SysFatalErrorHandler() which is
|
|
|
|
* responsible for implementing the error handling policy.
|
|
|
|
*
|
2015-07-01 17:29:04 -04:00
|
|
|
* @return This function does not return.
|
2015-04-10 16:44:37 -07:00
|
|
|
*/
|
|
|
|
void _Fault(void)
|
|
|
|
{
|
2017-04-20 13:30:33 -05:00
|
|
|
u32_t ecr = _arc_v2_aux_reg_read(_ARC_V2_ECR);
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2015-05-08 17:12:56 -05:00
|
|
|
FAULT_DUMP(&_default_esf, ecr);
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2015-05-08 17:12:56 -05:00
|
|
|
_SysFatalErrorHandler(_NANO_ERR_HW_EXCEPTION, &_default_esf);
|
2015-04-10 16:44:37 -07:00
|
|
|
}
|