blob: 277854aa878c2fbf6ffe3f05c6a60e8228fd7c49 [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>
Simon Glass9a3b4ce2019-12-28 10:45:01 -07008#include <cpu_func.h>
Simon Glassc30b7ad2019-11-14 12:57:41 -07009#include <irq_func.h>
rev13@wp.pl12d8a722015-03-01 12:44:39 +010010
11/*
12 * Upon exception entry ARMv7-M processors automatically save stack
13 * frames containing some registers. For simplicity initial
14 * implementation uses only this auto-saved stack frame.
15 * This does not contain complete register set dump,
16 * only R0-R3, R12, LR, PC and xPSR are saved.
17 */
18
19struct autosave_regs {
20 long uregs[8];
21};
22
23#define ARM_XPSR uregs[7]
24#define ARM_PC uregs[6]
25#define ARM_LR uregs[5]
26#define ARM_R12 uregs[4]
27#define ARM_R3 uregs[3]
28#define ARM_R2 uregs[2]
29#define ARM_R1 uregs[1]
30#define ARM_R0 uregs[0]
31
32int interrupt_init(void)
33{
Ovidiu Panait5cf9e3b2020-04-20 10:31:44 +030034 enable_interrupts();
35
rev13@wp.pl12d8a722015-03-01 12:44:39 +010036 return 0;
37}
38
39void enable_interrupts(void)
40{
41 return;
42}
43
44int disable_interrupts(void)
45{
46 return 0;
47}
48
49void dump_regs(struct autosave_regs *regs)
50{
51 printf("pc : %08lx lr : %08lx xPSR : %08lx\n",
52 regs->ARM_PC, regs->ARM_LR, regs->ARM_XPSR);
53 printf("r12 : %08lx r3 : %08lx r2 : %08lx\n"
54 "r1 : %08lx r0 : %08lx\n",
55 regs->ARM_R12, regs->ARM_R3, regs->ARM_R2,
56 regs->ARM_R1, regs->ARM_R0);
57}
58
59void bad_mode(void)
60{
61 panic("Resetting CPU ...\n");
Harald Seiler35b65dd2020-12-15 16:47:52 +010062 reset_cpu();
rev13@wp.pl12d8a722015-03-01 12:44:39 +010063}
64
65void do_hard_fault(struct autosave_regs *autosave_regs)
66{
67 printf("Hard fault\n");
68 dump_regs(autosave_regs);
69 bad_mode();
70}
71
72void do_mm_fault(struct autosave_regs *autosave_regs)
73{
74 printf("Memory management fault\n");
75 dump_regs(autosave_regs);
76 bad_mode();
77}
78
79void do_bus_fault(struct autosave_regs *autosave_regs)
80{
81 printf("Bus fault\n");
82 dump_regs(autosave_regs);
83 bad_mode();
84}
85
86void do_usage_fault(struct autosave_regs *autosave_regs)
87{
88 printf("Usage fault\n");
89 dump_regs(autosave_regs);
90 bad_mode();
91}
92
93void do_invalid_entry(struct autosave_regs *autosave_regs)
94{
95 printf("Exception\n");
96 dump_regs(autosave_regs);
97 bad_mode();
98}