diff options
author | Antony Pavlov <antonynpavlov@gmail.com> | 2013-12-04 00:48:55 +0400 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-12-04 17:01:11 +0100 |
commit | 28c14216707ba546bd42d5e56a329c2eaf221b55 (patch) | |
tree | 203527df2822f5b6cf3441ecf8d0e4eacd990461 /arch/mips/lib/traps.c | |
parent | ddac4f3ea2b76bba4e675fbcb712daf403b60de1 (diff) | |
download | barebox-28c14216707ba546bd42d5e56a329c2eaf221b55.tar.gz barebox-28c14216707ba546bd42d5e56a329c2eaf221b55.tar.xz |
MIPS: import exception registers saving from linux kernel
Checking registers saving:
$ make qemu-malta_defconfig
$ make
...
$ qemu-system-mips -nodefaults -M malta -m 256 \
-nographic -serial stdio -bios ./barebox-flash-image
...
barebox:/ md -l 0x03
Ooops, address error on load or ifetch!
$ 0 : 00000000 00000000 ffffffff 0000003f
$ 4 : 00000000 ffffffff 00000004 00000004
$ 8 : 00000003 a0404d50 00000001 00000002
$12 : a0404d50 0000000a a0840000 00000003
$16 : 00000100 a0404d50 00000100 00000003
$20 : 00000000 a0406cd8 00000000 00000000
$24 : a083b4d8 a083058c
$28 : 00000000 a03ffca8 a0406ab0 a0830604
Hi : 00000000
Lo : 00000040
epc : a083056c
ra : a0830604
Status: 00000006
Cause : 00000410
Config: 80008482
### ERROR ### Please RESET the board ###
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/mips/lib/traps.c')
-rw-r--r-- | arch/mips/lib/traps.c | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/arch/mips/lib/traps.c b/arch/mips/lib/traps.c index 4e167cc9f4..0a5914ea81 100644 --- a/arch/mips/lib/traps.c +++ b/arch/mips/lib/traps.c @@ -1,8 +1,9 @@ #include <common.h> #include <asm/mipsregs.h> +#include <asm/ptrace.h> -void barebox_exc_handler(void *regs); +void barebox_exc_handler(const struct pt_regs *regs); /* * Trap codes from OpenBSD trap.h @@ -95,13 +96,44 @@ static char *get_exc_name(u32 cause) return "unknown exception"; } -void barebox_exc_handler(void *regs) +void barebox_exc_handler(const struct pt_regs *regs) { - printf("\nOoops, %s!\n", get_exc_name(read_c0_cause())); - printf("EPC = 0x%08x\n", read_c0_epc()); - printf("CP0_STATUS = 0x%08x\n", read_c0_status()); - printf("CP0_CAUSE = 0x%08x\n", read_c0_cause()); - printf("CP0_CONFIG = 0x%08x\n\n", read_c0_config()); + const int field = 2 * sizeof(unsigned long); + unsigned int cause = regs->cp0_cause; + int i; + + printf("\nOoops, %s!\n\n", get_exc_name(cause)); + + /* + * Saved main processor registers + */ + for (i = 0; i < 32; ) { + if ((i % 4) == 0) + printf("$%2d :", i); + if (i == 0) + printf(" %0*lx", field, 0UL); + else if (i == 26 || i == 27) + printf(" %*s", field, ""); + else + printf(" %0*lx", field, regs->regs[i]); + + i++; + if ((i % 4) == 0) + printf("\n"); + } + + printf("Hi : %0*lx\n", field, regs->hi); + printf("Lo : %0*lx\n", field, regs->lo); + + /* + * Saved cp0 registers + */ + printf("epc : %0*lx\n", field, regs->cp0_epc); + printf("ra : %0*lx\n", field, regs->regs[31]); + + printf("Status: %08x\n", (uint32_t) regs->cp0_status); + printf("Cause : %08x\n", cause); + printf("Config: %08x\n\n", read_c0_config()); hang(); } |