1 // SPDX-License-Identifier: GPL-2.0+
10 * This file handles the architecture-dependent parts of hardware
15 #include <asm/global_data.h>
16 #include <asm/ptrace.h>
19 #include <asm/processor.h>
20 #include <asm/mpc8349_pci.h>
22 DECLARE_GLOBAL_DATA_PTR;
24 /* Returns 0 if exception not found and fixup otherwise. */
25 extern unsigned long search_exception_table(unsigned long);
27 #define END_OF_MEM (gd->ram_base + gd->ram_size)
30 * Trap & Exception support
33 static void print_backtrace(unsigned long *sp)
38 puts ("Call backtrace: ");
40 if ((uint)sp > END_OF_MEM)
48 sp = (unsigned long *)*sp;
53 void show_regs(struct pt_regs *regs)
57 printf("NIP: %08lX XER: %08lX LR: %08lX REGS: %p TRAP: %04lx DAR: %08lX\n",
58 regs->nip, regs->xer, regs->link, regs, regs->trap, regs->dar);
59 printf("MSR: %08lx EE: %01x PR: %01x FP: %01x ME: %01x IR/DR: %01x%01x\n",
60 regs->msr, regs->msr&MSR_EE ? 1 : 0, regs->msr&MSR_PR ? 1 : 0,
61 regs->msr & MSR_FP ? 1 : 0,regs->msr&MSR_ME ? 1 : 0,
62 regs->msr&MSR_IR ? 1 : 0,
63 regs->msr&MSR_DR ? 1 : 0);
66 for (i = 0; i < 32; i++) {
68 printf("GPR%02d: ", i);
71 printf("%08lX ", regs->gpr[i]);
79 static void _exception(int signr, struct pt_regs *regs)
82 print_backtrace((unsigned long *)regs->gpr[1]);
83 panic("Exception in kernel pc %lx signal %d",regs->nip,signr);
90 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
91 printf ("PCI: err status %x err mask %x err ctrl %x\n",
92 le32_to_cpu (immap->im_pci.pci_esr),
93 le32_to_cpu (immap->im_pci.pci_emr),
94 le32_to_cpu (immap->im_pci.pci_ecr));
95 printf (" error address %x error data %x ctrl %x\n",
96 le32_to_cpu (immap->im_pci.pci_eacr),
97 le32_to_cpu (immap->im_pci.pci_edcr),
98 le32_to_cpu (immap->im_pci.pci_eccr));
103 void MachineCheckException(struct pt_regs *regs)
107 /* Probing PCI using config cycles cause this exception
108 * when a device is not present. Catch it and return to
109 * the PCI exception handler.
113 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
117 /* clear the error in the error status register */
118 if(immap->im_pci.pci_esr & cpu_to_le32(PCI_ERROR_PCI_NO_RSP)) {
119 immap->im_pci.pci_esr = cpu_to_le32(PCI_ERROR_PCI_NO_RSP);
123 #endif /* CONFIG_PCI */
124 if ((fixup = search_exception_table(regs->nip)) != 0) {
129 #if defined(CONFIG_CMD_KGDB)
130 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
134 puts ("Machine check in kernel mode.\n"
135 "Caused by (from msr): ");
136 printf("regs %p ",regs);
137 switch( regs->msr & 0x000F0000) {
138 case (0x80000000>>12):
139 puts ("Machine check signal - probably due to mm fault\n"
142 case (0x80000000>>13):
143 puts ("Transfer error ack signal\n");
145 case (0x80000000>>14):
146 puts ("Data parity signal\n");
148 case (0x80000000>>15):
149 puts ("Address parity signal\n");
152 puts ("Unknown values in msr\n");
155 print_backtrace((unsigned long *)regs->gpr[1]);
159 panic("machine check");
162 void AlignmentException(struct pt_regs *regs)
164 #if defined(CONFIG_CMD_KGDB)
165 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
169 print_backtrace((unsigned long *)regs->gpr[1]);
170 panic("Alignment Exception");
173 void ProgramCheckException(struct pt_regs *regs)
175 #if defined(CONFIG_CMD_KGDB)
176 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
180 print_backtrace((unsigned long *)regs->gpr[1]);
181 panic("Program Check Exception");
184 void SoftEmuException(struct pt_regs *regs)
186 #if defined(CONFIG_CMD_KGDB)
187 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
191 print_backtrace((unsigned long *)regs->gpr[1]);
192 panic("Software Emulation Exception");
196 void UnknownException(struct pt_regs *regs)
198 #if defined(CONFIG_CMD_KGDB)
199 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
202 printf("Bad trap at PC: %lx, SR: %lx, vector=%lx\n",
203 regs->nip, regs->msr, regs->trap);
207 #if defined(CONFIG_CMD_BEDBUG)
208 extern void do_bedbug_breakpoint(struct pt_regs *);
211 void DebugException(struct pt_regs *regs)
213 printf("Debugger trap at @ %lx\n", regs->nip );
215 #if defined(CONFIG_CMD_BEDBUG)
216 do_bedbug_breakpoint( regs );