drm/i915: remove unused intel_pipe_get_connector()
[safe/jmp/linux-2.6] / arch / powerpc / xmon / xmon.c
index 865e367..8bad7d5 100644 (file)
 #include <asm/spu.h>
 #include <asm/spu_priv1.h>
 #include <asm/firmware.h>
+#include <asm/setjmp.h>
+#include <asm/reg.h>
 
 #ifdef CONFIG_PPC64
 #include <asm/hvcall.h>
 #include <asm/paca.h>
-#include <asm/iseries/it_lp_reg_save.h>
 #endif
 
 #include "nonstdio.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;
@@ -71,12 +72,9 @@ static unsigned long ncsum = 4096;
 static int termch;
 static char tmpstr[128];
 
-#define JMP_BUF_LEN    23
 static long bus_error_jmp[JMP_BUF_LEN];
 static int catch_memory_errors;
 static long *xmon_fault_jmp[NR_CPUS];
-#define setjmp xmon_setjmp
-#define longjmp xmon_longjmp
 
 /* Breakpoint stuff */
 struct bpt {
@@ -112,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 *);
@@ -157,15 +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 long setjmp(long *);
-extern void longjmp(long *, long);
-extern void xmon_save_regs(struct pt_regs *);
-
 #ifdef CONFIG_PPC64
 #define REG            "%.16lx"
 #define REGS_PER_LINE  4
@@ -203,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\
@@ -332,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;
@@ -387,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) {
@@ -398,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();
@@ -489,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();
@@ -506,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) {
@@ -519,7 +539,7 @@ static int xmon_core(struct pt_regs *regs, int fromipi)
                        }
                }
        }
-
+#endif
        insert_cpu_bpts();
 
        local_irq_restore(flags);
@@ -532,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;
        }
 
@@ -598,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;
@@ -883,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.
@@ -913,6 +941,7 @@ static int do_step(struct pt_regs *regs)
        regs->msr |= MSR_SE;
        return 1;
 }
+#endif
 
 static void bootcmds(void)
 {
@@ -1147,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;
                        }
@@ -1248,15 +1277,12 @@ static void get_function_bounds(unsigned long pc, unsigned long *startp,
 
 static int xmon_depth_to_print = 64;
 
-#ifdef CONFIG_PPC64
-#define LRSAVE_OFFSET          0x10
-#define REG_FRAME_MARKER       0x7265677368657265ul    /* "regshere" */
-#define MARKER_OFFSET          0x60
+#define LRSAVE_OFFSET          (STACK_FRAME_LR_SAVE * sizeof(unsigned long))
+#define MARKER_OFFSET          (STACK_FRAME_MARKER * sizeof(unsigned long))
+
+#ifdef __powerpc64__
 #define REGS_OFFSET            0x70
 #else
-#define LRSAVE_OFFSET          4
-#define REG_FRAME_MARKER       0x72656773
-#define MARKER_OFFSET          8
 #define REGS_OFFSET            16
 #endif
 
@@ -1322,7 +1348,7 @@ static void xmon_show_stack(unsigned long sp, unsigned long lr,
                /* Look for "regshere" marker to see if this is
                   an exception frame. */
                if (mread(sp + MARKER_OFFSET, &marker, sizeof(unsigned long))
-                   && marker == REG_FRAME_MARKER) {
+                   && marker == STACK_FRAME_REGS_MARKER) {
                        if (mread(sp + REGS_OFFSET, &regs, sizeof(regs))
                            != sizeof(regs)) {
                                printf("Couldn't read registers at %lx\n",
@@ -1356,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;
 
@@ -1376,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;
 
@@ -1416,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;
@@ -1471,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;
@@ -1503,7 +1531,7 @@ void cacheflush(void)
        catch_memory_errors = 0;
 }
 
-unsigned long
+static unsigned long
 read_spr(int n)
 {
        unsigned int instrs[2];
@@ -1541,7 +1569,7 @@ read_spr(int n)
        return ret;
 }
 
-void
+static void
 write_spr(int n, unsigned long val)
 {
        unsigned int instrs[2];
@@ -1579,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;
@@ -1602,7 +1630,6 @@ void super_regs(void)
                if (firmware_has_feature(FW_FEATURE_ISERIES)) {
                        struct paca_struct *ptrPaca;
                        struct lppaca *ptrLpPaca;
-                       struct ItLpRegSave *ptrLpRegSave;
 
                        /* Dump out relevant Paca data areas. */
                        printf("Paca: \n");
@@ -1614,16 +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("  Local Processor Register Save Area (LpRegSave): \n");
-                       ptrLpRegSave = ptrPaca->reg_save_ptr;
-                       printf("    Saved Sprg0=%.16lx  Saved Sprg1=%.16lx \n",
-                              ptrLpRegSave->xSPRG0, ptrLpRegSave->xSPRG0);
-                       printf("    Saved Sprg2=%.16lx  Saved Sprg3=%.16lx \n",
-                              ptrLpRegSave->xSPRG2, ptrLpRegSave->xSPRG3);
-                       printf("    Saved Msr  =%.16lx  Saved Nia  =%.16lx \n",
-                              ptrLpRegSave->xMSR, ptrLpRegSave->xNIA);
+                       printf("    Saved Gpr5=%.16lx \n",
+                               ptrLpPaca->gpr5_dword.saved_gpr5);
                }
 #endif
 
@@ -1647,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;
@@ -1684,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;
@@ -1749,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;
@@ -1811,7 +1830,7 @@ static char *memex_subcmd_help_string =
     "  x        exit this mode\n"
     "";
 
-void
+static void
 memex(void)
 {
        int cmd, inc, i, nslash;
@@ -1962,7 +1981,7 @@ memex(void)
        }
 }
 
-int
+static int
 bsesc(void)
 {
        int c;
@@ -2002,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;
@@ -2021,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)
@@ -2040,7 +2061,7 @@ dump(void)
        }
 }
 
-void
+static void
 prdump(unsigned long adrs, long ndump)
 {
        long n, m, c, r, nr;
@@ -2084,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)
 {
@@ -2122,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);
@@ -2134,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
@@ -2144,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);
@@ -2170,7 +2234,7 @@ memops(int cmd)
        }
 }
 
-void
+static void
 memdiffs(unsigned char *p1, unsigned char *p2, unsigned nb, unsigned maxpr)
 {
        unsigned n, prt;
@@ -2188,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;
@@ -2221,7 +2285,7 @@ memlocate(void)
 static unsigned long mskip = 0x1000;
 static unsigned long mlim = 0xffffffff;
 
-void
+static void
 memzcan(void)
 {
        unsigned char v;
@@ -2248,7 +2312,7 @@ memzcan(void)
                printf("%.8x\n", a - mskip);
 }
 
-void proccall(void)
+static void proccall(void)
 {
        unsigned long args[8];
        unsigned long ret;
@@ -2406,7 +2470,7 @@ scanhex(unsigned long *vp)
        return 1;
 }
 
-void
+static void
 scannl(void)
 {
        int c;
@@ -2417,7 +2481,7 @@ scannl(void)
                c = inchar();
 }
 
-int hexdigit(int c)
+static int hexdigit(int c)
 {
        if( '0' <= c && c <= '9' )
                return c - '0';
@@ -2448,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) {
@@ -2467,7 +2531,7 @@ inchar(void)
        return *lineptr++;
 }
 
-void
+static void
 take_input(char *str)
 {
        lineptr = str;
@@ -2535,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;
@@ -2636,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))
@@ -2860,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]);