2 * (C) Copyright 2000 - 2007
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 * Derived from the MPC83xx code.
26 * This file handles the architecture-dependent parts of hardware
31 #include <asm/processor.h>
33 DECLARE_GLOBAL_DATA_PTR;
35 extern unsigned long search_exception_table(unsigned long);
38 * End of addressable memory. This may be less than the actual
39 * amount of memory on the system if we're unable to keep all
40 * the memory mapped in.
42 extern ulong get_effective_memsize(void);
43 #define END_OF_MEM (gd->bd->bi_memstart + get_effective_memsize())
46 * Trap & Exception support
50 print_backtrace (unsigned long *sp)
55 puts ("Call backtrace: ");
57 if ((uint)sp > END_OF_MEM)
65 sp = (unsigned long *) *sp;
70 void show_regs (struct pt_regs * regs)
74 printf ("NIP: %08lX XER: %08lX LR: %08lX REGS: %p TRAP: %04lx DAR: %08lX\n",
75 regs->nip, regs->xer, regs->link, regs, regs->trap, regs->dar);
76 printf ("MSR: %08lx EE: %01x PR: %01x FP: %01x ME: %01x IR/DR: %01x%01x\n",
77 regs->msr, regs->msr & MSR_EE ? 1 : 0, regs->msr & MSR_PR ? 1 : 0,
78 regs->msr & MSR_FP ? 1 : 0,regs->msr & MSR_ME ? 1 : 0,
79 regs->msr & MSR_IR ? 1 : 0,
80 regs->msr & MSR_DR ? 1 : 0);
83 for (i = 0; i < 32; i++) {
85 printf ("GPR%02d: ", i);
88 printf ("%08lX ", regs->gpr[i]);
97 _exception (int signr, struct pt_regs *regs)
100 print_backtrace ((unsigned long *)regs->gpr[1]);
101 panic ("Exception at pc %lx signal %d", regs->nip,signr);
106 MachineCheckException (struct pt_regs *regs)
110 if ((fixup = search_exception_table (regs->nip)) != 0) {
115 #ifdef CONFIG_CMD_KGDB
116 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
120 puts ("Machine check.\nCaused by (from msr): ");
121 printf ("regs %p ",regs);
122 switch (regs->msr & 0x00FF0000) {
123 case (0x80000000 >> 10):
124 puts ("Instruction cache parity signal\n");
126 case (0x80000000 >> 11):
127 puts ("Data cache parity signal\n");
129 case (0x80000000 >> 12):
130 puts ("Machine check signal\n");
132 case (0x80000000 >> 13):
133 puts ("Transfer error ack signal\n");
135 case (0x80000000 >> 14):
136 puts ("Data parity signal\n");
138 case (0x80000000 >> 15):
139 puts ("Address parity signal\n");
142 puts ("Unknown values in msr\n");
145 print_backtrace ((unsigned long *)regs->gpr[1]);
147 panic ("machine check");
151 AlignmentException (struct pt_regs *regs)
153 #ifdef CONFIG_CMD_KGDB
154 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
158 print_backtrace ((unsigned long *)regs->gpr[1]);
159 panic ("Alignment Exception");
163 ProgramCheckException (struct pt_regs *regs)
165 #ifdef CONFIG_CMD_KGDB
166 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
170 print_backtrace ((unsigned long *)regs->gpr[1]);
171 panic ("Program Check Exception");
175 SoftEmuException (struct pt_regs *regs)
177 #ifdef 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 UnknownException (struct pt_regs *regs)
190 #ifdef CONFIG_CMD_KGDB
191 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
194 printf ("Bad trap at PC: %lx, SR: %lx, vector=%lx\n",
195 regs->nip, regs->msr, regs->trap);
196 _exception (0, regs);
199 #ifdef CONFIG_CMD_BEDBUG
200 extern void do_bedbug_breakpoint (struct pt_regs *);
204 DebugException (struct pt_regs *regs)
206 printf ("Debugger trap at @ %lx\n", regs->nip );
208 #ifdef CONFIG_CMD_BEDBUG
209 do_bedbug_breakpoint (regs);