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)
49 sp = (unsigned long *)*sp;
54 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, regs->msr&MSR_PR ? 1 : 0,
62 regs->msr & MSR_FP ? 1 : 0,regs->msr&MSR_ME ? 1 : 0,
63 regs->msr&MSR_IR ? 1 : 0,
64 regs->msr&MSR_DR ? 1 : 0);
67 for (i = 0; i < 32; i++) {
70 printf("GPR%02d: ", i);
73 printf("%08lX ", regs->gpr[i]);
82 static void _exception(int signr, struct pt_regs *regs)
85 print_backtrace((unsigned long *)regs->gpr[1]);
86 panic("Exception in kernel pc %lx signal %d",regs->nip,signr);
89 void MachineCheckException(struct pt_regs *regs)
93 /* Probing PCI using config cycles cause this exception
94 * when a device is not present. Catch it and return to
95 * the PCI exception handler.
97 if ((fixup = search_exception_table(regs->nip)) != 0) {
102 printf("Machine check in kernel mode.\n");
103 printf("Caused by (from msr): ");
104 printf("regs %p ",regs);
105 switch( regs->msr & 0x000F0000) {
106 case (0x80000000>>12):
107 printf("Machine check signal - probably due to mm fault\n"
110 case (0x80000000>>13):
111 printf("Transfer error ack signal\n");
113 case (0x80000000>>14):
114 printf("Data parity signal\n");
116 case (0x80000000>>15):
117 printf("Address parity signal\n");
120 printf("Unknown values in msr\n");
123 print_backtrace((unsigned long *)regs->gpr[1]);
124 panic("machine check");
127 void AlignmentException(struct pt_regs *regs)
130 print_backtrace((unsigned long *)regs->gpr[1]);
131 panic("Alignment Exception");
134 void ProgramCheckException(struct pt_regs *regs)
137 print_backtrace((unsigned long *)regs->gpr[1]);
138 panic("Program Check Exception");
141 void SoftEmuException(struct pt_regs *regs)
144 print_backtrace((unsigned long *)regs->gpr[1]);
145 panic("Software Emulation Exception");
149 void UnknownException(struct pt_regs *regs)
151 printf("Bad trap at PC: %lx, SR: %lx, vector=%lx\n",
152 regs->nip, regs->msr, regs->trap);
156 void DebugException(struct pt_regs *regs)
158 printf("Debugger trap at @ %lx\n", regs->nip );
162 /* Probe an address by reading. If not present, return -1, otherwise
165 int addr_probe(uint *addr)