Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / arch / arm / lib / interrupts_64.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2013
4  * David Feng <fenghua@phytium.com.cn>
5  */
6
7 #include <common.h>
8 #include <asm/ptrace.h>
9 #include <irq_func.h>
10 #include <linux/compiler.h>
11 #include <efi_loader.h>
12
13 DECLARE_GLOBAL_DATA_PTR;
14
15 int interrupt_init(void)
16 {
17         enable_interrupts();
18
19         return 0;
20 }
21
22 void enable_interrupts(void)
23 {
24         return;
25 }
26
27 int disable_interrupts(void)
28 {
29         return 0;
30 }
31
32 static void show_efi_loaded_images(struct pt_regs *regs)
33 {
34         efi_print_image_infos((void *)regs->elr);
35 }
36
37 static void dump_instr(struct pt_regs *regs)
38 {
39         u32 *addr = (u32 *)(regs->elr & ~3UL);
40         int i;
41
42         printf("Code: ");
43         for (i = -4; i < 1; i++)
44                 printf(i == 0 ? "(%08x) " : "%08x ", addr[i]);
45         printf("\n");
46 }
47
48 void show_regs(struct pt_regs *regs)
49 {
50         int i;
51
52         if (gd->flags & GD_FLG_RELOC)
53                 printf("elr: %016lx lr : %016lx (reloc)\n",
54                        regs->elr - gd->reloc_off,
55                        regs->regs[30] - gd->reloc_off);
56         printf("elr: %016lx lr : %016lx\n", regs->elr, regs->regs[30]);
57
58         for (i = 0; i < 29; i += 2)
59                 printf("x%-2d: %016lx x%-2d: %016lx\n",
60                        i, regs->regs[i], i+1, regs->regs[i+1]);
61         printf("\n");
62         dump_instr(regs);
63 }
64
65 /*
66  * do_bad_sync handles the impossible case in the Synchronous Abort vector.
67  */
68 void do_bad_sync(struct pt_regs *pt_regs, unsigned int esr)
69 {
70         efi_restore_gd();
71         printf("Bad mode in \"Synchronous Abort\" handler, esr 0x%08x\n", esr);
72         show_regs(pt_regs);
73         show_efi_loaded_images(pt_regs);
74         panic("Resetting CPU ...\n");
75 }
76
77 /*
78  * do_bad_irq handles the impossible case in the Irq vector.
79  */
80 void do_bad_irq(struct pt_regs *pt_regs, unsigned int esr)
81 {
82         efi_restore_gd();
83         printf("Bad mode in \"Irq\" handler, esr 0x%08x\n", esr);
84         show_regs(pt_regs);
85         show_efi_loaded_images(pt_regs);
86         panic("Resetting CPU ...\n");
87 }
88
89 /*
90  * do_bad_fiq handles the impossible case in the Fiq vector.
91  */
92 void do_bad_fiq(struct pt_regs *pt_regs, unsigned int esr)
93 {
94         efi_restore_gd();
95         printf("Bad mode in \"Fiq\" handler, esr 0x%08x\n", esr);
96         show_regs(pt_regs);
97         show_efi_loaded_images(pt_regs);
98         panic("Resetting CPU ...\n");
99 }
100
101 /*
102  * do_bad_error handles the impossible case in the Error vector.
103  */
104 void do_bad_error(struct pt_regs *pt_regs, unsigned int esr)
105 {
106         efi_restore_gd();
107         printf("Bad mode in \"Error\" handler, esr 0x%08x\n", esr);
108         show_regs(pt_regs);
109         show_efi_loaded_images(pt_regs);
110         panic("Resetting CPU ...\n");
111 }
112
113 /*
114  * do_sync handles the Synchronous Abort exception.
115  */
116 void do_sync(struct pt_regs *pt_regs, unsigned int esr)
117 {
118         efi_restore_gd();
119         printf("\"Synchronous Abort\" handler, esr 0x%08x\n", esr);
120         show_regs(pt_regs);
121         show_efi_loaded_images(pt_regs);
122         panic("Resetting CPU ...\n");
123 }
124
125 /*
126  * do_irq handles the Irq exception.
127  */
128 void do_irq(struct pt_regs *pt_regs, unsigned int esr)
129 {
130         efi_restore_gd();
131         printf("\"Irq\" handler, esr 0x%08x\n", esr);
132         show_regs(pt_regs);
133         show_efi_loaded_images(pt_regs);
134         panic("Resetting CPU ...\n");
135 }
136
137 /*
138  * do_fiq handles the Fiq exception.
139  */
140 void do_fiq(struct pt_regs *pt_regs, unsigned int esr)
141 {
142         efi_restore_gd();
143         printf("\"Fiq\" handler, esr 0x%08x\n", esr);
144         show_regs(pt_regs);
145         show_efi_loaded_images(pt_regs);
146         panic("Resetting CPU ...\n");
147 }
148
149 /*
150  * do_error handles the Error exception.
151  * Errors are more likely to be processor specific,
152  * it is defined with weak attribute and can be redefined
153  * in processor specific code.
154  */
155 void __weak do_error(struct pt_regs *pt_regs, unsigned int esr)
156 {
157         efi_restore_gd();
158         printf("\"Error\" handler, esr 0x%08x\n", esr);
159         show_regs(pt_regs);
160         show_efi_loaded_images(pt_regs);
161         panic("Resetting CPU ...\n");
162 }