1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35#include <common.h>
36#include <command.h>
37#include <kgdb.h>
38#include <asm/processor.h>
39
40#if defined(CONFIG_CMD_BEDBUG)
41extern void do_bedbug_breakpoint(struct pt_regs *);
42#endif
43
44
45extern unsigned long search_exception_table(unsigned long);
46
47
48
49#define END_OF_MEM 0x0001000
50
51
52
53
54
55void print_backtrace(unsigned long *sp)
56{
57 int cnt = 0;
58 unsigned long i;
59
60 printf("Call backtrace: ");
61 while (sp) {
62 if ((uint)sp > END_OF_MEM)
63 break;
64
65 i = sp[1];
66 if (cnt++ % 7 == 0)
67 printf("\n");
68 printf("%08lX ", i);
69 if (cnt > 32) break;
70 sp = (unsigned long *)*sp;
71 }
72 printf("\n");
73}
74
75
76
77
78void show_regs(struct pt_regs * regs)
79{
80 int i;
81 printf("NIP: %08lX XER: %08lX LR: %08lX REGS: %p TRAP: %04lx DAR: %08lX\n",
82 regs->nip, regs->xer, regs->link, regs, regs->trap, regs->dar);
83 printf("MSR: %08lx EE: %01x PR: %01x FP: %01x ME: %01x IR/DR: %01x%01x\n",
84 regs->msr, regs->msr&MSR_EE ? 1 : 0, regs->msr&MSR_PR ? 1 : 0,
85 regs->msr & MSR_FP ? 1 : 0,regs->msr&MSR_ME ? 1 : 0,
86 regs->msr&MSR_IR ? 1 : 0,
87 regs->msr&MSR_DR ? 1 : 0);
88
89 printf("\n");
90 for (i = 0; i < 32; i++) {
91 if ((i % 8) == 0)
92 {
93 printf("GPR%02d: ", i);
94 }
95
96 printf("%08lX ", regs->gpr[i]);
97 if ((i % 8) == 7)
98 {
99 printf("\n");
100 }
101 }
102}
103
104
105
106
107
108void _exception(int signr, struct pt_regs *regs)
109{
110 show_regs(regs);
111 print_backtrace((unsigned long *)regs->gpr[1]);
112 panic("Exception in kernel pc %lx signal %d",regs->nip,signr);
113}
114
115
116
117
118void MachineCheckException(struct pt_regs *regs)
119{
120 unsigned long fixup;
121
122
123
124
125
126 if ((fixup = search_exception_table(regs->nip)) != 0) {
127 regs->nip = fixup;
128 return;
129 }
130
131#if defined(CONFIG_CMD_KGDB)
132 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
133 return;
134#endif
135
136 printf("Machine check in kernel mode.\n");
137 printf("Caused by (from msr): ");
138 printf("regs %p ",regs);
139 switch( regs->msr & 0x000F0000) {
140 case (0x80000000>>12):
141 printf("Machine check signal\n");
142 break;
143 case (0x80000000>>13):
144 printf("Transfer error ack signal\n");
145 break;
146 case (0x80000000>>14):
147 printf("Data parity signal\n");
148 break;
149 case (0x80000000>>15):
150 printf("Address parity signal\n");
151 break;
152 default:
153 printf("Unknown values in msr\n");
154 }
155 show_regs(regs);
156 print_backtrace((unsigned long *)regs->gpr[1]);
157 panic("machine check");
158}
159
160
161
162
163void AlignmentException(struct pt_regs *regs)
164{
165#if defined(CONFIG_CMD_KGDB)
166 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
167 return;
168#endif
169 show_regs(regs);
170 print_backtrace((unsigned long *)regs->gpr[1]);
171 panic("Alignment Exception");
172}
173
174
175
176
177void ProgramCheckException(struct pt_regs *regs)
178{
179#if defined(CONFIG_CMD_KGDB)
180 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
181 return;
182#endif
183 show_regs(regs);
184 print_backtrace((unsigned long *)regs->gpr[1]);
185 panic("Program Check Exception");
186}
187
188
189
190
191void SoftEmuException(struct pt_regs *regs)
192{
193#if defined(CONFIG_CMD_KGDB)
194 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
195 return;
196#endif
197 show_regs(regs);
198 print_backtrace((unsigned long *)regs->gpr[1]);
199 panic("Software Emulation Exception");
200}
201
202
203
204
205
206void UnknownException(struct pt_regs *regs)
207{
208#if defined(CONFIG_CMD_KGDB)
209 if (debugger_exception_handler && (*debugger_exception_handler)(regs))
210 return;
211#endif
212 printf("Bad trap at PC: %lx, SR: %lx, vector=%lx\n",
213 regs->nip, regs->msr, regs->trap);
214 _exception(0, regs);
215}
216
217
218
219
220void DebugException(struct pt_regs *regs)
221{
222 printf("Debugger trap at @ %lx\n", regs->nip );
223 show_regs(regs);
224#if defined(CONFIG_CMD_BEDBUG)
225 do_bedbug_breakpoint( regs );
226#endif
227}
228