David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2013 |
| 3 | * David Feng <fenghua@phytium.com.cn> |
| 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 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 | |
| 29 | void show_regs(struct pt_regs *regs) |
| 30 | { |
| 31 | int i; |
| 32 | |
Peng Fan | c3c9b33 | 2017-11-28 10:08:08 +0800 | [diff] [blame] | 33 | if (gd->flags & GD_FLG_RELOC) { |
| 34 | printf("ELR: %lx\n", regs->elr - gd->reloc_off); |
| 35 | printf("LR: %lx\n", regs->regs[30] - gd->reloc_off); |
| 36 | } else { |
| 37 | printf("ELR: %lx\n", regs->elr); |
| 38 | printf("LR: %lx\n", regs->regs[30]); |
| 39 | } |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 40 | for (i = 0; i < 29; i += 2) |
| 41 | printf("x%-2d: %016lx x%-2d: %016lx\n", |
| 42 | i, regs->regs[i], i+1, regs->regs[i+1]); |
| 43 | printf("\n"); |
| 44 | } |
| 45 | |
| 46 | /* |
| 47 | * do_bad_sync handles the impossible case in the Synchronous Abort vector. |
| 48 | */ |
| 49 | void do_bad_sync(struct pt_regs *pt_regs, unsigned int esr) |
| 50 | { |
Alexander Graf | 5817786 | 2016-03-04 01:10:06 +0100 | [diff] [blame] | 51 | efi_restore_gd(); |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 52 | printf("Bad mode in \"Synchronous Abort\" handler, esr 0x%08x\n", esr); |
| 53 | show_regs(pt_regs); |
| 54 | panic("Resetting CPU ...\n"); |
| 55 | } |
| 56 | |
| 57 | /* |
| 58 | * do_bad_irq handles the impossible case in the Irq vector. |
| 59 | */ |
| 60 | void do_bad_irq(struct pt_regs *pt_regs, unsigned int esr) |
| 61 | { |
Alexander Graf | 5817786 | 2016-03-04 01:10:06 +0100 | [diff] [blame] | 62 | efi_restore_gd(); |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 63 | printf("Bad mode in \"Irq\" handler, esr 0x%08x\n", esr); |
| 64 | show_regs(pt_regs); |
| 65 | panic("Resetting CPU ...\n"); |
| 66 | } |
| 67 | |
| 68 | /* |
| 69 | * do_bad_fiq handles the impossible case in the Fiq vector. |
| 70 | */ |
| 71 | void do_bad_fiq(struct pt_regs *pt_regs, unsigned int esr) |
| 72 | { |
Alexander Graf | 5817786 | 2016-03-04 01:10:06 +0100 | [diff] [blame] | 73 | efi_restore_gd(); |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 74 | printf("Bad mode in \"Fiq\" handler, esr 0x%08x\n", esr); |
| 75 | show_regs(pt_regs); |
| 76 | panic("Resetting CPU ...\n"); |
| 77 | } |
| 78 | |
| 79 | /* |
| 80 | * do_bad_error handles the impossible case in the Error vector. |
| 81 | */ |
| 82 | void do_bad_error(struct pt_regs *pt_regs, unsigned int esr) |
| 83 | { |
Alexander Graf | 5817786 | 2016-03-04 01:10:06 +0100 | [diff] [blame] | 84 | efi_restore_gd(); |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 85 | printf("Bad mode in \"Error\" handler, esr 0x%08x\n", esr); |
| 86 | show_regs(pt_regs); |
| 87 | panic("Resetting CPU ...\n"); |
| 88 | } |
| 89 | |
| 90 | /* |
| 91 | * do_sync handles the Synchronous Abort exception. |
| 92 | */ |
| 93 | void do_sync(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("\"Synchronous Abort\" handler, esr 0x%08x\n", esr); |
| 97 | show_regs(pt_regs); |
| 98 | panic("Resetting CPU ...\n"); |
| 99 | } |
| 100 | |
| 101 | /* |
| 102 | * do_irq handles the Irq exception. |
| 103 | */ |
| 104 | void do_irq(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("\"Irq\" handler, esr 0x%08x\n", esr); |
| 108 | show_regs(pt_regs); |
| 109 | panic("Resetting CPU ...\n"); |
| 110 | } |
| 111 | |
| 112 | /* |
| 113 | * do_fiq handles the Fiq exception. |
| 114 | */ |
| 115 | void do_fiq(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("\"Fiq\" handler, esr 0x%08x\n", esr); |
| 119 | show_regs(pt_regs); |
| 120 | panic("Resetting CPU ...\n"); |
| 121 | } |
| 122 | |
| 123 | /* |
| 124 | * do_error handles the Error exception. |
| 125 | * Errors are more likely to be processor specific, |
| 126 | * it is defined with weak attribute and can be redefined |
| 127 | * in processor specific code. |
| 128 | */ |
| 129 | void __weak do_error(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("\"Error\" handler, esr 0x%08x\n", esr); |
| 133 | show_regs(pt_regs); |
| 134 | panic("Resetting CPU ...\n"); |
| 135 | } |