1 // SPDX-License-Identifier: GPL-2.0+
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
10 * This file handles the architecture-dependent parts of hardware
17 #include <asm/processor.h>
18 #include <asm/mpc8349_pci.h>
20 DECLARE_GLOBAL_DATA_PTR;
22 /* Returns 0 if exception not found and fixup otherwise. */
23 extern unsigned long search_exception_table(unsigned long);
25 #define END_OF_MEM (gd->bd->bi_memstart + gd->bd->bi_memsize)
28 * Trap & Exception support
31 static void print_backtrace(unsigned long *sp)
36 puts ("Call backtrace: ");
38 if ((uint)sp > END_OF_MEM)
46 sp = (unsigned long *)*sp;
51 void show_regs(struct pt_regs *regs)
55 printf("NIP: %08lX XER: %08lX LR: %08lX REGS: %p TRAP: %04lx DAR: %08lX\n",
56 regs->nip, regs->xer, regs->link, regs, regs->trap, regs->dar);
57 printf("MSR: %08lx EE: %01x PR: %01x FP: %01x ME: %01x IR/DR: %01x%01x\n",
58 regs->msr, regs->msr&MSR_EE ? 1 : 0, regs->msr&MSR_PR ? 1 : 0,
59 regs->msr & MSR_FP ? 1 : 0,regs->msr&MSR_ME ? 1 : 0,
60 regs->msr&MSR_IR ? 1 : 0,
61 regs->msr&MSR_DR ? 1 : 0);
64 for (i = 0; i < 32; i++) {
66 printf("GPR%02d: ", i);
69 printf("%08lX ", regs->gpr[i]);
77 static void _exception(int signr, struct pt_regs *regs)
80 print_backtrace((unsigned long *)regs->gpr[1]);
81 panic("Exception in kernel pc %lx signal %d",regs->nip,signr);
88 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
89 printf ("PCI: err status %x err mask %x err ctrl %x\n",
90 le32_to_cpu (immap->im_pci.pci_esr),
91 le32_to_cpu (immap->im_pci.pci_emr),
92 le32_to_cpu (immap->im_pci.pci_ecr));
93 printf (" error address %x error data %x ctrl %x\n",
94 le32_to_cpu (immap->im_pci.pci_eacr),
95 le32_to_cpu (immap->im_pci.pci_edcr),
96 le32_to_cpu (immap->im_pci.pci_eccr));
101 void MachineCheckException(struct pt_regs *regs)
105 /* Probing PCI using config cycles cause this exception
106 * when a device is not present. Catch it and return to
107 * the PCI exception handler.
111 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
115 /* clear the error in the error status register */
116 if(immap->im_pci.pci_esr & cpu_to_le32(PCI_ERROR_PCI_NO_RSP)) {
117 immap->im_pci.pci_esr = cpu_to_le32(PCI_ERROR_PCI_NO_RSP);
121 #endif /* CONFIG_PCI */
122 if ((fixup = search_exception_table(regs->nip)) != 0) {
127 #if defined(CONFIG_CMD_KGDB)
128 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
132 puts ("Machine check in kernel mode.\n"
133 "Caused by (from msr): ");
134 printf("regs %p ",regs);
135 switch( regs->msr & 0x000F0000) {
136 case (0x80000000>>12):
137 puts ("Machine check signal - probably due to mm fault\n"
140 case (0x80000000>>13):
141 puts ("Transfer error ack signal\n");
143 case (0x80000000>>14):
144 puts ("Data parity signal\n");
146 case (0x80000000>>15):
147 puts ("Address parity signal\n");
150 puts ("Unknown values in msr\n");
153 print_backtrace((unsigned long *)regs->gpr[1]);
157 panic("machine check");
160 void AlignmentException(struct pt_regs *regs)
162 #if defined(CONFIG_CMD_KGDB)
163 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
167 print_backtrace((unsigned long *)regs->gpr[1]);
168 panic("Alignment Exception");
171 void ProgramCheckException(struct pt_regs *regs)
173 #if defined(CONFIG_CMD_KGDB)
174 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
178 print_backtrace((unsigned long *)regs->gpr[1]);
179 panic("Program Check Exception");
182 void SoftEmuException(struct pt_regs *regs)
184 #if defined(CONFIG_CMD_KGDB)
185 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
189 print_backtrace((unsigned long *)regs->gpr[1]);
190 panic("Software Emulation Exception");
194 void UnknownException(struct pt_regs *regs)
196 #if defined(CONFIG_CMD_KGDB)
197 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
200 printf("Bad trap at PC: %lx, SR: %lx, vector=%lx\n",
201 regs->nip, regs->msr, regs->trap);
205 #if defined(CONFIG_CMD_BEDBUG)
206 extern void do_bedbug_breakpoint(struct pt_regs *);
209 void DebugException(struct pt_regs *regs)
211 printf("Debugger trap at @ %lx\n", regs->nip );
213 #if defined(CONFIG_CMD_BEDBUG)
214 do_bedbug_breakpoint( regs );