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