1 // SPDX-License-Identifier: GPL-2.0+
4 * Texas Instruments <www.ti.com>
7 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
8 * Marius Groeger <mgroeger@sysgo.de>
11 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
12 * Alex Zuepke <azu@sysgo.de>
14 * (C) Copyright 2002-2004
15 * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
18 * Philippe Robin, ARM Ltd. <philippe.robin@arm.com>
23 #include <efi_loader.h>
25 #include <asm/proc-armv/ptrace.h>
26 #include <asm/u-boot-arm.h>
28 DECLARE_GLOBAL_DATA_PTR;
30 int interrupt_init(void)
33 * setup up stacks if necessary
35 IRQ_STACK_START_IN = gd->irq_sp + 8;
40 void enable_interrupts(void)
44 int disable_interrupts(void)
51 panic ("Resetting CPU ...\n");
55 static void show_efi_loaded_images(struct pt_regs *regs)
57 efi_print_image_infos((void *)instruction_pointer(regs));
60 static void dump_instr(struct pt_regs *regs)
62 unsigned long addr = instruction_pointer(regs);
63 const int thumb = thumb_mode(regs);
64 const int width = thumb ? 4 : 8;
72 for (i = -4; i < 1 + !!thumb; i++) {
76 val = ((u16 *)addr)[i];
78 val = ((u32 *)addr)[i];
79 printf(i == 0 ? "(%0*x) " : "%0*x ", width, val);
84 void show_regs (struct pt_regs *regs)
86 unsigned long __maybe_unused flags;
87 const char __maybe_unused *processor_modes[] = {
88 "USER_26", "FIQ_26", "IRQ_26", "SVC_26",
89 "UK4_26", "UK5_26", "UK6_26", "UK7_26",
90 "UK8_26", "UK9_26", "UK10_26", "UK11_26",
91 "UK12_26", "UK13_26", "UK14_26", "UK15_26",
92 "USER_32", "FIQ_32", "IRQ_32", "SVC_32",
93 "UK4_32", "UK5_32", "UK6_32", "ABT_32",
94 "UK8_32", "UK9_32", "HYP_32", "UND_32",
95 "UK12_32", "UK13_32", "UK14_32", "SYS_32",
98 flags = condition_codes (regs);
100 printf("pc : [<%08lx>] lr : [<%08lx>]\n",
101 instruction_pointer(regs), regs->ARM_lr);
102 if (gd->flags & GD_FLG_RELOC) {
103 printf("reloc pc : [<%08lx>] lr : [<%08lx>]\n",
104 instruction_pointer(regs) - gd->reloc_off,
105 regs->ARM_lr - gd->reloc_off);
107 printf("sp : %08lx ip : %08lx fp : %08lx\n",
108 regs->ARM_sp, regs->ARM_ip, regs->ARM_fp);
109 printf ("r10: %08lx r9 : %08lx r8 : %08lx\n",
110 regs->ARM_r10, regs->ARM_r9, regs->ARM_r8);
111 printf ("r7 : %08lx r6 : %08lx r5 : %08lx r4 : %08lx\n",
112 regs->ARM_r7, regs->ARM_r6, regs->ARM_r5, regs->ARM_r4);
113 printf ("r3 : %08lx r2 : %08lx r1 : %08lx r0 : %08lx\n",
114 regs->ARM_r3, regs->ARM_r2, regs->ARM_r1, regs->ARM_r0);
115 printf ("Flags: %c%c%c%c",
116 flags & CC_N_BIT ? 'N' : 'n',
117 flags & CC_Z_BIT ? 'Z' : 'z',
118 flags & CC_C_BIT ? 'C' : 'c', flags & CC_V_BIT ? 'V' : 'v');
119 printf (" IRQs %s FIQs %s Mode %s%s\n",
120 interrupts_enabled (regs) ? "on" : "off",
121 fast_interrupts_enabled (regs) ? "on" : "off",
122 processor_modes[processor_mode (regs)],
123 thumb_mode (regs) ? " (T)" : "");
127 /* fixup PC to point to the instruction leading to the exception */
128 static inline void fixup_pc(struct pt_regs *regs, int offset)
130 uint32_t pc = instruction_pointer(regs) + offset;
131 regs->ARM_pc = pc | (regs->ARM_pc & PCMASK);
134 void do_undefined_instruction (struct pt_regs *pt_regs)
137 printf ("undefined instruction\n");
138 fixup_pc(pt_regs, -4);
140 show_efi_loaded_images(pt_regs);
144 void do_software_interrupt (struct pt_regs *pt_regs)
147 printf ("software interrupt\n");
148 fixup_pc(pt_regs, -4);
150 show_efi_loaded_images(pt_regs);
154 void do_prefetch_abort (struct pt_regs *pt_regs)
157 printf ("prefetch abort\n");
158 fixup_pc(pt_regs, -8);
160 show_efi_loaded_images(pt_regs);
164 void do_data_abort (struct pt_regs *pt_regs)
167 printf ("data abort\n");
168 fixup_pc(pt_regs, -8);
170 show_efi_loaded_images(pt_regs);
174 void do_not_used (struct pt_regs *pt_regs)
177 printf ("not used\n");
178 fixup_pc(pt_regs, -8);
180 show_efi_loaded_images(pt_regs);
184 void do_fiq (struct pt_regs *pt_regs)
187 printf ("fast interrupt request\n");
188 fixup_pc(pt_regs, -8);
190 show_efi_loaded_images(pt_regs);
194 void do_irq (struct pt_regs *pt_regs)
197 printf ("interrupt request\n");
198 fixup_pc(pt_regs, -8);
200 show_efi_loaded_images(pt_regs);