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