1 /* Author: Domen Puncer <domen@cba.si>. License: WTFPL, see file LICENSE */
5 #include <arch/cm3_regs.h>
8 extern void _ram_start
;
11 static const char * const exceptions
[] = {
21 static const char * const regnames
[16] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
22 "r8", "r9", "r10/sl", "r11/fp", "r12/ip", "sp", "lr", "pc" };
24 /* my precious debugging function
25 * HardFault is triggered on ie. invalid memory access.
26 * note: on IMPRECISERR, this doesn't help much. it just means that some
27 * invalid access occured but possibly before (after/prediction?) PC
29 void generic_exception_handler_c(u32
*oldstack
, u32
*newstack
, unsigned exception
)
31 int oldstack_valid
= (oldstack
>= (u32
*)&_ram_start
&& oldstack
< (u32
*)&_ram_end
);
34 if (exception
< ALEN(exceptions
))
35 printf("%s was called, dumping regs:\n", exceptions
[exception
]);
37 printf("Exception #%i was caled, dumping regs:\n", exception
);
39 printf("new_lr\t0x%08x\n", newstack
[8]);
42 printf("%s\t0x%08x\t%i\n", regnames
[i
], oldstack
[i
], oldstack
[i
]);
44 printf("sp\t%p (newstack:%p)\n", oldstack
, newstack
);
45 printf("sp is invalid, so some registers are missing\n");
48 printf("%s\t0x%08x\t%i\n", regnames
[i
+4], newstack
[i
], newstack
[i
]);
51 printf("r12/ip\t0x%08x\t%i\n", oldstack
[4], oldstack
[4]);
52 printf("sp\t%p\n", oldstack
);
53 printf("lr\t0x%08x\n", oldstack
[5]);
54 printf("pc\t0x%08x\n", oldstack
[6]);
55 printf("xPSR\t0x%08x\n", oldstack
[7]);
58 printf("HFSR\t0x%08x\n", HFSR
);
59 if (MMAR
!= 0xe000ed34)
60 printf("MMAR\t0x%08x\n", MMAR
);
61 if (BFAR
!= 0xe000ed38)
62 printf("BFAR\t0x%08x\n", BFAR
);
64 printf("\nentering cbashell\n");