2 * linux/arch/ppc/kernel/traps.c
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of
7 * the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
23 * Modified by Cort Dougan (cort@cs.nmt.edu)
24 * and Paul Mackerras (paulus@cs.anu.edu.au)
27 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
29 * 20050101: Eran Liberty (liberty@freescale.com)
30 * Initial file creating (porting from 85XX & 8260)
34 * This file handles the architecture-dependent parts of hardware
40 #include <asm/processor.h>
41 #include <asm/mpc8349_pci.h>
43 /* Returns 0 if exception not found and fixup otherwise. */
44 extern unsigned long search_exception_table(unsigned long);
46 #define END_OF_MEM (gd->bd->bi_memstart + gd->bd->bi_memsize)
49 * Trap & Exception support
53 print_backtrace(unsigned long *sp
)
55 DECLARE_GLOBAL_DATA_PTR
;
59 puts ("Call backtrace: ");
61 if ((uint
)sp
> END_OF_MEM
)
69 sp
= (unsigned long *)*sp
;
74 void show_regs(struct pt_regs
* regs
)
78 printf("NIP: %08lX XER: %08lX LR: %08lX REGS: %p TRAP: %04lx DAR: %08lX\n",
79 regs
->nip
, regs
->xer
, regs
->link
, regs
, regs
->trap
, regs
->dar
);
80 printf("MSR: %08lx EE: %01x PR: %01x FP: %01x ME: %01x IR/DR: %01x%01x\n",
81 regs
->msr
, regs
->msr
&MSR_EE
? 1 : 0, regs
->msr
&MSR_PR
? 1 : 0,
82 regs
->msr
& MSR_FP
? 1 : 0,regs
->msr
&MSR_ME
? 1 : 0,
83 regs
->msr
&MSR_IR
? 1 : 0,
84 regs
->msr
&MSR_DR
? 1 : 0);
87 for (i
= 0; i
< 32; i
++) {
89 printf("GPR%02d: ", i
);
92 printf("%08lX ", regs
->gpr
[i
]);
101 _exception(int signr
, struct pt_regs
*regs
)
104 print_backtrace((unsigned long *)regs
->gpr
[1]);
105 panic("Exception in kernel pc %lx signal %d",regs
->nip
,signr
);
112 volatile immap_t *immap = (immap_t *) CFG_IMMR;
113 printf ("PCI: err status %x err mask %x err ctrl %x\n",
114 le32_to_cpu (immap->im_pci.pci_esr),
115 le32_to_cpu (immap->im_pci.pci_emr),
116 le32_to_cpu (immap->im_pci.pci_ecr));
117 printf (" error address %x error data %x ctrl %x\n",
118 le32_to_cpu (immap->im_pci.pci_eacr),
119 le32_to_cpu (immap->im_pci.pci_edcr),
120 le32_to_cpu (immap->im_pci.pci_eccr));
126 MachineCheckException(struct pt_regs
*regs
)
130 /* Probing PCI using config cycles cause this exception
131 * when a device is not present. Catch it and return to
132 * the PCI exception handler.
136 volatile immap_t
*immap
= (immap_t
*)CFG_IMMR
;
140 /* clear the error in the error status register */
141 if(immap
->im_pci
.pci_esr
& cpu_to_le32(PCI_ERROR_PCI_NO_RSP
)) {
142 immap
->im_pci
.pci_esr
= cpu_to_le32(PCI_ERROR_PCI_NO_RSP
);
146 #endif /* CONFIG_PCI */
147 if ((fixup
= search_exception_table(regs
->nip
)) != 0) {
152 #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
153 if (debugger_exception_handler
&& (*debugger_exception_handler
)(regs
))
157 puts ("Machine check in kernel mode.\n"
158 "Caused by (from msr): ");
159 printf("regs %p ",regs
);
160 switch( regs
->msr
& 0x000F0000) {
161 case (0x80000000>>12):
162 puts ("Machine check signal - probably due to mm fault\n"
165 case (0x80000000>>13):
166 puts ("Transfer error ack signal\n");
168 case (0x80000000>>14):
169 puts ("Data parity signal\n");
171 case (0x80000000>>15):
172 puts ("Address parity signal\n");
175 puts ("Unknown values in msr\n");
178 print_backtrace((unsigned long *)regs
->gpr
[1]);
182 panic("machine check");
186 AlignmentException(struct pt_regs
*regs
)
188 #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
189 if (debugger_exception_handler
&& (*debugger_exception_handler
)(regs
))
193 print_backtrace((unsigned long *)regs
->gpr
[1]);
194 panic("Alignment Exception");
198 ProgramCheckException(struct pt_regs
*regs
)
200 #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
201 if (debugger_exception_handler
&& (*debugger_exception_handler
)(regs
))
205 print_backtrace((unsigned long *)regs
->gpr
[1]);
206 panic("Program Check Exception");
210 SoftEmuException(struct pt_regs
*regs
)
212 #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
213 if (debugger_exception_handler
&& (*debugger_exception_handler
)(regs
))
217 print_backtrace((unsigned long *)regs
->gpr
[1]);
218 panic("Software Emulation Exception");
223 UnknownException(struct pt_regs
*regs
)
225 #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
226 if (debugger_exception_handler
&& (*debugger_exception_handler
)(regs
))
229 printf("Bad trap at PC: %lx, SR: %lx, vector=%lx\n",
230 regs
->nip
, regs
->msr
, regs
->trap
);
234 #if (CONFIG_COMMANDS & CFG_CMD_BEDBUG)
235 extern void do_bedbug_breakpoint(struct pt_regs
*);
239 DebugException(struct pt_regs
*regs
)
241 printf("Debugger trap at @ %lx\n", regs
->nip
);
243 #if (CONFIG_COMMANDS & CFG_CMD_BEDBUG)
244 do_bedbug_breakpoint( regs
);
248 /* Probe an address by reading. If not present, return -1, otherwise
252 addr_probe(uint
*addr
)
257 __asm__
__volatile__( \
258 "1: lwz %0,0(%1)\n" \
262 ".section .fixup,\"ax\"\n" \
265 ".section __ex_table,\"a\"\n" \
269 : "=r" (retval
) : "r"(addr
));