Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2013 |
| 4 | * David Feng <fenghua@phytium.com.cn> |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | 6b9f010 | 2020-05-10 11:40:06 -0600 | [diff] [blame] | 8 | #include <asm/ptrace.h> |
Simon Glass | 9b61c7c | 2019-11-14 12:57:41 -0700 | [diff] [blame] | 9 | #include <irq_func.h> |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 10 | #include <linux/compiler.h> |
Alexander Graf | 5817786 | 2016-03-04 01:10:06 +0100 | [diff] [blame] | 11 | #include <efi_loader.h> |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 12 | |
Peng Fan | c3c9b33 | 2017-11-28 10:08:08 +0800 | [diff] [blame] | 13 | DECLARE_GLOBAL_DATA_PTR; |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 14 | |
| 15 | int interrupt_init(void) |
| 16 | { |
Ovidiu Panait | 8998e71 | 2020-04-20 10:31:44 +0300 | [diff] [blame] | 17 | enable_interrupts(); |
| 18 | |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 19 | return 0; |
| 20 | } |
| 21 | |
| 22 | void enable_interrupts(void) |
| 23 | { |
| 24 | return; |
| 25 | } |
| 26 | |
| 27 | int disable_interrupts(void) |
| 28 | { |
| 29 | return 0; |
| 30 | } |
| 31 | |
Heinrich Schuchardt | b7c0c38 | 2019-04-04 22:06:25 +0200 | [diff] [blame] | 32 | static void show_efi_loaded_images(struct pt_regs *regs) |
| 33 | { |
| 34 | efi_print_image_infos((void *)regs->elr); |
| 35 | } |
| 36 | |
Heinrich Schuchardt | 11efc1a | 2019-09-12 19:09:26 +0200 | [diff] [blame] | 37 | static void dump_instr(struct pt_regs *regs) |
| 38 | { |
| 39 | u32 *addr = (u32 *)(regs->elr & ~3UL); |
| 40 | int i; |
| 41 | |
| 42 | printf("Code: "); |
| 43 | for (i = -4; i < 1; i++) |
| 44 | printf(i == 0 ? "(%08x) " : "%08x ", addr[i]); |
| 45 | printf("\n"); |
| 46 | } |
| 47 | |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 48 | void show_regs(struct pt_regs *regs) |
| 49 | { |
| 50 | int i; |
| 51 | |
Karl Beldan | b33ccd1 | 2018-02-20 23:30:08 +0000 | [diff] [blame] | 52 | if (gd->flags & GD_FLG_RELOC) |
| 53 | printf("elr: %016lx lr : %016lx (reloc)\n", |
| 54 | regs->elr - gd->reloc_off, |
| 55 | regs->regs[30] - gd->reloc_off); |
| 56 | printf("elr: %016lx lr : %016lx\n", regs->elr, regs->regs[30]); |
| 57 | |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 58 | for (i = 0; i < 29; i += 2) |
| 59 | printf("x%-2d: %016lx x%-2d: %016lx\n", |
| 60 | i, regs->regs[i], i+1, regs->regs[i+1]); |
| 61 | printf("\n"); |
Heinrich Schuchardt | 11efc1a | 2019-09-12 19:09:26 +0200 | [diff] [blame] | 62 | dump_instr(regs); |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | /* |
| 66 | * do_bad_sync handles the impossible case in the Synchronous Abort vector. |
| 67 | */ |
| 68 | void do_bad_sync(struct pt_regs *pt_regs, unsigned int esr) |
| 69 | { |
Alexander Graf | 5817786 | 2016-03-04 01:10:06 +0100 | [diff] [blame] | 70 | efi_restore_gd(); |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 71 | printf("Bad mode in \"Synchronous Abort\" handler, esr 0x%08x\n", esr); |
| 72 | show_regs(pt_regs); |
Heinrich Schuchardt | b7c0c38 | 2019-04-04 22:06:25 +0200 | [diff] [blame] | 73 | show_efi_loaded_images(pt_regs); |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 74 | panic("Resetting CPU ...\n"); |
| 75 | } |
| 76 | |
| 77 | /* |
| 78 | * do_bad_irq handles the impossible case in the Irq vector. |
| 79 | */ |
| 80 | void do_bad_irq(struct pt_regs *pt_regs, unsigned int esr) |
| 81 | { |
Alexander Graf | 5817786 | 2016-03-04 01:10:06 +0100 | [diff] [blame] | 82 | efi_restore_gd(); |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 83 | printf("Bad mode in \"Irq\" handler, esr 0x%08x\n", esr); |
| 84 | show_regs(pt_regs); |
Heinrich Schuchardt | b7c0c38 | 2019-04-04 22:06:25 +0200 | [diff] [blame] | 85 | show_efi_loaded_images(pt_regs); |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 86 | panic("Resetting CPU ...\n"); |
| 87 | } |
| 88 | |
| 89 | /* |
| 90 | * do_bad_fiq handles the impossible case in the Fiq vector. |
| 91 | */ |
| 92 | void do_bad_fiq(struct pt_regs *pt_regs, unsigned int esr) |
| 93 | { |
Alexander Graf | 5817786 | 2016-03-04 01:10:06 +0100 | [diff] [blame] | 94 | efi_restore_gd(); |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 95 | printf("Bad mode in \"Fiq\" handler, esr 0x%08x\n", esr); |
| 96 | show_regs(pt_regs); |
Heinrich Schuchardt | b7c0c38 | 2019-04-04 22:06:25 +0200 | [diff] [blame] | 97 | show_efi_loaded_images(pt_regs); |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 98 | panic("Resetting CPU ...\n"); |
| 99 | } |
| 100 | |
| 101 | /* |
| 102 | * do_bad_error handles the impossible case in the Error vector. |
| 103 | */ |
| 104 | void do_bad_error(struct pt_regs *pt_regs, unsigned int esr) |
| 105 | { |
Alexander Graf | 5817786 | 2016-03-04 01:10:06 +0100 | [diff] [blame] | 106 | efi_restore_gd(); |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 107 | printf("Bad mode in \"Error\" handler, esr 0x%08x\n", esr); |
| 108 | show_regs(pt_regs); |
Heinrich Schuchardt | b7c0c38 | 2019-04-04 22:06:25 +0200 | [diff] [blame] | 109 | show_efi_loaded_images(pt_regs); |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 110 | panic("Resetting CPU ...\n"); |
| 111 | } |
| 112 | |
| 113 | /* |
| 114 | * do_sync handles the Synchronous Abort exception. |
| 115 | */ |
| 116 | void do_sync(struct pt_regs *pt_regs, unsigned int esr) |
| 117 | { |
Alexander Graf | 5817786 | 2016-03-04 01:10:06 +0100 | [diff] [blame] | 118 | efi_restore_gd(); |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 119 | printf("\"Synchronous Abort\" handler, esr 0x%08x\n", esr); |
| 120 | show_regs(pt_regs); |
Heinrich Schuchardt | b7c0c38 | 2019-04-04 22:06:25 +0200 | [diff] [blame] | 121 | show_efi_loaded_images(pt_regs); |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 122 | panic("Resetting CPU ...\n"); |
| 123 | } |
| 124 | |
| 125 | /* |
| 126 | * do_irq handles the Irq exception. |
| 127 | */ |
| 128 | void do_irq(struct pt_regs *pt_regs, unsigned int esr) |
| 129 | { |
Alexander Graf | 5817786 | 2016-03-04 01:10:06 +0100 | [diff] [blame] | 130 | efi_restore_gd(); |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 131 | printf("\"Irq\" handler, esr 0x%08x\n", esr); |
| 132 | show_regs(pt_regs); |
Heinrich Schuchardt | b7c0c38 | 2019-04-04 22:06:25 +0200 | [diff] [blame] | 133 | show_efi_loaded_images(pt_regs); |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 134 | panic("Resetting CPU ...\n"); |
| 135 | } |
| 136 | |
| 137 | /* |
| 138 | * do_fiq handles the Fiq exception. |
| 139 | */ |
| 140 | void do_fiq(struct pt_regs *pt_regs, unsigned int esr) |
| 141 | { |
Alexander Graf | 5817786 | 2016-03-04 01:10:06 +0100 | [diff] [blame] | 142 | efi_restore_gd(); |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 143 | printf("\"Fiq\" handler, esr 0x%08x\n", esr); |
| 144 | show_regs(pt_regs); |
Heinrich Schuchardt | b7c0c38 | 2019-04-04 22:06:25 +0200 | [diff] [blame] | 145 | show_efi_loaded_images(pt_regs); |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 146 | panic("Resetting CPU ...\n"); |
| 147 | } |
| 148 | |
| 149 | /* |
| 150 | * do_error handles the Error exception. |
| 151 | * Errors are more likely to be processor specific, |
| 152 | * it is defined with weak attribute and can be redefined |
| 153 | * in processor specific code. |
| 154 | */ |
| 155 | void __weak do_error(struct pt_regs *pt_regs, unsigned int esr) |
| 156 | { |
Alexander Graf | 5817786 | 2016-03-04 01:10:06 +0100 | [diff] [blame] | 157 | efi_restore_gd(); |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 158 | printf("\"Error\" handler, esr 0x%08x\n", esr); |
| 159 | show_regs(pt_regs); |
Heinrich Schuchardt | b7c0c38 | 2019-04-04 22:06:25 +0200 | [diff] [blame] | 160 | show_efi_loaded_images(pt_regs); |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 161 | panic("Resetting CPU ...\n"); |
| 162 | } |