drm/i915: remove unused intel_pipe_get_connector()
[safe/jmp/linux-2.6] / arch / powerpc / xmon / xmon.c
index 0689c08..8bad7d5 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/sysrq.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
+#include <linux/bug.h>
 
 #include <asm/ptrace.h>
 #include <asm/string.h>
 #include <asm/cputable.h>
 #include <asm/rtas.h>
 #include <asm/sstep.h>
-#include <asm/bug.h>
 #include <asm/irq_regs.h>
 #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>
 #endif
 
 #include "nonstdio.h"
+#include "dis-asm.h"
 
 #define scanhex        xmon_scanhex
 #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;
@@ -68,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 {
@@ -109,7 +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);
-void print_address(unsigned long);
+static void dump_log_buf(void);
 static void backtrace(struct pt_regs *);
 static void excprint(struct pt_regs *);
 static void prregs(struct pt_regs *);
@@ -151,17 +152,15 @@ static const char *getvecname(unsigned long vec);
 
 static int do_spu_cmd(void);
 
-int xmon_no_auto_backtrace;
+#ifdef CONFIG_44x
+static void dump_tlb_44x(void);
+#endif
 
-extern int print_insn_powerpc(unsigned long, unsigned long, int);
+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
@@ -199,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\
@@ -214,10 +214,12 @@ Commands:\n\
   p    call a procedure\n\
   r    print registers\n\
   s    single step\n"
-#ifdef CONFIG_PPC_CELL
+#ifdef CONFIG_SPU_BASE
 "  ss  stop execution on all spus\n\
   sr   restore execution on stopped spus\n\
-  sf # dump spu fields for spu # (in hex)\n"
+  sf  #        dump spu fields for spu # (in hex)\n\
+  sd  #        dump spu local store for spu # (in hex)\n\
+  sdi #        disassemble spu local store for spu # (in hex)\n"
 #endif
 "  S   print special registers\n\
   t    print backtrace\n\
@@ -229,6 +231,9 @@ Commands:\n\
 #ifdef CONFIG_PPC_STD_MMU_32
 "  u   dump segment registers\n"
 #endif
+#ifdef CONFIG_44x
+"  u   dump TLB\n"
+#endif
 "  ?   help\n"
 "  zr  reboot\n\
   zh   halt\n"
@@ -323,23 +328,37 @@ 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;
-       unsigned long msr;
        struct bpt *bp;
        long recurse_jmp[JMP_BUF_LEN];
        unsigned long offset;
+       unsigned long flags;
 #ifdef CONFIG_SMP
        int cpu;
        int secondary;
        unsigned long timeout;
 #endif
 
-       msr = mfmsr();
-       mtmsr(msr & ~MSR_EE);   /* disable interrupts */
+       local_irq_save(flags);
 
        bp = in_breakpoint_table(regs->nip, &offset);
        if (bp != NULL) {
@@ -379,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) {
@@ -390,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();
@@ -481,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();
@@ -498,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) {
@@ -511,10 +539,10 @@ static int xmon_core(struct pt_regs *regs, int fromipi)
                        }
                }
        }
-
+#endif
        insert_cpu_bpts();
 
-       mtmsr(msr);             /* restore interrupt enable */
+       local_irq_restore(flags);
 
        return cmd != 'X' && cmd != EOF;
 }
@@ -524,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;
        }
 
@@ -590,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;
@@ -832,7 +860,7 @@ cmds(struct pt_regs *excp)
                        mdelay(2000);
                        return cmd;
                case '?':
-                       printf(help_string);
+                       xmon_puts(help_string);
                        break;
                case 'b':
                        bpt_cmds();
@@ -855,6 +883,11 @@ cmds(struct pt_regs *excp)
                        dump_segments();
                        break;
 #endif
+#ifdef CONFIG_4xx
+               case 'u':
+                       dump_tlb_44x();
+                       break;
+#endif
                default:
                        printf("Unrecognized command: ");
                        do {
@@ -870,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.
@@ -900,6 +941,7 @@ static int do_step(struct pt_regs *regs)
        regs->msr |= MSR_SE;
        return 1;
 }
+#endif
 
 static void bootcmds(void)
 {
@@ -1134,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;
                        }
@@ -1216,7 +1258,6 @@ static void get_function_bounds(unsigned long pc, unsigned long *startp,
 {
        unsigned long size, offset;
        const char *name;
-       char *modname;
 
        *startp = *endp = 0;
        if (pc == 0)
@@ -1224,7 +1265,7 @@ static void get_function_bounds(unsigned long pc, unsigned long *startp,
        if (setjmp(bus_error_jmp) == 0) {
                catch_memory_errors = 1;
                sync();
-               name = kallsyms_lookup(pc, &size, &offset, &modname, tmpstr);
+               name = kallsyms_lookup(pc, &size, &offset, NULL, tmpstr);
                if (name != NULL) {
                        *startp = pc - offset;
                        *endp = pc - offset + size;
@@ -1236,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
 
@@ -1310,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",
@@ -1344,7 +1382,8 @@ static void backtrace(struct pt_regs *excp)
 
 static void print_bug_trap(struct pt_regs *regs)
 {
-       struct bug_entry *bug;
+#ifdef CONFIG_BUG
+       const struct bug_entry *bug;
        unsigned long addr;
 
        if (regs->msr & MSR_PR)
@@ -1355,14 +1394,19 @@ static void print_bug_trap(struct pt_regs *regs)
        bug = find_bug(regs->nip);
        if (bug == NULL)
                return;
-       if (bug->line & BUG_WARNING_TRAP)
+       if (is_warning_bug(bug))
                return;
 
-       printf("kernel BUG in %s at %s:%d!\n",
-              bug->function, bug->file, (unsigned int)bug->line);
+#ifdef CONFIG_DEBUG_BUGVERBOSE
+       printf("kernel BUG at %s:%u!\n",
+              bug->file, bug->line);
+#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;
 
@@ -1400,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;
@@ -1455,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;
@@ -1487,7 +1531,7 @@ void cacheflush(void)
        catch_memory_errors = 0;
 }
 
-unsigned long
+static unsigned long
 read_spr(int n)
 {
        unsigned int instrs[2];
@@ -1525,7 +1569,7 @@ read_spr(int n)
        return ret;
 }
 
-void
+static void
 write_spr(int n, unsigned long val)
 {
        unsigned int instrs[2];
@@ -1563,15 +1607,10 @@ 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;
-#ifdef CONFIG_PPC_ISERIES
-       struct paca_struct *ptrPaca = NULL;
-       struct lppaca *ptrLpPaca = NULL;
-       struct ItLpRegSave *ptrLpRegSave = NULL;
-#endif
 
        cmd = skipbl();
        if (cmd == '\n') {
@@ -1588,26 +1627,23 @@ void super_regs(void)
                printf("sp   = "REG"  sprg3= "REG"\n", sp, mfspr(SPRN_SPRG3));
                printf("toc  = "REG"  dar  = "REG"\n", toc, mfspr(SPRN_DAR));
 #ifdef CONFIG_PPC_ISERIES
-               // Dump out relevant Paca data areas.
-               printf("Paca: \n");
-               ptrPaca = get_paca();
-    
-               printf("  Local Processor Control Area (LpPaca): \n");
-               ptrLpPaca = ptrPaca->lppaca_ptr;
-               printf("    Saved Srr0=%.16lx  Saved Srr1=%.16lx \n",
-                      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);
+               if (firmware_has_feature(FW_FEATURE_ISERIES)) {
+                       struct paca_struct *ptrPaca;
+                       struct lppaca *ptrLpPaca;
+
+                       /* Dump out relevant Paca data areas. */
+                       printf("Paca: \n");
+                       ptrPaca = get_paca();
+
+                       printf("  Local Processor Control Area (LpPaca): \n");
+                       ptrLpPaca = ptrPaca->lppaca_ptr;
+                       printf("    Saved Srr0=%.16lx  Saved Srr1=%.16lx \n",
+                              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->gpr5_dword.saved_gpr5);
+               }
 #endif
 
                return;
@@ -1630,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;
@@ -1667,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;
@@ -1732,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;
@@ -1794,7 +1830,7 @@ static char *memex_subcmd_help_string =
     "  x        exit this mode\n"
     "";
 
-void
+static void
 memex(void)
 {
        int cmd, inc, i, nslash;
@@ -1945,7 +1981,7 @@ memex(void)
        }
 }
 
-int
+static int
 bsesc(void)
 {
        int c;
@@ -1985,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;
@@ -2004,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)
@@ -2023,7 +2061,7 @@ dump(void)
        }
 }
 
-void
+static void
 prdump(unsigned long adrs, long ndump)
 {
        long n, m, c, r, nr;
@@ -2065,8 +2103,11 @@ prdump(unsigned long adrs, long ndump)
        }
 }
 
-int
-ppc_inst_dump(unsigned long adr, long count, int praddr)
+typedef int (*instruction_dump_func)(unsigned long inst, unsigned long addr);
+
+static int
+generic_inst_dump(unsigned long adr, long count, int praddr,
+                       instruction_dump_func dump_func)
 {
        int nr, dotted;
        unsigned long first_adr;
@@ -2096,18 +2137,67 @@ ppc_inst_dump(unsigned long adr, long count, int praddr)
                if (praddr)
                        printf(REG"  %.8x", adr, inst);
                printf("\t");
-               print_insn_powerpc(inst, adr, 0);       /* always returns 4 */
+               dump_func(inst, adr);
                printf("\n");
        }
        return adr - first_adr;
 }
 
+static int
+ppc_inst_dump(unsigned long adr, long count, int praddr)
+{
+       return generic_inst_dump(adr, count, praddr, print_insn_powerpc);
+}
+
 void
 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
@@ -2118,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);
@@ -2144,7 +2234,7 @@ memops(int cmd)
        }
 }
 
-void
+static void
 memdiffs(unsigned char *p1, unsigned char *p2, unsigned nb, unsigned maxpr)
 {
        unsigned n, prt;
@@ -2162,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;
@@ -2195,7 +2285,7 @@ memlocate(void)
 static unsigned long mskip = 0x1000;
 static unsigned long mlim = 0xffffffff;
 
-void
+static void
 memzcan(void)
 {
        unsigned char v;
@@ -2222,7 +2312,7 @@ memzcan(void)
                printf("%.8x\n", a - mskip);
 }
 
-void proccall(void)
+static void proccall(void)
 {
        unsigned long args[8];
        unsigned long ret;
@@ -2380,7 +2470,7 @@ scanhex(unsigned long *vp)
        return 1;
 }
 
-void
+static void
 scannl(void)
 {
        int c;
@@ -2391,7 +2481,7 @@ scannl(void)
                c = inchar();
 }
 
-int hexdigit(int c)
+static int hexdigit(int c)
 {
        if( '0' <= c && c <= '9' )
                return c - '0';
@@ -2422,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) {
@@ -2441,7 +2531,7 @@ inchar(void)
        return *lineptr++;
 }
 
-void
+static void
 take_input(char *str)
 {
        lineptr = str;
@@ -2509,20 +2599,37 @@ 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;
-       unsigned long tmp;
+       unsigned long esid,vsid,valid;
+       unsigned long llp;
 
        printf("SLB contents of cpu %x\n", smp_processor_id());
 
-       for (i = 0; i < SLB_NUM_ENTRIES; i++) {
-               asm volatile("slbmfee  %0,%1" : "=r" (tmp) : "r" (i));
-               printf("%02d %016lx ", i, tmp);
-
-               asm volatile("slbmfev  %0,%1" : "=r" (tmp) : "r" (i));
-               printf("%016lx\n", tmp);
+       for (i = 0; i < mmu_slb_size; i++) {
+               asm volatile("slbmfee  %0,%1" : "=r" (esid) : "r" (i));
+               asm volatile("slbmfev  %0,%1" : "=r" (vsid) : "r" (i));
+               valid = (esid & SLB_ESID_V);
+               if (valid | esid | vsid) {
+                       printf("%02d %016lx %016lx", i, esid, vsid);
+                       if (valid) {
+                               llp = vsid & SLB_VSID_LLP;
+                               if (vsid & SLB_VSID_B_1T) {
+                                       printf("  1T  ESID=%9lx  VSID=%13lx LLP:%3lx \n",
+                                               GET_ESID_1T(esid),
+                                               (vsid & ~SLB_VSID_B) >> SLB_VSID_SHIFT_1T,
+                                               llp);
+                               } else {
+                                       printf(" 256M ESID=%9lx  VSID=%13lx LLP:%3lx \n",
+                                               GET_ESID(esid),
+                                               (vsid & ~SLB_VSID_B) >> SLB_VSID_SHIFT,
+                                               llp);
+                               }
+                       } else
+                               printf("\n");
+               }
        }
 }
 
@@ -2567,8 +2674,39 @@ void dump_segments(void)
 }
 #endif
 
-void xmon_init(int enable)
+#ifdef CONFIG_44x
+static void dump_tlb_44x(void)
 {
+       int i;
+
+       for (i = 0; i < PPC44x_TLB_SIZE; i++) {
+               unsigned long w0,w1,w2;
+               asm volatile("tlbre  %0,%1,0" : "=r" (w0) : "r" (i));
+               asm volatile("tlbre  %0,%1,1" : "=r" (w1) : "r" (i));
+               asm volatile("tlbre  %0,%1,2" : "=r" (w2) : "r" (i));
+               printf("[%02x] %08x %08x %08x ", i, w0, w1, w2);
+               if (w0 & PPC44x_TLB_VALID) {
+                       printf("V %08x -> %01x%08x %c%c%c%c%c",
+                              w0 & PPC44x_TLB_EPN_MASK,
+                              w1 & PPC44x_TLB_ERPN_MASK,
+                              w1 & PPC44x_TLB_RPN_MASK,
+                              (w2 & PPC44x_TLB_W) ? 'W' : 'w',
+                              (w2 & PPC44x_TLB_I) ? 'I' : 'i',
+                              (w2 & PPC44x_TLB_M) ? 'M' : 'm',
+                              (w2 & PPC44x_TLB_G) ? 'G' : 'g',
+                              (w2 & PPC44x_TLB_E) ? 'E' : 'e');
+               }
+               printf("\n");
+       }
+}
+#endif /* CONFIG_44x */
+
+static void xmon_init(int enable)
+{
+#ifdef CONFIG_PPC_ISERIES
+       if (firmware_has_feature(FW_FEATURE_ISERIES))
+               return;
+#endif
        if (enable) {
                __debugger = xmon;
                __debugger_ipi = xmon_ipi;
@@ -2606,13 +2744,17 @@ static struct sysrq_key_op sysrq_xmon_op =
 
 static int __init setup_xmon_sysrq(void)
 {
+#ifdef CONFIG_PPC_ISERIES
+       if (firmware_has_feature(FW_FEATURE_ISERIES))
+               return 0;
+#endif
        register_sysrq_key('x', &sysrq_xmon_op);
        return 0;
 }
 __initcall(setup_xmon_sysrq);
 #endif /* CONFIG_MAGIC_SYSRQ */
 
-int __initdata xmon_early, xmon_off;
+static int __initdata xmon_early, xmon_off;
 
 static int __init early_parse_xmon(char *p)
 {
@@ -2643,12 +2785,13 @@ void __init xmon_setup(void)
                debugger(NULL);
 }
 
-#ifdef CONFIG_PPC_CELL
+#ifdef CONFIG_SPU_BASE
 
 struct spu_info {
        struct spu *spu;
        u64 saved_mfc_sr1_RW;
        u32 saved_spu_runcntl_RW;
+       unsigned long dump_addr;
        u8 stopped_ok;
 };
 
@@ -2668,6 +2811,8 @@ void xmon_register_spus(struct list_head *list)
 
                spu_info[spu->number].spu = spu;
                spu_info[spu->number].stopped_ok = 0;
+               spu_info[spu->number].dump_addr = (unsigned long)
+                               spu_info[spu->number].spu->local_store;
        }
 }
 
@@ -2700,7 +2845,10 @@ static void stop_spus(void)
                        __delay(200);
 
                        spu_info[i].stopped_ok = 1;
-                       printf("Stopped spu %.2d\n", i);
+
+                       printf("Stopped spu %.2d (was %s)\n", i,
+                                       spu_info[i].saved_spu_runcntl_RW ?
+                                       "running" : "stopped");
                } else {
                        catch_memory_errors = 0;
                        printf("*** Error stopping spu %.2d\n", i);
@@ -2746,13 +2894,13 @@ static void restart_spus(void)
 }
 
 #define DUMP_WIDTH     23
-#define DUMP_FIELD(obj, format, field)                                 \
+#define DUMP_VALUE(format, field, value)                               \
 do {                                                                   \
        if (setjmp(bus_error_jmp) == 0) {                               \
                catch_memory_errors = 1;                                \
                sync();                                                 \
                printf("  %-*s = "format"\n", DUMP_WIDTH,               \
-                               #field, obj->field);                    \
+                               #field, value);                         \
                sync();                                                 \
                __delay(200);                                           \
        } else {                                                        \
@@ -2763,49 +2911,97 @@ do {                                                                    \
        catch_memory_errors = 0;                                        \
 } while (0)
 
+#define DUMP_FIELD(obj, format, field) \
+       DUMP_VALUE(format, field, obj->field)
+
 static void dump_spu_fields(struct spu *spu)
 {
        printf("Dumping spu fields at address %p:\n", spu);
 
        DUMP_FIELD(spu, "0x%x", number);
        DUMP_FIELD(spu, "%s", name);
-       DUMP_FIELD(spu, "%s", devnode->full_name);
-       DUMP_FIELD(spu, "0x%x", nid);
        DUMP_FIELD(spu, "0x%lx", local_store_phys);
        DUMP_FIELD(spu, "0x%p", local_store);
        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]);
        DUMP_FIELD(spu, "0x%x", slb_replace);
        DUMP_FIELD(spu, "%d", pid);
-       DUMP_FIELD(spu, "%d", prio);
        DUMP_FIELD(spu, "0x%p", mm);
        DUMP_FIELD(spu, "0x%p", ctx);
        DUMP_FIELD(spu, "0x%p", rq);
        DUMP_FIELD(spu, "0x%p", timestamp);
        DUMP_FIELD(spu, "0x%lx", problem_phys);
        DUMP_FIELD(spu, "0x%p", problem);
-       DUMP_FIELD(spu, "0x%x", problem->spu_runcntl_RW);
-       DUMP_FIELD(spu, "0x%x", problem->spu_status_R);
-       DUMP_FIELD(spu, "0x%x", problem->spu_npc_RW);
-       DUMP_FIELD(spu, "0x%p", priv1);
+       DUMP_VALUE("0x%x", problem->spu_runcntl_RW,
+                       in_be32(&spu->problem->spu_runcntl_RW));
+       DUMP_VALUE("0x%x", problem->spu_status_R,
+                       in_be32(&spu->problem->spu_status_R));
+       DUMP_VALUE("0x%x", problem->spu_npc_RW,
+                       in_be32(&spu->problem->spu_npc_RW));
+       DUMP_FIELD(spu, "0x%p", priv2);
+       DUMP_FIELD(spu, "0x%p", pdata);
+}
+
+int
+spu_inst_dump(unsigned long adr, long count, int praddr)
+{
+       return generic_inst_dump(adr, count, praddr, print_insn_spu);
+}
 
-       if (spu->priv1)
-               DUMP_FIELD(spu, "0x%lx", priv1->mfc_sr1_RW);
+static void dump_spu_ls(unsigned long num, int subcmd)
+{
+       unsigned long offset, addr, ls_addr;
 
-       DUMP_FIELD(spu, "0x%p", priv2);
+       if (setjmp(bus_error_jmp) == 0) {
+               catch_memory_errors = 1;
+               sync();
+               ls_addr = (unsigned long)spu_info[num].spu->local_store;
+               sync();
+               __delay(200);
+       } else {
+               catch_memory_errors = 0;
+               printf("*** Error: accessing spu info for spu %d\n", num);
+               return;
+       }
+       catch_memory_errors = 0;
+
+       if (scanhex(&offset))
+               addr = ls_addr + offset;
+       else
+               addr = spu_info[num].dump_addr;
+
+       if (addr >= ls_addr + LS_SIZE) {
+               printf("*** Error: address outside of local store\n");
+               return;
+       }
+
+       switch (subcmd) {
+       case 'i':
+               addr += spu_inst_dump(addr, 16, 1);
+               last_cmd = "sdi\n";
+               break;
+       default:
+               prdump(addr, 64);
+               addr += 64;
+               last_cmd = "sd\n";
+               break;
+       }
+
+       spu_info[num].dump_addr = addr;
 }
 
 static int do_spu_cmd(void)
 {
-       unsigned long num = 0;
-       int cmd;
+       static unsigned long num = 0;
+       int cmd, subcmd = 0;
 
        cmd = inchar();
        switch (cmd) {
@@ -2815,11 +3011,26 @@ static int do_spu_cmd(void)
        case 'r':
                restart_spus();
                break;
+       case 'd':
+               subcmd = inchar();
+               if (isxdigit(subcmd) || subcmd == '\n')
+                       termch = subcmd;
        case 'f':
-               if (scanhex(&num) && num < XMON_NUM_SPUS && spu_info[num].spu)
-                       dump_spu_fields(spu_info[num].spu);
-               else
+               scanhex(&num);
+               if (num >= XMON_NUM_SPUS || !spu_info[num].spu) {
                        printf("*** Error: invalid spu number\n");
+                       return 0;
+               }
+
+               switch (cmd) {
+               case 'f':
+                       dump_spu_fields(spu_info[num].spu);
+                       break;
+               default:
+                       dump_spu_ls(num, subcmd);
+                       break;
+               }
+
                break;
        default:
                return -1;
@@ -2827,7 +3038,7 @@ static int do_spu_cmd(void)
 
        return 0;
 }
-#else /* ! CONFIG_PPC_CELL */
+#else /* ! CONFIG_SPU_BASE */
 static int do_spu_cmd(void)
 {
        return -1;