blob: 0bfdb8d93d256656d8fc2f5969d51fec56c47ef3 [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>
8#include <linux/compiler.h>
Alexander Graf58177862016-03-04 01:10:06 +01009#include <efi_loader.h>
David Feng85fd5f12013-12-14 11:47:35 +080010
Peng Fanc3c9b332017-11-28 10:08:08 +080011DECLARE_GLOBAL_DATA_PTR;
David Feng85fd5f12013-12-14 11:47:35 +080012
13int interrupt_init(void)
14{
15 return 0;
16}
17
18void enable_interrupts(void)
19{
20 return;
21}
22
23int disable_interrupts(void)
24{
25 return 0;
26}
27
Heinrich Schuchardtb7c0c382019-04-04 22:06:25 +020028static void show_efi_loaded_images(struct pt_regs *regs)
29{
30 efi_print_image_infos((void *)regs->elr);
31}
32
David Feng85fd5f12013-12-14 11:47:35 +080033void show_regs(struct pt_regs *regs)
34{
35 int i;
36
Karl Beldanb33ccd12018-02-20 23:30:08 +000037 if (gd->flags & GD_FLG_RELOC)
38 printf("elr: %016lx lr : %016lx (reloc)\n",
39 regs->elr - gd->reloc_off,
40 regs->regs[30] - gd->reloc_off);
41 printf("elr: %016lx lr : %016lx\n", regs->elr, regs->regs[30]);
42
David Feng85fd5f12013-12-14 11:47:35 +080043 for (i = 0; i < 29; i += 2)
44 printf("x%-2d: %016lx x%-2d: %016lx\n",
45 i, regs->regs[i], i+1, regs->regs[i+1]);
46 printf("\n");
47}
48
49/*
50 * do_bad_sync handles the impossible case in the Synchronous Abort vector.
51 */
52void do_bad_sync(struct pt_regs *pt_regs, unsigned int esr)
53{
Alexander Graf58177862016-03-04 01:10:06 +010054 efi_restore_gd();
David Feng85fd5f12013-12-14 11:47:35 +080055 printf("Bad mode in \"Synchronous Abort\" handler, esr 0x%08x\n", esr);
56 show_regs(pt_regs);
Heinrich Schuchardtb7c0c382019-04-04 22:06:25 +020057 show_efi_loaded_images(pt_regs);
David Feng85fd5f12013-12-14 11:47:35 +080058 panic("Resetting CPU ...\n");
59}
60
61/*
62 * do_bad_irq handles the impossible case in the Irq vector.
63 */
64void do_bad_irq(struct pt_regs *pt_regs, unsigned int esr)
65{
Alexander Graf58177862016-03-04 01:10:06 +010066 efi_restore_gd();
David Feng85fd5f12013-12-14 11:47:35 +080067 printf("Bad mode in \"Irq\" handler, esr 0x%08x\n", esr);
68 show_regs(pt_regs);
Heinrich Schuchardtb7c0c382019-04-04 22:06:25 +020069 show_efi_loaded_images(pt_regs);
David Feng85fd5f12013-12-14 11:47:35 +080070 panic("Resetting CPU ...\n");
71}
72
73/*
74 * do_bad_fiq handles the impossible case in the Fiq vector.
75 */
76void do_bad_fiq(struct pt_regs *pt_regs, unsigned int esr)
77{
Alexander Graf58177862016-03-04 01:10:06 +010078 efi_restore_gd();
David Feng85fd5f12013-12-14 11:47:35 +080079 printf("Bad mode in \"Fiq\" handler, esr 0x%08x\n", esr);
80 show_regs(pt_regs);
Heinrich Schuchardtb7c0c382019-04-04 22:06:25 +020081 show_efi_loaded_images(pt_regs);
David Feng85fd5f12013-12-14 11:47:35 +080082 panic("Resetting CPU ...\n");
83}
84
85/*
86 * do_bad_error handles the impossible case in the Error vector.
87 */
88void do_bad_error(struct pt_regs *pt_regs, unsigned int esr)
89{
Alexander Graf58177862016-03-04 01:10:06 +010090 efi_restore_gd();
David Feng85fd5f12013-12-14 11:47:35 +080091 printf("Bad mode in \"Error\" handler, esr 0x%08x\n", esr);
92 show_regs(pt_regs);
Heinrich Schuchardtb7c0c382019-04-04 22:06:25 +020093 show_efi_loaded_images(pt_regs);
David Feng85fd5f12013-12-14 11:47:35 +080094 panic("Resetting CPU ...\n");
95}
96
97/*
98 * do_sync handles the Synchronous Abort exception.
99 */
100void do_sync(struct pt_regs *pt_regs, unsigned int esr)
101{
Alexander Graf58177862016-03-04 01:10:06 +0100102 efi_restore_gd();
David Feng85fd5f12013-12-14 11:47:35 +0800103 printf("\"Synchronous Abort\" handler, esr 0x%08x\n", esr);
104 show_regs(pt_regs);
Heinrich Schuchardtb7c0c382019-04-04 22:06:25 +0200105 show_efi_loaded_images(pt_regs);
David Feng85fd5f12013-12-14 11:47:35 +0800106 panic("Resetting CPU ...\n");
107}
108
109/*
110 * do_irq handles the Irq exception.
111 */
112void do_irq(struct pt_regs *pt_regs, unsigned int esr)
113{
Alexander Graf58177862016-03-04 01:10:06 +0100114 efi_restore_gd();
David Feng85fd5f12013-12-14 11:47:35 +0800115 printf("\"Irq\" handler, esr 0x%08x\n", esr);
116 show_regs(pt_regs);
Heinrich Schuchardtb7c0c382019-04-04 22:06:25 +0200117 show_efi_loaded_images(pt_regs);
David Feng85fd5f12013-12-14 11:47:35 +0800118 panic("Resetting CPU ...\n");
119}
120
121/*
122 * do_fiq handles the Fiq exception.
123 */
124void do_fiq(struct pt_regs *pt_regs, unsigned int esr)
125{
Alexander Graf58177862016-03-04 01:10:06 +0100126 efi_restore_gd();
David Feng85fd5f12013-12-14 11:47:35 +0800127 printf("\"Fiq\" handler, esr 0x%08x\n", esr);
128 show_regs(pt_regs);
Heinrich Schuchardtb7c0c382019-04-04 22:06:25 +0200129 show_efi_loaded_images(pt_regs);
David Feng85fd5f12013-12-14 11:47:35 +0800130 panic("Resetting CPU ...\n");
131}
132
133/*
134 * do_error handles the Error exception.
135 * Errors are more likely to be processor specific,
136 * it is defined with weak attribute and can be redefined
137 * in processor specific code.
138 */
139void __weak do_error(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("\"Error\" 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}