3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
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,
24 * This file handles the architecture-dependent parts of hardware
31 #include <asm/processor.h>
32 #include <asm/mpc8349_pci.h>
34 DECLARE_GLOBAL_DATA_PTR;
36 /* Returns 0 if exception not found and fixup otherwise. */
37 extern unsigned long search_exception_table(unsigned long);
39 #define END_OF_MEM (gd->bd->bi_memstart + gd->bd->bi_memsize)
42 * Trap & Exception support
46 print_backtrace(unsigned long *sp)
51 puts ("Call backtrace: ");
53 if ((uint)sp > END_OF_MEM)
61 sp = (unsigned long *)*sp;
66 void show_regs(struct pt_regs * regs)
70 printf("NIP: %08lX XER: %08lX LR: %08lX REGS: %p TRAP: %04lx DAR: %08lX\n",
71 regs->nip, regs->xer, regs->link, regs, regs->trap, regs->dar);
72 printf("MSR: %08lx EE: %01x PR: %01x FP: %01x ME: %01x IR/DR: %01x%01x\n",
73 regs->msr, regs->msr&MSR_EE ? 1 : 0, regs->msr&MSR_PR ? 1 : 0,
74 regs->msr & MSR_FP ? 1 : 0,regs->msr&MSR_ME ? 1 : 0,
75 regs->msr&MSR_IR ? 1 : 0,
76 regs->msr&MSR_DR ? 1 : 0);
79 for (i = 0; i < 32; i++) {
81 printf("GPR%02d: ", i);
84 printf("%08lX ", regs->gpr[i]);
93 _exception(int signr, struct pt_regs *regs)
96 print_backtrace((unsigned long *)regs->gpr[1]);
97 panic("Exception in kernel pc %lx signal %d",regs->nip,signr);
104 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
105 printf ("PCI: err status %x err mask %x err ctrl %x\n",
106 le32_to_cpu (immap->im_pci.pci_esr),
107 le32_to_cpu (immap->im_pci.pci_emr),
108 le32_to_cpu (immap->im_pci.pci_ecr));
109 printf (" error address %x error data %x ctrl %x\n",
110 le32_to_cpu (immap->im_pci.pci_eacr),
111 le32_to_cpu (immap->im_pci.pci_edcr),
112 le32_to_cpu (immap->im_pci.pci_eccr));
118 MachineCheckException(struct pt_regs *regs)
122 /* Probing PCI using config cycles cause this exception
123 * when a device is not present. Catch it and return to
124 * the PCI exception handler.
128 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
132 /* clear the error in the error status register */
133 if(immap->im_pci.pci_esr & cpu_to_le32(PCI_ERROR_PCI_NO_RSP)) {
134 immap->im_pci.pci_esr = cpu_to_le32(PCI_ERROR_PCI_NO_RSP);
138 #endif /* CONFIG_PCI */
139 if ((fixup = search_exception_table(regs->nip)) != 0) {
144 #if defined(CONFIG_CMD_KGDB)
145 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
149 puts ("Machine check in kernel mode.\n"
150 "Caused by (from msr): ");
151 printf("regs %p ",regs);
152 switch( regs->msr & 0x000F0000) {
153 case (0x80000000>>12):
154 puts ("Machine check signal - probably due to mm fault\n"
157 case (0x80000000>>13):
158 puts ("Transfer error ack signal\n");
160 case (0x80000000>>14):
161 puts ("Data parity signal\n");
163 case (0x80000000>>15):
164 puts ("Address parity signal\n");
167 puts ("Unknown values in msr\n");
170 print_backtrace((unsigned long *)regs->gpr[1]);
174 panic("machine check");
178 AlignmentException(struct pt_regs *regs)
180 #if defined(CONFIG_CMD_KGDB)
181 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
185 print_backtrace((unsigned long *)regs->gpr[1]);
186 panic("Alignment Exception");
190 ProgramCheckException(struct pt_regs *regs)
192 #if defined(CONFIG_CMD_KGDB)
193 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
197 print_backtrace((unsigned long *)regs->gpr[1]);
198 panic("Program Check Exception");
202 SoftEmuException(struct pt_regs *regs)
204 #if defined(CONFIG_CMD_KGDB)
205 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
209 print_backtrace((unsigned long *)regs->gpr[1]);
210 panic("Software Emulation Exception");
215 UnknownException(struct pt_regs *regs)
217 #if defined(CONFIG_CMD_KGDB)
218 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
221 printf("Bad trap at PC: %lx, SR: %lx, vector=%lx\n",
222 regs->nip, regs->msr, regs->trap);
226 #if defined(CONFIG_CMD_BEDBUG)
227 extern void do_bedbug_breakpoint(struct pt_regs *);
231 DebugException(struct pt_regs *regs)
233 printf("Debugger trap at @ %lx\n", regs->nip );
235 #if defined(CONFIG_CMD_BEDBUG)
236 do_bedbug_breakpoint( regs );
240 /* Probe an address by reading. If not present, return -1, otherwise
244 addr_probe(uint *addr)
249 __asm__ __volatile__( \
250 "1: lwz %0,0(%1)\n" \
254 ".section .fixup,\"ax\"\n" \
257 ".section __ex_table,\"a\"\n" \
261 : "=r" (retval) : "r"(addr));