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