2015-04-11 01:44:37 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014 Wind River Systems, Inc.
|
|
|
|
*
|
2017-01-19 02:01:01 +01:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-04-11 01:44:37 +02:00
|
|
|
*/
|
|
|
|
|
2015-12-04 16:09:39 +01:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief Common fault handler for ARCv2
|
|
|
|
*
|
2015-04-11 01:44:37 +02:00
|
|
|
* Common fault handler for ARCv2 processors.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <toolchain.h>
|
|
|
|
#include <sections.h>
|
2016-08-18 22:04:06 +02:00
|
|
|
#include <inttypes.h>
|
2015-04-11 01:44:37 +02:00
|
|
|
|
2016-12-23 14:35:34 +01:00
|
|
|
#include <kernel.h>
|
2016-11-08 16:36:50 +01:00
|
|
|
#include <kernel_structs.h>
|
2015-04-11 01:44:37 +02: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 23:51:40 +02:00
|
|
|
* @brief Dump information regarding fault (FAULT_DUMP > 0)
|
2015-04-11 01:44:37 +02:00
|
|
|
*
|
|
|
|
* Dump information regarding the fault when CONFIG_FAULT_DUMP is set to 1
|
|
|
|
* (short form).
|
|
|
|
*
|
2015-07-01 23:29:04 +02:00
|
|
|
* @return N/A
|
2015-04-11 01:44:37 +02:00
|
|
|
*/
|
|
|
|
void _FaultDump(const NANO_ESF *esf, int fault)
|
|
|
|
{
|
|
|
|
ARG_UNUSED(esf);
|
2016-12-21 07:25:52 +01:00
|
|
|
ARG_UNUSED(fault);
|
|
|
|
|
2015-09-18 04:51:21 +02:00
|
|
|
#ifdef CONFIG_PRINTK
|
2017-04-20 20:30:33 +02: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-11 01:44:37 +02:00
|
|
|
|
2017-04-21 17:55:34 +02:00
|
|
|
PR_EXC("Exception vector: 0x%x, cause code: 0x%x, parameter 0x%x\n",
|
2015-04-11 01:44:37 +02:00
|
|
|
_ARC_V2_ECR_VECTOR(ecr),
|
|
|
|
_ARC_V2_ECR_CODE(ecr),
|
|
|
|
_ARC_V2_ECR_PARAMETER(ecr));
|
2017-04-20 20:30:33 +02:00
|
|
|
PR_EXC("Address 0x%x\n", exc_addr);
|
2015-09-18 04:51:21 +02:00
|
|
|
#endif
|
2015-04-11 01:44:37 +02:00
|
|
|
}
|
|
|
|
#endif /* CONFIG_FAULT_DUMP */
|
|
|
|
|
|
|
|
/*
|
2015-07-01 23:51:40 +02:00
|
|
|
* @brief Fault handler
|
2015-04-11 01:44:37 +02: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 23:29:04 +02:00
|
|
|
* @return This function does not return.
|
2015-04-11 01:44:37 +02:00
|
|
|
*/
|
|
|
|
void _Fault(void)
|
|
|
|
{
|
2017-04-20 20:30:33 +02:00
|
|
|
u32_t ecr = _arc_v2_aux_reg_read(_ARC_V2_ECR);
|
2015-04-11 01:44:37 +02:00
|
|
|
|
2015-05-09 00:12:56 +02:00
|
|
|
FAULT_DUMP(&_default_esf, ecr);
|
2015-04-11 01:44:37 +02:00
|
|
|
|
2015-05-09 00:12:56 +02:00
|
|
|
_SysFatalErrorHandler(_NANO_ERR_HW_EXCEPTION, &_default_esf);
|
2015-04-11 01:44:37 +02:00
|
|
|
}
|