blob: c653e67db286ffc9ad5232fc76ef2cd9ebee321f [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
David Feng0ae76532013-12-14 11:47:35 +08002/*
3 * (C) Copyright 2013
4 * David Feng <fenghua@phytium.com.cn>
David Feng0ae76532013-12-14 11:47:35 +08005 */
6
7#include <common.h>
Simon Glass401d1c42020-10-30 21:38:53 -06008#include <asm/global_data.h>
Simon Glass25a58182020-05-10 11:40:06 -06009#include <asm/ptrace.h>
Simon Glassc30b7ad2019-11-14 12:57:41 -070010#include <irq_func.h>
David Feng0ae76532013-12-14 11:47:35 +080011#include <linux/compiler.h>
Alexander Graf64982912016-03-04 01:10:06 +010012#include <efi_loader.h>
David Feng0ae76532013-12-14 11:47:35 +080013
Peng Fan082693f2017-11-28 10:08:08 +080014DECLARE_GLOBAL_DATA_PTR;
David Feng0ae76532013-12-14 11:47:35 +080015
16int interrupt_init(void)
17{
Ovidiu Panait5cf9e3b2020-04-20 10:31:44 +030018 enable_interrupts();
19
David Feng0ae76532013-12-14 11:47:35 +080020 return 0;
21}
22
23void enable_interrupts(void)
24{
25 return;
26}
27
28int disable_interrupts(void)
29{
30 return 0;
31}
32
Heinrich Schuchardtbba81652019-04-04 22:06:25 +020033static void show_efi_loaded_images(struct pt_regs *regs)
34{
35 efi_print_image_infos((void *)regs->elr);
36}
37
Heinrich Schuchardt57bbf442019-09-12 19:09:26 +020038static 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 Feng0ae76532013-12-14 11:47:35 +080049void show_regs(struct pt_regs *regs)
50{
51 int i;
52
Karl Beldanfa7b8ea2018-02-20 23:30:08 +000053 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 Feng0ae76532013-12-14 11:47:35 +080059 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 Schuchardt57bbf442019-09-12 19:09:26 +020063 dump_instr(regs);
David Feng0ae76532013-12-14 11:47:35 +080064}
65
66/*
67 * do_bad_sync handles the impossible case in the Synchronous Abort vector.
68 */
69void do_bad_sync(struct pt_regs *pt_regs, unsigned int esr)
70{
Alexander Graf64982912016-03-04 01:10:06 +010071 efi_restore_gd();
David Feng0ae76532013-12-14 11:47:35 +080072 printf("Bad mode in \"Synchronous Abort\" handler, esr 0x%08x\n", esr);
73 show_regs(pt_regs);
Heinrich Schuchardtbba81652019-04-04 22:06:25 +020074 show_efi_loaded_images(pt_regs);
David Feng0ae76532013-12-14 11:47:35 +080075 panic("Resetting CPU ...\n");
76}
77
78/*
79 * do_bad_irq handles the impossible case in the Irq vector.
80 */
81void do_bad_irq(struct pt_regs *pt_regs, unsigned int esr)
82{
Alexander Graf64982912016-03-04 01:10:06 +010083 efi_restore_gd();
David Feng0ae76532013-12-14 11:47:35 +080084 printf("Bad mode in \"Irq\" handler, esr 0x%08x\n", esr);
85 show_regs(pt_regs);
Heinrich Schuchardtbba81652019-04-04 22:06:25 +020086 show_efi_loaded_images(pt_regs);
David Feng0ae76532013-12-14 11:47:35 +080087 panic("Resetting CPU ...\n");
88}
89
90/*
91 * do_bad_fiq handles the impossible case in the Fiq vector.
92 */
93void do_bad_fiq(struct pt_regs *pt_regs, unsigned int esr)
94{
Alexander Graf64982912016-03-04 01:10:06 +010095 efi_restore_gd();
David Feng0ae76532013-12-14 11:47:35 +080096 printf("Bad mode in \"Fiq\" handler, esr 0x%08x\n", esr);
97 show_regs(pt_regs);
Heinrich Schuchardtbba81652019-04-04 22:06:25 +020098 show_efi_loaded_images(pt_regs);
David Feng0ae76532013-12-14 11:47:35 +080099 panic("Resetting CPU ...\n");
100}
101
102/*
103 * do_bad_error handles the impossible case in the Error vector.
104 */
105void do_bad_error(struct pt_regs *pt_regs, unsigned int esr)
106{
Alexander Graf64982912016-03-04 01:10:06 +0100107 efi_restore_gd();
David Feng0ae76532013-12-14 11:47:35 +0800108 printf("Bad mode in \"Error\" handler, esr 0x%08x\n", esr);
109 show_regs(pt_regs);
Heinrich Schuchardtbba81652019-04-04 22:06:25 +0200110 show_efi_loaded_images(pt_regs);
David Feng0ae76532013-12-14 11:47:35 +0800111 panic("Resetting CPU ...\n");
112}
113
114/*
115 * do_sync handles the Synchronous Abort exception.
116 */
117void do_sync(struct pt_regs *pt_regs, unsigned int esr)
118{
Alexander Graf64982912016-03-04 01:10:06 +0100119 efi_restore_gd();
David Feng0ae76532013-12-14 11:47:35 +0800120 printf("\"Synchronous Abort\" handler, esr 0x%08x\n", esr);
121 show_regs(pt_regs);
Heinrich Schuchardtbba81652019-04-04 22:06:25 +0200122 show_efi_loaded_images(pt_regs);
David Feng0ae76532013-12-14 11:47:35 +0800123 panic("Resetting CPU ...\n");
124}
125
126/*
127 * do_irq handles the Irq exception.
128 */
129void do_irq(struct pt_regs *pt_regs, unsigned int esr)
130{
Alexander Graf64982912016-03-04 01:10:06 +0100131 efi_restore_gd();
David Feng0ae76532013-12-14 11:47:35 +0800132 printf("\"Irq\" handler, esr 0x%08x\n", esr);
133 show_regs(pt_regs);
Heinrich Schuchardtbba81652019-04-04 22:06:25 +0200134 show_efi_loaded_images(pt_regs);
David Feng0ae76532013-12-14 11:47:35 +0800135 panic("Resetting CPU ...\n");
136}
137
138/*
139 * do_fiq handles the Fiq exception.
140 */
141void do_fiq(struct pt_regs *pt_regs, unsigned int esr)
142{
Alexander Graf64982912016-03-04 01:10:06 +0100143 efi_restore_gd();
David Feng0ae76532013-12-14 11:47:35 +0800144 printf("\"Fiq\" handler, esr 0x%08x\n", esr);
145 show_regs(pt_regs);
Heinrich Schuchardtbba81652019-04-04 22:06:25 +0200146 show_efi_loaded_images(pt_regs);
David Feng0ae76532013-12-14 11:47:35 +0800147 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 */
156void __weak do_error(struct pt_regs *pt_regs, unsigned int esr)
157{
Alexander Graf64982912016-03-04 01:10:06 +0100158 efi_restore_gd();
David Feng0ae76532013-12-14 11:47:35 +0800159 printf("\"Error\" handler, esr 0x%08x\n", esr);
160 show_regs(pt_regs);
Heinrich Schuchardtbba81652019-04-04 22:06:25 +0200161 show_efi_loaded_images(pt_regs);
David Feng0ae76532013-12-14 11:47:35 +0800162 panic("Resetting CPU ...\n");
163}