3 * Kamil Lulko, <kamil.lulko@gmail.com>
5 * SPDX-License-Identifier: GPL-2.0+
11 * Upon exception entry ARMv7-M processors automatically save stack
12 * frames containing some registers. For simplicity initial
13 * implementation uses only this auto-saved stack frame.
14 * This does not contain complete register set dump,
15 * only R0-R3, R12, LR, PC and xPSR are saved.
18 struct autosave_regs {
22 #define ARM_XPSR uregs[7]
23 #define ARM_PC uregs[6]
24 #define ARM_LR uregs[5]
25 #define ARM_R12 uregs[4]
26 #define ARM_R3 uregs[3]
27 #define ARM_R2 uregs[2]
28 #define ARM_R1 uregs[1]
29 #define ARM_R0 uregs[0]
31 int interrupt_init(void)
36 void enable_interrupts(void)
41 int disable_interrupts(void)
46 void dump_regs(struct autosave_regs *regs)
48 printf("pc : %08lx lr : %08lx xPSR : %08lx\n",
49 regs->ARM_PC, regs->ARM_LR, regs->ARM_XPSR);
50 printf("r12 : %08lx r3 : %08lx r2 : %08lx\n"
51 "r1 : %08lx r0 : %08lx\n",
52 regs->ARM_R12, regs->ARM_R3, regs->ARM_R2,
53 regs->ARM_R1, regs->ARM_R0);
58 panic("Resetting CPU ...\n");
62 void do_hard_fault(struct autosave_regs *autosave_regs)
64 printf("Hard fault\n");
65 dump_regs(autosave_regs);
69 void do_mm_fault(struct autosave_regs *autosave_regs)
71 printf("Memory management fault\n");
72 dump_regs(autosave_regs);
76 void do_bus_fault(struct autosave_regs *autosave_regs)
78 printf("Bus fault\n");
79 dump_regs(autosave_regs);
83 void do_usage_fault(struct autosave_regs *autosave_regs)
85 printf("Usage fault\n");
86 dump_regs(autosave_regs);
90 void do_invalid_entry(struct autosave_regs *autosave_regs)
92 printf("Exception\n");
93 dump_regs(autosave_regs);