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