Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions arch/arc/core/fatal.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
#include <offsets_short.h>
#include <toolchain.h>
#include <arch/cpu.h>
#include <misc/printk.h>
#include <logging/log.h>
#include <logging/log_ctrl.h>

LOG_MODULE_REGISTER(fatal);

/**
*
Expand All @@ -35,38 +38,40 @@
*/
void _NanoFatalErrorHandler(unsigned int reason, const NANO_ESF *pEsf)
{
LOG_PANIC();

switch (reason) {
case _NANO_ERR_HW_EXCEPTION:
break;

#if defined(CONFIG_STACK_CANARIES) || defined(CONFIG_ARC_STACK_CHECKING) \
|| defined(CONFIG_STACK_SENTINEL)
case _NANO_ERR_STACK_CHK_FAIL:
printk("***** Stack Check Fail! *****\n");
LOG_ERR("***** Stack Check Fail! *****");
break;
#endif

case _NANO_ERR_ALLOCATION_FAIL:
printk("**** Kernel Allocation Failure! ****\n");
LOG_ERR("**** Kernel Allocation Failure! ****");
break;

case _NANO_ERR_KERNEL_OOPS:
printk("***** Kernel OOPS! *****\n");
LOG_ERR("***** Kernel OOPS! *****");
break;

case _NANO_ERR_KERNEL_PANIC:
printk("***** Kernel Panic! *****\n");
LOG_ERR("***** Kernel Panic! *****");
break;

default:
printk("**** Unknown Fatal Error %d! ****\n", reason);
LOG_ERR("**** Unknown Fatal Error %d! ****", reason);
break;
}

printk("Current thread ID = %p\n", k_current_get());
LOG_ERR("Current thread ID = %p", k_current_get());

if (reason == _NANO_ERR_HW_EXCEPTION) {
printk("Faulting instruction address = 0x%lx\n",
LOG_ERR("Faulting instruction address = 0x%lx",
_arc_v2_aux_reg_read(_ARC_V2_ERET));
}

Expand All @@ -83,6 +88,8 @@ void _NanoFatalErrorHandler(unsigned int reason, const NANO_ESF *pEsf)

FUNC_NORETURN void _arch_syscall_oops(void *ssf_ptr)
{
LOG_PANIC();

_SysFatalErrorHandler(_NANO_ERR_KERNEL_OOPS, ssf_ptr);
CODE_UNREACHABLE;
}
11 changes: 8 additions & 3 deletions arch/arc/core/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@

#include <kernel.h>
#include <kernel_structs.h>
#include <misc/printk.h>
#include <exc_handle.h>
#include <logging/log.h>
#include <logging/log_ctrl.h>

LOG_MODULE_DECLARE(fatal);

#ifdef CONFIG_USERSPACE
Z_EXC_DECLARE(z_arch_user_string_nlen);
Expand All @@ -42,6 +45,8 @@ void _Fault(NANO_ESF *esf)
u32_t exc_addr = _arc_v2_aux_reg_read(_ARC_V2_EFA);
u32_t ecr = _arc_v2_aux_reg_read(_ARC_V2_ECR);

LOG_PANIC();

#ifdef CONFIG_USERSPACE
for (int i = 0; i < ARRAY_SIZE(exceptions); i++) {
u32_t start = (u32_t)exceptions[i].start;
Expand All @@ -65,9 +70,9 @@ void _Fault(NANO_ESF *esf)
return;
}

printk("Exception vector: 0x%x, cause code: 0x%x, parameter 0x%x\n",
LOG_ERR("Exception vector: 0x%x, cause code: 0x%x, parameter 0x%x",
vector, code, parameter);
printk("Address 0x%x\n", exc_addr);
LOG_ERR("Address 0x%x", exc_addr);
#ifdef CONFIG_ARC_STACK_CHECKING
/* Vector 6 = EV_ProV. Regardless of code, parameter 2 means stack
* check violation
Expand Down
8 changes: 5 additions & 3 deletions arch/arc/core/sys_fatal_error_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
#include <toolchain.h>
#include <linker/sections.h>
#include <kernel_structs.h>
#include <misc/printk.h>
#include <logging/log.h>

LOG_MODULE_DECLARE(fatal);

/**
*
Expand Down Expand Up @@ -53,11 +55,11 @@ __weak void _SysFatalErrorHandler(unsigned int reason,
}

if (_is_thread_essential()) {
printk("Fatal fault in essential thread! Spinning...\n");
LOG_ERR("Fatal fault in essential thread! Spinning...");
goto hang_system;
}

printk("Fatal fault in thread %p! Aborting.\n", _current);
LOG_ERR("Fatal fault in thread %p! Aborting.", _current);

k_thread_abort(_current);

Expand Down
27 changes: 16 additions & 11 deletions arch/arm/core/fatal.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
#include <toolchain.h>
#include <linker/sections.h>
#include <inttypes.h>

#include <kernel.h>
#include <kernel_structs.h>
#include <misc/printk.h>
#include <logging/log.h>
#include <logging/log_ctrl.h>

LOG_MODULE_REGISTER(fatal);

/**
*
Expand Down Expand Up @@ -47,35 +48,37 @@
void _NanoFatalErrorHandler(unsigned int reason,
const NANO_ESF *pEsf)
{
LOG_PANIC();

switch (reason) {
case _NANO_ERR_HW_EXCEPTION:
printk("***** Hardware exception *****\n");
LOG_ERR("***** Hardware exception *****");
break;
#if defined(CONFIG_STACK_CANARIES) || defined(CONFIG_STACK_SENTINEL)
case _NANO_ERR_STACK_CHK_FAIL:
printk("***** Stack Check Fail! *****\n");
LOG_ERR("***** Stack Check Fail! *****");
break;
#endif /* CONFIG_STACK_CANARIES */

case _NANO_ERR_ALLOCATION_FAIL:
printk("**** Kernel Allocation Failure! ****\n");
LOG_ERR("**** Kernel Allocation Failure! ****");
break;

case _NANO_ERR_KERNEL_OOPS:
printk("***** Kernel OOPS! *****\n");
LOG_ERR("***** Kernel OOPS! *****");
break;

case _NANO_ERR_KERNEL_PANIC:
printk("***** Kernel Panic! *****\n");
LOG_ERR("***** Kernel Panic! *****");
break;

default:
printk("**** Unknown Fatal Error %d! ****\n", reason);
LOG_ERR("**** Unknown Fatal Error %d! ****", reason);
break;
}
printk("Current thread ID = %p\n"
"Faulting instruction address = 0x%x\n",
k_current_get(), pEsf->pc);

LOG_ERR("Current thread ID = %p", k_current_get());
LOG_ERR("Faulting instruction address = 0x%x", pEsf->pc);

/*
* Now that the error has been reported, call the user implemented
Expand All @@ -98,6 +101,8 @@ FUNC_NORETURN void _arch_syscall_oops(void *ssf_ptr)
u32_t *ssf_contents = ssf_ptr;
NANO_ESF oops_esf = { 0 };

LOG_PANIC();

oops_esf.pc = ssf_contents[3];

_do_kernel_oops(&oops_esf);
Expand Down
Loading