1 // SPDX-License-Identifier: GPL-2.0+
3 * linux/arch/powerpc/kernel/traps.c
5 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
7 * Modified by Cort Dougan (cort@cs.nmt.edu)
8 * and Paul Mackerras (paulus@cs.anu.edu.au)
11 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
15 * This file handles the architecture-dependent parts of hardware exceptions
20 #include <asm/processor.h>
22 /* Returns 0 if exception not found and fixup otherwise. */
23 extern unsigned long search_exception_table(unsigned long);
25 /* THIS NEEDS CHANGING to use the board info structure.
27 #define END_OF_MEM 0x02000000
30 * Trap & Exception support
33 static void print_backtrace(unsigned long *sp)
38 printf("Call backtrace: ");
40 if ((uint)sp > END_OF_MEM)
49 sp = (unsigned long *)*sp;
54 static void show_regs(struct pt_regs *regs)
58 printf("NIP: %08lX XER: %08lX LR: %08lX REGS: %p TRAP: %04lx DAR: %08lX\n",
59 regs->nip, regs->xer, regs->link, regs, regs->trap, regs->dar);
60 printf("MSR: %08lx EE: %01x PR: %01x FP: %01x ME: %01x IR/DR: %01x%01x\n",
61 regs->msr, regs->msr & MSR_EE ? 1 : 0,
62 regs->msr & MSR_PR ? 1 : 0, regs->msr & MSR_FP ? 1 : 0,
63 regs->msr & MSR_ME ? 1 : 0, regs->msr & MSR_IR ? 1 : 0,
64 regs->msr & MSR_DR ? 1 : 0);
67 for (i = 0; i < 32; i++) {
69 printf("GPR%02d: ", i);
71 printf("%08lX ", regs->gpr[i]);
78 static void _exception(int signr, struct pt_regs *regs)
81 print_backtrace((unsigned long *)regs->gpr[1]);
82 panic("Exception in kernel pc %lx signal %d", regs->nip, signr);
85 void MachineCheckException(struct pt_regs *regs)
87 unsigned long fixup = search_exception_table(regs->nip);
89 /* Probing PCI using config cycles cause this exception
90 * when a device is not present. Catch it and return to
91 * the PCI exception handler.
98 printf("Machine check in kernel mode.\n");
99 printf("Caused by (from msr): ");
100 printf("regs %p ", regs);
101 switch (regs->msr & 0x000F0000) {
102 case (0x80000000 >> 12):
103 printf("Machine check signal - probably due to mm fault\n"
106 case (0x80000000 >> 13):
107 printf("Transfer error ack signal\n");
109 case (0x80000000 >> 14):
110 printf("Data parity signal\n");
112 case (0x80000000 >> 15):
113 printf("Address parity signal\n");
116 printf("Unknown values in msr\n");
119 print_backtrace((unsigned long *)regs->gpr[1]);
120 panic("machine check");
123 void AlignmentException(struct pt_regs *regs)
126 print_backtrace((unsigned long *)regs->gpr[1]);
127 panic("Alignment Exception");
130 void ProgramCheckException(struct pt_regs *regs)
133 print_backtrace((unsigned long *)regs->gpr[1]);
134 panic("Program Check Exception");
137 void SoftEmuException(struct pt_regs *regs)
140 print_backtrace((unsigned long *)regs->gpr[1]);
141 panic("Software Emulation Exception");
145 void UnknownException(struct pt_regs *regs)
147 printf("Bad trap at PC: %lx, SR: %lx, vector=%lx\n",
148 regs->nip, regs->msr, regs->trap);
152 void DebugException(struct pt_regs *regs)
154 printf("Debugger trap at @ %lx\n", regs->nip);