traps.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. * Probabily 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 <asm/system.h>
  23. #include <asm/irq.h>
  24. #include <asm/traps.h>
  25. #include <asm/page.h>
  26. #include <asm/gpio.h>
  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. printk("\nCURRENT PROCESS:\n\n");
  50. printk("COMM=%s PID=%d\n", current->comm, current->pid);
  51. if (current->mm) {
  52. printk("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. printk("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. printk("\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. printk("\n%08x: ", (int) (tp + i));
  69. printk("%08x ", (int) *sp++);
  70. }
  71. printk("\n");
  72. printk("\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. printk("\n%08x: ", (int) (tp + i));
  77. printk("%08x ", (int) *sp++);
  78. }
  79. printk("\n");
  80. if (STACK_MAGIC != *(unsigned long *)((unsigned long)current+PAGE_SIZE))
  81. printk("(Possibly corrupted stack page??)\n");
  82. printk("\n\n");
  83. }
  84. void die_if_kernel (char *str, struct pt_regs *fp, int nr)
  85. {
  86. extern int console_loglevel;
  87. if (!(fp->ccr & PS_S))
  88. return;
  89. console_loglevel = 15;
  90. dump(fp);
  91. do_exit(SIGSEGV);
  92. }
  93. extern char _start, _etext;
  94. #define check_kernel_text(addr) \
  95. ((addr >= (unsigned long)(&_start)) && \
  96. (addr < (unsigned long)(&_etext)))
  97. static int kstack_depth_to_print = 24;
  98. void show_stack(struct task_struct *task, unsigned long *esp)
  99. {
  100. unsigned long *stack, addr;
  101. int i;
  102. if (esp == NULL)
  103. esp = (unsigned long *) &esp;
  104. stack = esp;
  105. printk("Stack from %08lx:", (unsigned long)stack);
  106. for (i = 0; i < kstack_depth_to_print; i++) {
  107. if (((unsigned long)stack & (THREAD_SIZE - 1)) == 0)
  108. break;
  109. if (i % 8 == 0)
  110. printk("\n ");
  111. printk(" %08lx", *stack++);
  112. }
  113. printk("\nCall Trace:");
  114. i = 0;
  115. stack = esp;
  116. while (((unsigned long)stack & (THREAD_SIZE - 1)) == 0) {
  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. printk("\n ");
  129. printk(" [<%08lx>]", addr);
  130. i++;
  131. }
  132. }
  133. printk("\n");
  134. }
  135. void show_trace_task(struct task_struct *tsk)
  136. {
  137. show_stack(tsk,(unsigned long *)tsk->thread.esp0);
  138. }
  139. void dump_stack(void)
  140. {
  141. show_stack(NULL,NULL);
  142. }
  143. EXPORT_SYMBOL(dump_stack);