2
* (C) Copyright 2000 - 2007
3
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5
* Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
7
* SPDX-License-Identifier: GPL-2.0+
9
* Derived from the MPC83xx code.
13
* This file handles the architecture-dependent parts of hardware
19
#include <asm/processor.h>
21
DECLARE_GLOBAL_DATA_PTR;
23
extern unsigned long search_exception_table(unsigned long);
26
* End of addressable memory. This may be less than the actual
27
* amount of memory on the system if we're unable to keep all
28
* the memory mapped in.
30
#define END_OF_MEM (gd->bd->bi_memstart + get_effective_memsize())
33
* Trap & Exception support
36
static void print_backtrace(unsigned long *sp)
41
puts("Call backtrace: ");
43
if ((uint)sp > END_OF_MEM)
51
sp = (unsigned long *) *sp;
56
void show_regs(struct pt_regs *regs)
60
printf("NIP: %08lX XER: %08lX LR: %08lX REGS: %p TRAP: %04lx DAR: %08lX\n",
61
regs->nip, regs->xer, regs->link, regs, regs->trap, regs->dar);
62
printf("MSR: %08lx EE: %01x PR: %01x FP: %01x ME: %01x IR/DR: %01x%01x\n",
63
regs->msr, regs->msr & MSR_EE ? 1 : 0, regs->msr & MSR_PR ? 1 : 0,
64
regs->msr & MSR_FP ? 1 : 0,regs->msr & MSR_ME ? 1 : 0,
65
regs->msr & MSR_IR ? 1 : 0,
66
regs->msr & MSR_DR ? 1 : 0);
69
for (i = 0; i < 32; i++) {
71
printf("GPR%02d: ", i);
74
printf("%08lX ", regs->gpr[i]);
82
static void _exception(int signr, struct pt_regs *regs)
85
print_backtrace((unsigned long *)regs->gpr[1]);
86
panic("Exception at pc %lx signal %d", regs->nip, signr);
90
void MachineCheckException(struct pt_regs *regs)
92
unsigned long fixup = search_exception_table(regs->nip);
99
#ifdef CONFIG_CMD_KGDB
100
if (debugger_exception_handler && (*debugger_exception_handler)(regs))
104
puts("Machine check.\nCaused by (from msr): ");
105
printf("regs %p ", regs);
106
switch (regs->msr & 0x00FF0000) {
107
case (0x80000000 >> 10):
108
puts("Instruction cache parity signal\n");
110
case (0x80000000 >> 11):
111
puts("Data cache parity signal\n");
113
case (0x80000000 >> 12):
114
puts("Machine check signal\n");
116
case (0x80000000 >> 13):
117
puts("Transfer error ack signal\n");
119
case (0x80000000 >> 14):
120
puts("Data parity signal\n");
122
case (0x80000000 >> 15):
123
puts("Address parity signal\n");
126
puts("Unknown values in msr\n");
129
print_backtrace((unsigned long *)regs->gpr[1]);
131
panic("machine check");
134
void AlignmentException(struct pt_regs *regs)
136
#ifdef CONFIG_CMD_KGDB
137
if (debugger_exception_handler && (*debugger_exception_handler)(regs))
141
print_backtrace((unsigned long *)regs->gpr[1]);
142
panic("Alignment Exception");
145
void ProgramCheckException(struct pt_regs *regs)
147
#ifdef CONFIG_CMD_KGDB
148
if (debugger_exception_handler && (*debugger_exception_handler)(regs))
152
print_backtrace((unsigned long *)regs->gpr[1]);
153
panic("Program Check Exception");
156
void SoftEmuException(struct pt_regs *regs)
158
#ifdef CONFIG_CMD_KGDB
159
if (debugger_exception_handler && (*debugger_exception_handler)(regs))
163
print_backtrace((unsigned long *)regs->gpr[1]);
164
panic("Software Emulation Exception");
168
void UnknownException(struct pt_regs *regs)
170
#ifdef CONFIG_CMD_KGDB
171
if (debugger_exception_handler && (*debugger_exception_handler)(regs))
174
printf("Bad trap at PC: %lx, SR: %lx, vector=%lx\n",
175
regs->nip, regs->msr, regs->trap);
179
#ifdef CONFIG_CMD_BEDBUG
180
extern void do_bedbug_breakpoint(struct pt_regs *);
183
void DebugException(struct pt_regs *regs)
185
printf("Debugger trap at @ %lx\n", regs->nip);
187
#ifdef CONFIG_CMD_BEDBUG
188
do_bedbug_breakpoint(regs);