X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=arch%2Fblackfin%2Fkernel%2Ftraps.c;h=1a72a8029a34f8047fcbcceb3a59dca8221d145b;hb=4c26c6c9bf1837ef413c18055d38f0b70af8574e;hp=8766bd612b4734778492aa6b9a9b693f1e2c9ee4;hpb=6a302358d87fedaf7bda12b8e909265ebf1ce674;p=linux-2.6-omap-h63xx.git diff --git a/arch/blackfin/kernel/traps.c b/arch/blackfin/kernel/traps.c index 8766bd612b4..1a72a8029a3 100644 --- a/arch/blackfin/kernel/traps.c +++ b/arch/blackfin/kernel/traps.c @@ -31,15 +31,30 @@ #include #include #include +#include #include #include #include #include #include +#include #ifdef CONFIG_KGDB # include # include + +# define CHK_DEBUGGER_TRAP() \ + do { \ + CHK_DEBUGGER(trapnr, sig, info.si_code, fp, ); \ + } while (0) +# define CHK_DEBUGGER_TRAP_MAYBE() \ + do { \ + if (kgdb_connected) \ + CHK_DEBUGGER_TRAP(); \ + } while (0) +#else +# define CHK_DEBUGGER_TRAP() do { } while (0) +# define CHK_DEBUGGER_TRAP_MAYBE() do { } while (0) #endif /* Initiate the event table handler */ @@ -50,16 +65,15 @@ void __init trap_init(void) CSYNC(); } -asmlinkage void trap_c(struct pt_regs *fp); - int kstack_depth_to_print = 48; -static int printk_address(unsigned long address) +static void decode_address(char *buf, unsigned long address) { struct vm_list_struct *vml; struct task_struct *p; struct mm_struct *mm; - unsigned long offset; + unsigned long flags, offset; + unsigned int in_exception = bfin_read_IPEND() & 0x10; #ifdef CONFIG_KALLSYMS unsigned long symsize; @@ -75,20 +89,33 @@ static int printk_address(unsigned long address) /* yeah! kernel space! */ if (!modname) modname = delim = ""; - return printk("<0x%p> { %s%s%s%s + 0x%lx }", + sprintf(buf, "<0x%p> { %s%s%s%s + 0x%lx }", (void *)address, delim, modname, delim, symname, (unsigned long)offset); + return; } #endif + /* Problem in fixed code section? */ + if (address >= FIXED_CODE_START && address < FIXED_CODE_END) { + sprintf(buf, "<0x%p> /* Maybe fixed code section */", (void *)address); + return; + } + + /* Problem somewhere before the kernel start address */ + if (address < CONFIG_BOOT_LOAD) { + sprintf(buf, "<0x%p> /* Maybe null pointer? */", (void *)address); + return; + } + /* looks like we're off in user-land, so let's walk all the * mappings of all our processes and see if we can't be a whee * bit more specific */ - write_lock_irq(&tasklist_lock); + write_lock_irqsave(&tasklist_lock, flags); for_each_process(p) { - mm = get_task_mm(p); + mm = (in_exception ? p->mm : get_task_mm(p)); if (!mm) continue; @@ -117,42 +144,68 @@ static int printk_address(unsigned long address) else offset = (address - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT); - write_unlock_irq(&tasklist_lock); - return printk("<0x%p> [ %s + 0x%lx ]", - (void *)address, name, offset); + sprintf(buf, "<0x%p> [ %s + 0x%lx ]", + (void *)address, name, offset); + if (!in_exception) + mmput(mm); + goto done; } vml = vml->next; } + if (!in_exception) + mmput(mm); } - write_unlock_irq(&tasklist_lock); /* we were unable to find this address anywhere */ - return printk("[<0x%p>]", (void *)address); + sprintf(buf, "<0x%p> /* unknown address */", (void *)address); + +done: + write_unlock_irqrestore(&tasklist_lock, flags); +} + +asmlinkage void double_fault_c(struct pt_regs *fp) +{ + console_verbose(); + oops_in_progress = 1; + printk(KERN_EMERG "\n" KERN_EMERG "Double Fault\n"); + dump_bfin_regs(fp, (void *)fp->retx); + panic("Double Fault - unrecoverable event\n"); + } asmlinkage void trap_c(struct pt_regs *fp) { - int j, sig = 0; +#ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON + int j; +#endif + int sig = 0; siginfo_t info; unsigned long trapnr = fp->seqstat & SEQSTAT_EXCAUSE; + trace_buffer_save(j); + + /* Important - be very careful dereferncing pointers - will lead to + * double faults if the stack has become corrupt + */ + + /* If the fault was caused by a kernel thread, or interrupt handler + * we will kernel panic, so the system reboots. + * If KGDB is enabled, don't set this for kernel breakpoints + */ + if ((bfin_read_IPEND() & 0xFFC0) #ifdef CONFIG_KGDB -# define CHK_DEBUGGER_TRAP() \ - do { \ - CHK_DEBUGGER(trapnr, sig, info.si_code, fp, ); \ - } while (0) -# define CHK_DEBUGGER_TRAP_MAYBE() \ - do { \ - if (kgdb_connected) \ - CHK_DEBUGGER_TRAP(); \ - } while (0) -#else -# define CHK_DEBUGGER_TRAP() do { } while (0) -# define CHK_DEBUGGER_TRAP_MAYBE() do { } while (0) + && trapnr != VEC_EXCPT02 #endif - - trace_buffer_save(j); + ){ + console_verbose(); + oops_in_progress = 1; + } else if (current) { + if (current->mm == NULL) { + console_verbose(); + oops_in_progress = 1; + } + } /* trap_c() will be called for exceptions. During exceptions * processing, the pc value should be set with retx value. @@ -197,7 +250,7 @@ asmlinkage void trap_c(struct pt_regs *fp) case VEC_EXCPT03: info.si_code = SEGV_STACKFLOW; sig = SIGSEGV; - printk(KERN_EMERG EXC_0x03); + printk(KERN_NOTICE EXC_0x03); CHK_DEBUGGER_TRAP(); break; /* 0x04 - User Defined, Caught by default */ @@ -226,7 +279,7 @@ asmlinkage void trap_c(struct pt_regs *fp) case VEC_OVFLOW: info.si_code = TRAP_TRACEFLOW; sig = SIGTRAP; - printk(KERN_EMERG EXC_0x11); + printk(KERN_NOTICE EXC_0x11); CHK_DEBUGGER_TRAP(); break; /* 0x12 - Reserved, Caught by default */ @@ -248,36 +301,35 @@ asmlinkage void trap_c(struct pt_regs *fp) case VEC_UNDEF_I: info.si_code = ILL_ILLOPC; sig = SIGILL; - printk(KERN_EMERG EXC_0x21); + printk(KERN_NOTICE EXC_0x21); CHK_DEBUGGER_TRAP(); break; /* 0x22 - Illegal Instruction Combination, handled here */ case VEC_ILGAL_I: info.si_code = ILL_ILLPARAOP; sig = SIGILL; - printk(KERN_EMERG EXC_0x22); + printk(KERN_NOTICE EXC_0x22); CHK_DEBUGGER_TRAP(); break; - /* 0x23 - Data CPLB Protection Violation, - normal case is handled in _cplb_hdr */ + /* 0x23 - Data CPLB protection violation, handled here */ case VEC_CPLB_VL: info.si_code = ILL_CPLB_VI; - sig = SIGILL; - printk(KERN_EMERG EXC_0x23); + sig = SIGBUS; + printk(KERN_NOTICE EXC_0x23); CHK_DEBUGGER_TRAP(); break; /* 0x24 - Data access misaligned, handled here */ case VEC_MISALI_D: info.si_code = BUS_ADRALN; sig = SIGBUS; - printk(KERN_EMERG EXC_0x24); + printk(KERN_NOTICE EXC_0x24); CHK_DEBUGGER_TRAP(); break; /* 0x25 - Unrecoverable Event, handled here */ case VEC_UNCOV: info.si_code = ILL_ILLEXCPT; sig = SIGILL; - printk(KERN_EMERG EXC_0x25); + printk(KERN_NOTICE EXC_0x25); CHK_DEBUGGER_TRAP(); break; /* 0x26 - Data CPLB Miss, normal case is handled in _cplb_hdr, @@ -285,7 +337,7 @@ asmlinkage void trap_c(struct pt_regs *fp) case VEC_CPLB_M: info.si_code = BUS_ADRALN; sig = SIGBUS; - printk(KERN_EMERG EXC_0x26); + printk(KERN_NOTICE EXC_0x26); CHK_DEBUGGER_TRAP(); break; /* 0x27 - Data CPLB Multiple Hits - Linux Trap Zero, handled here */ @@ -293,11 +345,10 @@ asmlinkage void trap_c(struct pt_regs *fp) info.si_code = ILL_CPLB_MULHIT; #ifdef CONFIG_DEBUG_HUNT_FOR_ZERO sig = SIGSEGV; - printk(KERN_EMERG "\n" - KERN_EMERG "NULL pointer access (probably)\n"); + printk(KERN_NOTICE "NULL pointer access (probably)\n"); #else sig = SIGILL; - printk(KERN_EMERG EXC_0x27); + printk(KERN_NOTICE EXC_0x27); #endif CHK_DEBUGGER_TRAP(); break; @@ -317,7 +368,7 @@ asmlinkage void trap_c(struct pt_regs *fp) case VEC_ISTRU_VL: /* ADSP-BF535 only (MH) */ info.si_code = BUS_OPFETCH; sig = SIGBUS; - printk(KERN_EMERG "BF535: VEC_ISTRU_VL\n"); + printk(KERN_NOTICE "BF535: VEC_ISTRU_VL\n"); CHK_DEBUGGER_TRAP(); break; #else @@ -327,22 +378,21 @@ asmlinkage void trap_c(struct pt_regs *fp) case VEC_MISALI_I: info.si_code = BUS_ADRALN; sig = SIGBUS; - printk(KERN_EMERG EXC_0x2A); + printk(KERN_NOTICE EXC_0x2A); CHK_DEBUGGER_TRAP(); break; - /* 0x2B - Instruction CPLB protection Violation, - handled in _cplb_hdr */ + /* 0x2B - Instruction CPLB protection violation, handled here */ case VEC_CPLB_I_VL: info.si_code = ILL_CPLB_VI; - sig = SIGILL; - printk(KERN_EMERG EXC_0x2B); + sig = SIGBUS; + printk(KERN_NOTICE EXC_0x2B); CHK_DEBUGGER_TRAP(); break; /* 0x2C - Instruction CPLB miss, handled in _cplb_hdr */ case VEC_CPLB_I_M: info.si_code = ILL_CPLB_MISS; sig = SIGBUS; - printk(KERN_EMERG EXC_0x2C); + printk(KERN_NOTICE EXC_0x2C); CHK_DEBUGGER_TRAP(); break; /* 0x2D - Instruction CPLB Multiple Hits, handled here */ @@ -350,10 +400,10 @@ asmlinkage void trap_c(struct pt_regs *fp) info.si_code = ILL_CPLB_MULHIT; #ifdef CONFIG_DEBUG_HUNT_FOR_ZERO sig = SIGSEGV; - printk(KERN_EMERG "\n\nJump to address 0 - 0x0fff\n"); + printk(KERN_NOTICE "Jump to address 0 - 0x0fff\n"); #else sig = SIGILL; - printk(KERN_EMERG EXC_0x2D); + printk(KERN_NOTICE EXC_0x2D); #endif CHK_DEBUGGER_TRAP(); break; @@ -361,7 +411,7 @@ asmlinkage void trap_c(struct pt_regs *fp) case VEC_ILL_RES: info.si_code = ILL_PRVOPC; sig = SIGILL; - printk(KERN_EMERG EXC_0x2E); + printk(KERN_NOTICE EXC_0x2E); CHK_DEBUGGER_TRAP(); break; /* 0x2F - Reserved, Caught by default */ @@ -390,37 +440,40 @@ asmlinkage void trap_c(struct pt_regs *fp) break; } - info.si_signo = sig; - info.si_errno = 0; - info.si_addr = (void *)fp->pc; - force_sig_info(sig, &info, current); - if (sig != 0 && sig != SIGTRAP) { + BUG_ON(sig == 0); + + if (sig != SIGTRAP) { unsigned long stack; dump_bfin_regs(fp, (void *)fp->retx); - dump_bfin_trace_buffer(); - show_stack(current, &stack); - if (current->mm == NULL) - panic("Kernel exception"); - } - /* if the address that we are about to return to is not valid, set it - * to a valid address, if we have a current application or panic - */ - if (!(fp->pc <= physical_mem_end -#if L1_CODE_LENGTH != 0 - || (fp->pc >= L1_CODE_START && - fp->pc <= (L1_CODE_START + L1_CODE_LENGTH)) + /* Print out the trace buffer if it makes sense */ +#ifndef CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE + if (trapnr == VEC_CPLB_I_M || trapnr == VEC_CPLB_M) + printk(KERN_NOTICE "No trace since you do not have " + "CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE enabled\n" + KERN_NOTICE "\n"); + else #endif - )) { - if (current->mm) { - fp->pc = current->mm->start_code; - } else { - printk(KERN_EMERG - "I can't return to memory that doesn't exist" - " - bad things happen\n"); - panic("Help - I've fallen and can't get up\n"); + dump_bfin_trace_buffer(); + show_stack(current, &stack); + if (oops_in_progress) { +#ifndef CONFIG_ACCESS_CHECK + printk(KERN_EMERG "Hey - dork - please turn on " + "CONFIG_ACCESS_CHECK\n"); +#endif + panic("Kernel exception"); } + + /* Ensure that bad return addresses don't end up in an infinite + * loop, due to speculative loads/reads + */ + if (trapnr == VEC_CPLB_I_M) + fp->pc = SAFE_USER_INSTRUCTION; } + info.si_signo = sig; + info.si_errno = 0; + info.si_addr = (void *)fp->pc; + force_sig_info(sig, &info, current); trace_buffer_restore(j); return; @@ -428,24 +481,55 @@ asmlinkage void trap_c(struct pt_regs *fp) /* Typical exception handling routines */ +#define EXPAND_LEN ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN) * 256 - 1) + void dump_bfin_trace_buffer(void) { - int tflags; +#ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON + int tflags, i = 0; + char buf[150]; +#ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND + int j, index; +#endif + trace_buffer_save(tflags); + printk(KERN_NOTICE "Hardware Trace:\n"); + if (likely(bfin_read_TBUFSTAT() & TBUFCNT)) { - int i; - printk(KERN_EMERG "Hardware Trace:\n"); - for (i = 0; bfin_read_TBUFSTAT() & TBUFCNT; i++) { - printk(KERN_EMERG "%2i Target : ", i); - printk_address((unsigned long)bfin_read_TBUF()); - printk("\n" KERN_EMERG " Source : "); - printk_address((unsigned long)bfin_read_TBUF()); - printk("\n"); + for (; bfin_read_TBUFSTAT() & TBUFCNT; i++) { + decode_address(buf, (unsigned long)bfin_read_TBUF()); + printk(KERN_NOTICE "%4i Target : %s\n", i, buf); + decode_address(buf, (unsigned long)bfin_read_TBUF()); + printk(KERN_NOTICE " Source : %s\n", buf); } } +#ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND + if (trace_buff_offset) + index = trace_buff_offset/4 - 1; + else + index = EXPAND_LEN; + + j = (1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN) * 128; + while (j) { + decode_address(buf, software_trace_buff[index]); + printk(KERN_NOTICE "%4i Target : %s\n", i, buf); + index -= 1; + if (index < 0 ) + index = EXPAND_LEN; + decode_address(buf, software_trace_buff[index]); + printk(KERN_NOTICE " Source : %s\n", buf); + index -= 1; + if (index < 0) + index = EXPAND_LEN; + j--; + i++; + } +#endif + trace_buffer_restore(tflags); +#endif } EXPORT_SYMBOL(dump_bfin_trace_buffer); @@ -453,10 +537,7 @@ static void show_trace(struct task_struct *tsk, unsigned long *sp) { unsigned long addr; - printk("\nCall Trace:"); -#ifdef CONFIG_KALLSYMS - printk("\n"); -#endif + printk(KERN_NOTICE "\n" KERN_NOTICE "Call Trace:\n"); while (!kstack_end(sp)) { addr = *sp++; @@ -472,7 +553,7 @@ static void show_trace(struct task_struct *tsk, unsigned long *sp) print_ip_sym(addr); } - printk("\n"); + printk(KERN_NOTICE "\n"); } void show_stack(struct task_struct *task, unsigned long *stack) @@ -494,14 +575,15 @@ void show_stack(struct task_struct *task, unsigned long *stack) addr = (unsigned long)stack; endstack = (unsigned long *)PAGE_ALIGN(addr); - printk(KERN_EMERG "Stack from %08lx:", (unsigned long)stack); + printk(KERN_NOTICE "Stack from %08lx:", (unsigned long)stack); for (i = 0; i < kstack_depth_to_print; i++) { if (stack + 1 > endstack) break; if (i % 8 == 0) - printk("\n" KERN_EMERG " "); + printk("\n" KERN_NOTICE " "); printk(" %08lx", *stack++); } + printk("\n"); show_trace(task, stack); } @@ -509,7 +591,9 @@ void show_stack(struct task_struct *task, unsigned long *stack) void dump_stack(void) { unsigned long stack; +#ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON int tflags; +#endif trace_buffer_save(tflags); dump_bfin_trace_buffer(); show_stack(current, &stack); @@ -520,33 +604,35 @@ EXPORT_SYMBOL(dump_stack); void dump_bfin_regs(struct pt_regs *fp, void *retaddr) { - if (current->pid) { - printk(KERN_EMERG "\n" KERN_EMERG "CURRENT PROCESS:\n" - KERN_EMERG "\n"); - printk(KERN_EMERG "COMM=%s PID=%d\n", - current->comm, current->pid); + char buf [150]; + + if (!oops_in_progress) { + if (current->pid && current->mm) { + printk(KERN_NOTICE "\n" KERN_NOTICE "CURRENT PROCESS:\n"); + printk(KERN_NOTICE "COMM=%s PID=%d\n", + current->comm, current->pid); + + printk(KERN_NOTICE "TEXT = 0x%p-0x%p DATA = 0x%p-0x%p\n" + KERN_NOTICE "BSS = 0x%p-0x%p USER-STACK = 0x%p\n" + KERN_NOTICE "\n", + (void *)current->mm->start_code, + (void *)current->mm->end_code, + (void *)current->mm->start_data, + (void *)current->mm->end_data, + (void *)current->mm->end_data, + (void *)current->mm->brk, + (void *)current->mm->start_stack); + } else { + printk (KERN_NOTICE "\n" KERN_NOTICE + "No Valid pid - Either things are really messed up," + " or you are in the kernel\n"); + } } else { - printk - (KERN_EMERG "\n" KERN_EMERG - "No Valid pid - Either things are really messed up," - " or you are in the kernel\n"); - } - - if (current->mm) { - printk(KERN_EMERG "TEXT = 0x%p-0x%p DATA = 0x%p-0x%p\n" - KERN_EMERG "BSS = 0x%p-0x%p USER-STACK = 0x%p\n" - KERN_EMERG "\n", - (void *)current->mm->start_code, - (void *)current->mm->end_code, - (void *)current->mm->start_data, - (void *)current->mm->end_data, - (void *)current->mm->end_data, - (void *)current->mm->brk, - (void *)current->mm->start_stack); + printk(KERN_NOTICE "Kernel or interrupt exception\n"); + print_modules(); } - printk(KERN_EMERG "return address: [0x%p]; contents of:", retaddr); - if (retaddr != 0 && retaddr <= (void *)physical_mem_end + if (retaddr >= (void *)FIXED_CODE_START && retaddr < (void *)physical_mem_end #if L1_CODE_LENGTH != 0 /* FIXME: Copy the code out of L1 Instruction SRAM through dma memcpy. */ @@ -556,19 +642,20 @@ void dump_bfin_regs(struct pt_regs *fp, void *retaddr) ) { int i = ((unsigned int)retaddr & 0xFFFFFFF0) - 32; unsigned short x = 0; + printk(KERN_NOTICE "return address: [0x%p]; contents of:", retaddr); for (; i < ((unsigned int)retaddr & 0xFFFFFFF0) + 32; i += 2) { if (!(i & 0xF)) - printk(KERN_EMERG "\n" KERN_EMERG - "0x%08x: ", i); + printk("\n" KERN_NOTICE "0x%08x: ", i); if (get_user(x, (unsigned short *)i)) break; #ifndef CONFIG_DEBUG_HWERR /* If one of the last few instructions was a STI * it is likely that the error occured awhile ago - * and we just noticed + * and we just noticed. This only happens in kernel + * context, which should mean an oops is happening */ - if (x >= 0x0040 && x <= 0x0047 && i <= 0) + if (oops_in_progress && x >= 0x0040 && x <= 0x0047 && i <= 0) panic("\n\nWARNING : You should reconfigure" " the kernel to turn on\n" " 'Hardware error interrupt" @@ -581,56 +668,60 @@ void dump_bfin_regs(struct pt_regs *fp, void *retaddr) else printk(" %04x ", x); } - printk("\n" KERN_EMERG "\n"); + printk("\n"); } else - printk(KERN_EMERG - "Cannot look at the [PC] for it is" - "in unreadable L1 SRAM - sorry\n"); - - - printk(KERN_EMERG - "RETE: %08lx RETN: %08lx RETX: %08lx RETS: %08lx\n", - fp->rete, fp->retn, fp->retx, fp->rets); - printk(KERN_EMERG "IPEND: %04lx SYSCFG: %04lx\n", - fp->ipend, fp->syscfg); - printk(KERN_EMERG "SEQSTAT: %08lx SP: %08lx\n", - (long)fp->seqstat, (long)fp); - printk(KERN_EMERG "R0: %08lx R1: %08lx R2: %08lx R3: %08lx\n", + printk("\n" KERN_NOTICE + "Cannot look at the [PC] <%p> for it is" + " in unreadable memory - sorry\n", retaddr); + + printk(KERN_NOTICE "\n" KERN_NOTICE "SEQUENCER STATUS:\n"); + printk(KERN_NOTICE " SEQSTAT: %08lx IPEND: %04lx SYSCFG: %04lx\n", + (long)fp->seqstat, fp->ipend, fp->syscfg); + + decode_address(buf, fp->rete); + printk(KERN_NOTICE " RETE: %s\n", buf); + decode_address(buf, fp->retn); + printk(KERN_NOTICE " RETN: %s\n", buf); + decode_address(buf, fp->retx); + printk(KERN_NOTICE " RETX: %s\n", buf); + decode_address(buf, fp->rets); + printk(KERN_NOTICE " RETS: %s\n", buf); + + if ((long)fp->seqstat & SEQSTAT_EXCAUSE) { + decode_address(buf, bfin_read_DCPLB_FAULT_ADDR()); + printk(KERN_NOTICE "DCPLB_FAULT_ADDR: %s\n", buf); + decode_address(buf, bfin_read_ICPLB_FAULT_ADDR()); + printk(KERN_NOTICE "ICPLB_FAULT_ADDR: %s\n", buf); + } + + printk(KERN_NOTICE "\n" KERN_NOTICE "PROCESSOR STATE:\n"); + printk(KERN_NOTICE " R0 : %08lx R1 : %08lx R2 : %08lx R3 : %08lx\n", fp->r0, fp->r1, fp->r2, fp->r3); - printk(KERN_EMERG "R4: %08lx R5: %08lx R6: %08lx R7: %08lx\n", + printk(KERN_NOTICE " R4 : %08lx R5 : %08lx R6 : %08lx R7 : %08lx\n", fp->r4, fp->r5, fp->r6, fp->r7); - printk(KERN_EMERG "P0: %08lx P1: %08lx P2: %08lx P3: %08lx\n", + printk(KERN_NOTICE " P0 : %08lx P1 : %08lx P2 : %08lx P3 : %08lx\n", fp->p0, fp->p1, fp->p2, fp->p3); - printk(KERN_EMERG - "P4: %08lx P5: %08lx FP: %08lx\n", - fp->p4, fp->p5, fp->fp); - printk(KERN_EMERG - "A0.w: %08lx A0.x: %08lx A1.w: %08lx A1.x: %08lx\n", - fp->a0w, fp->a0x, fp->a1w, fp->a1x); - - printk(KERN_EMERG "LB0: %08lx LT0: %08lx LC0: %08lx\n", + printk(KERN_NOTICE " P4 : %08lx P5 : %08lx FP : %08lx SP : %08lx\n", + fp->p4, fp->p5, fp->fp, (long)fp); + printk(KERN_NOTICE " LB0: %08lx LT0: %08lx LC0: %08lx\n", fp->lb0, fp->lt0, fp->lc0); - printk(KERN_EMERG "LB1: %08lx LT1: %08lx LC1: %08lx\n", + printk(KERN_NOTICE " LB1: %08lx LT1: %08lx LC1: %08lx\n", fp->lb1, fp->lt1, fp->lc1); - printk(KERN_EMERG "B0: %08lx L0: %08lx M0: %08lx I0: %08lx\n", + printk(KERN_NOTICE " B0 : %08lx L0 : %08lx M0 : %08lx I0 : %08lx\n", fp->b0, fp->l0, fp->m0, fp->i0); - printk(KERN_EMERG "B1: %08lx L1: %08lx M1: %08lx I1: %08lx\n", + printk(KERN_NOTICE " B1 : %08lx L1 : %08lx M1 : %08lx I1 : %08lx\n", fp->b1, fp->l1, fp->m1, fp->i1); - printk(KERN_EMERG "B2: %08lx L2: %08lx M2: %08lx I2: %08lx\n", + printk(KERN_NOTICE " B2 : %08lx L2 : %08lx M2 : %08lx I2 : %08lx\n", fp->b2, fp->l2, fp->m2, fp->i2); - printk(KERN_EMERG "B3: %08lx L3: %08lx M3: %08lx I3: %08lx\n", + printk(KERN_NOTICE " B3 : %08lx L3 : %08lx M3 : %08lx I3 : %08lx\n", fp->b3, fp->l3, fp->m3, fp->i3); + printk(KERN_NOTICE "A0.w: %08lx A0.x: %08lx A1.w: %08lx A1.x: %08lx\n", + fp->a0w, fp->a0x, fp->a1w, fp->a1x); - printk(KERN_EMERG "\n" KERN_EMERG "USP: %08lx ASTAT: %08lx\n", + printk(KERN_NOTICE "USP : %08lx ASTAT: %08lx\n", rdusp(), fp->astat); - if ((long)fp->seqstat & SEQSTAT_EXCAUSE) { - printk(KERN_EMERG "DCPLB_FAULT_ADDR=%p\n", - (void *)bfin_read_DCPLB_FAULT_ADDR()); - printk(KERN_EMERG "ICPLB_FAULT_ADDR=%p\n", - (void *)bfin_read_ICPLB_FAULT_ADDR()); - } - printk("\n\n"); + printk(KERN_NOTICE "\n"); } #ifdef CONFIG_SYS_BFIN_SPINLOCK_L1 @@ -654,6 +745,42 @@ asmlinkage int sys_bfin_spinlock(int *spinlock) return ret; } +int bfin_request_exception(unsigned int exception, void (*handler)(void)) +{ + void (*curr_handler)(void); + + if (exception > 0x3F) + return -EINVAL; + + curr_handler = ex_table[exception]; + + if (curr_handler != ex_replaceable) + return -EBUSY; + + ex_table[exception] = handler; + + return 0; +} +EXPORT_SYMBOL(bfin_request_exception); + +int bfin_free_exception(unsigned int exception, void (*handler)(void)) +{ + void (*curr_handler)(void); + + if (exception > 0x3F) + return -EINVAL; + + curr_handler = ex_table[exception]; + + if (curr_handler != handler) + return -EBUSY; + + ex_table[exception] = ex_replaceable; + + return 0; +} +EXPORT_SYMBOL(bfin_free_exception); + void panic_cplb_error(int cplb_panic, struct pt_regs *fp) { switch (cplb_panic) { @@ -669,6 +796,8 @@ void panic_cplb_error(int cplb_panic, struct pt_regs *fp) break; } + oops_in_progress = 1; + printk(KERN_EMERG "DCPLB_FAULT_ADDR=%p\n", (void *)bfin_read_DCPLB_FAULT_ADDR()); printk(KERN_EMERG "ICPLB_FAULT_ADDR=%p\n", (void *)bfin_read_ICPLB_FAULT_ADDR()); dump_bfin_regs(fp, (void *)fp->retx);