blob: 52f87795ecc3db3e2f50d448bc92a43738f644c0 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <asm/mipsregs.h>
12#include <asm/page.h>
13#include <asm/pgtable.h>
14
15extern int r3k_have_wired_reg; /* defined in tlb-r3k.c */
16
Atsushi Nemoto69ed25b2007-06-02 00:30:25 +090017static void dump_tlb(int first, int last)
Linus Torvalds1da177e2005-04-16 15:20:36 -070018{
19 int i;
20 unsigned int asid;
21 unsigned long entryhi, entrylo0;
22
23 asid = read_c0_entryhi() & 0xfc0;
24
25 for (i = first; i <= last; i++) {
26 write_c0_index(i<<8);
27 __asm__ __volatile__(
28 ".set\tnoreorder\n\t"
29 "tlbr\n\t"
30 "nop\n\t"
31 ".set\treorder");
32 entryhi = read_c0_entryhi();
33 entrylo0 = read_c0_entrylo0();
34
35 /* Unused entries have a virtual address of KSEG0. */
36 if ((entryhi & 0xffffe000) != 0x80000000
37 && (entryhi & 0xfc0) == asid) {
38 /*
39 * Only print entries in use
40 */
41 printk("Index: %2d ", i);
42
43 printk("va=%08lx asid=%08lx"
44 " [pa=%06lx n=%d d=%d v=%d g=%d]",
45 (entryhi & 0xffffe000),
46 entryhi & 0xfc0,
47 entrylo0 & PAGE_MASK,
48 (entrylo0 & (1 << 11)) ? 1 : 0,
49 (entrylo0 & (1 << 10)) ? 1 : 0,
50 (entrylo0 & (1 << 9)) ? 1 : 0,
51 (entrylo0 & (1 << 8)) ? 1 : 0);
52 }
53 }
54 printk("\n");
55
56 write_c0_entryhi(asid);
57}
58
59void dump_tlb_all(void)
60{
61 dump_tlb(0, current_cpu_data.tlbsize - 1);
62}