Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Dump R3000 TLB for debugging purposes.
0004  *
0005  * Copyright (C) 1994, 1995 by Waldorf Electronics, written by Ralf Baechle.
0006  * Copyright (C) 1999 by Silicon Graphics, Inc.
0007  * Copyright (C) 1999 by Harald Koerfgen
0008  */
0009 #include <linux/kernel.h>
0010 #include <linux/mm.h>
0011 
0012 #include <asm/mipsregs.h>
0013 #include <asm/mmu_context.h>
0014 #include <asm/page.h>
0015 #include <asm/tlbdebug.h>
0016 
0017 void dump_tlb_regs(void)
0018 {
0019     pr_info("Index    : %0x\n", read_c0_index());
0020     pr_info("EntryHi  : %0lx\n", read_c0_entryhi());
0021     pr_info("EntryLo  : %0lx\n", read_c0_entrylo0());
0022 }
0023 
0024 static void dump_tlb(int first, int last)
0025 {
0026     int i;
0027     unsigned int asid;
0028     unsigned long entryhi, entrylo0, asid_mask;
0029 
0030     asid_mask = cpu_asid_mask(&current_cpu_data);
0031     asid = read_c0_entryhi() & asid_mask;
0032 
0033     for (i = first; i <= last; i++) {
0034         write_c0_index(i<<8);
0035         __asm__ __volatile__(
0036             ".set\tnoreorder\n\t"
0037             "tlbr\n\t"
0038             "nop\n\t"
0039             ".set\treorder");
0040         entryhi  = read_c0_entryhi();
0041         entrylo0 = read_c0_entrylo0();
0042 
0043         /* Unused entries have a virtual address of KSEG0.  */
0044         if ((entryhi & PAGE_MASK) != KSEG0 &&
0045             (entrylo0 & R3K_ENTRYLO_G ||
0046              (entryhi & asid_mask) == asid)) {
0047             /*
0048              * Only print entries in use
0049              */
0050             printk("Index: %2d ", i);
0051 
0052             pr_cont("va=%08lx asid=%08lx"
0053                 "  [pa=%06lx n=%d d=%d v=%d g=%d]",
0054                 entryhi & PAGE_MASK,
0055                 entryhi & asid_mask,
0056                 entrylo0 & PAGE_MASK,
0057                 (entrylo0 & R3K_ENTRYLO_N) ? 1 : 0,
0058                 (entrylo0 & R3K_ENTRYLO_D) ? 1 : 0,
0059                 (entrylo0 & R3K_ENTRYLO_V) ? 1 : 0,
0060                 (entrylo0 & R3K_ENTRYLO_G) ? 1 : 0);
0061         }
0062     }
0063     printk("\n");
0064 
0065     write_c0_entryhi(asid);
0066 }
0067 
0068 void dump_tlb_all(void)
0069 {
0070     dump_tlb(0, current_cpu_data.tlbsize - 1);
0071 }