2 * (C) Copyright 2000 - 2007
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
7 * SPDX-License-Identifier: GPL-2.0+
9 * Derived from the MPC83xx code.
13 * This file handles the architecture-dependent parts of hardware
19 #include <asm/processor.h>
21 DECLARE_GLOBAL_DATA_PTR;
23 extern unsigned long search_exception_table(unsigned long);
26 * End of addressable memory. This may be less than the actual
27 * amount of memory on the system if we're unable to keep all
28 * the memory mapped in.
30 extern ulong get_effective_memsize(void);
31 #define END_OF_MEM (gd->bd->bi_memstart + get_effective_memsize())
34 * Trap & Exception support
37 static void print_backtrace(unsigned long *sp)
42 puts("Call backtrace: ");
44 if ((uint)sp > END_OF_MEM)
52 sp = (unsigned long *) *sp;
57 void show_regs(struct pt_regs *regs)
61 printf("NIP: %08lX XER: %08lX LR: %08lX REGS: %p TRAP: %04lx DAR: %08lX\n",
62 regs->nip, regs->xer, regs->link, regs, regs->trap, regs->dar);
63 printf("MSR: %08lx EE: %01x PR: %01x FP: %01x ME: %01x IR/DR: %01x%01x\n",
64 regs->msr, regs->msr & MSR_EE ? 1 : 0, regs->msr & MSR_PR ? 1 : 0,
65 regs->msr & MSR_FP ? 1 : 0,regs->msr & MSR_ME ? 1 : 0,
66 regs->msr & MSR_IR ? 1 : 0,
67 regs->msr & MSR_DR ? 1 : 0);
70 for (i = 0; i < 32; i++) {
72 printf("GPR%02d: ", i);
75 printf("%08lX ", regs->gpr[i]);
83 static void _exception(int signr, struct pt_regs *regs)
86 print_backtrace((unsigned long *)regs->gpr[1]);
87 panic("Exception at pc %lx signal %d", regs->nip, signr);
91 void MachineCheckException(struct pt_regs *regs)
93 unsigned long fixup = search_exception_table(regs->nip);
100 #ifdef CONFIG_CMD_KGDB
101 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
105 puts("Machine check.\nCaused by (from msr): ");
106 printf("regs %p ", regs);
107 switch (regs->msr & 0x00FF0000) {
108 case (0x80000000 >> 10):
109 puts("Instruction cache parity signal\n");
111 case (0x80000000 >> 11):
112 puts("Data cache parity signal\n");
114 case (0x80000000 >> 12):
115 puts("Machine check signal\n");
117 case (0x80000000 >> 13):
118 puts("Transfer error ack signal\n");
120 case (0x80000000 >> 14):
121 puts("Data parity signal\n");
123 case (0x80000000 >> 15):
124 puts("Address parity signal\n");
127 puts("Unknown values in msr\n");
130 print_backtrace((unsigned long *)regs->gpr[1]);
132 panic("machine check");
135 void AlignmentException(struct pt_regs *regs)
137 #ifdef CONFIG_CMD_KGDB
138 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
142 print_backtrace((unsigned long *)regs->gpr[1]);
143 panic("Alignment Exception");
146 void ProgramCheckException(struct pt_regs *regs)
148 #ifdef CONFIG_CMD_KGDB
149 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
153 print_backtrace((unsigned long *)regs->gpr[1]);
154 panic("Program Check Exception");
157 void SoftEmuException(struct pt_regs *regs)
159 #ifdef CONFIG_CMD_KGDB
160 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
164 print_backtrace((unsigned long *)regs->gpr[1]);
165 panic("Software Emulation Exception");
169 void UnknownException(struct pt_regs *regs)
171 #ifdef CONFIG_CMD_KGDB
172 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
175 printf("Bad trap at PC: %lx, SR: %lx, vector=%lx\n",
176 regs->nip, regs->msr, regs->trap);
180 #ifdef CONFIG_CMD_BEDBUG
181 extern void do_bedbug_breakpoint(struct pt_regs *);
184 void DebugException(struct pt_regs *regs)
186 printf("Debugger trap at @ %lx\n", regs->nip);
188 #ifdef CONFIG_CMD_BEDBUG
189 do_bedbug_breakpoint(regs);