Path: blob/master/arch/cris/arch-v32/kernel/traps.c
15125 views
/*1* Copyright (C) 2003-2006, Axis Communications AB.2*/34#include <linux/ptrace.h>5#include <linux/module.h>6#include <asm/uaccess.h>7#include <hwregs/supp_reg.h>8#include <hwregs/intr_vect_defs.h>9#include <asm/irq.h>1011void show_registers(struct pt_regs *regs)12{13/*14* It's possible to use either the USP register or current->thread.usp.15* USP might not correspond to the current process for all cases this16* function is called, and current->thread.usp isn't up to date for the17* current process. Experience shows that using USP is the way to go.18*/19unsigned long usp = rdusp();20unsigned long d_mmu_cause;21unsigned long i_mmu_cause;2223printk("CPU: %d\n", smp_processor_id());2425printk("ERP: %08lx SRP: %08lx CCS: %08lx USP: %08lx MOF: %08lx\n",26regs->erp, regs->srp, regs->ccs, 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 acr: %08lx\n",38regs->r12, regs->r13, regs->orig_r10, regs->acr);3940printk(" sp: %08lx\n", (unsigned long)regs);4142SUPP_BANK_SEL(BANK_IM);43SUPP_REG_RD(RW_MM_CAUSE, i_mmu_cause);4445SUPP_BANK_SEL(BANK_DM);46SUPP_REG_RD(RW_MM_CAUSE, d_mmu_cause);4748printk(" Data MMU Cause: %08lx\n", d_mmu_cause);49printk("Instruction MMU Cause: %08lx\n", i_mmu_cause);5051printk("Process %s (pid: %d, stackpage=%08lx)\n",52current->comm, current->pid, (unsigned long)current);5354/*55* When in-kernel, we also print out the stack and code at the56* time of the fault..57*/58if (!user_mode(regs)) {59int i;6061show_stack(NULL, (unsigned long *)usp);6263/*64* If the previous stack-dump wasn't a kernel one, dump the65* kernel stack now.66*/67if (usp != 0)68show_stack(NULL, NULL);6970printk("\nCode: ");7172if (regs->erp < PAGE_OFFSET)73goto bad_value;7475/*76* Quite often the value at regs->erp doesn't point to the77* interesting instruction, which often is the previous78* instruction. So dump at an offset large enough that the79* instruction decoding should be in sync at the interesting80* point, but small enough to fit on a row. The regs->erp81* location is pointed out in a ksymoops-friendly way by82* wrapping the byte for that address in parenthesises.83*/84for (i = -12; i < 12; i++) {85unsigned char c;8687if (__get_user(c, &((unsigned char *)regs->erp)[i])) {88bad_value:89printk(" Bad IP value.");90break;91}9293if (i == 0)94printk("(%02x) ", c);95else96printk("%02x ", c);97}98printk("\n");99}100}101102void arch_enable_nmi(void)103{104unsigned long flags;105106local_save_flags(flags);107flags |= (1 << 30); /* NMI M flag is at bit 30 */108local_irq_restore(flags);109}110111extern void (*nmi_handler)(struct pt_regs *);112void handle_nmi(struct pt_regs *regs)113{114#ifdef CONFIG_ETRAXFS115reg_intr_vect_r_nmi r;116#endif117118if (nmi_handler)119nmi_handler(regs);120121#ifdef CONFIG_ETRAXFS122/* Wait until nmi is no longer active. */123do {124r = REG_RD(intr_vect, regi_irq, r_nmi);125} while (r.ext == regk_intr_vect_on);126#endif127}128129130#ifdef CONFIG_BUG131extern void die_if_kernel(const char *str, struct pt_regs *regs, long err);132133/* Copy of the regs at BUG() time. */134struct pt_regs BUG_regs;135136void do_BUG(char *file, unsigned int line)137{138printk("kernel BUG at %s:%d!\n", file, line);139die_if_kernel("Oops", &BUG_regs, 0);140}141EXPORT_SYMBOL(do_BUG);142143void fixup_BUG(struct pt_regs *regs)144{145BUG_regs = *regs;146147#ifdef CONFIG_DEBUG_BUGVERBOSE148/*149* Fixup the BUG arguments through exception handlers.150*/151{152const struct exception_table_entry *fixup;153154/*155* ERP points at the "break 14" + 2, compensate for the 2156* bytes.157*/158fixup = search_exception_tables(instruction_pointer(regs) - 2);159if (fixup) {160/* Adjust the instruction pointer in the stackframe. */161instruction_pointer(regs) = fixup->fixup;162arch_fixup(regs);163}164}165#else166/* Dont try to lookup the filename + line, just dump regs. */167do_BUG("unknown", 0);168#endif169}170171/*172* Break 14 handler. Save regs and jump into the fixup_BUG.173*/174__asm__ ( ".text\n\t"175".global breakh_BUG\n\t"176"breakh_BUG:\n\t"177SAVE_ALL178KGDB_FIXUP179"move.d $sp, $r10\n\t"180"jsr fixup_BUG\n\t"181"nop\n\t"182"jump ret_from_intr\n\t"183"nop\n\t");184185186#ifdef CONFIG_DEBUG_BUGVERBOSE187void188handle_BUG(struct pt_regs *regs)189{190}191#endif192#endif193194195