blob: 89ce493861fe4b83c49502a5acead87ceb780350 [file] [log] [blame]
rev13@wp.plb3b57e82015-03-01 12:44:39 +01001/*
2 * (C) Copyright 2015
3 * Kamil Lulko, <rev13@wp.pl>
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
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}