Merge tag 'u-boot-rockchip-20200501' of https://gitlab.denx.de/u-boot/custodians...
[platform/kernel/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 <irq_func.h>
9 #include <linux/compiler.h>
10 #include <efi_loader.h>
11
12 DECLARE_GLOBAL_DATA_PTR;
13
14 int interrupt_init(void)
15 {
16         enable_interrupts();
17
18         return 0;
19 }
20
21 void enable_interrupts(void)
22 {
23         return;
24 }
25
26 int disable_interrupts(void)
27 {
28         return 0;
29 }
30
31 static void show_efi_loaded_images(struct pt_regs *regs)
32 {
33         efi_print_image_infos((void *)regs->elr);
34 }
35
36 static 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
47 void show_regs(struct pt_regs *regs)
48 {
49         int i;
50
51         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
57         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");
61         dump_instr(regs);
62 }
63
64 /*
65  * do_bad_sync handles the impossible case in the Synchronous Abort vector.
66  */
67 void do_bad_sync(struct pt_regs *pt_regs, unsigned int esr)
68 {
69         efi_restore_gd();
70         printf("Bad mode in \"Synchronous Abort\" handler, esr 0x%08x\n", esr);
71         show_regs(pt_regs);
72         show_efi_loaded_images(pt_regs);
73         panic("Resetting CPU ...\n");
74 }
75
76 /*
77  * do_bad_irq handles the impossible case in the Irq vector.
78  */
79 void do_bad_irq(struct pt_regs *pt_regs, unsigned int esr)
80 {
81         efi_restore_gd();
82         printf("Bad mode in \"Irq\" handler, esr 0x%08x\n", esr);
83         show_regs(pt_regs);
84         show_efi_loaded_images(pt_regs);
85         panic("Resetting CPU ...\n");
86 }
87
88 /*
89  * do_bad_fiq handles the impossible case in the Fiq vector.
90  */
91 void do_bad_fiq(struct pt_regs *pt_regs, unsigned int esr)
92 {
93         efi_restore_gd();
94         printf("Bad mode in \"Fiq\" handler, esr 0x%08x\n", esr);
95         show_regs(pt_regs);
96         show_efi_loaded_images(pt_regs);
97         panic("Resetting CPU ...\n");
98 }
99
100 /*
101  * do_bad_error handles the impossible case in the Error vector.
102  */
103 void do_bad_error(struct pt_regs *pt_regs, unsigned int esr)
104 {
105         efi_restore_gd();
106         printf("Bad mode in \"Error\" handler, esr 0x%08x\n", esr);
107         show_regs(pt_regs);
108         show_efi_loaded_images(pt_regs);
109         panic("Resetting CPU ...\n");
110 }
111
112 /*
113  * do_sync handles the Synchronous Abort exception.
114  */
115 void do_sync(struct pt_regs *pt_regs, unsigned int esr)
116 {
117         efi_restore_gd();
118         printf("\"Synchronous Abort\" handler, esr 0x%08x\n", esr);
119         show_regs(pt_regs);
120         show_efi_loaded_images(pt_regs);
121         panic("Resetting CPU ...\n");
122 }
123
124 /*
125  * do_irq handles the Irq exception.
126  */
127 void do_irq(struct pt_regs *pt_regs, unsigned int esr)
128 {
129         efi_restore_gd();
130         printf("\"Irq\" handler, esr 0x%08x\n", esr);
131         show_regs(pt_regs);
132         show_efi_loaded_images(pt_regs);
133         panic("Resetting CPU ...\n");
134 }
135
136 /*
137  * do_fiq handles the Fiq exception.
138  */
139 void do_fiq(struct pt_regs *pt_regs, unsigned int esr)
140 {
141         efi_restore_gd();
142         printf("\"Fiq\" handler, esr 0x%08x\n", esr);
143         show_regs(pt_regs);
144         show_efi_loaded_images(pt_regs);
145         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  */
154 void __weak do_error(struct pt_regs *pt_regs, unsigned int esr)
155 {
156         efi_restore_gd();
157         printf("\"Error\" handler, esr 0x%08x\n", esr);
158         show_regs(pt_regs);
159         show_efi_loaded_images(pt_regs);
160         panic("Resetting CPU ...\n");
161 }