Path: blob/master/arch/cris/arch-v10/kernel/traps.c
15125 views
/*1* Helper functions for trap handlers2*3* Copyright (C) 2000-2007, Axis Communications AB.4*5* Authors: Bjorn Wesen6* Hans-Peter Nilsson7*8*/910#include <linux/ptrace.h>11#include <asm/uaccess.h>12#include <arch/sv_addr_ag.h>1314void15show_registers(struct pt_regs *regs)16{17/*18* It's possible to use either the USP register or current->thread.usp.19* USP might not correspond to the current process for all cases this20* function is called, and current->thread.usp isn't up to date for the21* current process. Experience shows that using USP is the way to go.22*/23unsigned long usp = rdusp();2425printk("IRP: %08lx SRP: %08lx DCCR: %08lx USP: %08lx MOF: %08lx\n",26regs->irp, regs->srp, regs->dccr, usp, regs->mof);2728printk(" r0: %08lx r1: %08lx r2: %08lx r3: %08lx\n",29regs->r0, regs->r1, regs->r2, regs->r3);3031printk(" r4: %08lx r5: %08lx r6: %08lx r7: %08lx\n",32regs->r4, regs->r5, regs->r6, regs->r7);3334printk(" r8: %08lx r9: %08lx r10: %08lx r11: %08lx\n",35regs->r8, regs->r9, regs->r10, regs->r11);3637printk("r12: %08lx r13: %08lx oR10: %08lx sp: %08lx\n",38regs->r12, regs->r13, regs->orig_r10, (long unsigned)regs);3940printk("R_MMU_CAUSE: %08lx\n", (unsigned long)*R_MMU_CAUSE);4142printk("Process %s (pid: %d, stackpage=%08lx)\n",43current->comm, current->pid, (unsigned long)current);4445/*46* When in-kernel, we also print out the stack and code at the47* time of the fault..48*/49if (!user_mode(regs)) {50int i;5152show_stack(NULL, (unsigned long *)usp);5354/*55* If the previous stack-dump wasn't a kernel one, dump the56* kernel stack now.57*/58if (usp != 0)59show_stack(NULL, NULL);6061printk("\nCode: ");6263if (regs->irp < PAGE_OFFSET)64goto bad_value;6566/*67* Quite often the value at regs->irp doesn't point to the68* interesting instruction, which often is the previous69* instruction. So dump at an offset large enough that the70* instruction decoding should be in sync at the interesting71* point, but small enough to fit on a row. The regs->irp72* location is pointed out in a ksymoops-friendly way by73* wrapping the byte for that address in parenthesises.74*/75for (i = -12; i < 12; i++) {76unsigned char c;7778if (__get_user(c, &((unsigned char *)regs->irp)[i])) {79bad_value:80printk(" Bad IP value.");81break;82}8384if (i == 0)85printk("(%02x) ", c);86else87printk("%02x ", c);88}89printk("\n");90}91}9293void94arch_enable_nmi(void)95{96asm volatile ("setf m");97}9899extern void (*nmi_handler)(struct pt_regs *);100void handle_nmi(struct pt_regs *regs)101{102if (nmi_handler)103nmi_handler(regs);104105/* Wait until nmi is no longer active. (We enable NMI immediately after106returning from this function, and we don't want it happening while107exiting from the NMI interrupt handler.) */108while (*R_IRQ_MASK0_RD & IO_STATE(R_IRQ_MASK0_RD, nmi_pin, active))109;110}111112#ifdef CONFIG_DEBUG_BUGVERBOSE113void114handle_BUG(struct pt_regs *regs)115{116struct bug_frame f;117unsigned char c;118unsigned long irp = regs->irp;119120if (__copy_from_user(&f, (const void __user *)(irp - 8), sizeof f))121return;122if (f.prefix != BUG_PREFIX || f.magic != BUG_MAGIC)123return;124if (__get_user(c, f.filename))125f.filename = "<bad filename>";126127printk("kernel BUG at %s:%d!\n", f.filename, f.line);128}129#endif130131132