aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/mips/lib-32/Makefile18
-rw-r--r--arch/mips/lib-32/dump_tlb.c242
-rw-r--r--arch/mips/lib-64/Makefile18
-rw-r--r--arch/mips/lib/Makefile18
-rw-r--r--arch/mips/lib/dump_tlb.c (renamed from arch/mips/lib-64/dump_tlb.c)58
-rw-r--r--arch/mips/lib/r3k_dump_tlb.c (renamed from arch/mips/lib-32/r3k_dump_tlb.c)0
6 files changed, 60 insertions, 294 deletions
diff --git a/arch/mips/lib-32/Makefile b/arch/mips/lib-32/Makefile
index 8b94d4cc5a30..7bae849e544a 100644
--- a/arch/mips/lib-32/Makefile
+++ b/arch/mips/lib-32/Makefile
@@ -3,21 +3,3 @@
3# 3#
4 4
5lib-y += watch.o 5lib-y += watch.o
6
7obj-$(CONFIG_CPU_MIPS32) += dump_tlb.o
8obj-$(CONFIG_CPU_MIPS64) += dump_tlb.o
9obj-$(CONFIG_CPU_NEVADA) += dump_tlb.o
10obj-$(CONFIG_CPU_R10000) += dump_tlb.o
11obj-$(CONFIG_CPU_R3000) += r3k_dump_tlb.o
12obj-$(CONFIG_CPU_R4300) += dump_tlb.o
13obj-$(CONFIG_CPU_R4X00) += dump_tlb.o
14obj-$(CONFIG_CPU_R5000) += dump_tlb.o
15obj-$(CONFIG_CPU_R5432) += dump_tlb.o
16obj-$(CONFIG_CPU_R6000) +=
17obj-$(CONFIG_CPU_R8000) +=
18obj-$(CONFIG_CPU_RM7000) += dump_tlb.o
19obj-$(CONFIG_CPU_RM9000) += dump_tlb.o
20obj-$(CONFIG_CPU_SB1) += dump_tlb.o
21obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o
22obj-$(CONFIG_CPU_TX49XX) += dump_tlb.o
23obj-$(CONFIG_CPU_VR41XX) += dump_tlb.o
diff --git a/arch/mips/lib-32/dump_tlb.c b/arch/mips/lib-32/dump_tlb.c
deleted file mode 100644
index 6a68deb51aae..000000000000
--- a/arch/mips/lib-32/dump_tlb.c
+++ /dev/null
@@ -1,242 +0,0 @@
1/*
2 * Dump R4x00 TLB for debugging purposes.
3 *
4 * Copyright (C) 1994, 1995 by Waldorf Electronics, written by Ralf Baechle.
5 * Copyright (C) 1999 by Silicon Graphics, Inc.
6 */
7#include <linux/kernel.h>
8#include <linux/mm.h>
9#include <linux/sched.h>
10#include <linux/string.h>
11
12#include <asm/bootinfo.h>
13#include <asm/cachectl.h>
14#include <asm/cpu.h>
15#include <asm/mipsregs.h>
16#include <asm/page.h>
17#include <asm/pgtable.h>
18
19static inline const char *msk2str(unsigned int mask)
20{
21 switch (mask) {
22 case PM_4K:
23 return "4kb";
24 case PM_16K:
25 return "16kb";
26 case PM_64K:
27 return "64kb";
28 case PM_256K:
29 return "256kb";
30#ifndef CONFIG_CPU_VR41XX
31 case PM_1M:
32 return "1Mb";
33 case PM_4M:
34 return "4Mb";
35 case PM_16M:
36 return "16Mb";
37 case PM_64M:
38 return "64Mb";
39 case PM_256M:
40 return "256Mb";
41#endif
42 }
43
44 return "unknown";
45}
46
47#define BARRIER() \
48 __asm__ __volatile__( \
49 ".set\tnoreorder\n\t" \
50 "nop;nop;nop;nop;nop;nop;nop\n\t" \
51 ".set\treorder");
52
53void dump_tlb(int first, int last)
54{
55 unsigned int pagemask, c0, c1, asid;
56 unsigned long long entrylo0, entrylo1;
57 unsigned long entryhi;
58 int i;
59
60 asid = read_c0_entryhi() & 0xff;
61
62 printk("\n");
63 for (i = first; i <= last; i++) {
64 write_c0_index(i);
65 BARRIER();
66 tlb_read();
67 BARRIER();
68 pagemask = read_c0_pagemask();
69 entryhi = read_c0_entryhi();
70 entrylo0 = read_c0_entrylo0();
71 entrylo1 = read_c0_entrylo1();
72
73 /* Unused entries have a virtual address in KSEG0. */
74 if ((entryhi & 0xf0000000) != 0x80000000
75 && (entryhi & 0xff) == asid) {
76 /*
77 * Only print entries in use
78 */
79 printk("Index: %2d pgmask=%s ", i, msk2str(pagemask));
80
81 c0 = (entrylo0 >> 3) & 7;
82 c1 = (entrylo1 >> 3) & 7;
83
84 printk("va=%08lx asid=%02lx\n",
85 (entryhi & 0xffffe000), (entryhi & 0xff));
86 printk("\t\t\t[pa=%08Lx c=%d d=%d v=%d g=%Ld]\n",
87 (entrylo0 << 6) & PAGE_MASK, c0,
88 (entrylo0 & 4) ? 1 : 0,
89 (entrylo0 & 2) ? 1 : 0, (entrylo0 & 1));
90 printk("\t\t\t[pa=%08Lx c=%d d=%d v=%d g=%Ld]\n",
91 (entrylo1 << 6) & PAGE_MASK, c1,
92 (entrylo1 & 4) ? 1 : 0,
93 (entrylo1 & 2) ? 1 : 0, (entrylo1 & 1));
94 printk("\n");
95 }
96 }
97
98 write_c0_entryhi(asid);
99}
100
101void dump_tlb_all(void)
102{
103 dump_tlb(0, current_cpu_data.tlbsize - 1);
104}
105
106void dump_tlb_wired(void)
107{
108 int wired;
109
110 wired = read_c0_wired();
111 printk("Wired: %d", wired);
112 dump_tlb(0, read_c0_wired());
113}
114
115void dump_tlb_addr(unsigned long addr)
116{
117 unsigned int flags, oldpid;
118 int index;
119
120 local_irq_save(flags);
121 oldpid = read_c0_entryhi() & 0xff;
122 BARRIER();
123 write_c0_entryhi((addr & PAGE_MASK) | oldpid);
124 BARRIER();
125 tlb_probe();
126 BARRIER();
127 index = read_c0_index();
128 write_c0_entryhi(oldpid);
129 local_irq_restore(flags);
130
131 if (index < 0) {
132 printk("No entry for address 0x%08lx in TLB\n", addr);
133 return;
134 }
135
136 printk("Entry %d maps address 0x%08lx\n", index, addr);
137 dump_tlb(index, index);
138}
139
140void dump_tlb_nonwired(void)
141{
142 dump_tlb(read_c0_wired(), current_cpu_data.tlbsize - 1);
143}
144
145void dump_list_process(struct task_struct *t, void *address)
146{
147 pgd_t *page_dir, *pgd;
148 pud_t *pud;
149 pmd_t *pmd;
150 pte_t *pte, page;
151 unsigned long addr, val;
152
153 addr = (unsigned long) address;
154
155 printk("Addr == %08lx\n", addr);
156 printk("task == %8p\n", t);
157 printk("task->mm == %8p\n", t->mm);
158 //printk("tasks->mm.pgd == %08x\n", (unsigned int) t->mm->pgd);
159
160 if (addr > KSEG0) {
161 page_dir = pgd_offset_k(0);
162 pgd = pgd_offset_k(addr);
163 } else if (t->mm) {
164 page_dir = pgd_offset(t->mm, 0);
165 pgd = pgd_offset(t->mm, addr);
166 } else {
167 printk("Current thread has no mm\n");
168 return;
169 }
170 printk("page_dir == %08x\n", (unsigned int) page_dir);
171 printk("pgd == %08x, ", (unsigned int) pgd);
172 pud = pud_offset(pgd, addr);
173 printk("pud == %08x, ", (unsigned int) pud);
174
175 pmd = pmd_offset(pud, addr);
176 printk("pmd == %08x, ", (unsigned int) pmd);
177
178 pte = pte_offset(pmd, addr);
179 printk("pte == %08x, ", (unsigned int) pte);
180
181 page = *pte;
182#ifdef CONFIG_64BIT_PHYS_ADDR
183 printk("page == %08Lx\n", pte_val(page));
184#else
185 printk("page == %08lx\n", pte_val(page));
186#endif
187
188 val = pte_val(page);
189 if (val & _PAGE_PRESENT)
190 printk("present ");
191 if (val & _PAGE_READ)
192 printk("read ");
193 if (val & _PAGE_WRITE)
194 printk("write ");
195 if (val & _PAGE_ACCESSED)
196 printk("accessed ");
197 if (val & _PAGE_MODIFIED)
198 printk("modified ");
199 if (val & _PAGE_R4KBUG)
200 printk("r4kbug ");
201 if (val & _PAGE_GLOBAL)
202 printk("global ");
203 if (val & _PAGE_VALID)
204 printk("valid ");
205 printk("\n");
206}
207
208void dump_list_current(void *address)
209{
210 dump_list_process(current, address);
211}
212
213unsigned int vtop(void *address)
214{
215 pgd_t *pgd;
216 pud_t *pud;
217 pmd_t *pmd;
218 pte_t *pte;
219 unsigned int addr, paddr;
220
221 addr = (unsigned long) address;
222 pgd = pgd_offset(current->mm, addr);
223 pud = pud_offset(pgd, addr);
224 pmd = pmd_offset(pud, addr);
225 pte = pte_offset(pmd, addr);
226 paddr = (KSEG1 | (unsigned int) pte_val(*pte)) & PAGE_MASK;
227 paddr |= (addr & ~PAGE_MASK);
228
229 return paddr;
230}
231
232void dump16(unsigned long *p)
233{
234 int i;
235
236 for (i = 0; i < 8; i++) {
237 printk("*%08lx == %08lx, ", (unsigned long) p, *p);
238 p++;
239 printk("*%08lx == %08lx\n", (unsigned long) p, *p);
240 p++;
241 }
242}
diff --git a/arch/mips/lib-64/Makefile b/arch/mips/lib-64/Makefile
index 8b94d4cc5a30..7bae849e544a 100644
--- a/arch/mips/lib-64/Makefile
+++ b/arch/mips/lib-64/Makefile
@@ -3,21 +3,3 @@
3# 3#
4 4
5lib-y += watch.o 5lib-y += watch.o
6
7obj-$(CONFIG_CPU_MIPS32) += dump_tlb.o
8obj-$(CONFIG_CPU_MIPS64) += dump_tlb.o
9obj-$(CONFIG_CPU_NEVADA) += dump_tlb.o
10obj-$(CONFIG_CPU_R10000) += dump_tlb.o
11obj-$(CONFIG_CPU_R3000) += r3k_dump_tlb.o
12obj-$(CONFIG_CPU_R4300) += dump_tlb.o
13obj-$(CONFIG_CPU_R4X00) += dump_tlb.o
14obj-$(CONFIG_CPU_R5000) += dump_tlb.o
15obj-$(CONFIG_CPU_R5432) += dump_tlb.o
16obj-$(CONFIG_CPU_R6000) +=
17obj-$(CONFIG_CPU_R8000) +=
18obj-$(CONFIG_CPU_RM7000) += dump_tlb.o
19obj-$(CONFIG_CPU_RM9000) += dump_tlb.o
20obj-$(CONFIG_CPU_SB1) += dump_tlb.o
21obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o
22obj-$(CONFIG_CPU_TX49XX) += dump_tlb.o
23obj-$(CONFIG_CPU_VR41XX) += dump_tlb.o
diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile
index 1c1aa9f92f6c..1a484e430b3c 100644
--- a/arch/mips/lib/Makefile
+++ b/arch/mips/lib/Makefile
@@ -8,5 +8,23 @@ lib-y += csum_partial.o memcpy.o memcpy-inatomic.o memset.o strlen_user.o \
8obj-y += iomap.o 8obj-y += iomap.o
9obj-$(CONFIG_PCI) += iomap-pci.o 9obj-$(CONFIG_PCI) += iomap-pci.o
10 10
11obj-$(CONFIG_CPU_MIPS32) += dump_tlb.o
12obj-$(CONFIG_CPU_MIPS64) += dump_tlb.o
13obj-$(CONFIG_CPU_NEVADA) += dump_tlb.o
14obj-$(CONFIG_CPU_R10000) += dump_tlb.o
15obj-$(CONFIG_CPU_R3000) += r3k_dump_tlb.o
16obj-$(CONFIG_CPU_R4300) += dump_tlb.o
17obj-$(CONFIG_CPU_R4X00) += dump_tlb.o
18obj-$(CONFIG_CPU_R5000) += dump_tlb.o
19obj-$(CONFIG_CPU_R5432) += dump_tlb.o
20obj-$(CONFIG_CPU_R6000) +=
21obj-$(CONFIG_CPU_R8000) +=
22obj-$(CONFIG_CPU_RM7000) += dump_tlb.o
23obj-$(CONFIG_CPU_RM9000) += dump_tlb.o
24obj-$(CONFIG_CPU_SB1) += dump_tlb.o
25obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o
26obj-$(CONFIG_CPU_TX49XX) += dump_tlb.o
27obj-$(CONFIG_CPU_VR41XX) += dump_tlb.o
28
11# libgcc-style stuff needed in the kernel 29# libgcc-style stuff needed in the kernel
12obj-y += ashldi3.o ashrdi3.o lshrdi3.o ucmpdi2.o 30obj-y += ashldi3.o ashrdi3.o lshrdi3.o ucmpdi2.o
diff --git a/arch/mips/lib-64/dump_tlb.c b/arch/mips/lib/dump_tlb.c
index 594df1a05ecc..fbf4b72f4306 100644
--- a/arch/mips/lib-64/dump_tlb.c
+++ b/arch/mips/lib/dump_tlb.c
@@ -31,8 +31,7 @@ static inline const char *msk2str(unsigned int mask)
31 case PM_256M: return "256Mb"; 31 case PM_256M: return "256Mb";
32#endif 32#endif
33 } 33 }
34 34 return "";
35 return "unknown";
36} 35}
37 36
38#define BARRIER() \ 37#define BARRIER() \
@@ -43,7 +42,8 @@ static inline const char *msk2str(unsigned int mask)
43 42
44void dump_tlb(int first, int last) 43void dump_tlb(int first, int last)
45{ 44{
46 unsigned long s_entryhi, entryhi, entrylo0, entrylo1, asid; 45 unsigned long s_entryhi, entryhi, asid;
46 unsigned long long entrylo0, entrylo1;
47 unsigned int s_index, pagemask, c0, c1, i; 47 unsigned int s_index, pagemask, c0, c1, i;
48 48
49 s_entryhi = read_c0_entryhi(); 49 s_entryhi = read_c0_entryhi();
@@ -63,6 +63,11 @@ void dump_tlb(int first, int last)
63 /* Unused entries have a virtual address of CKSEG0. */ 63 /* Unused entries have a virtual address of CKSEG0. */
64 if ((entryhi & ~0x1ffffUL) != CKSEG0 64 if ((entryhi & ~0x1ffffUL) != CKSEG0
65 && (entryhi & 0xff) == asid) { 65 && (entryhi & 0xff) == asid) {
66#ifdef CONFIG_32BIT
67 int width = 8;
68#else
69 int width = 11;
70#endif
66 /* 71 /*
67 * Only print entries in use 72 * Only print entries in use
68 */ 73 */
@@ -71,19 +76,21 @@ void dump_tlb(int first, int last)
71 c0 = (entrylo0 >> 3) & 7; 76 c0 = (entrylo0 >> 3) & 7;
72 c1 = (entrylo1 >> 3) & 7; 77 c1 = (entrylo1 >> 3) & 7;
73 78
74 printk("va=%011lx asid=%02lx\n", 79 printk("va=%0*lx asid=%02lx\n",
75 (entryhi & ~0x1fffUL), 80 width, (entryhi & ~0x1fffUL),
76 entryhi & 0xff); 81 entryhi & 0xff);
77 printk("\t[pa=%011lx c=%d d=%d v=%d g=%ld] ", 82 printk("\t[pa=%0*llx c=%d d=%d v=%d g=%d] ",
83 width,
78 (entrylo0 << 6) & PAGE_MASK, c0, 84 (entrylo0 << 6) & PAGE_MASK, c0,
79 (entrylo0 & 4) ? 1 : 0, 85 (entrylo0 & 4) ? 1 : 0,
80 (entrylo0 & 2) ? 1 : 0, 86 (entrylo0 & 2) ? 1 : 0,
81 (entrylo0 & 1)); 87 (entrylo0 & 1) ? 1 : 0);
82 printk("[pa=%011lx c=%d d=%d v=%d g=%ld]\n", 88 printk("[pa=%0*llx c=%d d=%d v=%d g=%d]\n",
89 width,
83 (entrylo1 << 6) & PAGE_MASK, c1, 90 (entrylo1 << 6) & PAGE_MASK, c1,
84 (entrylo1 & 4) ? 1 : 0, 91 (entrylo1 & 4) ? 1 : 0,
85 (entrylo1 & 2) ? 1 : 0, 92 (entrylo1 & 2) ? 1 : 0,
86 (entrylo1 & 1)); 93 (entrylo1 & 1) ? 1 : 0);
87 } 94 }
88 } 95 }
89 printk("\n"); 96 printk("\n");
@@ -143,29 +150,48 @@ void dump_list_process(struct task_struct *t, void *address)
143 pmd_t *pmd; 150 pmd_t *pmd;
144 pte_t *pte, page; 151 pte_t *pte, page;
145 unsigned long addr, val; 152 unsigned long addr, val;
153 int width = sizeof(long) * 2;
146 154
147 addr = (unsigned long) address; 155 addr = (unsigned long) address;
148 156
149 printk("Addr == %08lx\n", addr); 157 printk("Addr == %08lx\n", addr);
158#ifdef CONFIG_64BIT
150 printk("tasks->mm.pgd == %08lx\n", (unsigned long) t->mm->pgd); 159 printk("tasks->mm.pgd == %08lx\n", (unsigned long) t->mm->pgd);
160#endif
151 161
162#ifdef CONFIG_64BIT
152 page_dir = pgd_offset(t->mm, 0UL); 163 page_dir = pgd_offset(t->mm, 0UL);
153 printk("page_dir == %016lx\n", (unsigned long) page_dir);
154
155 pgd = pgd_offset(t->mm, addr); 164 pgd = pgd_offset(t->mm, addr);
156 printk("pgd == %016lx\n", (unsigned long) pgd); 165#else
166 if (addr > KSEG0) {
167 page_dir = pgd_offset_k(0);
168 pgd = pgd_offset_k(addr);
169 } else if (t->mm) {
170 page_dir = pgd_offset(t->mm, 0);
171 pgd = pgd_offset(t->mm, addr);
172 } else {
173 printk("Current thread has no mm\n");
174 return;
175 }
176#endif
177 printk("page_dir == %0*lx\n", width, (unsigned long) page_dir);
178 printk("pgd == %0*lx\n", width, (unsigned long) pgd);
157 179
158 pud = pud_offset(pgd, addr); 180 pud = pud_offset(pgd, addr);
159 printk("pud == %016lx\n", (unsigned long) pud); 181 printk("pud == %0*lx\n", width, (unsigned long) pud);
160 182
161 pmd = pmd_offset(pud, addr); 183 pmd = pmd_offset(pud, addr);
162 printk("pmd == %016lx\n", (unsigned long) pmd); 184 printk("pmd == %0*lx\n", width, (unsigned long) pmd);
163 185
164 pte = pte_offset(pmd, addr); 186 pte = pte_offset(pmd, addr);
165 printk("pte == %016lx\n", (unsigned long) pte); 187 printk("pte == %0*lx\n", width, (unsigned long) pte);
166 188
167 page = *pte; 189 page = *pte;
168 printk("page == %08lx\n", pte_val(page)); 190#ifdef CONFIG_64BIT_PHYS_ADDR
191 printk("page == %08Lx\n", pte_val(page));
192#else
193 printk("page == %0*lx\n", width, pte_val(page));
194#endif
169 195
170 val = pte_val(page); 196 val = pte_val(page);
171 if (val & _PAGE_PRESENT) printk("present "); 197 if (val & _PAGE_PRESENT) printk("present ");
diff --git a/arch/mips/lib-32/r3k_dump_tlb.c b/arch/mips/lib/r3k_dump_tlb.c
index 4f2cb74f0766..4f2cb74f0766 100644
--- a/arch/mips/lib-32/r3k_dump_tlb.c
+++ b/arch/mips/lib/r3k_dump_tlb.c