aboutsummaryrefslogtreecommitdiff
path: root/arch/v850/kernel/bug.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 15:20:36 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 15:20:36 -0700
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/v850/kernel/bug.c
Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/v850/kernel/bug.c')
-rw-r--r--arch/v850/kernel/bug.c142
1 files changed, 142 insertions, 0 deletions
diff --git a/arch/v850/kernel/bug.c b/arch/v850/kernel/bug.c
new file mode 100644
index 00000000000..c78cf750915
--- /dev/null
+++ b/arch/v850/kernel/bug.c
@@ -0,0 +1,142 @@
+/*
+ * arch/v850/kernel/bug.c -- Bug reporting functions
+ *
+ * Copyright (C) 2001,02,03 NEC Electronics Corporation
+ * Copyright (C) 2001,02,03 Miles Bader <miles@gnu.org>
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * Written by Miles Bader <miles@gnu.org>
+ */
+
+#include <linux/kernel.h>
+#include <linux/reboot.h>
+#include <linux/sched.h>
+#include <linux/module.h>
+
+#include <asm/errno.h>
+#include <asm/ptrace.h>
+#include <asm/processor.h>
+#include <asm/current.h>
+
+/* We should use __builtin_return_address, but it doesn't work in gcc-2.90
+ (which is currently our standard compiler on the v850). */
+#define ret_addr() ({ register u32 lp asm ("lp"); lp; })
+#define stack_addr() ({ register u32 sp asm ("sp"); sp; })
+
+void __bug ()
+{
+ printk (KERN_CRIT "kernel BUG at PC 0x%x (SP ~0x%x)!\n",
+ ret_addr() - 4, /* - 4 for `jarl' */
+ stack_addr());
+ machine_halt ();
+}
+
+int bad_trap (int trap_num, struct pt_regs *regs)
+{
+ printk (KERN_CRIT
+ "unimplemented trap %d called at 0x%08lx, pid %d!\n",
+ trap_num, regs->pc, current->pid);
+ return -ENOSYS;
+}
+
+#ifdef CONFIG_RESET_GUARD
+void unexpected_reset (unsigned long ret_addr, unsigned long kmode,
+ struct task_struct *task, unsigned long sp)
+{
+ printk (KERN_CRIT
+ "unexpected reset in %s mode, pid %d"
+ " (ret_addr = 0x%lx, sp = 0x%lx)\n",
+ kmode ? "kernel" : "user",
+ task ? task->pid : -1,
+ ret_addr, sp);
+
+ machine_halt ();
+}
+#endif /* CONFIG_RESET_GUARD */
+
+
+
+struct spec_reg_name {
+ const char *name;
+ int gpr;
+};
+
+struct spec_reg_name spec_reg_names[] = {
+ { "sp", GPR_SP },
+ { "gp", GPR_GP },
+ { "tp", GPR_TP },
+ { "ep", GPR_EP },
+ { "lp", GPR_LP },
+ { 0, 0 }
+};
+
+void show_regs (struct pt_regs *regs)
+{
+ int gpr_base, gpr_offs;
+
+ printk (" pc 0x%08lx psw 0x%08lx kernel_mode %d\n",
+ regs->pc, regs->psw, regs->kernel_mode);
+ printk (" ctpc 0x%08lx ctpsw 0x%08lx ctbp 0x%08lx\n",
+ regs->ctpc, regs->ctpsw, regs->ctbp);
+
+ for (gpr_base = 0; gpr_base < NUM_GPRS; gpr_base += 4) {
+ for (gpr_offs = 0; gpr_offs < 4; gpr_offs++) {
+ int gpr = gpr_base + gpr_offs;
+ long val = regs->gpr[gpr];
+ struct spec_reg_name *srn;
+
+ for (srn = spec_reg_names; srn->name; srn++)
+ if (srn->gpr == gpr)
+ break;
+
+ if (srn->name)
+ printk ("%7s 0x%08lx", srn->name, val);
+ else
+ printk (" r%02d 0x%08lx", gpr, val);
+ }
+
+ printk ("\n");
+ }
+}
+
+/*
+ * TASK is a pointer to the task whose backtrace we want to see (or NULL
+ * for current task), SP is the stack pointer of the first frame that
+ * should be shown in the back trace (or NULL if the entire call-chain of
+ * the task should be shown).
+ */
+void show_stack (struct task_struct *task, unsigned long *sp)
+{
+ unsigned long addr, end;
+
+ if (sp)
+ addr = (unsigned long)sp;
+ else if (task)
+ addr = task_sp (task);
+ else
+ addr = stack_addr ();
+
+ addr = addr & ~3;
+ end = (addr + THREAD_SIZE - 1) & THREAD_MASK;
+
+ while (addr < end) {
+ printk ("%8lX: ", addr);
+ while (addr < end) {
+ printk (" %8lX", *(unsigned long *)addr);
+ addr += sizeof (unsigned long);
+ if (! (addr & 0xF))
+ break;
+ }
+ printk ("\n");
+ }
+}
+
+void dump_stack ()
+{
+ show_stack (0, 0);
+}
+
+EXPORT_SYMBOL(dump_stack);