2 * File: arch/blackfin/kernel/traps.c
4 * Author: Hamish Macdonald
7 * Description: uses S/W interrupt 15 for the system calls
10 * Copyright 2004-2006 Analog Devices Inc.
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
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.
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.
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
30 #include <linux/uaccess.h>
31 #include <linux/interrupt.h>
32 #include <linux/module.h>
33 #include <linux/kallsyms.h>
35 #include <asm/traps.h>
36 #include <asm/cacheflush.h>
37 #include <asm/blackfin.h>
38 #include <asm/irq_handler.h>
39 #include <linux/irq.h>
40 #include <asm/trace.h>
41 #include <asm/fixed_code.h>
45 # include <linux/debugger.h>
46 # include <linux/kgdb.h>
48 # define CHK_DEBUGGER_TRAP() \
50 CHK_DEBUGGER(trapnr, sig, info.si_code, fp, ); \
52 # define CHK_DEBUGGER_TRAP_MAYBE() \
55 CHK_DEBUGGER_TRAP(); \
58 # define CHK_DEBUGGER_TRAP() do { } while (0)
59 # define CHK_DEBUGGER_TRAP_MAYBE() do { } while (0)
62 /* Initiate the event table handler */
63 void __init trap_init(void)
66 bfin_write_EVT3(trap);
70 unsigned long saved_icplb_fault_addr, saved_dcplb_fault_addr;
72 int kstack_depth_to_print = 48;
74 static void decode_address(char *buf, unsigned long address)
76 struct vm_list_struct *vml;
77 struct task_struct *p;
79 unsigned long flags, offset;
80 unsigned char in_atomic = (bfin_read_IPEND() & 0x10) || in_atomic();
82 #ifdef CONFIG_KALLSYMS
83 unsigned long symsize;
89 /* look up the address and see if we are in kernel space */
90 symname = kallsyms_lookup(address, &symsize, &offset, &modname, namebuf);
93 /* yeah! kernel space! */
96 sprintf(buf, "<0x%p> { %s%s%s%s + 0x%lx }",
97 (void *)address, delim, modname, delim, symname,
98 (unsigned long)offset);
104 /* Problem in fixed code section? */
105 if (address >= FIXED_CODE_START && address < FIXED_CODE_END) {
106 sprintf(buf, "<0x%p> /* Maybe fixed code section */", (void *)address);
110 /* Problem somewhere before the kernel start address */
111 if (address < CONFIG_BOOT_LOAD) {
112 sprintf(buf, "<0x%p> /* Maybe null pointer? */", (void *)address);
116 /* looks like we're off in user-land, so let's walk all the
117 * mappings of all our processes and see if we can't be a whee
120 write_lock_irqsave(&tasklist_lock, flags);
121 for_each_process(p) {
122 mm = (in_atomic ? p->mm : get_task_mm(p));
126 vml = mm->context.vmlist;
128 struct vm_area_struct *vma = vml->vma;
130 if (address >= vma->vm_start && address < vma->vm_end) {
132 char *name = p->comm;
133 struct file *file = vma->vm_file;
136 name = d_path(&file->f_path, _tmpbuf,
139 /* FLAT does not have its text aligned to the start of
140 * the map while FDPIC ELF does ...
143 /* before we can check flat/fdpic, we need to
144 * make sure current is valid
146 if ((unsigned long)current >= FIXED_CODE_START &&
147 !((unsigned long)current & 0x3)) {
149 (address > current->mm->start_code) &&
150 (address < current->mm->end_code))
151 offset = address - current->mm->start_code;
153 offset = (address - vma->vm_start) +
154 (vma->vm_pgoff << PAGE_SHIFT);
156 sprintf(buf, "<0x%p> [ %s + 0x%lx ]",
157 (void *)address, name, offset);
159 sprintf(buf, "<0x%p> [ %s vma:0x%lx-0x%lx]",
160 (void *)address, name,
161 vma->vm_start, vma->vm_end);
175 /* we were unable to find this address anywhere */
176 sprintf(buf, "<0x%p> /* unknown address */", (void *)address);
179 write_unlock_irqrestore(&tasklist_lock, flags);
182 asmlinkage void double_fault_c(struct pt_regs *fp)
185 oops_in_progress = 1;
186 printk(KERN_EMERG "\n" KERN_EMERG "Double Fault\n");
187 dump_bfin_process(fp);
190 panic("Double Fault - unrecoverable event\n");
194 asmlinkage void trap_c(struct pt_regs *fp)
196 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
201 unsigned long trapnr = fp->seqstat & SEQSTAT_EXCAUSE;
203 trace_buffer_save(j);
205 /* Important - be very careful dereferncing pointers - will lead to
206 * double faults if the stack has become corrupt
209 /* If the fault was caused by a kernel thread, or interrupt handler
210 * we will kernel panic, so the system reboots.
211 * If KGDB is enabled, don't set this for kernel breakpoints
214 /* TODO: check to see if we are in some sort of deferred HWERR
215 * that we should be able to recover from, not kernel panic
217 if ((bfin_read_IPEND() & 0xFFC0) && (trapnr != VEC_STEP)
219 && (trapnr != VEC_EXCPT02)
223 oops_in_progress = 1;
224 } else if (current) {
225 if (current->mm == NULL) {
227 oops_in_progress = 1;
231 /* trap_c() will be called for exceptions. During exceptions
232 * processing, the pc value should be set with retx value.
233 * With this change we can cleanup some code in signal.c- TODO
235 fp->orig_pc = fp->retx;
236 /* printk("exception: 0x%x, ipend=%x, reti=%x, retx=%x\n",
237 trapnr, fp->ipend, fp->pc, fp->retx); */
239 /* send the appropriate signal to the user program */
242 /* This table works in conjuction with the one in ./mach-common/entry.S
243 * Some exceptions are handled there (in assembly, in exception space)
244 * Some are handled here, (in C, in interrupt space)
245 * Some, like CPLB, are handled in both, where the normal path is
246 * handled in assembly/exception space, and the error path is handled
250 /* 0x00 - Linux Syscall, getting here is an error */
251 /* 0x01 - userspace gdb breakpoint, handled here */
253 info.si_code = TRAP_ILLTRAP;
255 CHK_DEBUGGER_TRAP_MAYBE();
256 /* Check if this is a breakpoint in kernel space */
257 if (fp->ipend & 0xffc0)
262 case VEC_EXCPT02 : /* gdb connection */
263 info.si_code = TRAP_ILLTRAP;
268 /* 0x02 - User Defined, Caught by default */
270 /* 0x03 - User Defined, userspace stack overflow */
272 info.si_code = SEGV_STACKFLOW;
274 printk(KERN_NOTICE EXC_0x03(KERN_NOTICE));
277 /* 0x04 - User Defined, Caught by default */
278 /* 0x05 - User Defined, Caught by default */
279 /* 0x06 - User Defined, Caught by default */
280 /* 0x07 - User Defined, Caught by default */
281 /* 0x08 - User Defined, Caught by default */
282 /* 0x09 - User Defined, Caught by default */
283 /* 0x0A - User Defined, Caught by default */
284 /* 0x0B - User Defined, Caught by default */
285 /* 0x0C - User Defined, Caught by default */
286 /* 0x0D - User Defined, Caught by default */
287 /* 0x0E - User Defined, Caught by default */
288 /* 0x0F - User Defined, Caught by default */
289 /* 0x10 HW Single step, handled here */
291 info.si_code = TRAP_STEP;
293 CHK_DEBUGGER_TRAP_MAYBE();
294 /* Check if this is a single step in kernel space */
295 if (fp->ipend & 0xffc0)
299 /* 0x11 - Trace Buffer Full, handled here */
301 info.si_code = TRAP_TRACEFLOW;
303 printk(KERN_NOTICE EXC_0x11(KERN_NOTICE));
306 /* 0x12 - Reserved, Caught by default */
307 /* 0x13 - Reserved, Caught by default */
308 /* 0x14 - Reserved, Caught by default */
309 /* 0x15 - Reserved, Caught by default */
310 /* 0x16 - Reserved, Caught by default */
311 /* 0x17 - Reserved, Caught by default */
312 /* 0x18 - Reserved, Caught by default */
313 /* 0x19 - Reserved, Caught by default */
314 /* 0x1A - Reserved, Caught by default */
315 /* 0x1B - Reserved, Caught by default */
316 /* 0x1C - Reserved, Caught by default */
317 /* 0x1D - Reserved, Caught by default */
318 /* 0x1E - Reserved, Caught by default */
319 /* 0x1F - Reserved, Caught by default */
320 /* 0x20 - Reserved, Caught by default */
321 /* 0x21 - Undefined Instruction, handled here */
323 info.si_code = ILL_ILLOPC;
325 printk(KERN_NOTICE EXC_0x21(KERN_NOTICE));
328 /* 0x22 - Illegal Instruction Combination, handled here */
330 info.si_code = ILL_ILLPARAOP;
332 printk(KERN_NOTICE EXC_0x22(KERN_NOTICE));
335 /* 0x23 - Data CPLB protection violation, handled here */
337 info.si_code = ILL_CPLB_VI;
339 printk(KERN_NOTICE EXC_0x23(KERN_NOTICE));
342 /* 0x24 - Data access misaligned, handled here */
344 info.si_code = BUS_ADRALN;
346 printk(KERN_NOTICE EXC_0x24(KERN_NOTICE));
349 /* 0x25 - Unrecoverable Event, handled here */
351 info.si_code = ILL_ILLEXCPT;
353 printk(KERN_NOTICE EXC_0x25(KERN_NOTICE));
356 /* 0x26 - Data CPLB Miss, normal case is handled in _cplb_hdr,
357 error case is handled here */
359 info.si_code = BUS_ADRALN;
361 printk(KERN_NOTICE EXC_0x26(KERN_NOTICE));
364 /* 0x27 - Data CPLB Multiple Hits - Linux Trap Zero, handled here */
366 info.si_code = ILL_CPLB_MULHIT;
368 #ifdef CONFIG_DEBUG_HUNT_FOR_ZERO
369 if (saved_dcplb_fault_addr < FIXED_CODE_START)
370 printk(KERN_NOTICE "NULL pointer access\n");
373 printk(KERN_NOTICE EXC_0x27(KERN_NOTICE));
376 /* 0x28 - Emulation Watchpoint, handled here */
378 info.si_code = TRAP_WATCHPT;
380 pr_debug(EXC_0x28(KERN_DEBUG));
381 CHK_DEBUGGER_TRAP_MAYBE();
382 /* Check if this is a watchpoint in kernel space */
383 if (fp->ipend & 0xffc0)
388 /* 0x29 - Instruction fetch access error (535 only) */
389 case VEC_ISTRU_VL: /* ADSP-BF535 only (MH) */
390 info.si_code = BUS_OPFETCH;
392 printk(KERN_NOTICE "BF535: VEC_ISTRU_VL\n");
396 /* 0x29 - Reserved, Caught by default */
398 /* 0x2A - Instruction fetch misaligned, handled here */
400 info.si_code = BUS_ADRALN;
402 printk(KERN_NOTICE EXC_0x2A(KERN_NOTICE));
405 /* 0x2B - Instruction CPLB protection violation, handled here */
407 info.si_code = ILL_CPLB_VI;
409 printk(KERN_NOTICE EXC_0x2B(KERN_NOTICE));
412 /* 0x2C - Instruction CPLB miss, handled in _cplb_hdr */
414 info.si_code = ILL_CPLB_MISS;
416 printk(KERN_NOTICE EXC_0x2C(KERN_NOTICE));
419 /* 0x2D - Instruction CPLB Multiple Hits, handled here */
420 case VEC_CPLB_I_MHIT:
421 info.si_code = ILL_CPLB_MULHIT;
423 #ifdef CONFIG_DEBUG_HUNT_FOR_ZERO
424 if (saved_icplb_fault_addr < FIXED_CODE_START)
425 printk(KERN_NOTICE "Jump to NULL address\n");
428 printk(KERN_NOTICE EXC_0x2D(KERN_NOTICE));
431 /* 0x2E - Illegal use of Supervisor Resource, handled here */
433 info.si_code = ILL_PRVOPC;
435 printk(KERN_NOTICE EXC_0x2E(KERN_NOTICE));
438 /* 0x2F - Reserved, Caught by default */
439 /* 0x30 - Reserved, Caught by default */
440 /* 0x31 - Reserved, Caught by default */
441 /* 0x32 - Reserved, Caught by default */
442 /* 0x33 - Reserved, Caught by default */
443 /* 0x34 - Reserved, Caught by default */
444 /* 0x35 - Reserved, Caught by default */
445 /* 0x36 - Reserved, Caught by default */
446 /* 0x37 - Reserved, Caught by default */
447 /* 0x38 - Reserved, Caught by default */
448 /* 0x39 - Reserved, Caught by default */
449 /* 0x3A - Reserved, Caught by default */
450 /* 0x3B - Reserved, Caught by default */
451 /* 0x3C - Reserved, Caught by default */
452 /* 0x3D - Reserved, Caught by default */
453 /* 0x3E - Reserved, Caught by default */
454 /* 0x3F - Reserved, Caught by default */
456 info.si_code = BUS_ADRALN;
458 switch (fp->seqstat & SEQSTAT_HWERRCAUSE) {
459 /* System MMR Error */
460 case (SEQSTAT_HWERRCAUSE_SYSTEM_MMR):
461 info.si_code = BUS_ADRALN;
463 printk(KERN_NOTICE HWC_x2(KERN_NOTICE));
465 /* External Memory Addressing Error */
466 case (SEQSTAT_HWERRCAUSE_EXTERN_ADDR):
467 info.si_code = BUS_ADRERR;
469 printk(KERN_NOTICE HWC_x3(KERN_NOTICE));
471 /* Performance Monitor Overflow */
472 case (SEQSTAT_HWERRCAUSE_PERF_FLOW):
473 printk(KERN_NOTICE HWC_x12(KERN_NOTICE));
475 /* RAISE 5 instruction */
476 case (SEQSTAT_HWERRCAUSE_RAISE_5):
477 printk(KERN_NOTICE HWC_x18(KERN_NOTICE));
479 default: /* Reserved */
480 printk(KERN_NOTICE HWC_default(KERN_NOTICE));
486 info.si_code = TRAP_ILLTRAP;
488 printk(KERN_EMERG "Caught Unhandled Exception, code = %08lx\n",
489 (fp->seqstat & SEQSTAT_EXCAUSE));
496 if (sig != SIGTRAP) {
498 dump_bfin_process(fp);
502 /* Print out the trace buffer if it makes sense */
503 #ifndef CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE
504 if (trapnr == VEC_CPLB_I_M || trapnr == VEC_CPLB_M)
505 printk(KERN_NOTICE "No trace since you do not have "
506 "CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE enabled\n"
510 dump_bfin_trace_buffer();
511 show_stack(current, &stack);
512 if (oops_in_progress) {
514 #ifndef CONFIG_ACCESS_CHECK
515 printk(KERN_EMERG "Please turn on "
516 "CONFIG_ACCESS_CHECK\n");
518 panic("Kernel exception");
524 info.si_addr = (void __user *)fp->pc;
525 force_sig_info(sig, &info, current);
527 trace_buffer_restore(j);
531 /* Typical exception handling routines */
533 #define EXPAND_LEN ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN) * 256 - 1)
535 void dump_bfin_trace_buffer(void)
537 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
540 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
544 trace_buffer_save(tflags);
546 printk(KERN_NOTICE "Hardware Trace:\n");
548 if (likely(bfin_read_TBUFSTAT() & TBUFCNT)) {
549 for (; bfin_read_TBUFSTAT() & TBUFCNT; i++) {
550 decode_address(buf, (unsigned long)bfin_read_TBUF());
551 printk(KERN_NOTICE "%4i Target : %s\n", i, buf);
552 decode_address(buf, (unsigned long)bfin_read_TBUF());
553 printk(KERN_NOTICE " Source : %s\n", buf);
557 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
558 if (trace_buff_offset)
559 index = trace_buff_offset/4 - 1;
563 j = (1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN) * 128;
565 decode_address(buf, software_trace_buff[index]);
566 printk(KERN_NOTICE "%4i Target : %s\n", i, buf);
570 decode_address(buf, software_trace_buff[index]);
571 printk(KERN_NOTICE " Source : %s\n", buf);
580 trace_buffer_restore(tflags);
583 EXPORT_SYMBOL(dump_bfin_trace_buffer);
585 static void show_trace(struct task_struct *tsk, unsigned long *sp)
589 printk(KERN_NOTICE "\n" KERN_NOTICE "Call Trace:\n");
591 while (!kstack_end(sp)) {
594 * If the address is either in the text segment of the
595 * kernel, or in the region which contains vmalloc'ed
596 * memory, it *may* be the address of a calling
597 * routine; if so, print it so that someone tracing
598 * down the cause of the crash will be able to figure
599 * out the call path that was taken.
601 if (kernel_text_address(addr))
605 printk(KERN_NOTICE "\n");
608 void show_stack(struct task_struct *task, unsigned long *stack)
610 unsigned long *endstack, addr;
613 /* Cannot call dump_bfin_trace_buffer() here as show_stack() is
614 * called externally in some places in the kernel.
619 stack = (unsigned long *)task->thread.ksp;
621 stack = (unsigned long *)&stack;
624 addr = (unsigned long)stack;
625 endstack = (unsigned long *)PAGE_ALIGN(addr);
627 printk(KERN_NOTICE "Stack from %08lx:", (unsigned long)stack);
628 for (i = 0; i < kstack_depth_to_print; i++) {
629 if (stack + 1 > endstack)
632 printk("\n" KERN_NOTICE " ");
633 printk(" %08lx", *stack++);
637 show_trace(task, stack);
640 void dump_stack(void)
643 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
646 trace_buffer_save(tflags);
647 dump_bfin_trace_buffer();
648 show_stack(current, &stack);
649 trace_buffer_restore(tflags);
651 EXPORT_SYMBOL(dump_stack);
653 void dump_bfin_process(struct pt_regs *fp)
655 /* We should be able to look at fp->ipend, but we don't push it on the
656 * stack all the time, so do this until we fix that */
657 unsigned int context = bfin_read_IPEND();
659 if (oops_in_progress)
660 printk(KERN_EMERG "Kernel OOPS in progress\n");
662 if (context & 0x0020 && (fp->seqstat & SEQSTAT_EXCAUSE) == VEC_HWERR)
663 printk(KERN_NOTICE "HW Error context\n");
664 else if (context & 0x0020)
665 printk(KERN_NOTICE "Deferred Exception context\n");
666 else if (context & 0x3FC0)
667 printk(KERN_NOTICE "Interrupt context\n");
668 else if (context & 0x4000)
669 printk(KERN_NOTICE "Deferred Interrupt context\n");
670 else if (context & 0x8000)
671 printk(KERN_NOTICE "Kernel process context\n");
673 /* Because we are crashing, and pointers could be bad, we check things
674 * pretty closely before we use them
676 if ((unsigned long)current >= FIXED_CODE_START &&
677 !((unsigned long)current & 0x3) && current->pid) {
678 printk(KERN_NOTICE "CURRENT PROCESS:\n");
679 if (current->comm >= (char *)FIXED_CODE_START)
680 printk(KERN_NOTICE "COMM=%s PID=%d\n",
681 current->comm, current->pid);
683 printk(KERN_NOTICE "COMM= invalid\n");
685 if (!((unsigned long)current->mm & 0x3) && (unsigned long)current->mm >= FIXED_CODE_START)
686 printk(KERN_NOTICE "TEXT = 0x%p-0x%p DATA = 0x%p-0x%p\n"
687 KERN_NOTICE " BSS = 0x%p-0x%p USER-STACK = 0x%p\n"
689 (void *)current->mm->start_code,
690 (void *)current->mm->end_code,
691 (void *)current->mm->start_data,
692 (void *)current->mm->end_data,
693 (void *)current->mm->end_data,
694 (void *)current->mm->brk,
695 (void *)current->mm->start_stack);
697 printk(KERN_NOTICE "invalid mm\n");
699 printk(KERN_NOTICE "\n" KERN_NOTICE
700 "No Valid process in current context\n");
703 void dump_bfin_mem(struct pt_regs *fp)
705 unsigned short *addr, *erraddr, val = 0, err = 0;
706 char sti = 0, buf[6];
708 erraddr = (void *)fp->pc;
710 printk(KERN_NOTICE "return address: [0x%p]; contents of:", erraddr);
712 for (addr = (unsigned short *)((unsigned long)erraddr & ~0xF) - 0x10;
713 addr < (unsigned short *)((unsigned long)erraddr & ~0xF) + 0x10;
715 if (!((unsigned long)addr & 0xF))
716 printk("\n" KERN_NOTICE "0x%p: ", addr);
718 if (get_user(val, addr)) {
719 if (addr >= (unsigned short *)L1_CODE_START &&
720 addr < (unsigned short *)(L1_CODE_START + L1_CODE_LENGTH)) {
721 dma_memcpy(&val, addr, sizeof(val));
722 sprintf(buf, "%04x", val);
723 } else if (addr >= (unsigned short *)FIXED_CODE_START &&
724 addr <= (unsigned short *)memory_start) {
725 val = bfin_read16(addr);
726 sprintf(buf, "%04x", val);
729 sprintf(buf, "????");
732 sprintf(buf, "%04x", val);
734 if (addr == erraddr) {
740 /* Do any previous instructions turn on interrupts? */
741 if (addr <= erraddr && /* in the past */
742 ((val >= 0x0040 && val <= 0x0047) || /* STI instruction */
743 val == 0x017b)) /* [SP++] = RETI */
749 /* Hardware error interrupts can be deferred */
750 if (unlikely(sti && (fp->seqstat & SEQSTAT_EXCAUSE) == VEC_HWERR &&
752 printk(KERN_NOTICE "Looks like this was a deferred error - sorry\n");
753 #ifndef CONFIG_DEBUG_HWERR
754 printk(KERN_NOTICE "The remaining message may be meaningless\n"
755 KERN_NOTICE "You should enable CONFIG_DEBUG_HWERR to get a"
756 " better idea where it came from\n");
758 /* If we are handling only one peripheral interrupt
759 * and current mm and pid are valid, and the last error
760 * was in that user space process's text area
761 * print it out - because that is where the problem exists
763 if ((!(((fp)->ipend & ~0x30) & (((fp)->ipend & ~0x30) - 1))) &&
764 (current->pid && current->mm)) {
765 /* And the last RETI points to the current userspace context */
766 if ((fp + 1)->pc >= current->mm->start_code &&
767 (fp + 1)->pc <= current->mm->end_code) {
768 printk(KERN_NOTICE "It might be better to look around here : \n");
769 printk(KERN_NOTICE "-------------------------------------------\n");
771 printk(KERN_NOTICE "-------------------------------------------\n");
778 void show_regs(struct pt_regs *fp)
781 struct irqaction *action;
785 printk(KERN_NOTICE "\n" KERN_NOTICE "SEQUENCER STATUS:\t\t%s\n", print_tainted());
786 printk(KERN_NOTICE " SEQSTAT: %08lx IPEND: %04lx SYSCFG: %04lx\n",
787 (long)fp->seqstat, fp->ipend, fp->syscfg);
788 printk(KERN_NOTICE " HWERRCAUSE: 0x%lx\n",
789 (fp->seqstat & SEQSTAT_HWERRCAUSE) >> 14);
790 printk(KERN_NOTICE " EXCAUSE : 0x%lx\n",
791 fp->seqstat & SEQSTAT_EXCAUSE);
792 for (i = 6; i <= 15 ; i++) {
793 if (fp->ipend & (1 << i)) {
794 decode_address(buf, bfin_read32(EVT0 + 4*i));
795 printk(KERN_NOTICE " physical IVG%i asserted : %s\n", i, buf);
799 /* if no interrupts are going off, don't print this out */
800 if (fp->ipend & ~0x3F) {
801 for (i = 0; i < (NR_IRQS - 1); i++) {
802 spin_lock_irqsave(&irq_desc[i].lock, flags);
803 action = irq_desc[i].action;
807 decode_address(buf, (unsigned int)action->handler);
808 printk(KERN_NOTICE " logical irq %3d mapped : %s", i, buf);
809 for (action = action->next; action; action = action->next) {
810 decode_address(buf, (unsigned int)action->handler);
815 spin_unlock_irqrestore(&irq_desc[i].lock, flags);
819 decode_address(buf, fp->rete);
820 printk(KERN_NOTICE " RETE: %s\n", buf);
821 decode_address(buf, fp->retn);
822 printk(KERN_NOTICE " RETN: %s\n", buf);
823 decode_address(buf, fp->retx);
824 printk(KERN_NOTICE " RETX: %s\n", buf);
825 decode_address(buf, fp->rets);
826 printk(KERN_NOTICE " RETS: %s\n", buf);
827 decode_address(buf, fp->pc);
828 printk(KERN_NOTICE " PC : %s\n", buf);
830 if (((long)fp->seqstat & SEQSTAT_EXCAUSE) &&
831 (((long)fp->seqstat & SEQSTAT_EXCAUSE) != VEC_HWERR)) {
832 decode_address(buf, saved_dcplb_fault_addr);
833 printk(KERN_NOTICE "DCPLB_FAULT_ADDR: %s\n", buf);
834 decode_address(buf, saved_icplb_fault_addr);
835 printk(KERN_NOTICE "ICPLB_FAULT_ADDR: %s\n", buf);
838 printk(KERN_NOTICE "\n" KERN_NOTICE "PROCESSOR STATE:\n");
839 printk(KERN_NOTICE " R0 : %08lx R1 : %08lx R2 : %08lx R3 : %08lx\n",
840 fp->r0, fp->r1, fp->r2, fp->r3);
841 printk(KERN_NOTICE " R4 : %08lx R5 : %08lx R6 : %08lx R7 : %08lx\n",
842 fp->r4, fp->r5, fp->r6, fp->r7);
843 printk(KERN_NOTICE " P0 : %08lx P1 : %08lx P2 : %08lx P3 : %08lx\n",
844 fp->p0, fp->p1, fp->p2, fp->p3);
845 printk(KERN_NOTICE " P4 : %08lx P5 : %08lx FP : %08lx SP : %08lx\n",
846 fp->p4, fp->p5, fp->fp, (long)fp);
847 printk(KERN_NOTICE " LB0: %08lx LT0: %08lx LC0: %08lx\n",
848 fp->lb0, fp->lt0, fp->lc0);
849 printk(KERN_NOTICE " LB1: %08lx LT1: %08lx LC1: %08lx\n",
850 fp->lb1, fp->lt1, fp->lc1);
851 printk(KERN_NOTICE " B0 : %08lx L0 : %08lx M0 : %08lx I0 : %08lx\n",
852 fp->b0, fp->l0, fp->m0, fp->i0);
853 printk(KERN_NOTICE " B1 : %08lx L1 : %08lx M1 : %08lx I1 : %08lx\n",
854 fp->b1, fp->l1, fp->m1, fp->i1);
855 printk(KERN_NOTICE " B2 : %08lx L2 : %08lx M2 : %08lx I2 : %08lx\n",
856 fp->b2, fp->l2, fp->m2, fp->i2);
857 printk(KERN_NOTICE " B3 : %08lx L3 : %08lx M3 : %08lx I3 : %08lx\n",
858 fp->b3, fp->l3, fp->m3, fp->i3);
859 printk(KERN_NOTICE "A0.w: %08lx A0.x: %08lx A1.w: %08lx A1.x: %08lx\n",
860 fp->a0w, fp->a0x, fp->a1w, fp->a1x);
862 printk(KERN_NOTICE "USP : %08lx ASTAT: %08lx\n",
865 printk(KERN_NOTICE "\n");
868 #ifdef CONFIG_SYS_BFIN_SPINLOCK_L1
869 asmlinkage int sys_bfin_spinlock(int *spinlock)__attribute__((l1_text));
872 asmlinkage int sys_bfin_spinlock(int *spinlock)
878 ret = get_user(tmp, spinlock);
883 put_user(tmp, spinlock);
889 int bfin_request_exception(unsigned int exception, void (*handler)(void))
891 void (*curr_handler)(void);
893 if (exception > 0x3F)
896 curr_handler = ex_table[exception];
898 if (curr_handler != ex_replaceable)
901 ex_table[exception] = handler;
905 EXPORT_SYMBOL(bfin_request_exception);
907 int bfin_free_exception(unsigned int exception, void (*handler)(void))
909 void (*curr_handler)(void);
911 if (exception > 0x3F)
914 curr_handler = ex_table[exception];
916 if (curr_handler != handler)
919 ex_table[exception] = ex_replaceable;
923 EXPORT_SYMBOL(bfin_free_exception);
925 void panic_cplb_error(int cplb_panic, struct pt_regs *fp)
927 switch (cplb_panic) {
928 case CPLB_NO_UNLOCKED:
929 printk(KERN_EMERG "All CPLBs are locked\n");
933 case CPLB_NO_ADDR_MATCH:
935 case CPLB_UNKNOWN_ERR:
936 printk(KERN_EMERG "Unknown CPLB Exception\n");
940 oops_in_progress = 1;
942 dump_bfin_process(fp);
946 panic("Unrecoverable event\n");