9 #include <linux/kernel.h>
13 #include <linux/oom.h>
14 #include <linux/sched.h>
16 #include <linux/module.h>
22 #include <asm/trace.h>
24 #include <asm/traps.h>
35 #ifdef CONFIG_KALLSYMS
36 unsigned long symsize;
43 buf +=
sprintf(buf,
"<0x%08lx> ", address);
45 #ifdef CONFIG_KALLSYMS
47 symname =
kallsyms_lookup(address, &symsize, &offset, &modname, namebuf);
53 sprintf(buf,
"{ %s%s%s%s + 0x%lx }",
54 delim, modname, delim, symname,
55 (
unsigned long)offset);
62 strcat(buf,
"/* Maybe fixed code section */");
65 }
else if (address < CONFIG_BOOT_LOAD) {
67 strcat(buf,
"/* Maybe null pointer? */");
71 strcat(buf,
"/* core mmrs */");
75 strcat(buf,
"/* system mmrs */");
79 strcat(buf,
"/* on-chip L1 ROM */");
83 strcat(buf,
"/* on-chip scratchpad */");
87 strcat(buf,
"/* unconnected memory */");
91 strcat(buf,
"/* reserved memory */");
95 strcat(buf,
"/* on-chip Data Bank A */");
99 strcat(buf,
"/* on-chip Data Bank B */");
108 strcat(buf,
"/* kernel dynamic memory (maybe user-space) */");
153 !((
unsigned long)
current & 0x3)) {
155 (address >
current->mm->start_code) &&
157 offset = address -
current->mm->start_code;
159 offset = (address - vma->
vm_start) +
162 sprintf(buf,
"[ %s + 0x%lx ]", name, offset);
164 sprintf(buf,
"[ %s vma:0x%lx-0x%lx]",
171 sprintf(buf,
"[ %s ] dynamic memory", name);
186 sprintf(buf,
"/* kernel dynamic memory */");
192 #define EXPAND_LEN ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN) * 256 - 1)
200 unsigned long addr = (
unsigned long)address;
224 unsigned long addr = (
unsigned long)address;
225 unsigned short opcode0, opcode1;
247 if ((opcode0 & 0xc000) == 0xc000) {
250 *val = (opcode0 << 16) + opcode1;
257 #if defined(CONFIG_DEBUG_BFIN_HWTRACE_ON)
266 #define ProgCtrl_opcode 0x0000
267 #define ProgCtrl_poprnd_bits 0
268 #define ProgCtrl_poprnd_mask 0xf
269 #define ProgCtrl_prgfunc_bits 4
270 #define ProgCtrl_prgfunc_mask 0xf
271 #define ProgCtrl_code_bits 8
272 #define ProgCtrl_code_mask 0xff
274 static void decode_ProgCtrl_0(
unsigned int opcode)
276 int poprnd = ((opcode >> ProgCtrl_poprnd_bits) & ProgCtrl_poprnd_mask);
277 int prgfunc = ((opcode >> ProgCtrl_prgfunc_bits) & ProgCtrl_prgfunc_mask);
279 if (prgfunc == 0 && poprnd == 0)
281 else if (prgfunc == 1 && poprnd == 0)
283 else if (prgfunc == 1 && poprnd == 1)
285 else if (prgfunc == 1 && poprnd == 2)
287 else if (prgfunc == 1 && poprnd == 3)
289 else if (prgfunc == 1 && poprnd == 4)
291 else if (prgfunc == 2 && poprnd == 0)
293 else if (prgfunc == 2 && poprnd == 3)
295 else if (prgfunc == 2 && poprnd == 4)
297 else if (prgfunc == 2 && poprnd == 5)
299 else if (prgfunc == 3)
301 else if (prgfunc == 4)
303 else if (prgfunc == 5)
305 else if (prgfunc == 6)
307 else if (prgfunc == 7)
308 pr_cont(
"CALL (PC + P%i)", poprnd);
309 else if (prgfunc == 8)
310 pr_cont(
"JUMP (PC + P%i", poprnd);
311 else if (prgfunc == 9)
313 else if (prgfunc == 10)
320 #define BRCC_opcode 0x1000
321 #define BRCC_offset_bits 0
322 #define BRCC_offset_mask 0x3ff
323 #define BRCC_B_bits 10
324 #define BRCC_B_mask 0x1
325 #define BRCC_T_bits 11
326 #define BRCC_T_mask 0x1
327 #define BRCC_code_bits 12
328 #define BRCC_code_mask 0xf
330 static void decode_BRCC_0(
unsigned int opcode)
332 int B = ((opcode >> BRCC_B_bits) & BRCC_B_mask);
333 int T = ((opcode >> BRCC_T_bits) & BRCC_T_mask);
335 pr_cont(
"IF %sCC JUMP pcrel %s", T ?
"" :
"!", B ?
"(BP)" :
"");
338 #define CALLa_opcode 0xe2000000
339 #define CALLa_addr_bits 0
340 #define CALLa_addr_mask 0xffffff
341 #define CALLa_S_bits 24
342 #define CALLa_S_mask 0x1
343 #define CALLa_code_bits 25
344 #define CALLa_code_mask 0x7f
346 static void decode_CALLa_0(
unsigned int opcode)
348 int S = ((opcode >> (CALLa_S_bits - 16)) & CALLa_S_mask);
356 #define LoopSetup_opcode 0xe0800000
357 #define LoopSetup_eoffset_bits 0
358 #define LoopSetup_eoffset_mask 0x3ff
359 #define LoopSetup_dontcare_bits 10
360 #define LoopSetup_dontcare_mask 0x3
361 #define LoopSetup_reg_bits 12
362 #define LoopSetup_reg_mask 0xf
363 #define LoopSetup_soffset_bits 16
364 #define LoopSetup_soffset_mask 0xf
365 #define LoopSetup_c_bits 20
366 #define LoopSetup_c_mask 0x1
367 #define LoopSetup_rop_bits 21
368 #define LoopSetup_rop_mask 0x3
369 #define LoopSetup_code_bits 23
370 #define LoopSetup_code_mask 0x1ff
372 static void decode_LoopSetup_0(
unsigned int opcode)
374 int c = ((opcode >> LoopSetup_c_bits) & LoopSetup_c_mask);
375 int reg = ((opcode >> LoopSetup_reg_bits) & LoopSetup_reg_mask);
376 int rop = ((opcode >> LoopSetup_rop_bits) & LoopSetup_rop_mask);
385 #define DspLDST_opcode 0x9c00
386 #define DspLDST_reg_bits 0
387 #define DspLDST_reg_mask 0x7
388 #define DspLDST_i_bits 3
389 #define DspLDST_i_mask 0x3
390 #define DspLDST_m_bits 5
391 #define DspLDST_m_mask 0x3
392 #define DspLDST_aop_bits 7
393 #define DspLDST_aop_mask 0x3
394 #define DspLDST_W_bits 9
395 #define DspLDST_W_mask 0x1
396 #define DspLDST_code_bits 10
397 #define DspLDST_code_mask 0x3f
399 static void decode_dspLDST_0(
unsigned int opcode)
401 int i = ((opcode >> DspLDST_i_bits) & DspLDST_i_mask);
402 int m = ((opcode >> DspLDST_m_bits) & DspLDST_m_mask);
403 int W = ((opcode >> DspLDST_W_bits) & DspLDST_W_mask);
404 int aop = ((opcode >> DspLDST_aop_bits) & DspLDST_aop_mask);
405 int reg = ((opcode >> DspLDST_reg_bits) & DspLDST_reg_mask);
446 #define LDST_opcode 0x9000
447 #define LDST_reg_bits 0
448 #define LDST_reg_mask 0x7
449 #define LDST_ptr_bits 3
450 #define LDST_ptr_mask 0x7
451 #define LDST_Z_bits 6
452 #define LDST_Z_mask 0x1
453 #define LDST_aop_bits 7
454 #define LDST_aop_mask 0x3
455 #define LDST_W_bits 9
456 #define LDST_W_mask 0x1
457 #define LDST_sz_bits 10
458 #define LDST_sz_mask 0x3
459 #define LDST_code_bits 12
460 #define LDST_code_mask 0xf
462 static void decode_LDST_0(
unsigned int opcode)
464 int Z = ((opcode >> LDST_Z_bits) & LDST_Z_mask);
465 int W = ((opcode >> LDST_W_bits) & LDST_W_mask);
466 int sz = ((opcode >> LDST_sz_bits) & LDST_sz_mask);
467 int aop = ((opcode >> LDST_aop_bits) & LDST_aop_mask);
468 int reg = ((opcode >> LDST_reg_bits) & LDST_reg_mask);
469 int ptr = ((opcode >> LDST_ptr_bits) & LDST_ptr_mask);
472 pr_cont(
"%s%i = ", (sz == 0 && Z == 1) ?
"P" :
"R", reg);
496 pr_cont(
" = %s%i ", (sz == 0 && Z == 1) ?
"P" :
"R", reg);
506 #define LDSTii_opcode 0xa000
507 #define LDSTii_reg_bit 0
508 #define LDSTii_reg_mask 0x7
509 #define LDSTii_ptr_bit 3
510 #define LDSTii_ptr_mask 0x7
511 #define LDSTii_offset_bit 6
512 #define LDSTii_offset_mask 0xf
513 #define LDSTii_op_bit 10
514 #define LDSTii_op_mask 0x3
515 #define LDSTii_W_bit 12
516 #define LDSTii_W_mask 0x1
517 #define LDSTii_code_bit 13
518 #define LDSTii_code_mask 0x7
520 static void decode_LDSTii_0(
unsigned int opcode)
522 int reg = ((opcode >> LDSTii_reg_bit) & LDSTii_reg_mask);
523 int ptr = ((opcode >> LDSTii_ptr_bit) & LDSTii_ptr_mask);
524 int offset = ((opcode >> LDSTii_offset_bit) & LDSTii_offset_mask);
525 int op = ((opcode >> LDSTii_op_bit) & LDSTii_op_mask);
526 int W = ((opcode >> LDSTii_W_bit) & LDSTii_W_mask);
529 pr_cont(
"%s%i = %s[P%i + %i]", op == 3 ?
"R" :
"P", reg,
530 op == 1 || op == 2 ?
"" :
"W", ptr, offset);
536 pr_cont(
"%s[P%i + %i] = %s%i", op == 0 ?
"" :
"W", ptr,
537 offset, op == 3 ?
"P" :
"R", reg);
541 #define LDSTidxI_opcode 0xe4000000
542 #define LDSTidxI_offset_bits 0
543 #define LDSTidxI_offset_mask 0xffff
544 #define LDSTidxI_reg_bits 16
545 #define LDSTidxI_reg_mask 0x7
546 #define LDSTidxI_ptr_bits 19
547 #define LDSTidxI_ptr_mask 0x7
548 #define LDSTidxI_sz_bits 22
549 #define LDSTidxI_sz_mask 0x3
550 #define LDSTidxI_Z_bits 24
551 #define LDSTidxI_Z_mask 0x1
552 #define LDSTidxI_W_bits 25
553 #define LDSTidxI_W_mask 0x1
554 #define LDSTidxI_code_bits 26
555 #define LDSTidxI_code_mask 0x3f
557 static void decode_LDSTidxI_0(
unsigned int opcode)
559 int Z = ((opcode >> LDSTidxI_Z_bits) & LDSTidxI_Z_mask);
560 int W = ((opcode >> LDSTidxI_W_bits) & LDSTidxI_W_mask);
561 int sz = ((opcode >> LDSTidxI_sz_bits) & LDSTidxI_sz_mask);
562 int reg = ((opcode >> LDSTidxI_reg_bits) & LDSTidxI_reg_mask);
563 int ptr = ((opcode >> LDSTidxI_ptr_bits) & LDSTidxI_ptr_mask);
564 int offset = ((opcode >> LDSTidxI_offset_bits) & LDSTidxI_offset_mask);
567 pr_cont(
"%s%i = ", sz == 0 && Z == 1 ?
"P" :
"R", reg);
574 pr_cont(
"[P%i + %s0x%x]", ptr, offset & 0x20 ?
"-" :
"",
575 (offset & 0x1f) << 2);
577 if (W == 0 && sz != 0) {
585 pr_cont(
"= %s%i", (sz == 0 && Z == 1) ?
"P" :
"R", reg);
589 static void decode_opcode(
unsigned int opcode)
592 if (opcode == BFIN_BUG_OPCODE)
596 if ((opcode & 0xffffff00) == ProgCtrl_opcode)
597 decode_ProgCtrl_0(opcode);
598 else if ((opcode & 0xfffff000) == BRCC_opcode)
599 decode_BRCC_0(opcode);
600 else if ((opcode & 0xfffff000) == 0x2000)
602 else if ((opcode & 0xfe000000) == CALLa_opcode)
603 decode_CALLa_0(opcode);
604 else if ((opcode & 0xff8000C0) == LoopSetup_opcode)
605 decode_LoopSetup_0(opcode);
606 else if ((opcode & 0xfffffc00) == DspLDST_opcode)
607 decode_dspLDST_0(opcode);
608 else if ((opcode & 0xfffff000) == LDST_opcode)
609 decode_LDST_0(opcode);
610 else if ((opcode & 0xffffe000) == LDSTii_opcode)
611 decode_LDSTii_0(opcode);
612 else if ((opcode & 0xfc000000) == LDSTidxI_opcode)
613 decode_LDSTidxI_0(opcode);
614 else if (opcode & 0xffff0000)
620 #define BIT_MULTI_INS 0x08000000
621 static void decode_instruction(
unsigned short *
address)
628 decode_opcode(opcode);
634 if ((opcode & 0xc0000000) == 0xc0000000 &&
635 (opcode & BIT_MULTI_INS) &&
636 (opcode & 0xe8000000) != 0xe8000000) {
640 decode_opcode(opcode);
644 decode_opcode(opcode);
651 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
652 int tflags, i = 0,
fault = 0;
654 unsigned short *
addr;
656 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
664 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
665 pr_notice(
"WARNING: Expanded trace turned on - can not trace exceptions\n");
681 decode_instruction(addr);
686 if (!
fault && addr == (
unsigned short *)
trap &&
690 decode_instruction((
unsigned short *)
cpu_pda[cpu].icplb_fault_addr);
697 decode_instruction(addr);
702 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
708 j = (1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN) * 128;
739 pr_emerg(
"Kernel OOPS in progress\n");
743 else if (context & 0x0020)
744 pr_notice(
"Deferred Exception context\n");
745 else if (context & 0x3FC0)
747 else if (context & 0x4000)
748 pr_notice(
"Deferred Interrupt context\n");
749 else if (context & 0x8000)
765 if (!((
unsigned long)
current->mm & 0x3) &&
767 pr_notice(
"TEXT = 0x%p-0x%p DATA = 0x%p-0x%p\n",
768 (
void *)
current->mm->start_code,
770 (
void *)
current->mm->start_data,
771 (
void *)
current->mm->end_data);
772 pr_notice(
" BSS = 0x%p-0x%p USER-STACK = 0x%p\n\n",
775 (
void *)
current->mm->start_stack);
779 pr_notice(
"No Valid process in current context\n");
784 unsigned short *
addr, *erraddr,
val = 0,
err = 0;
785 char sti = 0,
buf[6];
787 erraddr = (
void *)fp->
pc;
789 pr_notice(
"return address: [0x%p]; contents of:", erraddr);
791 for (addr = (
unsigned short *)((
unsigned long)erraddr & ~0xF) - 0x10;
792 addr < (
unsigned short *)((
unsigned long)erraddr & ~0xF) + 0x10;
794 if (!((
unsigned long)addr & 0xF))
803 if (addr == erraddr) {
810 if (addr <= erraddr &&
811 ((val >= 0x0040 && val <= 0x0047) ||
821 pr_notice(
"Looks like this was a deferred error - sorry\n");
822 #ifndef CONFIG_DEBUG_HWERR
823 pr_notice(
"The remaining message may be meaningless\n");
824 pr_notice(
"You should enable CONFIG_DEBUG_HWERR to get a better idea where it came from\n");
831 if ((!(((fp)->ipend & ~0x30) & (((fp)->ipend & ~0x30) - 1))) &&
834 if ((fp + 1)->
pc >=
current->mm->start_code &&
835 (fp + 1)->pc <=
current->mm->end_code) {
836 pr_notice(
"It might be better to look around here :\n");
837 pr_notice(
"-------------------------------------------\n");
839 pr_notice(
"-------------------------------------------\n");
851 unsigned long flags = 0;
856 if (CPUID != bfin_cpuid())
857 pr_notice(
"Compiled for cpu family 0x%04x (Rev %d), "
858 "but running on:0x%04x (Rev %d)\n",
859 CPUID, bfin_compiled_revid(), bfin_cpuid(), bfin_revid());
862 CPU, bfin_compiled_revid());
864 if (bfin_compiled_revid() != bfin_revid())
865 pr_cont(
"(Detected 0.%d)", bfin_revid());
867 pr_cont(
" %lu(MHz CCLK) %lu(MHz SCLK) (%s)\n",
879 pr_notice(
" SEQSTAT: %08lx IPEND: %04lx IMASK: %04lx SYSCFG: %04lx\n",
882 pr_notice(
" Global Interrupts Disabled (IPEND[4])\n");
885 pr_notice(
" Peripheral interrupts masked off\n");
887 pr_notice(
" Kernel interrupts masked off\n");
894 pr_notice(
" EBIU Error Reason : 0x%04x\n",
896 pr_notice(
" EBIU Error Address : 0x%08x\n",
903 for (i = 2; i <= 15 ; i++) {
904 if (fp->
ipend & (1 << i)) {
907 pr_notice(
" physical IVG%i asserted : %s\n", i, buf);
914 if (fp->
ipend & ~0x3F) {
915 for (i = 0; i < (
NR_IRQS - 1); i++) {
925 pr_notice(
" logical irq %3d mapped : %s", i, buf);
926 for (action = action->
next; action; action = action->
next) {
951 pr_notice(
"DCPLB_FAULT_ADDR: %s\n", buf);
953 pr_notice(
"ICPLB_FAULT_ADDR: %s\n", buf);
957 pr_notice(
" R0 : %08lx R1 : %08lx R2 : %08lx R3 : %08lx\n",
959 pr_notice(
" R4 : %08lx R5 : %08lx R6 : %08lx R7 : %08lx\n",
961 pr_notice(
" P0 : %08lx P1 : %08lx P2 : %08lx P3 : %08lx\n",
963 pr_notice(
" P4 : %08lx P5 : %08lx FP : %08lx SP : %08lx\n",
964 fp->
p4, fp->
p5, fp->
fp, (
long)fp);
965 pr_notice(
" LB0: %08lx LT0: %08lx LC0: %08lx\n",
966 fp->lb0, fp->lt0, fp->lc0);
967 pr_notice(
" LB1: %08lx LT1: %08lx LC1: %08lx\n",
968 fp->lb1, fp->lt1, fp->lc1);
969 pr_notice(
" B0 : %08lx L0 : %08lx M0 : %08lx I0 : %08lx\n",
970 fp->b0, fp->l0, fp->m0, fp->i0);
971 pr_notice(
" B1 : %08lx L1 : %08lx M1 : %08lx I1 : %08lx\n",
972 fp->b1, fp->l1, fp->m1, fp->i1);
973 pr_notice(
" B2 : %08lx L2 : %08lx M2 : %08lx I2 : %08lx\n",
974 fp->b2, fp->l2, fp->m2, fp->i2);
975 pr_notice(
" B3 : %08lx L3 : %08lx M3 : %08lx I3 : %08lx\n",
976 fp->b3, fp->l3, fp->m3, fp->i3);
977 pr_notice(
"A0.w: %08lx A0.x: %08lx A1.w: %08lx A1.x: %08lx\n",
978 fp->a0w, fp->a0x, fp->a1w, fp->a1x);