aboutsummaryrefslogtreecommitdiffstats
path: root/arch/h8300/kernel/traps.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/h8300/kernel/traps.c')
-rw-r--r--arch/h8300/kernel/traps.c169
1 files changed, 169 insertions, 0 deletions
diff --git a/arch/h8300/kernel/traps.c b/arch/h8300/kernel/traps.c
new file mode 100644
index 000000000000..300e3279ca5a
--- /dev/null
+++ b/arch/h8300/kernel/traps.c
@@ -0,0 +1,169 @@
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
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
24#include <asm/system.h>
25#include <asm/irq.h>
26#include <asm/traps.h>
27#include <asm/page.h>
28#include <asm/gpio.h>
29
30/*
31 * this must be called very early as the kernel might
32 * use some instruction that are emulated on the 060
33 */
34
35void __init base_trap_init(void)
36{
37}
38
39void __init trap_init (void)
40{
41}
42
43asmlinkage void set_esp0 (unsigned long ssp)
44{
45 current->thread.esp0 = ssp;
46}
47
48/*
49 * Generic dumping code. Used for panic and debug.
50 */
51
52static void dump(struct pt_regs *fp)
53{
54 unsigned long *sp;
55 unsigned char *tp;
56 int i;
57
58 printk("\nCURRENT PROCESS:\n\n");
59 printk("COMM=%s PID=%d\n", current->comm, current->pid);
60 if (current->mm) {
61 printk("TEXT=%08x-%08x DATA=%08x-%08x BSS=%08x-%08x\n",
62 (int) current->mm->start_code,
63 (int) current->mm->end_code,
64 (int) current->mm->start_data,
65 (int) current->mm->end_data,
66 (int) current->mm->end_data,
67 (int) current->mm->brk);
68 printk("USER-STACK=%08x KERNEL-STACK=%08lx\n\n",
69 (int) current->mm->start_stack,
70 (int) PAGE_SIZE+(unsigned long)current);
71 }
72
73 show_regs(fp);
74 printk("\nCODE:");
75 tp = ((unsigned char *) fp->pc) - 0x20;
76 for (sp = (unsigned long *) tp, i = 0; (i < 0x40); i += 4) {
77 if ((i % 0x10) == 0)
78 printk("\n%08x: ", (int) (tp + i));
79 printk("%08x ", (int) *sp++);
80 }
81 printk("\n");
82
83 printk("\nKERNEL STACK:");
84 tp = ((unsigned char *) fp) - 0x40;
85 for (sp = (unsigned long *) tp, i = 0; (i < 0xc0); i += 4) {
86 if ((i % 0x10) == 0)
87 printk("\n%08x: ", (int) (tp + i));
88 printk("%08x ", (int) *sp++);
89 }
90 printk("\n");
91 if (STACK_MAGIC != *(unsigned long *)((unsigned long)current+PAGE_SIZE))
92 printk("(Possibly corrupted stack page??)\n");
93
94 printk("\n\n");
95}
96
97void die_if_kernel (char *str, struct pt_regs *fp, int nr)
98{
99 extern int console_loglevel;
100
101 if (!(fp->ccr & PS_S))
102 return;
103
104 console_loglevel = 15;
105 dump(fp);
106
107 do_exit(SIGSEGV);
108}
109
110extern char _start, _etext;
111#define check_kernel_text(addr) \
112 ((addr >= (unsigned long)(&_start)) && \
113 (addr < (unsigned long)(&_etext)))
114
115static int kstack_depth_to_print = 24;
116
117void show_stack(struct task_struct *task, unsigned long *esp)
118{
119 unsigned long *stack, addr;
120 int i;
121
122 if (esp == NULL)
123 esp = (unsigned long *) &esp;
124
125 stack = esp;
126
127 printk("Stack from %08lx:", (unsigned long)stack);
128 for (i = 0; i < kstack_depth_to_print; i++) {
129 if (((unsigned long)stack & (THREAD_SIZE - 1)) == 0)
130 break;
131 if (i % 8 == 0)
132 printk("\n ");
133 printk(" %08lx", *stack++);
134 }
135
136 printk("\nCall Trace:");
137 i = 0;
138 stack = esp;
139 while (((unsigned long)stack & (THREAD_SIZE - 1)) == 0) {
140 addr = *stack++;
141 /*
142 * If the address is either in the text segment of the
143 * kernel, or in the region which contains vmalloc'ed
144 * memory, it *may* be the address of a calling
145 * routine; if so, print it so that someone tracing
146 * down the cause of the crash will be able to figure
147 * out the call path that was taken.
148 */
149 if (check_kernel_text(addr)) {
150 if (i % 4 == 0)
151 printk("\n ");
152 printk(" [<%08lx>]", addr);
153 i++;
154 }
155 }
156 printk("\n");
157}
158
159void show_trace_task(struct task_struct *tsk)
160{
161 show_stack(tsk,(unsigned long *)tsk->thread.esp0);
162}
163
164void dump_stack(void)
165{
166 show_stack(NULL,NULL);
167}
168
169EXPORT_SYMBOL(dump_stack);