xref: /openbmc/u-boot/arch/arm/lib/interrupts_m.c (revision e8f80a5a)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2015
4  * Kamil Lulko, <kamil.lulko@gmail.com>
5  */
6 
7 #include <common.h>
8 
9 /*
10  * Upon exception entry ARMv7-M processors automatically save stack
11  * frames containing some registers. For simplicity initial
12  * implementation uses only this auto-saved stack frame.
13  * This does not contain complete register set dump,
14  * only R0-R3, R12, LR, PC and xPSR are saved.
15  */
16 
17 struct autosave_regs {
18 	long uregs[8];
19 };
20 
21 #define ARM_XPSR	uregs[7]
22 #define ARM_PC		uregs[6]
23 #define ARM_LR		uregs[5]
24 #define ARM_R12		uregs[4]
25 #define ARM_R3		uregs[3]
26 #define ARM_R2		uregs[2]
27 #define ARM_R1		uregs[1]
28 #define ARM_R0		uregs[0]
29 
interrupt_init(void)30 int interrupt_init(void)
31 {
32 	return 0;
33 }
34 
enable_interrupts(void)35 void enable_interrupts(void)
36 {
37 	return;
38 }
39 
disable_interrupts(void)40 int disable_interrupts(void)
41 {
42 	return 0;
43 }
44 
dump_regs(struct autosave_regs * regs)45 void dump_regs(struct autosave_regs *regs)
46 {
47 	printf("pc : %08lx    lr : %08lx    xPSR : %08lx\n",
48 	       regs->ARM_PC, regs->ARM_LR, regs->ARM_XPSR);
49 	printf("r12 : %08lx   r3 : %08lx    r2 : %08lx\n"
50 		"r1 : %08lx    r0 : %08lx\n",
51 		regs->ARM_R12, regs->ARM_R3, regs->ARM_R2,
52 		regs->ARM_R1, regs->ARM_R0);
53 }
54 
bad_mode(void)55 void bad_mode(void)
56 {
57 	panic("Resetting CPU ...\n");
58 	reset_cpu(0);
59 }
60 
do_hard_fault(struct autosave_regs * autosave_regs)61 void do_hard_fault(struct autosave_regs *autosave_regs)
62 {
63 	printf("Hard fault\n");
64 	dump_regs(autosave_regs);
65 	bad_mode();
66 }
67 
do_mm_fault(struct autosave_regs * autosave_regs)68 void do_mm_fault(struct autosave_regs *autosave_regs)
69 {
70 	printf("Memory management fault\n");
71 	dump_regs(autosave_regs);
72 	bad_mode();
73 }
74 
do_bus_fault(struct autosave_regs * autosave_regs)75 void do_bus_fault(struct autosave_regs *autosave_regs)
76 {
77 	printf("Bus fault\n");
78 	dump_regs(autosave_regs);
79 	bad_mode();
80 }
81 
do_usage_fault(struct autosave_regs * autosave_regs)82 void do_usage_fault(struct autosave_regs *autosave_regs)
83 {
84 	printf("Usage fault\n");
85 	dump_regs(autosave_regs);
86 	bad_mode();
87 }
88 
do_invalid_entry(struct autosave_regs * autosave_regs)89 void do_invalid_entry(struct autosave_regs *autosave_regs)
90 {
91 	printf("Exception\n");
92 	dump_regs(autosave_regs);
93 	bad_mode();
94 }
95