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
21 #include <asm/processor.h>
23 /* Returns 0 if exception not found and fixup otherwise. */
24 extern unsigned long search_exception_table(unsigned long);
26 /* THIS NEEDS CHANGING to use the board info structure.
28 #define END_OF_MEM 0x02000000
31 * Trap & Exception support
34 static void print_backtrace(unsigned long *sp)
39 printf("Call backtrace: ");
41 if ((uint)sp > END_OF_MEM)
50 sp = (unsigned long *)*sp;
55 void show_regs(struct pt_regs *regs)
59 printf("NIP: %08lX XER: %08lX LR: %08lX REGS: %p TRAP: %04lx DAR: %08lX\n",
60 regs->nip, regs->xer, regs->link, regs, regs->trap, regs->dar);
61 printf("MSR: %08lx EE: %01x PR: %01x FP: %01x ME: %01x IR/DR: %01x%01x\n",
62 regs->msr, regs->msr & MSR_EE ? 1 : 0,
63 regs->msr & MSR_PR ? 1 : 0, regs->msr & MSR_FP ? 1 : 0,
64 regs->msr & MSR_ME ? 1 : 0, regs->msr & MSR_IR ? 1 : 0,
65 regs->msr & MSR_DR ? 1 : 0);
68 for (i = 0; i < 32; i++) {
70 printf("GPR%02d: ", i);
72 printf("%08lX ", regs->gpr[i]);
79 static void _exception(int signr, struct pt_regs *regs)
82 print_backtrace((unsigned long *)regs->gpr[1]);
83 panic("Exception in kernel pc %lx signal %d", regs->nip, signr);
86 void MachineCheckException(struct pt_regs *regs)
88 unsigned long fixup = search_exception_table(regs->nip);
90 /* Probing PCI using config cycles cause this exception
91 * when a device is not present. Catch it and return to
92 * the PCI exception handler.
99 printf("Machine check in kernel mode.\n");
100 printf("Caused by (from msr): ");
101 printf("regs %p ", regs);
102 switch (regs->msr & 0x000F0000) {
103 case (0x80000000 >> 12):
104 printf("Machine check signal - probably due to mm fault\n"
107 case (0x80000000 >> 13):
108 printf("Transfer error ack signal\n");
110 case (0x80000000 >> 14):
111 printf("Data parity signal\n");
113 case (0x80000000 >> 15):
114 printf("Address parity signal\n");
117 printf("Unknown values in msr\n");
120 print_backtrace((unsigned long *)regs->gpr[1]);
121 panic("machine check");
124 void AlignmentException(struct pt_regs *regs)
127 print_backtrace((unsigned long *)regs->gpr[1]);
128 panic("Alignment Exception");
131 void ProgramCheckException(struct pt_regs *regs)
134 print_backtrace((unsigned long *)regs->gpr[1]);
135 panic("Program Check Exception");
138 void SoftEmuException(struct pt_regs *regs)
141 print_backtrace((unsigned long *)regs->gpr[1]);
142 panic("Software Emulation Exception");
146 void UnknownException(struct pt_regs *regs)
148 printf("Bad trap at PC: %lx, SR: %lx, vector=%lx\n",
149 regs->nip, regs->msr, regs->trap);
153 void DebugException(struct pt_regs *regs)
155 printf("Debugger trap at @ %lx\n", regs->nip);