drm/i915: remove unused intel_pipe_get_connector()
[safe/jmp/linux-2.6] / arch / powerpc / xmon / xmon.c
index 52c7478..8bad7d5 100644 (file)
@@ -41,6 +41,7 @@
 #include <asm/spu_priv1.h>
 #include <asm/firmware.h>
 #include <asm/setjmp.h>
+#include <asm/reg.h>
 
 #ifdef CONFIG_PPC64
 #include <asm/hvcall.h>
 #define skipbl xmon_skipbl
 
 #ifdef CONFIG_SMP
-cpumask_t cpus_in_xmon = CPU_MASK_NONE;
+static cpumask_t cpus_in_xmon = CPU_MASK_NONE;
 static unsigned long xmon_taken = 1;
 static int xmon_owner;
 static int xmon_gate;
 #endif /* CONFIG_SMP */
 
-static unsigned long in_xmon = 0;
+static unsigned long in_xmon __read_mostly = 0;
 
 static unsigned long adrs;
 static int size = 1;
@@ -109,6 +110,7 @@ static int bsesc(void);
 static void dump(void);
 static void prdump(unsigned long, long);
 static int ppc_inst_dump(unsigned long, long, int);
+static void dump_log_buf(void);
 static void backtrace(struct pt_regs *);
 static void excprint(struct pt_regs *);
 static void prregs(struct pt_regs *);
@@ -154,13 +156,11 @@ static int do_spu_cmd(void);
 static void dump_tlb_44x(void);
 #endif
 
-int xmon_no_auto_backtrace;
+static int xmon_no_auto_backtrace;
 
 extern void xmon_enter(void);
 extern void xmon_leave(void);
 
-extern void xmon_save_regs(struct pt_regs *);
-
 #ifdef CONFIG_PPC64
 #define REG            "%.16lx"
 #define REGS_PER_LINE  4
@@ -198,6 +198,7 @@ Commands:\n\
   di   dump instructions\n\
   df   dump float values\n\
   dd   dump double values\n\
+  dl    dump the kernel log buffer\n\
   dr   dump stream of raw bytes\n\
   e    print exception information\n\
   f    flush cache\n\
@@ -327,8 +328,23 @@ static void release_output_lock(void)
 {
        xmon_speaker = 0;
 }
+
+int cpus_are_in_xmon(void)
+{
+       return !cpus_empty(cpus_in_xmon);
+}
 #endif
 
+static inline int unrecoverable_excp(struct pt_regs *regs)
+{
+#ifdef CONFIG_4xx
+       /* We have no MSR_RI bit on 4xx, so we simply return false */
+       return 0;
+#else
+       return ((regs->msr & MSR_RI) == 0);
+#endif
+}
+
 static int xmon_core(struct pt_regs *regs, int fromipi)
 {
        int cmd = 0;
@@ -382,7 +398,7 @@ static int xmon_core(struct pt_regs *regs, int fromipi)
        bp = NULL;
        if ((regs->msr & (MSR_IR|MSR_PR|MSR_SF)) == (MSR_IR|MSR_SF))
                bp = at_breakpoint(regs->nip);
-       if (bp || (regs->msr & MSR_RI) == 0)
+       if (bp || unrecoverable_excp(regs))
                fromipi = 0;
 
        if (!fromipi) {
@@ -393,7 +409,7 @@ static int xmon_core(struct pt_regs *regs, int fromipi)
                               cpu, BP_NUM(bp));
                        xmon_print_symbol(regs->nip, " ", ")\n");
                }
-               if ((regs->msr & MSR_RI) == 0)
+               if (unrecoverable_excp(regs))
                        printf("WARNING: exception is not recoverable, "
                               "can't continue\n");
                release_output_lock();
@@ -484,7 +500,7 @@ static int xmon_core(struct pt_regs *regs, int fromipi)
                        printf("Stopped at breakpoint %x (", BP_NUM(bp));
                        xmon_print_symbol(regs->nip, " ", ")\n");
                }
-               if ((regs->msr & MSR_RI) == 0)
+               if (unrecoverable_excp(regs))
                        printf("WARNING: exception is not recoverable, "
                               "can't continue\n");
                remove_bpts();
@@ -501,6 +517,15 @@ static int xmon_core(struct pt_regs *regs, int fromipi)
        in_xmon = 0;
 #endif
 
+#ifdef CONFIG_BOOKE
+       if (regs->msr & MSR_DE) {
+               bp = at_breakpoint(regs->nip);
+               if (bp != NULL) {
+                       regs->nip = (unsigned long) &bp->instr[0];
+                       atomic_inc(&bp->ref_count);
+               }
+       }
+#else
        if ((regs->msr & (MSR_IR|MSR_PR|MSR_SF)) == (MSR_IR|MSR_SF)) {
                bp = at_breakpoint(regs->nip);
                if (bp != NULL) {
@@ -514,7 +539,7 @@ static int xmon_core(struct pt_regs *regs, int fromipi)
                        }
                }
        }
-
+#endif
        insert_cpu_bpts();
 
        local_irq_restore(flags);
@@ -527,7 +552,7 @@ int xmon(struct pt_regs *excp)
        struct pt_regs regs;
 
        if (excp == NULL) {
-               xmon_save_regs(&regs);
+               ppc_save_regs(&regs);
                excp = &regs;
        }
 
@@ -593,7 +618,7 @@ static int xmon_iabr_match(struct pt_regs *regs)
 {
        if ((regs->msr & (MSR_IR|MSR_PR|MSR_SF)) != (MSR_IR|MSR_SF))
                return 0;
-       if (iabr == 0)
+       if (iabr == NULL)
                return 0;
        xmon_core(regs, 0);
        return 1;
@@ -878,6 +903,14 @@ cmds(struct pt_regs *excp)
        }
 }
 
+#ifdef CONFIG_BOOKE
+static int do_step(struct pt_regs *regs)
+{
+       regs->msr |= MSR_DE;
+       mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) | DBCR0_IC | DBCR0_IDM);
+       return 1;
+}
+#else
 /*
  * Step a single instruction.
  * Some instructions we emulate, others we execute with MSR_SE set.
@@ -908,6 +941,7 @@ static int do_step(struct pt_regs *regs)
        regs->msr |= MSR_SE;
        return 1;
 }
+#endif
 
 static void bootcmds(void)
 {
@@ -1142,7 +1176,7 @@ bpt_cmds(void)
                } else {
                        /* assume a breakpoint address */
                        bp = at_breakpoint(a);
-                       if (bp == 0) {
+                       if (bp == NULL) {
                                printf("No breakpoint at %x\n", a);
                                break;
                        }
@@ -1348,6 +1382,7 @@ static void backtrace(struct pt_regs *excp)
 
 static void print_bug_trap(struct pt_regs *regs)
 {
+#ifdef CONFIG_BUG
        const struct bug_entry *bug;
        unsigned long addr;
 
@@ -1368,9 +1403,10 @@ static void print_bug_trap(struct pt_regs *regs)
 #else
        printf("kernel BUG at %p!\n", (void *)bug->bug_addr);
 #endif
+#endif /* CONFIG_BUG */
 }
 
-void excprint(struct pt_regs *fp)
+static void excprint(struct pt_regs *fp)
 {
        unsigned long trap;
 
@@ -1408,7 +1444,7 @@ void excprint(struct pt_regs *fp)
                print_bug_trap(fp);
 }
 
-void prregs(struct pt_regs *fp)
+static void prregs(struct pt_regs *fp)
 {
        int n, trap;
        unsigned long base;
@@ -1463,7 +1499,7 @@ void prregs(struct pt_regs *fp)
                printf("dar = "REG"   dsisr = %.8lx\n", fp->dar, fp->dsisr);
 }
 
-void cacheflush(void)
+static void cacheflush(void)
 {
        int cmd;
        unsigned long nflush;
@@ -1495,7 +1531,7 @@ void cacheflush(void)
        catch_memory_errors = 0;
 }
 
-unsigned long
+static unsigned long
 read_spr(int n)
 {
        unsigned int instrs[2];
@@ -1533,7 +1569,7 @@ read_spr(int n)
        return ret;
 }
 
-void
+static void
 write_spr(int n, unsigned long val)
 {
        unsigned int instrs[2];
@@ -1571,7 +1607,7 @@ static unsigned long regno;
 extern char exc_prolog;
 extern char dec_exc;
 
-void super_regs(void)
+static void super_regs(void)
 {
        int cmd;
        unsigned long val;
@@ -1605,7 +1641,8 @@ void super_regs(void)
                               ptrLpPaca->saved_srr0, ptrLpPaca->saved_srr1);
                        printf("    Saved Gpr3=%.16lx  Saved Gpr4=%.16lx \n",
                               ptrLpPaca->saved_gpr3, ptrLpPaca->saved_gpr4);
-                       printf("    Saved Gpr5=%.16lx \n", ptrLpPaca->saved_gpr5);
+                       printf("    Saved Gpr5=%.16lx \n",
+                               ptrLpPaca->gpr5_dword.saved_gpr5);
                }
 #endif
 
@@ -1629,7 +1666,7 @@ void super_regs(void)
 /*
  * Stuff for reading and writing memory safely
  */
-int
+static int
 mread(unsigned long adrs, void *buf, int size)
 {
        volatile int n;
@@ -1666,7 +1703,7 @@ mread(unsigned long adrs, void *buf, int size)
        return n;
 }
 
-int
+static int
 mwrite(unsigned long adrs, void *buf, int size)
 {
        volatile int n;
@@ -1731,7 +1768,7 @@ static int handle_fault(struct pt_regs *regs)
 
 #define SWAP(a, b, t)  ((t) = (a), (a) = (b), (b) = (t))
 
-void
+static void
 byterev(unsigned char *val, int size)
 {
        int t;
@@ -1793,7 +1830,7 @@ static char *memex_subcmd_help_string =
     "  x        exit this mode\n"
     "";
 
-void
+static void
 memex(void)
 {
        int cmd, inc, i, nslash;
@@ -1944,7 +1981,7 @@ memex(void)
        }
 }
 
-int
+static int
 bsesc(void)
 {
        int c;
@@ -1984,7 +2021,7 @@ static void xmon_rawdump (unsigned long adrs, long ndump)
 #define isxdigit(c)    (('0' <= (c) && (c) <= '9') \
                         || ('a' <= (c) && (c) <= 'f') \
                         || ('A' <= (c) && (c) <= 'F'))
-void
+static void
 dump(void)
 {
        int c;
@@ -2003,6 +2040,8 @@ dump(void)
                        nidump = MAX_DUMP;
                adrs += ppc_inst_dump(adrs, nidump, 1);
                last_cmd = "di\n";
+       } else if (c == 'l') {
+               dump_log_buf();
        } else if (c == 'r') {
                scanhex(&ndump);
                if (ndump == 0)
@@ -2022,7 +2061,7 @@ dump(void)
        }
 }
 
-void
+static void
 prdump(unsigned long adrs, long ndump)
 {
        long n, m, c, r, nr;
@@ -2066,7 +2105,7 @@ prdump(unsigned long adrs, long ndump)
 
 typedef int (*instruction_dump_func)(unsigned long inst, unsigned long addr);
 
-int
+static int
 generic_inst_dump(unsigned long adr, long count, int praddr,
                        instruction_dump_func dump_func)
 {
@@ -2104,7 +2143,7 @@ generic_inst_dump(unsigned long adr, long count, int praddr,
        return adr - first_adr;
 }
 
-int
+static int
 ppc_inst_dump(unsigned long adr, long count, int praddr)
 {
        return generic_inst_dump(adr, count, praddr, print_insn_powerpc);
@@ -2116,6 +2155,49 @@ print_address(unsigned long addr)
        xmon_print_symbol(addr, "\t# ", "");
 }
 
+void
+dump_log_buf(void)
+{
+        const unsigned long size = 128;
+        unsigned long end, addr;
+        unsigned char buf[size + 1];
+
+        addr = 0;
+        buf[size] = '\0';
+
+        if (setjmp(bus_error_jmp) != 0) {
+                printf("Unable to lookup symbol __log_buf!\n");
+                return;
+        }
+
+        catch_memory_errors = 1;
+        sync();
+        addr = kallsyms_lookup_name("__log_buf");
+
+        if (! addr)
+                printf("Symbol __log_buf not found!\n");
+        else {
+                end = addr + (1 << CONFIG_LOG_BUF_SHIFT);
+                while (addr < end) {
+                        if (! mread(addr, buf, size)) {
+                                printf("Can't read memory at address 0x%lx\n", addr);
+                                break;
+                        }
+
+                        printf("%s", buf);
+
+                        if (strlen(buf) < size)
+                                break;
+
+                        addr += size;
+                }
+        }
+
+        sync();
+        /* wait a little while to see if we get a machine check */
+        __delay(200);
+        catch_memory_errors = 0;
+}
 
 /*
  * Memory operations - move, set, print differences
@@ -2126,7 +2208,7 @@ static unsigned long mval;                /* byte value to set memory to */
 static unsigned long mcount;           /* # bytes to affect */
 static unsigned long mdiffs;           /* max # differences to print */
 
-void
+static void
 memops(int cmd)
 {
        scanhex((void *)&mdest);
@@ -2152,7 +2234,7 @@ memops(int cmd)
        }
 }
 
-void
+static void
 memdiffs(unsigned char *p1, unsigned char *p2, unsigned nb, unsigned maxpr)
 {
        unsigned n, prt;
@@ -2170,7 +2252,7 @@ memdiffs(unsigned char *p1, unsigned char *p2, unsigned nb, unsigned maxpr)
 static unsigned mend;
 static unsigned mask;
 
-void
+static void
 memlocate(void)
 {
        unsigned a, n;
@@ -2203,7 +2285,7 @@ memlocate(void)
 static unsigned long mskip = 0x1000;
 static unsigned long mlim = 0xffffffff;
 
-void
+static void
 memzcan(void)
 {
        unsigned char v;
@@ -2230,7 +2312,7 @@ memzcan(void)
                printf("%.8x\n", a - mskip);
 }
 
-void proccall(void)
+static void proccall(void)
 {
        unsigned long args[8];
        unsigned long ret;
@@ -2388,7 +2470,7 @@ scanhex(unsigned long *vp)
        return 1;
 }
 
-void
+static void
 scannl(void)
 {
        int c;
@@ -2399,7 +2481,7 @@ scannl(void)
                c = inchar();
 }
 
-int hexdigit(int c)
+static int hexdigit(int c)
 {
        if( '0' <= c && c <= '9' )
                return c - '0';
@@ -2430,13 +2512,13 @@ getstring(char *s, int size)
 static char line[256];
 static char *lineptr;
 
-void
+static void
 flush_input(void)
 {
        lineptr = NULL;
 }
 
-int
+static int
 inchar(void)
 {
        if (lineptr == NULL || *lineptr == 0) {
@@ -2449,7 +2531,7 @@ inchar(void)
        return *lineptr++;
 }
 
-void
+static void
 take_input(char *str)
 {
        lineptr = str;
@@ -2517,7 +2599,7 @@ static void xmon_print_symbol(unsigned long address, const char *mid,
        printf("%s", after);
 }
 
-#ifdef CONFIG_PPC64
+#ifdef CONFIG_PPC_BOOK3S_64
 static void dump_slb(void)
 {
        int i;
@@ -2618,7 +2700,8 @@ static void dump_tlb_44x(void)
        }
 }
 #endif /* CONFIG_44x */
-void xmon_init(int enable)
+
+static void xmon_init(int enable)
 {
 #ifdef CONFIG_PPC_ISERIES
        if (firmware_has_feature(FW_FEATURE_ISERIES))
@@ -2842,9 +2925,10 @@ static void dump_spu_fields(struct spu *spu)
        DUMP_FIELD(spu, "0x%lx", ls_size);
        DUMP_FIELD(spu, "0x%x", node);
        DUMP_FIELD(spu, "0x%lx", flags);
-       DUMP_FIELD(spu, "0x%lx", dar);
-       DUMP_FIELD(spu, "0x%lx", dsisr);
        DUMP_FIELD(spu, "%d", class_0_pending);
+       DUMP_FIELD(spu, "0x%lx", class_0_dar);
+       DUMP_FIELD(spu, "0x%lx", class_1_dar);
+       DUMP_FIELD(spu, "0x%lx", class_1_dsisr);
        DUMP_FIELD(spu, "0x%lx", irqs[0]);
        DUMP_FIELD(spu, "0x%lx", irqs[1]);
        DUMP_FIELD(spu, "0x%lx", irqs[2]);