Linux Audio

Check our new training course

Loading...
v4.6
  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
 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>
 24
 25#include <asm/irq.h>
 26#include <asm/traps.h>
 27#include <asm/page.h>
 28
 29static DEFINE_SPINLOCK(die_lock);
 30
 31/*
 32 * this must be called very early as the kernel might
 33 * use some instruction that are emulated on the 060
 34 */
 35
 36void __init base_trap_init(void)
 37{
 38}
 39
 40void __init trap_init(void)
 41{
 42}
 43
 44asmlinkage void set_esp0(unsigned long ssp)
 45{
 46	current->thread.esp0 = ssp;
 47}
 48
 49/*
 50 *	Generic dumping code. Used for panic and debug.
 51 */
 52
 53static void dump(struct pt_regs *fp)
 54{
 55	unsigned long	*sp;
 56	unsigned char	*tp;
 57	int		i;
 58
 59	pr_info("\nCURRENT PROCESS:\n\n");
 60	pr_info("COMM=%s PID=%d\n", current->comm, current->pid);
 61	if (current->mm) {
 62		pr_info("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		pr_info("USER-STACK=%08x  KERNEL-STACK=%08lx\n\n",
 70			(int) current->mm->start_stack,
 71			(int) PAGE_SIZE+(unsigned long)current);
 72	}
 73
 74	show_regs(fp);
 75	pr_info("\nCODE:");
 76	tp = ((unsigned char *) fp->pc) - 0x20;
 77	for (sp = (unsigned long *) tp, i = 0; (i < 0x40);  i += 4) {
 78		if ((i % 0x10) == 0)
 79			pr_info("\n%08x: ", (int) (tp + i));
 80		pr_info("%08x ", (int) *sp++);
 81	}
 82	pr_info("\n");
 83
 84	pr_info("\nKERNEL STACK:");
 85	tp = ((unsigned char *) fp) - 0x40;
 86	for (sp = (unsigned long *) tp, i = 0; (i < 0xc0); i += 4) {
 87		if ((i % 0x10) == 0)
 88			pr_info("\n%08x: ", (int) (tp + i));
 89		pr_info("%08x ", (int) *sp++);
 90	}
 91	pr_info("\n");
 92	if (STACK_MAGIC != *(unsigned long *)((unsigned long)current+PAGE_SIZE))
 93		pr_info("(Possibly corrupted stack page??)\n");
 94
 95	pr_info("\n\n");
 96}
 97
 98void die(const char *str, struct pt_regs *fp, unsigned long err)
 99{
100	static int diecount;
101
102	oops_enter();
103
104	console_verbose();
105	spin_lock_irq(&die_lock);
106	report_bug(fp->pc, fp);
107	pr_crit("%s: %04lx [#%d] ", str, err & 0xffff, ++diecount);
108	dump(fp);
109
110	spin_unlock_irq(&die_lock);
111	do_exit(SIGSEGV);
112}
113
 
 
 
 
 
114static int kstack_depth_to_print = 24;
115
116void show_stack(struct task_struct *task, unsigned long *esp)
117{
118	unsigned long *stack,  addr;
119	int i;
120
121	if (esp == NULL)
122		esp = (unsigned long *) &esp;
123
124	stack = esp;
125
126	pr_info("Stack from %08lx:", (unsigned long)stack);
127	for (i = 0; i < kstack_depth_to_print; i++) {
128		if (((unsigned long)stack & (THREAD_SIZE - 1)) >=
129		    THREAD_SIZE-4)
130			break;
131		if (i % 8 == 0)
132			pr_info(" ");
133		pr_cont(" %08lx", *stack++);
134	}
135
136	pr_info("\nCall Trace:\n");
137	i = 0;
138	stack = esp;
139	while (((unsigned long)stack & (THREAD_SIZE - 1)) < THREAD_SIZE-4) {
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				pr_info("       ");
152			pr_cont(" [<%08lx>]", addr);
153			i++;
154		}
155	}
156	pr_info("\n");
 
 
 
 
 
157}
v3.5.6
  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
 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>
 24
 25#include <asm/irq.h>
 26#include <asm/traps.h>
 27#include <asm/page.h>
 28
 29static DEFINE_SPINLOCK(die_lock);
 30
 31/*
 32 * this must be called very early as the kernel might
 33 * use some instruction that are emulated on the 060
 34 */
 35
 36void __init base_trap_init(void)
 37{
 38}
 39
 40void __init trap_init (void)
 41{
 42}
 43
 44asmlinkage void set_esp0 (unsigned long ssp)
 45{
 46	current->thread.esp0 = ssp;
 47}
 48
 49/*
 50 *	Generic dumping code. Used for panic and debug.
 51 */
 52
 53static void dump(struct pt_regs *fp)
 54{
 55	unsigned long	*sp;
 56	unsigned char	*tp;
 57	int		i;
 58
 59	printk("\nCURRENT PROCESS:\n\n");
 60	printk("COMM=%s PID=%d\n", current->comm, current->pid);
 61	if (current->mm) {
 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);
 72	}
 73
 74	show_regs(fp);
 75	printk("\nCODE:");
 76	tp = ((unsigned char *) fp->pc) - 0x20;
 77	for (sp = (unsigned long *) tp, i = 0; (i < 0x40);  i += 4) {
 78		if ((i % 0x10) == 0)
 79			printk("\n%08x: ", (int) (tp + i));
 80		printk("%08x ", (int) *sp++);
 81	}
 82	printk("\n");
 83
 84	printk("\nKERNEL STACK:");
 85	tp = ((unsigned char *) fp) - 0x40;
 86	for (sp = (unsigned long *) tp, i = 0; (i < 0xc0); i += 4) {
 87		if ((i % 0x10) == 0)
 88			printk("\n%08x: ", (int) (tp + i));
 89		printk("%08x ", (int) *sp++);
 90	}
 91	printk("\n");
 92	if (STACK_MAGIC != *(unsigned long *)((unsigned long)current+PAGE_SIZE))
 93                printk("(Possibly corrupted stack page??)\n");
 94
 95	printk("\n\n");
 96}
 97
 98void die(const char *str, struct pt_regs *fp, unsigned long err)
 99{
100	static int diecount;
101
102	oops_enter();
103
104	console_verbose();
105	spin_lock_irq(&die_lock);
106	report_bug(fp->pc, fp);
107	printk(KERN_EMERG "%s: %04lx [#%d] ", str, err & 0xffff, ++diecount);
108	dump(fp);
109
110	spin_unlock_irq(&die_lock);
111	do_exit(SIGSEGV);
112}
113
114extern char _start, _etext;
115#define check_kernel_text(addr) \
116        ((addr >= (unsigned long)(&_start)) && \
117         (addr <  (unsigned long)(&_etext))) 
118
119static int kstack_depth_to_print = 24;
120
121void show_stack(struct task_struct *task, unsigned long *esp)
122{
123	unsigned long *stack,  addr;
124	int i;
125
126	if (esp == NULL)
127		esp = (unsigned long *) &esp;
128
129	stack = esp;
130
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)
 
134			break;
135		if (i % 8 == 0)
136			printk("\n       ");
137		printk(" %08lx", *stack++);
138	}
139
140	printk("\nCall Trace:");
141	i = 0;
142	stack = esp;
143	while (((unsigned long)stack & (THREAD_SIZE - 1)) != 0) {
144		addr = *stack++;
145		/*
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.
152		 */
153		if (check_kernel_text(addr)) {
154			if (i % 4 == 0)
155				printk("\n       ");
156			printk(" [<%08lx>]", addr);
157			i++;
158		}
159	}
160	printk("\n");
161}
162
163void show_trace_task(struct task_struct *tsk)
164{
165	show_stack(tsk,(unsigned long *)tsk->thread.esp0);
166}
167
168void dump_stack(void)
169{
170	show_stack(NULL,NULL);
171}
172
173EXPORT_SYMBOL(dump_stack);