Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
rev13@wp.pl | 12d8a72 | 2015-03-01 12:44:39 +0100 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2015 |
Kamil Lulko | 5be9356 | 2015-11-29 11:50:53 +0100 | [diff] [blame] | 4 | * Kamil Lulko, <kamil.lulko@gmail.com> |
rev13@wp.pl | 12d8a72 | 2015-03-01 12:44:39 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | 9a3b4ce | 2019-12-28 10:45:01 -0700 | [diff] [blame] | 8 | #include <cpu_func.h> |
Simon Glass | c30b7ad | 2019-11-14 12:57:41 -0700 | [diff] [blame] | 9 | #include <irq_func.h> |
rev13@wp.pl | 12d8a72 | 2015-03-01 12:44:39 +0100 | [diff] [blame] | 10 | |
| 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 | |
| 19 | struct 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 | |
| 32 | int interrupt_init(void) |
| 33 | { |
Ovidiu Panait | 5cf9e3b | 2020-04-20 10:31:44 +0300 | [diff] [blame] | 34 | enable_interrupts(); |
| 35 | |
rev13@wp.pl | 12d8a72 | 2015-03-01 12:44:39 +0100 | [diff] [blame] | 36 | return 0; |
| 37 | } |
| 38 | |
| 39 | void enable_interrupts(void) |
| 40 | { |
| 41 | return; |
| 42 | } |
| 43 | |
| 44 | int disable_interrupts(void) |
| 45 | { |
| 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | void 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 | |
| 59 | void bad_mode(void) |
| 60 | { |
| 61 | panic("Resetting CPU ...\n"); |
| 62 | reset_cpu(0); |
| 63 | } |
| 64 | |
| 65 | void do_hard_fault(struct autosave_regs *autosave_regs) |
| 66 | { |
| 67 | printf("Hard fault\n"); |
| 68 | dump_regs(autosave_regs); |
| 69 | bad_mode(); |
| 70 | } |
| 71 | |
| 72 | void 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 | |
| 79 | void do_bus_fault(struct autosave_regs *autosave_regs) |
| 80 | { |
| 81 | printf("Bus fault\n"); |
| 82 | dump_regs(autosave_regs); |
| 83 | bad_mode(); |
| 84 | } |
| 85 | |
| 86 | void do_usage_fault(struct autosave_regs *autosave_regs) |
| 87 | { |
| 88 | printf("Usage fault\n"); |
| 89 | dump_regs(autosave_regs); |
| 90 | bad_mode(); |
| 91 | } |
| 92 | |
| 93 | void do_invalid_entry(struct autosave_regs *autosave_regs) |
| 94 | { |
| 95 | printf("Exception\n"); |
| 96 | dump_regs(autosave_regs); |
| 97 | bad_mode(); |
| 98 | } |