blob: e4373f3781058649eed0934fbd462029824eba19 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
rev13@wp.plb3b57e82015-03-01 12:44:39 +01002/*
3 * (C) Copyright 2015
Kamil Lulkodecd33b2015-11-29 11:50:53 +01004 * Kamil Lulko, <kamil.lulko@gmail.com>
rev13@wp.plb3b57e82015-03-01 12:44:39 +01005 */
6
7#include <common.h>
Simon Glass9b61c7c2019-11-14 12:57:41 -07008#include <irq_func.h>
rev13@wp.plb3b57e82015-03-01 12:44:39 +01009
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
18struct 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
31int interrupt_init(void)
32{
33 return 0;
34}
35
36void enable_interrupts(void)
37{
38 return;
39}
40
41int disable_interrupts(void)
42{
43 return 0;
44}
45
46void 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
56void bad_mode(void)
57{
58 panic("Resetting CPU ...\n");
59 reset_cpu(0);
60}
61
62void do_hard_fault(struct autosave_regs *autosave_regs)
63{
64 printf("Hard fault\n");
65 dump_regs(autosave_regs);
66 bad_mode();
67}
68
69void 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
76void do_bus_fault(struct autosave_regs *autosave_regs)
77{
78 printf("Bus fault\n");
79 dump_regs(autosave_regs);
80 bad_mode();
81}
82
83void do_usage_fault(struct autosave_regs *autosave_regs)
84{
85 printf("Usage fault\n");
86 dump_regs(autosave_regs);
87 bad_mode();
88}
89
90void do_invalid_entry(struct autosave_regs *autosave_regs)
91{
92 printf("Exception\n");
93 dump_regs(autosave_regs);
94 bad_mode();
95}