From c89e3557f808c504d8feece4d28a96450089b05f Mon Sep 17 00:00:00 2001 From: Denis Brockus Date: Wed, 5 Jun 2019 10:21:01 -0600 Subject: minute-ia: ish software panic Adding functions for software panic to ISH. This includes panic_set_reason, panic_get_reason and software_panic. Added extra output when a software panic is detected. Had to touch nds32/panic.c in order to make panic_sw_reasons common. BUG=b:134502392 BRANCH=none TEST=Verified with crash assert, with CONFIG_DEBUG_ASSERT defined Change-Id: Iebfe62a7dcd59b4bbed82b450dfd44cc8eaed1da Signed-off-by: Denis Brockus Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1648958 Reviewed-by: Jack Rosenthal --- core/nds32/panic.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'core/nds32') diff --git a/core/nds32/panic.c b/core/nds32/panic.c index 3dabc1d2f0..9bc06fc409 100644 --- a/core/nds32/panic.c +++ b/core/nds32/panic.c @@ -8,6 +8,7 @@ #include "cpu.h" #include "panic.h" #include "printf.h" +#include "software_panic.h" #include "system.h" #include "task.h" #include "timer.h" @@ -78,18 +79,6 @@ static const char * const itype_exc_type[16] = { #endif /* CONFIG_DEBUG_EXCEPTIONS */ #ifdef CONFIG_SOFTWARE_PANIC -/* Software panic reasons */ -static const char * const panic_sw_reasons[8] = { - "PANIC_SW_DIV_ZERO", - "PANIC_SW_STACK_OVERFLOW", - "PANIC_SW_PD_CRASH", - "PANIC_SW_ASSERT", - "PANIC_SW_WATCHDOG", - NULL, - NULL, - NULL, -}; - void software_panic(uint32_t reason, uint32_t info) { asm volatile ("mov55 $r6, %0" : : "r"(reason)); @@ -163,10 +152,11 @@ static void print_panic_information(uint32_t *regs, uint32_t itype, #ifdef CONFIG_DEBUG_EXCEPTIONS panic_printf("SWID of ITYPE: %x\n", ((itype >> 16) & 0x7fff)); - if ((regs[SOFT_PANIC_GPR_REASON] & 0xfffffff0) == PANIC_SW_BASE) { + if (panic_sw_reason_is_valid(regs[SOFT_PANIC_GPR_REASON])) { #ifdef CONFIG_SOFTWARE_PANIC panic_printf("Software panic reason %s\n", - panic_sw_reasons[(regs[SOFT_PANIC_GPR_REASON] & 0x7)]); + panic_sw_reasons[(regs[SOFT_PANIC_GPR_REASON] - + PANIC_SW_BASE)]); panic_printf("Software panic info 0x%x\n", regs[SOFT_PANIC_GPR_INFO]); #endif -- cgit v1.2.1