xref: /openbmc/u-boot/arch/arm/lib/interrupts_m.c (revision f91281b1)
1 /*
2  * (C) Copyright 2015
3  * Kamil Lulko, <kamil.lulko@gmail.com>
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 
8 #include <common.h>
9 
10 /*
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.
16  */
17 
18 struct autosave_regs {
19 	long uregs[8];
20 };
21 
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]
30 
31 int interrupt_init(void)
32 {
33 	return 0;
34 }
35 
36 void enable_interrupts(void)
37 {
38 	return;
39 }
40 
41 int disable_interrupts(void)
42 {
43 	return 0;
44 }
45 
46 void dump_regs(struct autosave_regs *regs)
47 {
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);
54 }
55 
56 void bad_mode(void)
57 {
58 	panic("Resetting CPU ...\n");
59 	reset_cpu(0);
60 }
61 
62 void do_hard_fault(struct autosave_regs *autosave_regs)
63 {
64 	printf("Hard fault\n");
65 	dump_regs(autosave_regs);
66 	bad_mode();
67 }
68 
69 void do_mm_fault(struct autosave_regs *autosave_regs)
70 {
71 	printf("Memory management fault\n");
72 	dump_regs(autosave_regs);
73 	bad_mode();
74 }
75 
76 void do_bus_fault(struct autosave_regs *autosave_regs)
77 {
78 	printf("Bus fault\n");
79 	dump_regs(autosave_regs);
80 	bad_mode();
81 }
82 
83 void do_usage_fault(struct autosave_regs *autosave_regs)
84 {
85 	printf("Usage fault\n");
86 	dump_regs(autosave_regs);
87 	bad_mode();
88 }
89 
90 void do_invalid_entry(struct autosave_regs *autosave_regs)
91 {
92 	printf("Exception\n");
93 	dump_regs(autosave_regs);
94 	bad_mode();
95 }
96