2 * Dump R3000 TLB for debugging purposes.
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
8 #include <linux/kernel.h>
10 #include <linux/sched.h>
11 #include <linux/string.h>
13 #include <asm/bootinfo.h>
14 #include <asm/cachectl.h>
16 #include <asm/mipsregs.h>
18 #include <asm/pgtable.h>
20 extern int r3k_have_wired_reg; /* defined in tlb-r3k.c */
22 void dump_tlb(int first, int last)
26 unsigned long entryhi, entrylo0;
28 asid = read_c0_entryhi() & 0xfc0;
30 for (i = first; i <= last; i++) {
37 entryhi = read_c0_entryhi();
38 entrylo0 = read_c0_entrylo0();
40 /* Unused entries have a virtual address of KSEG0. */
41 if ((entryhi & 0xffffe000) != 0x80000000
42 && (entryhi & 0xfc0) == asid) {
44 * Only print entries in use
46 printk("Index: %2d ", i);
48 printk("va=%08lx asid=%08lx"
49 " [pa=%06lx n=%d d=%d v=%d g=%d]",
50 (entryhi & 0xffffe000),
53 (entrylo0 & (1 << 11)) ? 1 : 0,
54 (entrylo0 & (1 << 10)) ? 1 : 0,
55 (entrylo0 & (1 << 9)) ? 1 : 0,
56 (entrylo0 & (1 << 8)) ? 1 : 0);
61 write_c0_entryhi(asid);
64 void dump_tlb_all(void)
66 dump_tlb(0, current_cpu_data.tlbsize - 1);
69 void dump_tlb_wired(void)
71 int wired = r3k_have_wired_reg ? read_c0_wired() : 8;
73 printk("Wired: %d", wired);
74 dump_tlb(0, wired - 1);
77 void dump_tlb_addr(unsigned long addr)
79 unsigned long flags, oldpid;
82 local_irq_save(flags);
83 oldpid = read_c0_entryhi() & 0xff;
84 write_c0_entryhi((addr & PAGE_MASK) | oldpid);
86 index = read_c0_index();
87 write_c0_entryhi(oldpid);
88 local_irq_restore(flags);
91 printk("No entry for address 0x%08lx in TLB\n", addr);
95 printk("Entry %d maps address 0x%08lx\n", index, addr);
96 dump_tlb(index, index);
99 void dump_tlb_nonwired(void)
101 int wired = r3k_have_wired_reg ? read_c0_wired() : 8;
102 dump_tlb(wired, current_cpu_data.tlbsize - 1);
105 void dump_list_process(struct task_struct *t, void *address)
107 pgd_t *page_dir, *pgd;
114 addr = (unsigned int) address;
116 printk("Addr == %08x\n", addr);
117 printk("tasks->mm.pgd == %08x\n", (unsigned int) t->mm->pgd);
119 page_dir = pgd_offset(t->mm, 0);
120 printk("page_dir == %08x\n", (unsigned int) page_dir);
122 pgd = pgd_offset(t->mm, addr);
123 printk("pgd == %08x, ", (unsigned int) pgd);
125 pud = pud_offset(pgd, addr);
126 printk("pud == %08x, ", (unsigned int) pud);
128 pmd = pmd_offset(pud, addr);
129 printk("pmd == %08x, ", (unsigned int) pmd);
131 pte = pte_offset(pmd, addr);
132 printk("pte == %08x, ", (unsigned int) pte);
135 printk("page == %08x\n", (unsigned int) 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 ");
148 void dump_list_current(void *address)
150 dump_list_process(current, address);
153 unsigned int vtop(void *address)
159 unsigned int addr, paddr;
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);
172 void dump16(unsigned long *p)
176 for (i = 0; i < 8; i++) {
177 printk("*%08lx == %08lx, ", (unsigned long)p, *p);
179 printk("*%08lx == %08lx\n", (unsigned long)p, *p);