diff options
author | Atsushi Nemoto <anemo@mba.ocn.ne.jp> | 2007-06-01 11:21:30 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2007-07-10 12:32:56 -0400 |
commit | 4becef1d85a48ea4294c962c2cbacb6074f0dd58 (patch) | |
tree | beea6b8fa8a861035385e5800ef3b2ed2301f1f2 /arch/mips/lib-32 | |
parent | f6e2373ad6148476464fc7bb2610c6450c18cd2a (diff) |
[MIPS] Unify dump_tlb
Unify lib-{32,64}/dump_tlb.c into lib/dump_tlb.c and move
lib-32/r3k_dump_tlb.c to lib directory.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/lib-32')
-rw-r--r-- | arch/mips/lib-32/Makefile | 18 | ||||
-rw-r--r-- | arch/mips/lib-32/dump_tlb.c | 242 | ||||
-rw-r--r-- | arch/mips/lib-32/r3k_dump_tlb.c | 182 |
3 files changed, 0 insertions, 442 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 | ||
5 | lib-y += watch.o | 5 | lib-y += watch.o |
6 | |||
7 | obj-$(CONFIG_CPU_MIPS32) += dump_tlb.o | ||
8 | obj-$(CONFIG_CPU_MIPS64) += dump_tlb.o | ||
9 | obj-$(CONFIG_CPU_NEVADA) += dump_tlb.o | ||
10 | obj-$(CONFIG_CPU_R10000) += dump_tlb.o | ||
11 | obj-$(CONFIG_CPU_R3000) += r3k_dump_tlb.o | ||
12 | obj-$(CONFIG_CPU_R4300) += dump_tlb.o | ||
13 | obj-$(CONFIG_CPU_R4X00) += dump_tlb.o | ||
14 | obj-$(CONFIG_CPU_R5000) += dump_tlb.o | ||
15 | obj-$(CONFIG_CPU_R5432) += dump_tlb.o | ||
16 | obj-$(CONFIG_CPU_R6000) += | ||
17 | obj-$(CONFIG_CPU_R8000) += | ||
18 | obj-$(CONFIG_CPU_RM7000) += dump_tlb.o | ||
19 | obj-$(CONFIG_CPU_RM9000) += dump_tlb.o | ||
20 | obj-$(CONFIG_CPU_SB1) += dump_tlb.o | ||
21 | obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o | ||
22 | obj-$(CONFIG_CPU_TX49XX) += dump_tlb.o | ||
23 | obj-$(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 | |||
19 | static 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 | |||
53 | void 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 | |||
101 | void dump_tlb_all(void) | ||
102 | { | ||
103 | dump_tlb(0, current_cpu_data.tlbsize - 1); | ||
104 | } | ||
105 | |||
106 | void 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 | |||
115 | void 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 | |||
140 | void dump_tlb_nonwired(void) | ||
141 | { | ||
142 | dump_tlb(read_c0_wired(), current_cpu_data.tlbsize - 1); | ||
143 | } | ||
144 | |||
145 | void 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 | |||
208 | void dump_list_current(void *address) | ||
209 | { | ||
210 | dump_list_process(current, address); | ||
211 | } | ||
212 | |||
213 | unsigned 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 | |||
232 | void 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-32/r3k_dump_tlb.c b/arch/mips/lib-32/r3k_dump_tlb.c deleted file mode 100644 index 4f2cb74f0766..000000000000 --- a/arch/mips/lib-32/r3k_dump_tlb.c +++ /dev/null | |||
@@ -1,182 +0,0 @@ | |||
1 | /* | ||
2 | * Dump R3000 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 | * Copyright (C) 1999 by Harald Koerfgen | ||
7 | */ | ||
8 | #include <linux/kernel.h> | ||
9 | #include <linux/mm.h> | ||
10 | #include <linux/sched.h> | ||
11 | #include <linux/string.h> | ||
12 | |||
13 | #include <asm/bootinfo.h> | ||
14 | #include <asm/cachectl.h> | ||
15 | #include <asm/cpu.h> | ||
16 | #include <asm/mipsregs.h> | ||
17 | #include <asm/page.h> | ||
18 | #include <asm/pgtable.h> | ||
19 | |||
20 | extern int r3k_have_wired_reg; /* defined in tlb-r3k.c */ | ||
21 | |||
22 | void dump_tlb(int first, int last) | ||
23 | { | ||
24 | int i; | ||
25 | unsigned int asid; | ||
26 | unsigned long entryhi, entrylo0; | ||
27 | |||
28 | asid = read_c0_entryhi() & 0xfc0; | ||
29 | |||
30 | for (i = first; i <= last; i++) { | ||
31 | write_c0_index(i<<8); | ||
32 | __asm__ __volatile__( | ||
33 | ".set\tnoreorder\n\t" | ||
34 | "tlbr\n\t" | ||
35 | "nop\n\t" | ||
36 | ".set\treorder"); | ||
37 | entryhi = read_c0_entryhi(); | ||
38 | entrylo0 = read_c0_entrylo0(); | ||
39 | |||
40 | /* Unused entries have a virtual address of KSEG0. */ | ||
41 | if ((entryhi & 0xffffe000) != 0x80000000 | ||
42 | && (entryhi & 0xfc0) == asid) { | ||
43 | /* | ||
44 | * Only print entries in use | ||
45 | */ | ||
46 | printk("Index: %2d ", i); | ||
47 | |||
48 | printk("va=%08lx asid=%08lx" | ||
49 | " [pa=%06lx n=%d d=%d v=%d g=%d]", | ||
50 | (entryhi & 0xffffe000), | ||
51 | entryhi & 0xfc0, | ||
52 | entrylo0 & PAGE_MASK, | ||
53 | (entrylo0 & (1 << 11)) ? 1 : 0, | ||
54 | (entrylo0 & (1 << 10)) ? 1 : 0, | ||
55 | (entrylo0 & (1 << 9)) ? 1 : 0, | ||
56 | (entrylo0 & (1 << 8)) ? 1 : 0); | ||
57 | } | ||
58 | } | ||
59 | printk("\n"); | ||
60 | |||
61 | write_c0_entryhi(asid); | ||
62 | } | ||
63 | |||
64 | void dump_tlb_all(void) | ||
65 | { | ||
66 | dump_tlb(0, current_cpu_data.tlbsize - 1); | ||
67 | } | ||
68 | |||
69 | void dump_tlb_wired(void) | ||
70 | { | ||
71 | int wired = r3k_have_wired_reg ? read_c0_wired() : 8; | ||
72 | |||
73 | printk("Wired: %d", wired); | ||
74 | dump_tlb(0, wired - 1); | ||
75 | } | ||
76 | |||
77 | void dump_tlb_addr(unsigned long addr) | ||
78 | { | ||
79 | unsigned long flags, oldpid; | ||
80 | int index; | ||
81 | |||
82 | local_irq_save(flags); | ||
83 | oldpid = read_c0_entryhi() & 0xff; | ||
84 | write_c0_entryhi((addr & PAGE_MASK) | oldpid); | ||
85 | tlb_probe(); | ||
86 | index = read_c0_index(); | ||
87 | write_c0_entryhi(oldpid); | ||
88 | local_irq_restore(flags); | ||
89 | |||
90 | if (index < 0) { | ||
91 | printk("No entry for address 0x%08lx in TLB\n", addr); | ||
92 | return; | ||
93 | } | ||
94 | |||
95 | printk("Entry %d maps address 0x%08lx\n", index, addr); | ||
96 | dump_tlb(index, index); | ||
97 | } | ||
98 | |||
99 | void dump_tlb_nonwired(void) | ||
100 | { | ||
101 | int wired = r3k_have_wired_reg ? read_c0_wired() : 8; | ||
102 | dump_tlb(wired, current_cpu_data.tlbsize - 1); | ||
103 | } | ||
104 | |||
105 | void dump_list_process(struct task_struct *t, void *address) | ||
106 | { | ||
107 | pgd_t *page_dir, *pgd; | ||
108 | pud_t *pud; | ||
109 | pmd_t *pmd; | ||
110 | pte_t *pte, page; | ||
111 | unsigned int addr; | ||
112 | unsigned long val; | ||
113 | |||
114 | addr = (unsigned int) address; | ||
115 | |||
116 | printk("Addr == %08x\n", addr); | ||
117 | printk("tasks->mm.pgd == %08x\n", (unsigned int) t->mm->pgd); | ||
118 | |||
119 | page_dir = pgd_offset(t->mm, 0); | ||
120 | printk("page_dir == %08x\n", (unsigned int) page_dir); | ||
121 | |||
122 | pgd = pgd_offset(t->mm, addr); | ||
123 | printk("pgd == %08x, ", (unsigned int) pgd); | ||
124 | |||
125 | pud = pud_offset(pgd, addr); | ||
126 | printk("pud == %08x, ", (unsigned int) pud); | ||
127 | |||
128 | pmd = pmd_offset(pud, addr); | ||
129 | printk("pmd == %08x, ", (unsigned int) pmd); | ||
130 | |||
131 | pte = pte_offset(pmd, addr); | ||
132 | printk("pte == %08x, ", (unsigned int) pte); | ||
133 | |||
134 | page = *pte; | ||
135 | printk("page == %08x\n", (unsigned int) pte_val(page)); | ||
136 | |||
137 | val = pte_val(page); | ||
138 | if (val & _PAGE_PRESENT) printk("present "); | ||
139 | if (val & _PAGE_READ) printk("read "); | ||
140 | if (val & _PAGE_WRITE) printk("write "); | ||
141 | if (val & _PAGE_ACCESSED) printk("accessed "); | ||
142 | if (val & _PAGE_MODIFIED) printk("modified "); | ||
143 | if (val & _PAGE_GLOBAL) printk("global "); | ||
144 | if (val & _PAGE_VALID) printk("valid "); | ||
145 | printk("\n"); | ||
146 | } | ||
147 | |||
148 | void dump_list_current(void *address) | ||
149 | { | ||
150 | dump_list_process(current, address); | ||
151 | } | ||
152 | |||
153 | unsigned int vtop(void *address) | ||
154 | { | ||
155 | pgd_t *pgd; | ||
156 | pud_t *pud; | ||
157 | pmd_t *pmd; | ||
158 | pte_t *pte; | ||
159 | unsigned int addr, paddr; | ||
160 | |||
161 | addr = (unsigned long) address; | ||
162 | pgd = pgd_offset(current->mm, addr); | ||
163 | pud = pud_offset(pgd, addr); | ||
164 | pmd = pmd_offset(pud, addr); | ||
165 | pte = pte_offset(pmd, addr); | ||
166 | paddr = (KSEG1 | (unsigned int) pte_val(*pte)) & PAGE_MASK; | ||
167 | paddr |= (addr & ~PAGE_MASK); | ||
168 | |||
169 | return paddr; | ||
170 | } | ||
171 | |||
172 | void dump16(unsigned long *p) | ||
173 | { | ||
174 | int i; | ||
175 | |||
176 | for (i = 0; i < 8; i++) { | ||
177 | printk("*%08lx == %08lx, ", (unsigned long)p, *p); | ||
178 | p++; | ||
179 | printk("*%08lx == %08lx\n", (unsigned long)p, *p); | ||
180 | p++; | ||
181 | } | ||
182 | } | ||