aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/lib/dump_tlb.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-10 14:48:43 -0700
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-10 14:48:43 -0700
commit0f166396e7e8931bb4acfd1a6ea1bd4f0b43f1dd (patch)
tree6279fa70695a4c56b7e935018a4c0fc1dfa82e68 /arch/mips/lib/dump_tlb.c
parentMerge git://git.infradead.org/~dwmw2/battery-2.6 (diff)
parent[MIPS] PNX8550: Cleanup proc code. (diff)
downloadlinux-dev-0f166396e7e8931bb4acfd1a6ea1bd4f0b43f1dd.tar.xz
linux-dev-0f166396e7e8931bb4acfd1a6ea1bd4f0b43f1dd.zip
Merge branch 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus
* 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus: (62 commits) [MIPS] PNX8550: Cleanup proc code. [MIPS] WRPPMC: Fix build. [MIPS] Yosemite: Fix modpost warnings. [MIPS] Change names of local variables to silence sparse [MIPS] SB1: Fix modpost warning. [MIPS] PNX: Fix modpost warnings. [MIPS] Alchemy: Fix modpost warnings. [MIPS] Non-FPAFF: Fix warning. [MIPS] DEC: Fix modpost warning. [MIPS] MIPSsim: Enable MIPSsim virtual network driver. [MIPS] Delete Ocelot 3 support. [MIPS] remove LASAT Networks platforms support [MIPS] Early check for SMTC kernel on non-MT processor [MIPS] Add debugfs files to show fpuemu statistics [MIPS] Add some debugfs files to debug unaligned accesses [MIPS] rbtx4938: Fix secondary PCIC and glue internal NICs [MIPS] tc35815: Load MAC address via platform_device [MIPS] Move FPU affinity code into separate file. [MIPS] Make ioremap() work on TX39/49 special unmapped segment [MIPS] rbtx4938: Update and minimize defconfig ...
Diffstat (limited to 'arch/mips/lib/dump_tlb.c')
-rw-r--r--arch/mips/lib/dump_tlb.c100
1 files changed, 100 insertions, 0 deletions
diff --git a/arch/mips/lib/dump_tlb.c b/arch/mips/lib/dump_tlb.c
new file mode 100644
index 000000000000..1a4db7dc77cb
--- /dev/null
+++ b/arch/mips/lib/dump_tlb.c
@@ -0,0 +1,100 @@
+/*
+ * Dump R4x00 TLB for debugging purposes.
+ *
+ * Copyright (C) 1994, 1995 by Waldorf Electronics, written by Ralf Baechle.
+ * Copyright (C) 1999 by Silicon Graphics, Inc.
+ */
+#include <linux/kernel.h>
+#include <linux/mm.h>
+
+#include <asm/mipsregs.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
+
+static inline const char *msk2str(unsigned int mask)
+{
+ switch (mask) {
+ case PM_4K: return "4kb";
+ case PM_16K: return "16kb";
+ case PM_64K: return "64kb";
+ case PM_256K: return "256kb";
+#ifndef CONFIG_CPU_VR41XX
+ case PM_1M: return "1Mb";
+ case PM_4M: return "4Mb";
+ case PM_16M: return "16Mb";
+ case PM_64M: return "64Mb";
+ case PM_256M: return "256Mb";
+#endif
+ }
+ return "";
+}
+
+#define BARRIER() \
+ __asm__ __volatile__( \
+ ".set\tnoreorder\n\t" \
+ "nop;nop;nop;nop;nop;nop;nop\n\t" \
+ ".set\treorder");
+
+static void dump_tlb(int first, int last)
+{
+ unsigned long s_entryhi, entryhi, asid;
+ unsigned long long entrylo0, entrylo1;
+ unsigned int s_index, pagemask, c0, c1, i;
+
+ s_entryhi = read_c0_entryhi();
+ s_index = read_c0_index();
+ asid = s_entryhi & 0xff;
+
+ for (i = first; i <= last; i++) {
+ write_c0_index(i);
+ BARRIER();
+ tlb_read();
+ BARRIER();
+ pagemask = read_c0_pagemask();
+ entryhi = read_c0_entryhi();
+ entrylo0 = read_c0_entrylo0();
+ entrylo1 = read_c0_entrylo1();
+
+ /* Unused entries have a virtual address of CKSEG0. */
+ if ((entryhi & ~0x1ffffUL) != CKSEG0
+ && (entryhi & 0xff) == asid) {
+#ifdef CONFIG_32BIT
+ int width = 8;
+#else
+ int width = 11;
+#endif
+ /*
+ * Only print entries in use
+ */
+ printk("Index: %2d pgmask=%s ", i, msk2str(pagemask));
+
+ c0 = (entrylo0 >> 3) & 7;
+ c1 = (entrylo1 >> 3) & 7;
+
+ printk("va=%0*lx asid=%02lx\n",
+ width, (entryhi & ~0x1fffUL),
+ entryhi & 0xff);
+ printk("\t[pa=%0*llx c=%d d=%d v=%d g=%d] ",
+ width,
+ (entrylo0 << 6) & PAGE_MASK, c0,
+ (entrylo0 & 4) ? 1 : 0,
+ (entrylo0 & 2) ? 1 : 0,
+ (entrylo0 & 1) ? 1 : 0);
+ printk("[pa=%0*llx c=%d d=%d v=%d g=%d]\n",
+ width,
+ (entrylo1 << 6) & PAGE_MASK, c1,
+ (entrylo1 & 4) ? 1 : 0,
+ (entrylo1 & 2) ? 1 : 0,
+ (entrylo1 & 1) ? 1 : 0);
+ }
+ }
+ printk("\n");
+
+ write_c0_entryhi(s_entryhi);
+ write_c0_index(s_index);
+}
+
+void dump_tlb_all(void)
+{
+ dump_tlb(0, current_cpu_data.tlbsize - 1);
+}