]>
git.ipfire.org Git - people/ms/u-boot.git/blob - arch/powerpc/cpu/mpc824x/traps.c
2 * linux/arch/powerpc/kernel/traps.c
4 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
6 * Modified by Cort Dougan (cort@cs.nmt.edu)
7 * and Paul Mackerras (paulus@cs.anu.edu.au)
10 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
12 * SPDX-License-Identifier: GPL-2.0+
16 * This file handles the architecture-dependent parts of hardware exceptions
20 #include <asm/processor.h>
22 /* Returns 0 if exception not found and fixup otherwise. */
23 extern unsigned long search_exception_table(unsigned long);
25 /* THIS NEEDS CHANGING to use the board info structure.
27 #define END_OF_MEM 0x00400000
30 * Trap & Exception support
33 static void print_backtrace(unsigned long *sp
)
38 printf("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
++) {
69 printf("GPR%02d: ", i
);
72 printf("%08lX ", regs
->gpr
[i
]);
81 static void _exception(int signr
, struct pt_regs
*regs
)
84 print_backtrace((unsigned long *)regs
->gpr
[1]);
85 panic("Exception in kernel pc %lx signal %d",regs
->nip
,signr
);
88 void MachineCheckException(struct pt_regs
*regs
)
92 /* Probing PCI using config cycles cause this exception
93 * when a device is not present. Catch it and return to
94 * the PCI exception handler.
96 if ((fixup
= search_exception_table(regs
->nip
)) != 0) {
101 printf("Machine check in kernel mode.\n");
102 printf("Caused by (from msr): ");
103 printf("regs %p ",regs
);
104 switch( regs
->msr
& 0x000F0000) {
105 case (0x80000000>>12):
106 printf("Machine check signal - probably due to mm fault\n"
109 case (0x80000000>>13):
110 printf("Transfer error ack signal\n");
112 case (0x80000000>>14):
113 printf("Data parity signal\n");
115 case (0x80000000>>15):
116 printf("Address parity signal\n");
119 printf("Unknown values in msr\n");
122 print_backtrace((unsigned long *)regs
->gpr
[1]);
123 panic("machine check");
126 void AlignmentException(struct pt_regs
*regs
)
129 print_backtrace((unsigned long *)regs
->gpr
[1]);
130 panic("Alignment Exception");
133 void ProgramCheckException(struct pt_regs
*regs
)
136 print_backtrace((unsigned long *)regs
->gpr
[1]);
137 panic("Program Check Exception");
140 void SoftEmuException(struct pt_regs
*regs
)
143 print_backtrace((unsigned long *)regs
->gpr
[1]);
144 panic("Software Emulation Exception");
148 void UnknownException(struct pt_regs
*regs
)
150 printf("Bad trap at PC: %lx, SR: %lx, vector=%lx\n",
151 regs
->nip
, regs
->msr
, regs
->trap
);
155 #if defined(CONFIG_CMD_BEDBUG)
156 extern void do_bedbug_breakpoint(struct pt_regs
*);
159 void DebugException(struct pt_regs
*regs
)
162 printf("Debugger trap at @ %lx\n", regs
->nip
);
164 #if defined(CONFIG_CMD_BEDBUG)
165 do_bedbug_breakpoint( regs
);
169 /* Probe an address by reading. If not present, return -1, otherwise
172 int addr_probe(uint
*addr
)
177 __asm__
__volatile__( \
178 "1: lwz %0,0(%1)\n" \
182 ".section .fixup,\"ax\"\n" \
185 ".section __ex_table,\"a\"\n" \
189 : "=r" (retval
) : "r"(addr
));