traps.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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)) >=
  107. THREAD_SIZE-4)
  108. break;
  109. if (i % 8 == 0)
  110. pr_info(" ");
  111. pr_cont(" %08lx", *stack++);
  112. }
  113. pr_info("\nCall Trace:\n");
  114. i = 0;
  115. stack = esp;
  116. while (((unsigned long)stack & (THREAD_SIZE - 1)) < THREAD_SIZE-4) {
  117. addr = *stack++;
  118. /*
  119. * If the address is either in the text segment of the
  120. * kernel, or in the region which contains vmalloc'ed
  121. * memory, it *may* be the address of a calling
  122. * routine; if so, print it so that someone tracing
  123. * down the cause of the crash will be able to figure
  124. * out the call path that was taken.
  125. */
  126. if (check_kernel_text(addr)) {
  127. if (i % 4 == 0)
  128. pr_info(" ");
  129. pr_cont(" [<%08lx>]", addr);
  130. i++;
  131. }
  132. }
  133. pr_info("\n");
  134. }