2 * arch/v850/kernel/bug.c -- Bug reporting functions
4 * Copyright (C) 2001,02,03 NEC Electronics Corporation
5 * Copyright (C) 2001,02,03 Miles Bader <miles@gnu.org>
7 * This file is subject to the terms and conditions of the GNU General
8 * Public License. See the file COPYING in the main directory of this
9 * archive for more details.
11 * Written by Miles Bader <miles@gnu.org>
14 #include <linux/kernel.h>
15 #include <linux/reboot.h>
16 #include <linux/sched.h>
17 #include <linux/module.h>
19 #include <asm/errno.h>
20 #include <asm/ptrace.h>
21 #include <asm/processor.h>
22 #include <asm/current.h>
24 /* We should use __builtin_return_address, but it doesn't work in gcc-2.90
25 (which is currently our standard compiler on the v850). */
26 #define ret_addr() ({ register u32 lp asm ("lp"); lp; })
27 #define stack_addr() ({ register u32 sp asm ("sp"); sp; })
31 printk (KERN_CRIT "kernel BUG at PC 0x%x (SP ~0x%x)!\n",
32 ret_addr() - 4, /* - 4 for `jarl' */
37 int bad_trap (int trap_num, struct pt_regs *regs)
40 "unimplemented trap %d called at 0x%08lx, pid %d!\n",
41 trap_num, regs->pc, current->pid);
45 #ifdef CONFIG_RESET_GUARD
46 void unexpected_reset (unsigned long ret_addr, unsigned long kmode,
47 struct task_struct *task, unsigned long sp)
50 "unexpected reset in %s mode, pid %d"
51 " (ret_addr = 0x%lx, sp = 0x%lx)\n",
52 kmode ? "kernel" : "user",
53 task ? task->pid : -1,
58 #endif /* CONFIG_RESET_GUARD */
62 struct spec_reg_name {
67 struct spec_reg_name spec_reg_names[] = {
76 void show_regs (struct pt_regs *regs)
78 int gpr_base, gpr_offs;
80 printk (" pc 0x%08lx psw 0x%08lx kernel_mode %d\n",
81 regs->pc, regs->psw, regs->kernel_mode);
82 printk (" ctpc 0x%08lx ctpsw 0x%08lx ctbp 0x%08lx\n",
83 regs->ctpc, regs->ctpsw, regs->ctbp);
85 for (gpr_base = 0; gpr_base < NUM_GPRS; gpr_base += 4) {
86 for (gpr_offs = 0; gpr_offs < 4; gpr_offs++) {
87 int gpr = gpr_base + gpr_offs;
88 long val = regs->gpr[gpr];
89 struct spec_reg_name *srn;
91 for (srn = spec_reg_names; srn->name; srn++)
96 printk ("%7s 0x%08lx", srn->name, val);
98 printk (" r%02d 0x%08lx", gpr, val);
106 * TASK is a pointer to the task whose backtrace we want to see (or NULL
107 * for current task), SP is the stack pointer of the first frame that
108 * should be shown in the back trace (or NULL if the entire call-chain of
109 * the task should be shown).
111 void show_stack (struct task_struct *task, unsigned long *sp)
113 unsigned long addr, end;
116 addr = (unsigned long)sp;
118 addr = task_sp (task);
120 addr = stack_addr ();
123 end = (addr + THREAD_SIZE - 1) & THREAD_MASK;
126 printk ("%8lX: ", addr);
128 printk (" %8lX", *(unsigned long *)addr);
129 addr += sizeof (unsigned long);
142 EXPORT_SYMBOL(dump_stack);