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