traps.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * linux/arch/h8300/boot/traps.c -- general exception handling code
  3. * H8/300 support Yoshinori Sato <ysato@users.sourceforge.jp>
  4. *
  5. * Cloned from Linux/m68k.
  6. *
  7. * No original Copyright holder listed,
  8. * Probable original (C) Roman Zippel (assigned DJD, 1999)
  9. *
  10. * Copyright 1999-2000 D. Jeff Dionne, <jeff@rt-control.com>
  11. *
  12. * This file is subject to the terms and conditions of the GNU General Public
  13. * License. See the file COPYING in the main directory of this archive
  14. * for more details.
  15. */
  16. #include <linux/types.h>
  17. #include <linux/sched.h>
  18. #include <linux/kernel.h>
  19. #include <linux/errno.h>
  20. #include <linux/init.h>
  21. #include <linux/module.h>
  22. #include <linux/bug.h>
  23. #include <asm/irq.h>
  24. #include <asm/traps.h>
  25. #include <asm/page.h>
  26. static DEFINE_SPINLOCK(die_lock);
  27. /*
  28. * this must be called very early as the kernel might
  29. * use some instruction that are emulated on the 060
  30. */
  31. void __init base_trap_init(void)
  32. {
  33. }
  34. void __init trap_init(void)
  35. {
  36. }
  37. asmlinkage void set_esp0(unsigned long ssp)
  38. {
  39. current->thread.esp0 = ssp;
  40. }
  41. /*
  42. * Generic dumping code. Used for panic and debug.
  43. */
  44. static void dump(struct pt_regs *fp)
  45. {
  46. unsigned long *sp;
  47. unsigned char *tp;
  48. int i;
  49. pr_info("\nCURRENT PROCESS:\n\n");
  50. pr_info("COMM=%s PID=%d\n", current->comm, current->pid);
  51. if (current->mm) {
  52. pr_info("TEXT=%08x-%08x DATA=%08x-%08x BSS=%08x-%08x\n",
  53. (int) current->mm->start_code,
  54. (int) current->mm->end_code,
  55. (int) current->mm->start_data,
  56. (int) current->mm->end_data,
  57. (int) current->mm->end_data,
  58. (int) current->mm->brk);
  59. pr_info("USER-STACK=%08x KERNEL-STACK=%08lx\n\n",
  60. (int) current->mm->start_stack,
  61. (int) PAGE_SIZE+(unsigned long)current);
  62. }
  63. show_regs(fp);
  64. pr_info("\nCODE:");
  65. tp = ((unsigned char *) fp->pc) - 0x20;
  66. for (sp = (unsigned long *) tp, i = 0; (i < 0x40); i += 4) {
  67. if ((i % 0x10) == 0)
  68. pr_info("\n%08x: ", (int) (tp + i));
  69. pr_info("%08x ", (int) *sp++);
  70. }
  71. pr_info("\n");
  72. pr_info("\nKERNEL STACK:");
  73. tp = ((unsigned char *) fp) - 0x40;
  74. for (sp = (unsigned long *) tp, i = 0; (i < 0xc0); i += 4) {
  75. if ((i % 0x10) == 0)
  76. pr_info("\n%08x: ", (int) (tp + i));
  77. pr_info("%08x ", (int) *sp++);
  78. }
  79. pr_info("\n");
  80. if (STACK_MAGIC != *(unsigned long *)((unsigned long)current+PAGE_SIZE))
  81. pr_info("(Possibly corrupted stack page??)\n");
  82. pr_info("\n\n");
  83. }
  84. void die(const char *str, struct pt_regs *fp, unsigned long err)
  85. {
  86. static int diecount;
  87. oops_enter();
  88. console_verbose();
  89. spin_lock_irq(&die_lock);
  90. report_bug(fp->pc, fp);
  91. pr_crit("%s: %04lx [#%d] ", str, err & 0xffff, ++diecount);
  92. dump(fp);
  93. spin_unlock_irq(&die_lock);
  94. do_exit(SIGSEGV);
  95. }
  96. static int kstack_depth_to_print = 24;
  97. void show_stack(struct task_struct *task, unsigned long *esp)
  98. {
  99. unsigned long *stack, addr;
  100. int i;
  101. if (esp == NULL)
  102. esp = (unsigned long *) &esp;
  103. stack = esp;
  104. pr_info("Stack from %08lx:", (unsigned long)stack);
  105. for (i = 0; i < kstack_depth_to_print; i++) {
  106. if (((unsigned long)stack & (THREAD_SIZE - 1)) == 0)
  107. break;
  108. if (i % 8 == 0)
  109. pr_info("\n ");
  110. pr_info(" %08lx", *stack++);
  111. }
  112. pr_info("\nCall Trace:");
  113. i = 0;
  114. stack = esp;
  115. while (((unsigned long)stack & (THREAD_SIZE - 1)) != 0) {
  116. addr = *stack++;
  117. /*
  118. * If the address is either in the text segment of the
  119. * kernel, or in the region which contains vmalloc'ed
  120. * memory, it *may* be the address of a calling
  121. * routine; if so, print it so that someone tracing
  122. * down the cause of the crash will be able to figure
  123. * out the call path that was taken.
  124. */
  125. if (check_kernel_text(addr)) {
  126. if (i % 4 == 0)
  127. pr_info("\n ");
  128. pr_info(" [<%08lx>]", addr);
  129. i++;
  130. }
  131. }
  132. pr_info("\n");
  133. }
  134. void show_trace_task(struct task_struct *tsk)
  135. {
  136. show_stack(tsk, (unsigned long *)tsk->thread.esp0);
  137. }