blob: aa660f32d8c823c5c749161c9cb7df8ec0756351 [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001/*
2 * File: arch/blackfin/kernel/traps.c
3 * Based on:
4 * Author: Hamish Macdonald
5 *
6 * Created:
7 * Description: uses S/W interrupt 15 for the system calls
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <asm/uaccess.h>
31#include <asm/traps.h>
32#include <asm/cacheflush.h>
33#include <asm/blackfin.h>
34#include <asm/uaccess.h>
35#include <asm/irq_handler.h>
36#include <linux/interrupt.h>
37#include <linux/module.h>
38#include <linux/kallsyms.h>
39
40#ifdef CONFIG_KGDB
41# include <linux/debugger.h>
42# include <linux/kgdb.h>
43#endif
44
45/* Initiate the event table handler */
46void __init trap_init(void)
47{
48 CSYNC();
49 bfin_write_EVT3(trap);
50 CSYNC();
51}
52
53asmlinkage void trap_c(struct pt_regs *fp);
54
55int kstack_depth_to_print = 48;
56
57static int printk_address(unsigned long address)
58{
59 struct vm_list_struct *vml;
60 struct task_struct *p;
61 struct mm_struct *mm;
Mike Frysinger8a0e6652007-05-21 18:09:19 +080062 unsigned long offset;
Bryan Wu1394f032007-05-06 14:50:22 -070063
64#ifdef CONFIG_KALLSYMS
Mike Frysinger8a0e6652007-05-21 18:09:19 +080065 unsigned long symsize;
Bryan Wu1394f032007-05-06 14:50:22 -070066 const char *symname;
67 char *modname;
68 char *delim = ":";
69 char namebuf[128];
70
71 /* look up the address and see if we are in kernel space */
72 symname = kallsyms_lookup(address, &symsize, &offset, &modname, namebuf);
73
74 if (symname) {
75 /* yeah! kernel space! */
76 if (!modname)
77 modname = delim = "";
78 return printk("<0x%p> { %s%s%s%s + 0x%lx }",
79 (void*)address, delim, modname, delim, symname,
80 (unsigned long)offset);
81
82 }
83#endif
84
85 /* looks like we're off in user-land, so let's walk all the
86 * mappings of all our processes and see if we can't be a whee
87 * bit more specific
88 */
89 write_lock_irq(&tasklist_lock);
90 for_each_process(p) {
91 mm = get_task_mm(p);
92 if (!mm)
93 continue;
94
95 vml = mm->context.vmlist;
96 while (vml) {
97 struct vm_area_struct *vma = vml->vma;
98
99 if (address >= vma->vm_start && address < vma->vm_end) {
100 char *name = p->comm;
101 struct file *file = vma->vm_file;
102 if (file) {
103 char _tmpbuf[256];
104 name = d_path(file->f_dentry,
105 file->f_vfsmnt,
106 _tmpbuf,
107 sizeof(_tmpbuf));
108 }
109
Mike Frysinger8a0e6652007-05-21 18:09:19 +0800110 /* FLAT does not have its text aligned to the start of
111 * the map while FDPIC ELF does ...
112 */
113 if (current->mm &&
114 (address > current->mm->start_code) &&
115 (address < current->mm->end_code))
116 offset = address - current->mm->start_code;
117 else
118 offset = (address - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT);
119
Bryan Wu1394f032007-05-06 14:50:22 -0700120 write_unlock_irq(&tasklist_lock);
121 return printk("<0x%p> [ %s + 0x%lx ]",
Mike Frysinger8a0e6652007-05-21 18:09:19 +0800122 (void*)address, name, offset);
Bryan Wu1394f032007-05-06 14:50:22 -0700123 }
124
125 vml = vml->next;
126 }
127 }
128 write_unlock_irq(&tasklist_lock);
129
130 /* we were unable to find this address anywhere */
131 return printk("[<0x%p>]", (void*)address);
132}
133
134#define trace_buffer_save(x) \
135 do { \
136 (x) = bfin_read_TBUFCTL(); \
137 bfin_write_TBUFCTL((x) & ~TBUFEN); \
138 } while (0)
139#define trace_buffer_restore(x) \
140 do { \
141 bfin_write_TBUFCTL((x)); \
142 } while (0)
143
144asmlinkage void trap_c(struct pt_regs *fp)
145{
146 int j, sig = 0;
147 siginfo_t info;
148 unsigned long trapnr = fp->seqstat & SEQSTAT_EXCAUSE;
149
150#ifdef CONFIG_KGDB
Robin Getzc5d88d92007-06-21 11:34:16 +0800151# define CHK_DEBUGGER_TRAP() \
152 do { \
153 CHK_DEBUGGER(trapnr, sig, info.si_code, fp); \
154 } while (0)
155# define CHK_DEBUGGER_TRAP_MAYBE() \
156 do { \
157 if (kgdb_connected) \
158 CHK_DEBUGGER_TRAP(); \
159 } while (0)
Bryan Wu1394f032007-05-06 14:50:22 -0700160#else
161# define CHK_DEBUGGER_TRAP() do { } while (0)
162# define CHK_DEBUGGER_TRAP_MAYBE() do { } while (0)
163#endif
164
165 trace_buffer_save(j);
166
167 /* trap_c() will be called for exceptions. During exceptions
168 * processing, the pc value should be set with retx value.
169 * With this change we can cleanup some code in signal.c- TODO
170 */
171 fp->orig_pc = fp->retx;
172 /* printk("exception: 0x%x, ipend=%x, reti=%x, retx=%x\n",
173 trapnr, fp->ipend, fp->pc, fp->retx); */
174
175 /* send the appropriate signal to the user program */
176 switch (trapnr) {
177
178 /* This table works in conjuction with the one in ./mach-common/entry.S
179 * Some exceptions are handled there (in assembly, in exception space)
180 * Some are handled here, (in C, in interrupt space)
181 * Some, like CPLB, are handled in both, where the normal path is
182 * handled in assembly/exception space, and the error path is handled
183 * here
184 */
185
186 /* 0x00 - Linux Syscall, getting here is an error */
187 /* 0x01 - userspace gdb breakpoint, handled here */
188 case VEC_EXCPT01:
189 info.si_code = TRAP_ILLTRAP;
190 sig = SIGTRAP;
191 CHK_DEBUGGER_TRAP_MAYBE();
192 /* Check if this is a breakpoint in kernel space */
193 if (fp->ipend & 0xffc0)
194 return;
195 else
196 break;
197#ifdef CONFIG_KGDB
198 case VEC_EXCPT02 : /* gdb connection */
199 info.si_code = TRAP_ILLTRAP;
200 sig = SIGTRAP;
201 CHK_DEBUGGER_TRAP();
202 return;
203#else
204 /* 0x02 - User Defined, Caught by default */
205#endif
206 /* 0x03 - Atomic test and set */
207 case VEC_EXCPT03:
208 info.si_code = SEGV_STACKFLOW;
209 sig = SIGSEGV;
210 printk(KERN_EMERG EXC_0x03);
211 CHK_DEBUGGER_TRAP();
212 break;
213 /* 0x04 - spinlock - handled by _ex_spinlock,
214 getting here is an error */
215 /* 0x05 - User Defined, Caught by default */
216 /* 0x06 - User Defined, Caught by default */
217 /* 0x07 - User Defined, Caught by default */
218 /* 0x08 - User Defined, Caught by default */
219 /* 0x09 - User Defined, Caught by default */
220 /* 0x0A - User Defined, Caught by default */
221 /* 0x0B - User Defined, Caught by default */
222 /* 0x0C - User Defined, Caught by default */
223 /* 0x0D - User Defined, Caught by default */
224 /* 0x0E - User Defined, Caught by default */
225 /* 0x0F - User Defined, Caught by default */
226 /* 0x10 HW Single step, handled here */
227 case VEC_STEP:
228 info.si_code = TRAP_STEP;
229 sig = SIGTRAP;
230 CHK_DEBUGGER_TRAP_MAYBE();
231 /* Check if this is a single step in kernel space */
232 if (fp->ipend & 0xffc0)
233 return;
234 else
235 break;
236 /* 0x11 - Trace Buffer Full, handled here */
237 case VEC_OVFLOW:
238 info.si_code = TRAP_TRACEFLOW;
239 sig = SIGTRAP;
240 printk(KERN_EMERG EXC_0x11);
241 CHK_DEBUGGER_TRAP();
242 break;
243 /* 0x12 - Reserved, Caught by default */
244 /* 0x13 - Reserved, Caught by default */
245 /* 0x14 - Reserved, Caught by default */
246 /* 0x15 - Reserved, Caught by default */
247 /* 0x16 - Reserved, Caught by default */
248 /* 0x17 - Reserved, Caught by default */
249 /* 0x18 - Reserved, Caught by default */
250 /* 0x19 - Reserved, Caught by default */
251 /* 0x1A - Reserved, Caught by default */
252 /* 0x1B - Reserved, Caught by default */
253 /* 0x1C - Reserved, Caught by default */
254 /* 0x1D - Reserved, Caught by default */
255 /* 0x1E - Reserved, Caught by default */
256 /* 0x1F - Reserved, Caught by default */
257 /* 0x20 - Reserved, Caught by default */
258 /* 0x21 - Undefined Instruction, handled here */
259 case VEC_UNDEF_I:
260 info.si_code = ILL_ILLOPC;
261 sig = SIGILL;
262 printk(KERN_EMERG EXC_0x21);
263 CHK_DEBUGGER_TRAP();
264 break;
265 /* 0x22 - Illegal Instruction Combination, handled here */
266 case VEC_ILGAL_I:
267 info.si_code = ILL_ILLPARAOP;
268 sig = SIGILL;
269 printk(KERN_EMERG EXC_0x22);
270 CHK_DEBUGGER_TRAP();
271 break;
272 /* 0x23 - Data CPLB Protection Violation,
273 normal case is handled in _cplb_hdr */
274 case VEC_CPLB_VL:
275 info.si_code = ILL_CPLB_VI;
276 sig = SIGILL;
277 printk(KERN_EMERG EXC_0x23);
278 CHK_DEBUGGER_TRAP();
279 break;
280 /* 0x24 - Data access misaligned, handled here */
281 case VEC_MISALI_D:
282 info.si_code = BUS_ADRALN;
283 sig = SIGBUS;
284 printk(KERN_EMERG EXC_0x24);
285 CHK_DEBUGGER_TRAP();
286 break;
287 /* 0x25 - Unrecoverable Event, handled here */
288 case VEC_UNCOV:
289 info.si_code = ILL_ILLEXCPT;
290 sig = SIGILL;
291 printk(KERN_EMERG EXC_0x25);
292 CHK_DEBUGGER_TRAP();
293 break;
294 /* 0x26 - Data CPLB Miss, normal case is handled in _cplb_hdr,
295 error case is handled here */
296 case VEC_CPLB_M:
297 info.si_code = BUS_ADRALN;
298 sig = SIGBUS;
299 printk(KERN_EMERG EXC_0x26);
300 CHK_DEBUGGER_TRAP();
301 break;
302 /* 0x27 - Data CPLB Multiple Hits - Linux Trap Zero, handled here */
303 case VEC_CPLB_MHIT:
304 info.si_code = ILL_CPLB_MULHIT;
305#ifdef CONFIG_DEBUG_HUNT_FOR_ZERO
306 sig = SIGSEGV;
Robin Getzc5d88d92007-06-21 11:34:16 +0800307 printk(KERN_EMERG "\n"
308 KERN_EMERG "NULL pointer access (probably)\n");
Bryan Wu1394f032007-05-06 14:50:22 -0700309#else
310 sig = SIGILL;
311 printk(KERN_EMERG EXC_0x27);
312#endif
313 CHK_DEBUGGER_TRAP();
314 break;
315 /* 0x28 - Emulation Watchpoint, handled here */
316 case VEC_WATCH:
317 info.si_code = TRAP_WATCHPT;
318 sig = SIGTRAP;
319 pr_debug(EXC_0x28);
320 CHK_DEBUGGER_TRAP_MAYBE();
321 /* Check if this is a watchpoint in kernel space */
322 if (fp->ipend & 0xffc0)
323 return;
324 else
325 break;
326#ifdef CONFIG_BF535
327 /* 0x29 - Instruction fetch access error (535 only) */
328 case VEC_ISTRU_VL: /* ADSP-BF535 only (MH) */
329 info.si_code = BUS_OPFETCH;
330 sig = SIGBUS;
331 printk(KERN_EMERG "BF535: VEC_ISTRU_VL\n");
332 CHK_DEBUGGER_TRAP();
333 break;
334#else
335 /* 0x29 - Reserved, Caught by default */
336#endif
337 /* 0x2A - Instruction fetch misaligned, handled here */
338 case VEC_MISALI_I:
339 info.si_code = BUS_ADRALN;
340 sig = SIGBUS;
341 printk(KERN_EMERG EXC_0x2A);
342 CHK_DEBUGGER_TRAP();
343 break;
344 /* 0x2B - Instruction CPLB protection Violation,
345 handled in _cplb_hdr */
346 case VEC_CPLB_I_VL:
347 info.si_code = ILL_CPLB_VI;
348 sig = SIGILL;
349 printk(KERN_EMERG EXC_0x2B);
350 CHK_DEBUGGER_TRAP();
351 break;
352 /* 0x2C - Instruction CPLB miss, handled in _cplb_hdr */
353 case VEC_CPLB_I_M:
354 info.si_code = ILL_CPLB_MISS;
355 sig = SIGBUS;
356 printk(KERN_EMERG EXC_0x2C);
357 CHK_DEBUGGER_TRAP();
358 break;
359 /* 0x2D - Instruction CPLB Multiple Hits, handled here */
360 case VEC_CPLB_I_MHIT:
361 info.si_code = ILL_CPLB_MULHIT;
362#ifdef CONFIG_DEBUG_HUNT_FOR_ZERO
363 sig = SIGSEGV;
364 printk(KERN_EMERG "\n\nJump to address 0 - 0x0fff\n");
365#else
366 sig = SIGILL;
367 printk(KERN_EMERG EXC_0x2D);
368#endif
369 CHK_DEBUGGER_TRAP();
370 break;
371 /* 0x2E - Illegal use of Supervisor Resource, handled here */
372 case VEC_ILL_RES:
373 info.si_code = ILL_PRVOPC;
374 sig = SIGILL;
375 printk(KERN_EMERG EXC_0x2E);
376 CHK_DEBUGGER_TRAP();
377 break;
378 /* 0x2F - Reserved, Caught by default */
379 /* 0x30 - Reserved, Caught by default */
380 /* 0x31 - Reserved, Caught by default */
381 /* 0x32 - Reserved, Caught by default */
382 /* 0x33 - Reserved, Caught by default */
383 /* 0x34 - Reserved, Caught by default */
384 /* 0x35 - Reserved, Caught by default */
385 /* 0x36 - Reserved, Caught by default */
386 /* 0x37 - Reserved, Caught by default */
387 /* 0x38 - Reserved, Caught by default */
388 /* 0x39 - Reserved, Caught by default */
389 /* 0x3A - Reserved, Caught by default */
390 /* 0x3B - Reserved, Caught by default */
391 /* 0x3C - Reserved, Caught by default */
392 /* 0x3D - Reserved, Caught by default */
393 /* 0x3E - Reserved, Caught by default */
394 /* 0x3F - Reserved, Caught by default */
395 default:
396 info.si_code = TRAP_ILLTRAP;
397 sig = SIGTRAP;
398 printk(KERN_EMERG "Caught Unhandled Exception, code = %08lx\n",
399 (fp->seqstat & SEQSTAT_EXCAUSE));
400 CHK_DEBUGGER_TRAP();
401 break;
402 }
403
404 info.si_signo = sig;
405 info.si_errno = 0;
406 info.si_addr = (void *)fp->pc;
407 force_sig_info(sig, &info, current);
408 if (sig != 0 && sig != SIGTRAP) {
409 unsigned long stack;
410 dump_bfin_regs(fp, (void *)fp->retx);
411 dump_bfin_trace_buffer();
412 show_stack(current, &stack);
413 if (current->mm == NULL)
414 panic("Kernel exception");
415 }
416
417 /* if the address that we are about to return to is not valid, set it
418 * to a valid address, if we have a current application or panic
419 */
420 if (!(fp->pc <= physical_mem_end
421#if L1_CODE_LENGTH != 0
422 || (fp->pc >= L1_CODE_START &&
423 fp->pc <= (L1_CODE_START + L1_CODE_LENGTH))
424#endif
425 )) {
426 if (current->mm) {
427 fp->pc = current->mm->start_code;
428 } else {
Robin Getzc5d88d92007-06-21 11:34:16 +0800429 printk(KERN_EMERG
430 "I can't return to memory that doesn't exist"
431 " - bad things happen\n");
Bryan Wu1394f032007-05-06 14:50:22 -0700432 panic("Help - I've fallen and can't get up\n");
433 }
434 }
435
436 trace_buffer_restore(j);
437 return;
438}
439
440/* Typical exception handling routines */
441
442void dump_bfin_trace_buffer(void)
443{
444 int tflags;
445 trace_buffer_save(tflags);
446
447 if (likely(bfin_read_TBUFSTAT() & TBUFCNT)) {
448 int i;
449 printk(KERN_EMERG "Hardware Trace:\n");
450 for (i = 0; bfin_read_TBUFSTAT() & TBUFCNT; i++) {
451 printk(KERN_EMERG "%2i Target : ", i);
452 printk_address((unsigned long)bfin_read_TBUF());
453 printk("\n" KERN_EMERG " Source : ");
454 printk_address((unsigned long)bfin_read_TBUF());
455 printk("\n");
456 }
457 }
458
459 trace_buffer_restore(tflags);
460}
461EXPORT_SYMBOL(dump_bfin_trace_buffer);
462
463static void show_trace(struct task_struct *tsk, unsigned long *sp)
464{
465 unsigned long addr;
466
467 printk("\nCall Trace:");
468#ifdef CONFIG_KALLSYMS
469 printk("\n");
470#endif
471
472 while (!kstack_end(sp)) {
473 addr = *sp++;
474 /*
475 * If the address is either in the text segment of the
476 * kernel, or in the region which contains vmalloc'ed
477 * memory, it *may* be the address of a calling
478 * routine; if so, print it so that someone tracing
479 * down the cause of the crash will be able to figure
480 * out the call path that was taken.
481 */
482 if (kernel_text_address(addr))
483 print_ip_sym(addr);
484 }
485
486 printk("\n");
487}
488
489void show_stack(struct task_struct *task, unsigned long *stack)
490{
491 unsigned long *endstack, addr;
492 int i;
493
494 /* Cannot call dump_bfin_trace_buffer() here as show_stack() is
495 * called externally in some places in the kernel.
496 */
497
498 if (!stack) {
499 if (task)
500 stack = (unsigned long *)task->thread.ksp;
501 else
502 stack = (unsigned long *)&stack;
503 }
504
505 addr = (unsigned long)stack;
506 endstack = (unsigned long *)PAGE_ALIGN(addr);
507
508 printk(KERN_EMERG "Stack from %08lx:", (unsigned long)stack);
509 for (i = 0; i < kstack_depth_to_print; i++) {
510 if (stack + 1 > endstack)
511 break;
512 if (i % 8 == 0)
513 printk("\n" KERN_EMERG " ");
514 printk(" %08lx", *stack++);
515 }
516
517 show_trace(task, stack);
518}
519
520void dump_stack(void)
521{
522 unsigned long stack;
523 int tflags;
524 trace_buffer_save(tflags);
525 dump_bfin_trace_buffer();
526 show_stack(current, &stack);
527 trace_buffer_restore(tflags);
528}
529
530EXPORT_SYMBOL(dump_stack);
531
532void dump_bfin_regs(struct pt_regs *fp, void *retaddr)
533{
534 if (current->pid) {
Robin Getzc5d88d92007-06-21 11:34:16 +0800535 printk(KERN_EMERG "\n" KERN_EMERG "CURRENT PROCESS:\n"
536 KERN_EMERG "\n");
537 printk(KERN_EMERG "COMM=%s PID=%d\n",
538 current->comm, current->pid);
Bryan Wu1394f032007-05-06 14:50:22 -0700539 } else {
540 printk
Robin Getzc5d88d92007-06-21 11:34:16 +0800541 (KERN_EMERG "\n" KERN_EMERG
542 "No Valid pid - Either things are really messed up,"
543 " or you are in the kernel\n");
Bryan Wu1394f032007-05-06 14:50:22 -0700544 }
545
546 if (current->mm) {
Robin Getzc5d88d92007-06-21 11:34:16 +0800547 printk(KERN_EMERG "TEXT = 0x%p-0x%p DATA = 0x%p-0x%p\n"
Bryan Wu1394f032007-05-06 14:50:22 -0700548 "BSS = 0x%p-0x%p USER-STACK = 0x%p\n\n",
549 (void*)current->mm->start_code,
550 (void*)current->mm->end_code,
551 (void*)current->mm->start_data,
552 (void*)current->mm->end_data,
553 (void*)current->mm->end_data,
554 (void*)current->mm->brk,
555 (void*)current->mm->start_stack);
556 }
557
Robin Getzc5d88d92007-06-21 11:34:16 +0800558 printk(KERN_EMERG "return address: [0x%p]; contents of:", retaddr);
Bryan Wu1394f032007-05-06 14:50:22 -0700559 if (retaddr != 0 && retaddr <= (void*)physical_mem_end
560#if L1_CODE_LENGTH != 0
561 /* FIXME: Copy the code out of L1 Instruction SRAM through dma
562 memcpy. */
563 && !(retaddr >= (void*)L1_CODE_START
564 && retaddr < (void*)(L1_CODE_START + L1_CODE_LENGTH))
565#endif
566 ) {
Robin Getzc5d88d92007-06-21 11:34:16 +0800567 int i = ((unsigned int)retaddr & 0xFFFFFFF0) - 32;
Bryan Wu1394f032007-05-06 14:50:22 -0700568 unsigned short x = 0;
Robin Getzc5d88d92007-06-21 11:34:16 +0800569 for (; i < ((unsigned int)retaddr & 0xFFFFFFF0 ) + 32 ;
570 i += 2) {
571 if ( !(i & 0xF) )
572 printk(KERN_EMERG "\n" KERN_EMERG
573 "0x%08x: ", i);
574
575 if (get_user(x, (unsigned short *)i))
Bryan Wu1394f032007-05-06 14:50:22 -0700576 break;
577#ifndef CONFIG_DEBUG_HWERR
578 /* If one of the last few instructions was a STI
Simon Arlottd2d50aa2007-06-11 15:31:30 +0800579 * it is likely that the error occured awhile ago
Bryan Wu1394f032007-05-06 14:50:22 -0700580 * and we just noticed
581 */
582 if (x >= 0x0040 && x <= 0x0047 && i <= 0)
Robin Getzc5d88d92007-06-21 11:34:16 +0800583 panic("\n\nWARNING : You should reconfigure"
584 " the kernel to turn on\n"
585 " 'Hardware error interrupt"
586 " debugging'\n"
587 " The rest of this error"
588 " is meanless\n");
Bryan Wu1394f032007-05-06 14:50:22 -0700589#endif
Robin Getzc5d88d92007-06-21 11:34:16 +0800590 if ( i == (unsigned int)retaddr )
591 printk("[%04x]", x);
592 else
593 printk(" %04x ", x);
Bryan Wu1394f032007-05-06 14:50:22 -0700594 }
Robin Getzc5d88d92007-06-21 11:34:16 +0800595 printk("\n" KERN_EMERG "\n");
Bryan Wu1394f032007-05-06 14:50:22 -0700596 } else
Robin Getzc5d88d92007-06-21 11:34:16 +0800597 printk(KERN_EMERG
598 "Cannot look at the [PC] for it is"
599 "in unreadable L1 SRAM - sorry\n");
Bryan Wu1394f032007-05-06 14:50:22 -0700600
Bryan Wu1394f032007-05-06 14:50:22 -0700601
Robin Getzc5d88d92007-06-21 11:34:16 +0800602 printk(KERN_EMERG
603 "RETE: %08lx RETN: %08lx RETX: %08lx RETS: %08lx\n",
604 fp->rete, fp->retn, fp->retx, fp->rets);
605 printk(KERN_EMERG "IPEND: %04lx SYSCFG: %04lx\n",
606 fp->ipend, fp->syscfg);
607 printk(KERN_EMERG "SEQSTAT: %08lx SP: %08lx\n",
608 (long)fp->seqstat, (long)fp);
609 printk(KERN_EMERG "R0: %08lx R1: %08lx R2: %08lx R3: %08lx\n",
610 fp->r0, fp->r1, fp->r2, fp->r3);
611 printk(KERN_EMERG "R4: %08lx R5: %08lx R6: %08lx R7: %08lx\n",
612 fp->r4, fp->r5, fp->r6, fp->r7);
613 printk(KERN_EMERG "P0: %08lx P1: %08lx P2: %08lx P3: %08lx\n",
614 fp->p0, fp->p1, fp->p2, fp->p3);
615 printk(KERN_EMERG
616 "P4: %08lx P5: %08lx FP: %08lx\n",
617 fp->p4, fp->p5, fp->fp);
618 printk(KERN_EMERG
619 "A0.w: %08lx A0.x: %08lx A1.w: %08lx A1.x: %08lx\n",
620 fp->a0w, fp->a0x, fp->a1w, fp->a1x);
Bryan Wu1394f032007-05-06 14:50:22 -0700621
Robin Getzc5d88d92007-06-21 11:34:16 +0800622 printk(KERN_EMERG "LB0: %08lx LT0: %08lx LC0: %08lx\n",
623 fp->lb0, fp->lt0, fp->lc0);
624 printk(KERN_EMERG "LB1: %08lx LT1: %08lx LC1: %08lx\n",
625 fp->lb1, fp->lt1, fp->lc1);
626 printk(KERN_EMERG "B0: %08lx L0: %08lx M0: %08lx I0: %08lx\n",
627 fp->b0, fp->l0, fp->m0, fp->i0);
628 printk(KERN_EMERG "B1: %08lx L1: %08lx M1: %08lx I1: %08lx\n",
629 fp->b1, fp->l1, fp->m1, fp->i1);
630 printk(KERN_EMERG "B2: %08lx L2: %08lx M2: %08lx I2: %08lx\n",
631 fp->b2, fp->l2, fp->m2, fp->i2);
632 printk(KERN_EMERG "B3: %08lx L3: %08lx M3: %08lx I3: %08lx\n",
633 fp->b3, fp->l3, fp->m3, fp->i3);
Bryan Wu1394f032007-05-06 14:50:22 -0700634
Robin Getzc5d88d92007-06-21 11:34:16 +0800635 printk(KERN_EMERG "\n" KERN_EMERG "USP: %08lx ASTAT: %08lx\n",
636 rdusp(), fp->astat);
Bryan Wu1394f032007-05-06 14:50:22 -0700637 if ((long)fp->seqstat & SEQSTAT_EXCAUSE) {
Robin Getzc5d88d92007-06-21 11:34:16 +0800638 printk(KERN_EMERG "DCPLB_FAULT_ADDR=%p\n",
639 (void *)bfin_read_DCPLB_FAULT_ADDR());
640 printk(KERN_EMERG "ICPLB_FAULT_ADDR=%p\n",
641 (void *)bfin_read_ICPLB_FAULT_ADDR());
Bryan Wu1394f032007-05-06 14:50:22 -0700642 }
643
644 printk("\n\n");
645}
646
647#ifdef CONFIG_SYS_BFIN_SPINLOCK_L1
648asmlinkage int sys_bfin_spinlock(int *spinlock)__attribute__((l1_text));
649#endif
650
651asmlinkage int sys_bfin_spinlock(int *spinlock)
652{
653 int ret = 0;
654 int tmp = 0;
655
656 local_irq_disable();
657 ret = get_user(tmp, spinlock);
658 if (ret == 0) {
659 if (tmp)
660 ret = 1;
661 tmp = 1;
662 put_user(tmp, spinlock);
663 }
664 local_irq_enable();
665 return ret;
666}
667
668void panic_cplb_error(int cplb_panic, struct pt_regs *fp)
669{
670 switch (cplb_panic) {
671 case CPLB_NO_UNLOCKED:
672 printk(KERN_EMERG "All CPLBs are locked\n");
673 break;
674 case CPLB_PROT_VIOL:
675 return;
676 case CPLB_NO_ADDR_MATCH:
677 return;
678 case CPLB_UNKNOWN_ERR:
679 printk(KERN_EMERG "Unknown CPLB Exception\n");
680 break;
681 }
682
683 printk(KERN_EMERG "DCPLB_FAULT_ADDR=%p\n", (void*)bfin_read_DCPLB_FAULT_ADDR());
684 printk(KERN_EMERG "ICPLB_FAULT_ADDR=%p\n", (void*)bfin_read_ICPLB_FAULT_ADDR());
685 dump_bfin_regs(fp, (void *)fp->retx);
686 dump_stack();
687 panic("Unrecoverable event\n");
688}