xref: /openbmc/linux/arch/mips/lib/r3k_dump_tlb.c (revision 69ed25b8)
14becef1dSAtsushi Nemoto /*
24becef1dSAtsushi Nemoto  * Dump R3000 TLB for debugging purposes.
34becef1dSAtsushi Nemoto  *
44becef1dSAtsushi Nemoto  * Copyright (C) 1994, 1995 by Waldorf Electronics, written by Ralf Baechle.
54becef1dSAtsushi Nemoto  * Copyright (C) 1999 by Silicon Graphics, Inc.
64becef1dSAtsushi Nemoto  * Copyright (C) 1999 by Harald Koerfgen
74becef1dSAtsushi Nemoto  */
84becef1dSAtsushi Nemoto #include <linux/kernel.h>
94becef1dSAtsushi Nemoto #include <linux/mm.h>
104becef1dSAtsushi Nemoto 
114becef1dSAtsushi Nemoto #include <asm/mipsregs.h>
124becef1dSAtsushi Nemoto #include <asm/page.h>
134becef1dSAtsushi Nemoto #include <asm/pgtable.h>
144becef1dSAtsushi Nemoto 
154becef1dSAtsushi Nemoto extern int r3k_have_wired_reg;	/* defined in tlb-r3k.c */
164becef1dSAtsushi Nemoto 
1769ed25b8SAtsushi Nemoto static void dump_tlb(int first, int last)
184becef1dSAtsushi Nemoto {
194becef1dSAtsushi Nemoto 	int	i;
204becef1dSAtsushi Nemoto 	unsigned int asid;
214becef1dSAtsushi Nemoto 	unsigned long entryhi, entrylo0;
224becef1dSAtsushi Nemoto 
234becef1dSAtsushi Nemoto 	asid = read_c0_entryhi() & 0xfc0;
244becef1dSAtsushi Nemoto 
254becef1dSAtsushi Nemoto 	for (i = first; i <= last; i++) {
264becef1dSAtsushi Nemoto 		write_c0_index(i<<8);
274becef1dSAtsushi Nemoto 		__asm__ __volatile__(
284becef1dSAtsushi Nemoto 			".set\tnoreorder\n\t"
294becef1dSAtsushi Nemoto 			"tlbr\n\t"
304becef1dSAtsushi Nemoto 			"nop\n\t"
314becef1dSAtsushi Nemoto 			".set\treorder");
324becef1dSAtsushi Nemoto 		entryhi  = read_c0_entryhi();
334becef1dSAtsushi Nemoto 		entrylo0 = read_c0_entrylo0();
344becef1dSAtsushi Nemoto 
354becef1dSAtsushi Nemoto 		/* Unused entries have a virtual address of KSEG0.  */
364becef1dSAtsushi Nemoto 		if ((entryhi & 0xffffe000) != 0x80000000
374becef1dSAtsushi Nemoto 		    && (entryhi & 0xfc0) == asid) {
384becef1dSAtsushi Nemoto 			/*
394becef1dSAtsushi Nemoto 			 * Only print entries in use
404becef1dSAtsushi Nemoto 			 */
414becef1dSAtsushi Nemoto 			printk("Index: %2d ", i);
424becef1dSAtsushi Nemoto 
434becef1dSAtsushi Nemoto 			printk("va=%08lx asid=%08lx"
444becef1dSAtsushi Nemoto 			       "  [pa=%06lx n=%d d=%d v=%d g=%d]",
454becef1dSAtsushi Nemoto 			       (entryhi & 0xffffe000),
464becef1dSAtsushi Nemoto 			       entryhi & 0xfc0,
474becef1dSAtsushi Nemoto 			       entrylo0 & PAGE_MASK,
484becef1dSAtsushi Nemoto 			       (entrylo0 & (1 << 11)) ? 1 : 0,
494becef1dSAtsushi Nemoto 			       (entrylo0 & (1 << 10)) ? 1 : 0,
504becef1dSAtsushi Nemoto 			       (entrylo0 & (1 << 9)) ? 1 : 0,
514becef1dSAtsushi Nemoto 			       (entrylo0 & (1 << 8)) ? 1 : 0);
524becef1dSAtsushi Nemoto 		}
534becef1dSAtsushi Nemoto 	}
544becef1dSAtsushi Nemoto 	printk("\n");
554becef1dSAtsushi Nemoto 
564becef1dSAtsushi Nemoto 	write_c0_entryhi(asid);
574becef1dSAtsushi Nemoto }
584becef1dSAtsushi Nemoto 
594becef1dSAtsushi Nemoto void dump_tlb_all(void)
604becef1dSAtsushi Nemoto {
614becef1dSAtsushi Nemoto 	dump_tlb(0, current_cpu_data.tlbsize - 1);
624becef1dSAtsushi Nemoto }
63