2 * linux/arch/h8300/boot/traps.c -- general exception handling code
3 * H8/300 support Yoshinori Sato <ysato@users.sourceforge.jp>
5 * Cloned from Linux/m68k.
7 * No original Copyright holder listed,
8 * Probable original (C) Roman Zippel (assigned DJD, 1999)
10 * Copyright 1999-2000 D. Jeff Dionne, <jeff@rt-control.com>
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
17 #include <linux/types.h>
18 #include <linux/sched.h>
19 #include <linux/kernel.h>
20 #include <linux/errno.h>
21 #include <linux/init.h>
22 #include <linux/module.h>
23 #include <linux/bug.h>
26 #include <asm/traps.h>
29 static DEFINE_SPINLOCK(die_lock
);
32 * this must be called very early as the kernel might
33 * use some instruction that are emulated on the 060
36 void __init
base_trap_init(void)
40 void __init
trap_init (void)
44 asmlinkage
void set_esp0 (unsigned long ssp
)
46 current
->thread
.esp0
= ssp
;
50 * Generic dumping code. Used for panic and debug.
53 static void dump(struct pt_regs
*fp
)
59 printk("\nCURRENT PROCESS:\n\n");
60 printk("COMM=%s PID=%d\n", current
->comm
, current
->pid
);
62 printk("TEXT=%08x-%08x DATA=%08x-%08x BSS=%08x-%08x\n",
63 (int) current
->mm
->start_code
,
64 (int) current
->mm
->end_code
,
65 (int) current
->mm
->start_data
,
66 (int) current
->mm
->end_data
,
67 (int) current
->mm
->end_data
,
68 (int) current
->mm
->brk
);
69 printk("USER-STACK=%08x KERNEL-STACK=%08lx\n\n",
70 (int) current
->mm
->start_stack
,
71 (int) PAGE_SIZE
+(unsigned long)current
);
76 tp
= ((unsigned char *) fp
->pc
) - 0x20;
77 for (sp
= (unsigned long *) tp
, i
= 0; (i
< 0x40); i
+= 4) {
79 printk("\n%08x: ", (int) (tp
+ i
));
80 printk("%08x ", (int) *sp
++);
84 printk("\nKERNEL STACK:");
85 tp
= ((unsigned char *) fp
) - 0x40;
86 for (sp
= (unsigned long *) tp
, i
= 0; (i
< 0xc0); i
+= 4) {
88 printk("\n%08x: ", (int) (tp
+ i
));
89 printk("%08x ", (int) *sp
++);
92 if (STACK_MAGIC
!= *(unsigned long *)((unsigned long)current
+PAGE_SIZE
))
93 printk("(Possibly corrupted stack page??)\n");
98 void die(const char *str
, struct pt_regs
*fp
, unsigned long err
)
105 spin_lock_irq(&die_lock
);
106 report_bug(fp
->pc
, fp
);
107 printk(KERN_EMERG
"%s: %04lx [#%d] ", str
, err
& 0xffff, ++diecount
);
110 spin_unlock_irq(&die_lock
);
114 extern char _start
, _etext
;
115 #define check_kernel_text(addr) \
116 ((addr >= (unsigned long)(&_start)) && \
117 (addr < (unsigned long)(&_etext)))
119 static int kstack_depth_to_print
= 24;
121 void show_stack(struct task_struct
*task
, unsigned long *esp
)
123 unsigned long *stack
, addr
;
127 esp
= (unsigned long *) &esp
;
131 printk("Stack from %08lx:", (unsigned long)stack
);
132 for (i
= 0; i
< kstack_depth_to_print
; i
++) {
133 if (((unsigned long)stack
& (THREAD_SIZE
- 1)) == 0)
137 printk(" %08lx", *stack
++);
140 printk("\nCall Trace:");
143 while (((unsigned long)stack
& (THREAD_SIZE
- 1)) != 0) {
146 * If the address is either in the text segment of the
147 * kernel, or in the region which contains vmalloc'ed
148 * memory, it *may* be the address of a calling
149 * routine; if so, print it so that someone tracing
150 * down the cause of the crash will be able to figure
151 * out the call path that was taken.
153 if (check_kernel_text(addr
)) {
156 printk(" [<%08lx>]", addr
);
163 void show_trace_task(struct task_struct
*tsk
)
165 show_stack(tsk
,(unsigned long *)tsk
->thread
.esp0
);
168 void dump_stack(void)
170 show_stack(NULL
,NULL
);
173 EXPORT_SYMBOL(dump_stack
);