ae281c8eb1d0399863136a10d04928549fbbe269
[linux-flexiantxendom0-3.2.10.git] / arch / h8300 / kernel / traps.c
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_stat.h>
20 #include <linux/errno.h>
21 #include <linux/init.h>
22
23 #include <asm/system.h>
24 #include <asm/irq.h>
25 #include <asm/traps.h>
26 #include <asm/page.h>
27 #include <asm/gpio.h>
28
29 /*
30  * this must be called very early as the kernel might
31  * use some instruction that are emulated on the 060
32  */
33
34 void __init base_trap_init(void)
35 {
36 }
37
38 void __init trap_init (void)
39 {
40 }
41
42 asmlinkage void set_esp0 (unsigned long ssp)
43 {
44   current->thread.esp0 = ssp;
45 }
46
47 /*
48  *      Generic dumping code. Used for panic and debug.
49  */
50
51 static void dump(struct pt_regs *fp)
52 {
53         unsigned long   *sp;
54         unsigned char   *tp;
55         int             i;
56
57         printk("\nCURRENT PROCESS:\n\n");
58 #if 0
59 {
60         extern int      swt_lastjiffies, swt_reference;
61         printk("WATCHDOG: jiffies=%d lastjiffies=%d [%d] reference=%d\n",
62                 jiffies, swt_lastjiffies, (swt_lastjiffies - jiffies),
63                 swt_reference);
64 }
65 #endif
66         printk("COMM=%s PID=%d\n", current->comm, current->pid);
67         if (current->mm) {
68                 printk("TEXT=%08x-%08x DATA=%08x-%08x BSS=%08x-%08x\n",
69                         (int) current->mm->start_code,
70                         (int) current->mm->end_code,
71                         (int) current->mm->start_data,
72                         (int) current->mm->end_data,
73                         (int) current->mm->end_data,
74                         (int) current->mm->brk);
75                 printk("USER-STACK=%08x  KERNEL-STACK=%08x\n\n",
76                         (int) current->mm->start_stack,
77                         (int) PAGE_SIZE+(unsigned long)current);
78         }
79
80         printk("PC: %08lx\n", (long)fp->pc);
81         printk("CCR: %08lx   SP: %08lx\n", fp->ccr, (long) fp);
82         printk("ER0: %08lx  ER1: %08lx   ER2: %08lx   ER3: %08lx\n",
83                 fp->er0, fp->er1, fp->er2, fp->er3);
84         printk("\nCODE:");
85         tp = ((unsigned char *) fp->pc) - 0x20;
86         for (sp = (unsigned long *) tp, i = 0; (i < 0x40);  i += 4) {
87                 if ((i % 0x10) == 0)
88                         printk("\n%08x: ", (int) (tp + i));
89                 printk("%08x ", (int) *sp++);
90         }
91         printk("\n");
92
93         printk("\nKERNEL STACK:");
94         tp = ((unsigned char *) fp) - 0x40;
95         for (sp = (unsigned long *) tp, i = 0; (i < 0xc0); i += 4) {
96                 if ((i % 0x10) == 0)
97                         printk("\n%08x: ", (int) (tp + i));
98                 printk("%08x ", (int) *sp++);
99         }
100         printk("\n");
101         if (STACK_MAGIC != *(unsigned long *)((unsigned long)current+PAGE_SIZE))
102                 printk("(Possibly corrupted stack page??)\n");
103
104         printk("\n\n");
105 }
106
107 void show_trace_task(struct task_struct *tsk)
108 {
109         /* DAVIDM: we can do better, need a proper stack dump */
110         printk("STACK ksp=0x%lx, usp=0x%lx\n", tsk->thread.ksp, tsk->thread.usp);
111 }
112
113 void die_if_kernel (char *str, struct pt_regs *fp, int nr)
114 {
115         extern int console_loglevel;
116
117         if (!(fp->ccr & PS_S))
118                 return;
119
120         console_loglevel = 15;
121         dump(fp);
122
123         do_exit(SIGSEGV);
124 }