2 * linux/arch/powerpc/kernel/traps.c
4 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
6 * Modified by Cort Dougan (cort@cs.nmt.edu)
7 * and Paul Mackerras (paulus@cs.anu.edu.au)
10 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
12 * SPDX-License-Identifier: GPL-2.0+
16 * This file handles the architecture-dependent parts of hardware exceptions
22 #include <asm/processor.h>
24 #if defined(CONFIG_CMD_BEDBUG)
25 extern void do_bedbug_breakpoint(struct pt_regs
*);
28 /* Returns 0 if exception not found and fixup otherwise. */
29 extern unsigned long search_exception_table(unsigned long);
31 /* THIS NEEDS CHANGING to use the board info structure.
33 #define END_OF_MEM 0x0001000
37 * Print stack backtrace
39 static void print_backtrace(unsigned long *sp
)
44 printf("Call backtrace: ");
46 if ((uint
)sp
> END_OF_MEM
)
54 sp
= (unsigned long *)*sp
;
60 * Print current registers
62 void show_regs(struct pt_regs
*regs
)
65 printf("NIP: %08lX XER: %08lX LR: %08lX REGS: %p TRAP: %04lx DAR: %08lX\n",
66 regs
->nip
, regs
->xer
, regs
->link
, regs
, regs
->trap
, regs
->dar
);
67 printf("MSR: %08lx EE: %01x PR: %01x FP: %01x ME: %01x IR/DR: %01x%01x\n",
68 regs
->msr
, regs
->msr
&MSR_EE
? 1 : 0, regs
->msr
&MSR_PR
? 1 : 0,
69 regs
->msr
& MSR_FP
? 1 : 0,regs
->msr
&MSR_ME
? 1 : 0,
70 regs
->msr
&MSR_IR
? 1 : 0,
71 regs
->msr
&MSR_DR
? 1 : 0);
74 for (i
= 0; i
< 32; i
++) {
77 printf("GPR%02d: ", i
);
80 printf("%08lX ", regs
->gpr
[i
]);
90 * General exception handler routine
92 static void _exception(int signr
, struct pt_regs
*regs
)
95 print_backtrace((unsigned long *)regs
->gpr
[1]);
96 panic("Exception in kernel pc %lx signal %d",regs
->nip
,signr
);
100 * Machine check exception handler routine
102 void MachineCheckException(struct pt_regs
*regs
)
106 /* Probing PCI using config cycles cause this exception
107 * when a device is not present. Catch it and return to
108 * the PCI exception handler.
110 if ((fixup
= search_exception_table(regs
->nip
)) != 0) {
115 #if defined(CONFIG_CMD_KGDB)
116 if (debugger_exception_handler
&& (*debugger_exception_handler
)(regs
))
120 printf("Machine check in kernel mode.\n");
121 printf("Caused by (from msr): ");
122 printf("regs %p ",regs
);
123 switch( regs
->msr
& 0x000F0000) {
124 case (0x80000000>>12):
125 printf("Machine check signal\n");
127 case (0x80000000>>13):
128 printf("Transfer error ack signal\n");
130 case (0x80000000>>14):
131 printf("Data parity signal\n");
133 case (0x80000000>>15):
134 printf("Address parity signal\n");
137 printf("Unknown values in msr\n");
140 print_backtrace((unsigned long *)regs
->gpr
[1]);
141 panic("machine check");
145 * Alignment exception handler routine
147 void AlignmentException(struct pt_regs
*regs
)
149 #if defined(CONFIG_CMD_KGDB)
150 if (debugger_exception_handler
&& (*debugger_exception_handler
)(regs
))
154 print_backtrace((unsigned long *)regs
->gpr
[1]);
155 panic("Alignment Exception");
159 * Program check exception handler routine
161 void ProgramCheckException(struct pt_regs
*regs
)
163 #if defined(CONFIG_CMD_KGDB)
164 if (debugger_exception_handler
&& (*debugger_exception_handler
)(regs
))
168 print_backtrace((unsigned long *)regs
->gpr
[1]);
169 panic("Program Check Exception");
173 * Software emulation exception handler routine
175 void SoftEmuException(struct pt_regs
*regs
)
177 #if defined(CONFIG_CMD_KGDB)
178 if (debugger_exception_handler
&& (*debugger_exception_handler
)(regs
))
182 print_backtrace((unsigned long *)regs
->gpr
[1]);
183 panic("Software Emulation Exception");
188 * Unknown exception handler routine
190 void UnknownException(struct pt_regs
*regs
)
192 #if defined(CONFIG_CMD_KGDB)
193 if (debugger_exception_handler
&& (*debugger_exception_handler
)(regs
))
196 printf("Bad trap at PC: %lx, SR: %lx, vector=%lx\n",
197 regs
->nip
, regs
->msr
, regs
->trap
);
202 * Debug exception handler routine
204 void DebugException(struct pt_regs
*regs
)
206 printf("Debugger trap at @ %lx\n", regs
->nip
);
208 #if defined(CONFIG_CMD_BEDBUG)
209 do_bedbug_breakpoint( regs
);