xref: /OK3568_Linux_fs/u-boot/arch/arm/lib/interrupts.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * (C) Copyright 2003
3  * Texas Instruments <www.ti.com>
4  *
5  * (C) Copyright 2002
6  * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
7  * Marius Groeger <mgroeger@sysgo.de>
8  *
9  * (C) Copyright 2002
10  * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
11  * Alex Zuepke <azu@sysgo.de>
12  *
13  * (C) Copyright 2002-2004
14  * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
15  *
16  * (C) Copyright 2004
17  * Philippe Robin, ARM Ltd. <philippe.robin@arm.com>
18  *
19  * SPDX-License-Identifier:	GPL-2.0+
20  */
21 
22 #include <common.h>
23 #include <asm/proc-armv/ptrace.h>
24 #include <asm/u-boot-arm.h>
25 #include <efi_loader.h>
26 #include <iomem.h>
27 #include <stacktrace.h>
28 
29 DECLARE_GLOBAL_DATA_PTR;
30 
31 #if !CONFIG_IS_ENABLED(IRQ)
interrupt_init(void)32 int interrupt_init (void)
33 {
34 	/*
35 	 * setup up stacks if necessary
36 	 */
37 	IRQ_STACK_START_IN = gd->irq_sp + 8;
38 
39 	return 0;
40 }
41 
enable_interrupts(void)42 void enable_interrupts (void)
43 {
44 	return;
45 }
disable_interrupts(void)46 int disable_interrupts (void)
47 {
48 	return 0;
49 }
50 #endif
51 
bad_mode(void)52 void bad_mode (void)
53 {
54 	panic ("Resetting CPU ...\n");
55 	reset_cpu (0);
56 }
57 
show_regs(struct pt_regs * regs)58 void show_regs (struct pt_regs *regs)
59 {
60 	ulong pc, lr;
61 	unsigned long __maybe_unused flags;
62 	const char __maybe_unused *processor_modes[] = {
63 	"USER_26",	"FIQ_26",	"IRQ_26",	"SVC_26",
64 	"UK4_26",	"UK5_26",	"UK6_26",	"UK7_26",
65 	"UK8_26",	"UK9_26",	"UK10_26",	"UK11_26",
66 	"UK12_26",	"UK13_26",	"UK14_26",	"UK15_26",
67 	"USER_32",	"FIQ_32",	"IRQ_32",	"SVC_32",
68 	"UK4_32",	"UK5_32",	"UK6_32",	"ABT_32",
69 	"UK8_32",	"UK9_32",	"HYP_32",	"UND_32",
70 	"UK12_32",	"UK13_32",	"UK14_32",	"SYS_32",
71 	};
72 
73 	flags = condition_codes (regs);
74 
75 	if (gd->flags & GD_FLG_RELOC) {
76 		pc = instruction_pointer(regs) - gd->reloc_off;
77 		lr = regs->ARM_lr - gd->reloc_off;
78 	} else {
79 		pc = instruction_pointer(regs);
80 		lr = regs->ARM_lr;
81 	}
82 
83 	printf ("pc : %08lx  lr : %08lx\n", pc, lr);
84 	printf ("sp : %08lx  ip : %08lx	 fp : %08lx\n",
85 	        regs->ARM_sp, regs->ARM_ip, regs->ARM_fp);
86 	printf ("r10: %08lx  r9 : %08lx	 r8 : %08lx\n",
87 		regs->ARM_r10, regs->ARM_r9, regs->ARM_r8);
88 	printf ("r7 : %08lx  r6 : %08lx	 r5 : %08lx  r4 : %08lx\n",
89 		regs->ARM_r7, regs->ARM_r6, regs->ARM_r5, regs->ARM_r4);
90 	printf ("r3 : %08lx  r2 : %08lx	 r1 : %08lx  r0 : %08lx\n",
91 		regs->ARM_r3, regs->ARM_r2, regs->ARM_r1, regs->ARM_r0);
92 	printf ("Flags: %c%c%c%c",
93 		flags & CC_N_BIT ? 'N' : 'n',
94 		flags & CC_Z_BIT ? 'Z' : 'z',
95 		flags & CC_C_BIT ? 'C' : 'c', flags & CC_V_BIT ? 'V' : 'v');
96 	printf ("  IRQs %s  FIQs %s  Mode %s%s\n\n",
97 		interrupts_enabled (regs) ? "on" : "off",
98 		fast_interrupts_enabled (regs) ? "on" : "off",
99 		processor_modes[processor_mode (regs)],
100 		thumb_mode (regs) ? " (T)" : "");
101 
102 #ifdef CONFIG_ROCKCHIP_CRASH_DUMP
103 	iomem_show_by_compatible("-cru", 0, 0x400);
104 	iomem_show_by_compatible("-pmucru", 0, 0x400);
105 	iomem_show_by_compatible("-grf", 0, 0x400);
106 	iomem_show_by_compatible("-pmugrf", 0, 0x400);
107 #endif
108 
109 	dump_core_stack(regs);
110 }
111 
112 /* fixup PC to point to the instruction leading to the exception */
fixup_pc(struct pt_regs * regs,int offset)113 static inline void fixup_pc(struct pt_regs *regs, int offset)
114 {
115 	uint32_t pc = instruction_pointer(regs) + offset;
116 	regs->ARM_pc = pc | (regs->ARM_pc & PCMASK);
117 }
118 
do_undefined_instruction(struct pt_regs * pt_regs)119 void do_undefined_instruction (struct pt_regs *pt_regs)
120 {
121 	efi_restore_gd();
122 	printf ("undefined instruction\n");
123 	fixup_pc(pt_regs, -4);
124 	show_regs (pt_regs);
125 	bad_mode ();
126 }
127 
do_software_interrupt(struct pt_regs * pt_regs)128 void do_software_interrupt (struct pt_regs *pt_regs)
129 {
130 	efi_restore_gd();
131 	printf ("software interrupt\n");
132 	fixup_pc(pt_regs, -4);
133 	show_regs (pt_regs);
134 	bad_mode ();
135 }
136 
do_prefetch_abort(struct pt_regs * pt_regs)137 void do_prefetch_abort (struct pt_regs *pt_regs)
138 {
139 	efi_restore_gd();
140 	printf ("prefetch abort\n");
141 	fixup_pc(pt_regs, -8);
142 	show_regs (pt_regs);
143 	bad_mode ();
144 }
145 
do_data_abort(struct pt_regs * pt_regs)146 void do_data_abort (struct pt_regs *pt_regs)
147 {
148 	efi_restore_gd();
149 	printf ("data abort\n");
150 	fixup_pc(pt_regs, -8);
151 	show_regs (pt_regs);
152 	bad_mode ();
153 }
154 
do_not_used(struct pt_regs * pt_regs)155 void do_not_used (struct pt_regs *pt_regs)
156 {
157 	efi_restore_gd();
158 	printf ("not used\n");
159 	fixup_pc(pt_regs, -8);
160 	show_regs (pt_regs);
161 	bad_mode ();
162 }
163 
do_fiq(struct pt_regs * pt_regs)164 void do_fiq (struct pt_regs *pt_regs)
165 {
166 	efi_restore_gd();
167 	printf ("fast interrupt request\n");
168 	fixup_pc(pt_regs, -8);
169 	show_regs (pt_regs);
170 	bad_mode ();
171 }
172 
173 #if !CONFIG_IS_ENABLED(IRQ)
do_irq(struct pt_regs * pt_regs)174 void do_irq (struct pt_regs *pt_regs)
175 {
176 	efi_restore_gd();
177 	printf ("interrupt request\n");
178 	fixup_pc(pt_regs, -8);
179 	show_regs (pt_regs);
180 	bad_mode ();
181 }
182 #endif
183