initial import
[patches.git] / bfin-traps-update.patch
CommitLineData
5e993f12 1Index: arch/blackfin/kernel/traps.c
2===================================================================
3RCS file: /usr/local/src/blackfin/rsync/uclinux533/uClinux-dist/linux-2.6.x/arch/blackfin/kernel/traps.c,v
4retrieving revision 1.60
5diff -u -p -r1.60 traps.c
6--- arch/blackfin/kernel/traps.c 21 Aug 2006 10:31:28 -0000 1.60
7+++ arch/blackfin/kernel/traps.c 29 Aug 2006 22:48:11 -0000
8@@ -45,24 +45,26 @@
9 * >2 for various levels of hopefully increasingly useless information
10 */
11
12-#define TRAPS_DEBUG 1 /* Must be defined here or in in Makefile */
13+#ifndef TRAPS_DEBUG
14+# define TRAPS_DEBUG 0
15+#endif
16
17 #if (TRAPS_DEBUG > 2 )
18-#define DPRINTK3(args...) printk(args)
19+# define DPRINTK3(args...) printk(KERN_DEBUG args)
20 #else
21-#define DPRINTK3(args...)
22+# define DPRINTK3(args...)
23 #endif
24
25-#if TRAPS_DEBUG > 1
26-#define DPRINTK2(args...) printk(args)
27+#if (TRAPS_DEBUG > 1)
28+# define DPRINTK2(args...) printk(KERN_DEBUG args)
29 #else
30-#define DPRINTK2(args...)
31+# define DPRINTK2(args...)
32 #endif
33
34 #ifdef TRAPS_DEBUG
35-#define DPRINTK(args...) printk(args)
36+# define DPRINTK1(args...) printk(KERN_DEBUG args)
37 #else
38-#define DPRINTK(args...)
39+# define DPRINTK1(args...)
40 #endif
41
42 /* assembler routines */
43@@ -145,12 +147,12 @@ asmlinkage void trap_c(struct pt_regs *f
44 fp->orig_pc = fp->retx;
45
46 /* send the appropriate signal to the user program */
47- switch (fp->seqstat & 0x3f) {
48+ switch (fp->seqstat & SEQSTAT_EXCAUSE) {
49 case VEC_STEP:
50 info.si_code = TRAP_STEP;
51 sig = SIGTRAP;
52 /* Check if this is a single step in kernel space */
53- if(fp->ipend & 0xffc0)
54+ if (fp->ipend & 0xffc0)
55 return;
56 else
57 break;
58@@ -158,14 +160,14 @@ asmlinkage void trap_c(struct pt_regs *f
59 info.si_code = TRAP_ILLTRAP;
60 sig = SIGTRAP;
61 /* Check if this is a breakpoint in kernel space */
62- if(fp->ipend & 0xffc0)
63+ if (fp->ipend & 0xffc0)
64 return;
65 else
66 break;
67 case VEC_EXCPT03: /* Atomic test and set service */
68 info.si_code = SEGV_STACKFLOW;
69 sig = SIGSEGV;
70- DPRINTK(EXC_0x03);
71+ printk(KERN_EMERG EXC_0x03);
72 break;
73 case VEC_EXCPT04: /* Atomic test and set service */
74 panic("Exception 4");
75@@ -173,52 +175,53 @@ asmlinkage void trap_c(struct pt_regs *f
76 case VEC_UNDEF_I:
77 info.si_code = ILL_ILLOPC;
78 sig = SIGILL;
79- DPRINTK(EXC_0x21);
80+ printk(KERN_EMERG EXC_0x21);
81 break;
82 case VEC_OVFLOW:
83 info.si_code = TRAP_TRACEFLOW;
84 sig = SIGTRAP;
85- DPRINTK(EXC_0x11);
86+ printk(KERN_EMERG EXC_0x11);
87 break;
88 case VEC_ILGAL_I:
89 info.si_code = ILL_ILLPARAOP;
90 sig = SIGILL;
91- DPRINTK(EXC_0x22);
92+ printk(KERN_EMERG EXC_0x22);
93 break;
94 case VEC_ILL_RES:
95 info.si_code = ILL_PRVOPC;
96 sig = SIGILL;
97- DPRINTK(EXC_0x2E);
98+ printk(KERN_EMERG EXC_0x2E);
99 break;
100 case VEC_MISALI_D:
101 info.si_code = BUS_ADRALN;
102 sig = SIGBUS;
103- DPRINTK(EXC_0x24);
104- DPRINTK("DCPLB_FAULT_ADDR=%p\n", (void*)bfin_read_DCPLB_FAULT_ADDR());
105+ printk(KERN_EMERG EXC_0x24);
106+ printk(KERN_EMERG "DCPLB_FAULT_ADDR=%p\n", (void*)bfin_read_DCPLB_FAULT_ADDR());
107 break;
108 case VEC_MISALI_I:
109 info.si_code = BUS_ADRALN;
110 sig = SIGBUS;
111- DPRINTK(EXC_0x2A);
112- DPRINTK("ICPLB_FAULT_ADDR=%p\n", (void*)bfin_read_ICPLB_FAULT_ADDR());
113+ printk(KERN_EMERG EXC_0x2A);
114+ printk(KERN_EMERG "ICPLB_FAULT_ADDR=%p\n", (void*)bfin_read_ICPLB_FAULT_ADDR());
115 break;
116 case VEC_UNCOV:
117 info.si_code = ILL_ILLEXCPT;
118 sig = SIGILL;
119- DPRINTK(EXC_0x25);
120+ printk(KERN_EMERG EXC_0x25);
121 break;
122 case VEC_WATCH:
123 info.si_code = TRAP_WATCHPT;
124 sig = SIGTRAP;
125 DPRINTK3(EXC_0x28);
126 /* Check if this is a watchpoint in kernel space */
127- if(fp->ipend & 0xffc0)
128+ if (fp->ipend & 0xffc0)
129 return;
130 else
131 break;
132 case VEC_ISTRU_VL: /* ADSP-BF535 only (MH) */
133 info.si_code = BUS_OPFETCH;
134 sig = SIGBUS;
135+ printk(KERN_EMERG "BF535: VEC_ISTRU_VL\n");
136 break;
137 case VEC_CPLB_I_VL:
138 DPRINTK2(EXC_0x2B);
139@@ -229,8 +232,6 @@ asmlinkage void trap_c(struct pt_regs *f
140 DPRINTK3("DCPLB_FAULT_ADDR=%p\n", (void*)bfin_read_DCPLB_FAULT_ADDR());
141 _cplb_hdr();
142 goto nsig;
143- sig = SIGILL;
144- break;
145 case VEC_CPLB_I_M:
146 DPRINTK3(EXC_0x2C);
147 DPRINTK3("ICPLB_FAULT_ADDR=%p\n", (void*)bfin_read_ICPLB_FAULT_ADDR());
148@@ -244,18 +245,19 @@ asmlinkage void trap_c(struct pt_regs *f
149 case VEC_CPLB_I_MHIT:
150 info.si_code = ILL_CPLB_MULHIT;
151 sig = SIGILL;
152- DPRINTK3(EXC_0x2D);
153- DPRINTK3("ICPLB_FAULT_ADDR=%p\n", (void*)bfin_read_ICPLB_FAULT_ADDR());
154+ printk(KERN_EMERG EXC_0x2D);
155+ printk(KERN_EMERG "ICPLB_FAULT_ADDR=%p\n", (void*)bfin_read_ICPLB_FAULT_ADDR());
156 break;
157 case VEC_CPLB_MHIT:
158 info.si_code = ILL_CPLB_MULHIT;
159 #ifdef CONFIG_DEBUG_HUNT_FOR_ZERO
160 sig = SIGSEGV;
161+ printk(KERN_EMERG "\n\nNULL pointer access (probably)\n");
162 #else
163 sig = SIGILL;
164+ printk(KERN_EMERG EXC_0x27);
165 #endif
166- DPRINTK3(EXC_0x27);
167- DPRINTK3("DCPLB_FAULT_ADDR=%p\n", (void*)bfin_read_DCPLB_FAULT_ADDR());
168+ printk(KERN_EMERG "DCPLB_FAULT_ADDR=%p\n", (void*)bfin_read_DCPLB_FAULT_ADDR());
169 break;
170 default:
171 info.si_code = TRAP_ILLTRAP;
172@@ -270,6 +272,8 @@ asmlinkage void trap_c(struct pt_regs *f
173 unsigned long stack;
174 dump_bfin_regs(fp, (void *)fp->retx);
175 show_stack(current, &stack);
176+ if (current == NULL)
177+ panic("Kernel exception");
178 }
179 nsig:
180 trace_buffer_restore(j);
181Index: arch/blackfin/mach-common/irqpanic.c
182===================================================================
183RCS file: /usr/local/src/blackfin/rsync/uclinux533/uClinux-dist/linux-2.6.x/arch/blackfin/mach-common/irqpanic.c,v
184retrieving revision 1.17
185diff -u -p -r1.17 irqpanic.c
186--- arch/blackfin/mach-common/irqpanic.c 3 Aug 2006 17:37:12 -0000 1.17
187+++ arch/blackfin/mach-common/irqpanic.c 29 Aug 2006 20:35:23 -0000
188@@ -36,15 +36,15 @@
189
190 #include "../oprofile/op_blackfin.h"
191
192-/*********
193- * irq_panic - calls panic with string setup
194- *********/
195 #ifdef CONFIG_DEBUG_ICACHE_CHECK
196 #define L1_ICACHE_START 0xffa10000
197 #define L1_ICACHE_END 0xffa13fff
198 void irq_panic(int reason, struct pt_regs *regs) __attribute__ ((section (".text.l1")));
199 #endif
200
201+/*
202+ * irq_panic - calls panic with string setup
203+ */
204 asmlinkage void irq_panic(int reason, struct pt_regs *regs)
205 {
206 int sig = 0;
207@@ -135,31 +135,30 @@ asmlinkage void irq_panic(int reason, st
208 printk(" stack frame=0x%04x, ", (unsigned int)(unsigned long)regs);
209 printk(" bad PC=0x%04x\n", (unsigned int)regs->pc);
210 if (reason == 0x5) {
211-
212 printk("\n----------- HARDWARE ERROR -----------\n\n");
213
214 /* There is only need to check for Hardware Errors, since other
215 * EXCEPTIONS are handled in TRAPS.c (MH)
216 */
217- switch (((unsigned int)regs->seqstat) >> 14) {
218- case (0x2): /* System MMR Error */
219+ switch (regs->seqstat & SEQSTAT_HWERRCAUSE) {
220+ case (SEQSTAT_HWERRCAUSE_SYSTEM_MMR): /* System MMR Error */
221 info.si_code = BUS_ADRALN;
222 sig = SIGBUS;
223 printk(HWC_x2);
224 break;
225- case (0x3): /* External Memory Addressing Error */
226+ case (SEQSTAT_HWERRCAUSE_EXTERN_ADDR): /* External Memory Addressing Error */
227 info.si_code = BUS_ADRERR;
228 sig = SIGBUS;
229- printk(HWC_x3);
230+ printk(KERN_EMERG HWC_x3);
231 break;
232- case (0x12): /* Performance Monitor Overflow */
233- printk(HWC_x12);
234+ case (SEQSTAT_HWERRCAUSE_PERF_FLOW): /* Performance Monitor Overflow */
235+ printk(KERN_EMERG HWC_x12);
236 break;
237- case (0x18): /* RAISE 5 instruction */
238- printk(HWC_x18);
239+ case (SEQSTAT_HWERRCAUSE_RAISE_5): /* RAISE 5 instruction */
240+ printk(KERN_EMERG HWC_x18);
241 break;
242 default: /* Reserved */
243- printk(HWC_default);
244+ printk(KERN_EMERG HWC_default);
245 break;
246 }
247 }
248@@ -176,11 +175,11 @@ asmlinkage void irq_panic(int reason, st
249 }
250
251 #ifdef CONFIG_HARDWARE_PM
252-/****
253- *
254- * call the handler of Performance overflow
255- ****/
256-asmlinkage void pm_overflow(int irq, struct pt_regs *regs){
257- pm_overflow_handler(irq , regs);
258+/*
259+ * call the handler of Performance overflow
260+ */
261+asmlinkage void pm_overflow(int irq, struct pt_regs *regs)
262+{
263+ pm_overflow_handler(irq, regs);
264 }
265 #endif
266Index: include/asm-blackfin/mach-common/def_LPBlackfin.h
267===================================================================
268RCS file: /usr/local/src/blackfin/rsync/uclinux533/uClinux-dist/linux-2.6.x/include/asm-blackfin/mach-common/def_LPBlackfin.h,v
269retrieving revision 1.11
270diff -u -p -r1.11 def_LPBlackfin.h
271--- include/asm-blackfin/mach-common/def_LPBlackfin.h 3 Aug 2006 14:36:27 -0000 1.11
272+++ include/asm-blackfin/mach-common/def_LPBlackfin.h 29 Aug 2006 21:18:13 -0000
273@@ -182,29 +182,35 @@
274 #define SEQSTAT_HWERRCAUSE2_P 0x00000010 /* Last hw error cause bit 2 */
275 #define SEQSTAT_HWERRCAUSE3_P 0x00000011 /* Last hw error cause bit 3 */
276 #define SEQSTAT_HWERRCAUSE4_P 0x00000012 /* Last hw error cause bit 4 */
277-#define SEQSTAT_HWERRCAUSE5_P 0x00000013 /* Last hw error cause bit 5 */
278-#define SEQSTAT_HWERRCAUSE6_P 0x00000014 /* Last hw error cause bit 6 */
279-#define SEQSTAT_HWERRCAUSE7_P 0x00000015 /* Last hw error cause bit 7 */
280 /* Masks */
281 /* Exception cause */
282-#define SEQSTAT_EXCAUSE MK_BMSK_(SEQSTAT_EXCAUSE0_P ) | \
283- MK_BMSK_(SEQSTAT_EXCAUSE1_P ) | \
284- MK_BMSK_(SEQSTAT_EXCAUSE2_P ) | \
285- MK_BMSK_(SEQSTAT_EXCAUSE3_P ) | \
286- MK_BMSK_(SEQSTAT_EXCAUSE4_P ) | \
287- MK_BMSK_(SEQSTAT_EXCAUSE5_P ) | \
288- 0
289+#define SEQSTAT_EXCAUSE (MK_BMSK_(SEQSTAT_EXCAUSE0_P) | \
290+ MK_BMSK_(SEQSTAT_EXCAUSE1_P) | \
291+ MK_BMSK_(SEQSTAT_EXCAUSE2_P) | \
292+ MK_BMSK_(SEQSTAT_EXCAUSE3_P) | \
293+ MK_BMSK_(SEQSTAT_EXCAUSE4_P) | \
294+ MK_BMSK_(SEQSTAT_EXCAUSE5_P) | \
295+ 0)
296
297 /* Indicates whether the last reset was a software reset (=1) */
298-#define SEQSTAT_SFTRESET MK_BMSK_(SEQSTAT_SFTRESET_P )
299+#define SEQSTAT_SFTRESET (MK_BMSK_(SEQSTAT_SFTRESET_P))
300
301 /* Last hw error cause */
302-#define SEQSTAT_HWERRCAUSE MK_BMSK_(SEQSTAT_HWERRCAUSE0_P ) | \
303- MK_BMSK_(SEQSTAT_HWERRCAUSE1_P ) | \
304- MK_BMSK_(SEQSTAT_HWERRCAUSE2_P ) | \
305- MK_BMSK_(SEQSTAT_HWERRCAUSE3_P ) | \
306- MK_BMSK_(SEQSTAT_HWERRCAUSE4_P ) | \
307- 0
308+#define SEQSTAT_HWERRCAUSE (MK_BMSK_(SEQSTAT_HWERRCAUSE0_P) | \
309+ MK_BMSK_(SEQSTAT_HWERRCAUSE1_P) | \
310+ MK_BMSK_(SEQSTAT_HWERRCAUSE2_P) | \
311+ MK_BMSK_(SEQSTAT_HWERRCAUSE3_P) | \
312+ MK_BMSK_(SEQSTAT_HWERRCAUSE4_P) | \
313+ 0)
314+
315+/* Translate bits to something useful */
316+
317+/* Last hw error cause */
318+#define SEQSTAT_HWERRCAUSE_SHIFT (14)
319+#define SEQSTAT_HWERRCAUSE_SYSTEM_MMR (0x02 << SEQSTAT_HWERRCAUSE_SHIFT)
320+#define SEQSTAT_HWERRCAUSE_EXTERN_ADDR (0x03 << SEQSTAT_HWERRCAUSE_SHIFT)
321+#define SEQSTAT_HWERRCAUSE_PERF_FLOW (0x12 << SEQSTAT_HWERRCAUSE_SHIFT)
322+#define SEQSTAT_HWERRCAUSE_RAISE_5 (0x18 << SEQSTAT_HWERRCAUSE_SHIFT)
323
324 /**************************************************
325 * SYSCFG register