diff --git a/arch/arm/core/aarch64/fatal.c b/arch/arm/core/aarch64/fatal.c index 9ae566ef75a..b06100e12b0 100644 --- a/arch/arm/core/aarch64/fatal.c +++ b/arch/arm/core/aarch64/fatal.c @@ -131,7 +131,31 @@ static void print_EC_cause(u64_t esr) } } -void z_arm64_fatal_error(unsigned int reason) +static void esf_dump(const z_arch_esf_t *esf) +{ + LOG_ERR("x1: %-8llx x0: %llx", + esf->basic.regs[18], esf->basic.regs[19]); + LOG_ERR("x2: %-8llx x3: %llx", + esf->basic.regs[16], esf->basic.regs[17]); + LOG_ERR("x4: %-8llx x5: %llx", + esf->basic.regs[14], esf->basic.regs[15]); + LOG_ERR("x6: %-8llx x7: %llx", + esf->basic.regs[12], esf->basic.regs[13]); + LOG_ERR("x8: %-8llx x9: %llx", + esf->basic.regs[10], esf->basic.regs[11]); + LOG_ERR("x10: %-8llx x11: %llx", + esf->basic.regs[8], esf->basic.regs[9]); + LOG_ERR("x12: %-8llx x13: %llx", + esf->basic.regs[6], esf->basic.regs[7]); + LOG_ERR("x14: %-8llx x15: %llx", + esf->basic.regs[4], esf->basic.regs[5]); + LOG_ERR("x16: %-8llx x17: %llx", + esf->basic.regs[2], esf->basic.regs[3]); + LOG_ERR("x18: %-8llx x30: %llx", + esf->basic.regs[0], esf->basic.regs[1]); +} + +void z_arm64_fatal_error(unsigned int reason, const z_arch_esf_t *esf) { u64_t el, esr, elr, far; @@ -170,7 +194,10 @@ void z_arm64_fatal_error(unsigned int reason) } - z_fatal_error(reason, NULL); + if (esf != NULL) { + esf_dump(esf); + } + z_fatal_error(reason, esf); CODE_UNREACHABLE; } diff --git a/arch/arm/core/aarch64/irq_manage.c b/arch/arm/core/aarch64/irq_manage.c index 86ae753925c..e5717550bd9 100644 --- a/arch/arm/core/aarch64/irq_manage.c +++ b/arch/arm/core/aarch64/irq_manage.c @@ -19,7 +19,7 @@ #include #include -extern void z_arm64_fatal_error(unsigned int reason); +void z_arm64_fatal_error(unsigned int reason, const z_arch_esf_t *esf); void arch_irq_enable(unsigned int irq) { @@ -56,5 +56,5 @@ void z_irq_spurious(void *unused) { ARG_UNUSED(unused); - z_arm64_fatal_error(K_ERR_SPURIOUS_IRQ); + z_arm64_fatal_error(K_ERR_SPURIOUS_IRQ, NULL); } diff --git a/arch/arm/core/aarch64/swap_helper.S b/arch/arm/core/aarch64/swap_helper.S index 6c5987544eb..564f6297595 100644 --- a/arch/arm/core/aarch64/swap_helper.S +++ b/arch/arm/core/aarch64/swap_helper.S @@ -237,8 +237,8 @@ exit: b z_arm64_exit_exc inv: - /* K_ERR_CPU_EXCEPTION */ - mov x0, #0 + mov x1, sp + mov x0, #0 /* K_ERR_CPU_EXCEPTION */ b z_arm64_fatal_error diff --git a/arch/arm/core/aarch64/thread.c b/arch/arm/core/aarch64/thread.c index e78c796e93f..137deee64cb 100644 --- a/arch/arm/core/aarch64/thread.c +++ b/arch/arm/core/aarch64/thread.c @@ -56,10 +56,10 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack, pInitCtx = (struct __esf *)(STACK_ROUND_DOWN(stackEnd - sizeof(struct __basic_sf))); - pInitCtx->basic.x0 = (u64_t)pEntry; - pInitCtx->basic.x1 = (u64_t)parameter1; - pInitCtx->basic.x2 = (u64_t)parameter2; - pInitCtx->basic.x3 = (u64_t)parameter3; + pInitCtx->basic.regs[0] = (u64_t)pEntry; + pInitCtx->basic.regs[1] = (u64_t)parameter1; + pInitCtx->basic.regs[2] = (u64_t)parameter2; + pInitCtx->basic.regs[3] = (u64_t)parameter3; /* * We are saving: diff --git a/arch/arm/core/aarch64/vector_table.S b/arch/arm/core/aarch64/vector_table.S index 890a5ab9648..089a06fcdb6 100644 --- a/arch/arm/core/aarch64/vector_table.S +++ b/arch/arm/core/aarch64/vector_table.S @@ -86,6 +86,19 @@ SECTION_SUBSEC_FUNC(exc_vector_table,_vector_table_section,_vector_table) /* Current EL with SPx / SError */ .align 7 + stp x0, x1, [sp, #-16]! + stp x2, x3, [sp, #-16]! + stp x4, x5, [sp, #-16]! + stp x6, x7, [sp, #-16]! + stp x8, x9, [sp, #-16]! + stp x10, x11, [sp, #-16]! + stp x12, x13, [sp, #-16]! + stp x14, x15, [sp, #-16]! + stp x16, x17, [sp, #-16]! + stp x18, x30, [sp, #-16]! + + mov x1, sp mov x0, #0 /* K_ERR_CPU_EXCEPTION */ + b z_arm64_fatal_error diff --git a/arch/arm/include/aarch64/kernel_arch_func.h b/arch/arm/include/aarch64/kernel_arch_func.h index 8e28a6b6e01..762e48377ba 100644 --- a/arch/arm/include/aarch64/kernel_arch_func.h +++ b/arch/arm/include/aarch64/kernel_arch_func.h @@ -38,7 +38,7 @@ arch_thread_return_value_set(struct k_thread *thread, unsigned int value) thread->arch.swap_return_value = value; } -extern void z_arm64_fatal_error(unsigned int reason); +extern void z_arm64_fatal_error(const z_arch_esf_t *esf, unsigned int reason); #endif /* _ASMLANGUAGE */ diff --git a/include/arch/arm/aarch64/exc.h b/include/arch/arm/aarch64/exc.h index 78cd5996d2d..3d1f2d0ff27 100644 --- a/include/arch/arm/aarch64/exc.h +++ b/include/arch/arm/aarch64/exc.h @@ -26,10 +26,7 @@ extern "C" { struct __esf { struct __basic_sf { - u64_t x0; - u64_t x1; - u64_t x2; - u64_t x3; + u64_t regs[20]; } basic; };