blob: a2df7cf193c57966b8db2e634de58e6e1d1f3567 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
David Feng85fd5f12013-12-14 11:47:35 +08002/*
3 * (C) Copyright 2013
4 * David Feng <fenghua@phytium.com.cn>
David Feng85fd5f12013-12-14 11:47:35 +08005 */
6
7#include <common.h>
Simon Glass9b61c7c2019-11-14 12:57:41 -07008#include <irq_func.h>
David Feng85fd5f12013-12-14 11:47:35 +08009#include <linux/compiler.h>
Alexander Graf58177862016-03-04 01:10:06 +010010#include <efi_loader.h>
David Feng85fd5f12013-12-14 11:47:35 +080011
Peng Fanc3c9b332017-11-28 10:08:08 +080012DECLARE_GLOBAL_DATA_PTR;
David Feng85fd5f12013-12-14 11:47:35 +080013
14int interrupt_init(void)
15{
Ovidiu Panait8998e712020-04-20 10:31:44 +030016 enable_interrupts();
17
David Feng85fd5f12013-12-14 11:47:35 +080018 return 0;
19}
20
21void enable_interrupts(void)
22{
23 return;
24}
25
26int disable_interrupts(void)
27{
28 return 0;
29}
30
Heinrich Schuchardtb7c0c382019-04-04 22:06:25 +020031static void show_efi_loaded_images(struct pt_regs *regs)
32{
33 efi_print_image_infos((void *)regs->elr);
34}
35
Heinrich Schuchardt11efc1a2019-09-12 19:09:26 +020036static 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 Feng85fd5f12013-12-14 11:47:35 +080047void show_regs(struct pt_regs *regs)
48{
49 int i;
50
Karl Beldanb33ccd12018-02-20 23:30:08 +000051 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 Feng85fd5f12013-12-14 11:47:35 +080057 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 Schuchardt11efc1a2019-09-12 19:09:26 +020061 dump_instr(regs);
David Feng85fd5f12013-12-14 11:47:35 +080062}
63
64/*
65 * do_bad_sync handles the impossible case in the Synchronous Abort vector.
66 */
67void do_bad_sync(struct pt_regs *pt_regs, unsigned int esr)
68{
Alexander Graf58177862016-03-04 01:10:06 +010069 efi_restore_gd();
David Feng85fd5f12013-12-14 11:47:35 +080070 printf("Bad mode in \"Synchronous Abort\" handler, esr 0x%08x\n", esr);
71 show_regs(pt_regs);
Heinrich Schuchardtb7c0c382019-04-04 22:06:25 +020072 show_efi_loaded_images(pt_regs);
David Feng85fd5f12013-12-14 11:47:35 +080073 panic("Resetting CPU ...\n");
74}
75
76/*
77 * do_bad_irq handles the impossible case in the Irq vector.
78 */
79void do_bad_irq(struct pt_regs *pt_regs, unsigned int esr)
80{
Alexander Graf58177862016-03-04 01:10:06 +010081 efi_restore_gd();
David Feng85fd5f12013-12-14 11:47:35 +080082 printf("Bad mode in \"Irq\" handler, esr 0x%08x\n", esr);
83 show_regs(pt_regs);
Heinrich Schuchardtb7c0c382019-04-04 22:06:25 +020084 show_efi_loaded_images(pt_regs);
David Feng85fd5f12013-12-14 11:47:35 +080085 panic("Resetting CPU ...\n");
86}
87
88/*
89 * do_bad_fiq handles the impossible case in the Fiq vector.
90 */
91void do_bad_fiq(struct pt_regs *pt_regs, unsigned int esr)
92{
Alexander Graf58177862016-03-04 01:10:06 +010093 efi_restore_gd();
David Feng85fd5f12013-12-14 11:47:35 +080094 printf("Bad mode in \"Fiq\" handler, esr 0x%08x\n", esr);
95 show_regs(pt_regs);
Heinrich Schuchardtb7c0c382019-04-04 22:06:25 +020096 show_efi_loaded_images(pt_regs);
David Feng85fd5f12013-12-14 11:47:35 +080097 panic("Resetting CPU ...\n");
98}
99
100/*
101 * do_bad_error handles the impossible case in the Error vector.
102 */
103void do_bad_error(struct pt_regs *pt_regs, unsigned int esr)
104{
Alexander Graf58177862016-03-04 01:10:06 +0100105 efi_restore_gd();
David Feng85fd5f12013-12-14 11:47:35 +0800106 printf("Bad mode in \"Error\" handler, esr 0x%08x\n", esr);
107 show_regs(pt_regs);
Heinrich Schuchardtb7c0c382019-04-04 22:06:25 +0200108 show_efi_loaded_images(pt_regs);
David Feng85fd5f12013-12-14 11:47:35 +0800109 panic("Resetting CPU ...\n");
110}
111
112/*
113 * do_sync handles the Synchronous Abort exception.
114 */
115void do_sync(struct pt_regs *pt_regs, unsigned int esr)
116{
Alexander Graf58177862016-03-04 01:10:06 +0100117 efi_restore_gd();
David Feng85fd5f12013-12-14 11:47:35 +0800118 printf("\"Synchronous Abort\" handler, esr 0x%08x\n", esr);
119 show_regs(pt_regs);
Heinrich Schuchardtb7c0c382019-04-04 22:06:25 +0200120 show_efi_loaded_images(pt_regs);
David Feng85fd5f12013-12-14 11:47:35 +0800121 panic("Resetting CPU ...\n");
122}
123
124/*
125 * do_irq handles the Irq exception.
126 */
127void do_irq(struct pt_regs *pt_regs, unsigned int esr)
128{
Alexander Graf58177862016-03-04 01:10:06 +0100129 efi_restore_gd();
David Feng85fd5f12013-12-14 11:47:35 +0800130 printf("\"Irq\" handler, esr 0x%08x\n", esr);
131 show_regs(pt_regs);
Heinrich Schuchardtb7c0c382019-04-04 22:06:25 +0200132 show_efi_loaded_images(pt_regs);
David Feng85fd5f12013-12-14 11:47:35 +0800133 panic("Resetting CPU ...\n");
134}
135
136/*
137 * do_fiq handles the Fiq exception.
138 */
139void do_fiq(struct pt_regs *pt_regs, unsigned int esr)
140{
Alexander Graf58177862016-03-04 01:10:06 +0100141 efi_restore_gd();
David Feng85fd5f12013-12-14 11:47:35 +0800142 printf("\"Fiq\" handler, esr 0x%08x\n", esr);
143 show_regs(pt_regs);
Heinrich Schuchardtb7c0c382019-04-04 22:06:25 +0200144 show_efi_loaded_images(pt_regs);
David Feng85fd5f12013-12-14 11:47:35 +0800145 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 */
154void __weak do_error(struct pt_regs *pt_regs, unsigned int esr)
155{
Alexander Graf58177862016-03-04 01:10:06 +0100156 efi_restore_gd();
David Feng85fd5f12013-12-14 11:47:35 +0800157 printf("\"Error\" handler, esr 0x%08x\n", esr);
158 show_regs(pt_regs);
Heinrich Schuchardtb7c0c382019-04-04 22:06:25 +0200159 show_efi_loaded_images(pt_regs);
David Feng85fd5f12013-12-14 11:47:35 +0800160 panic("Resetting CPU ...\n");
161}