Blame view

kernel/linux-rt-4.4.41/arch/mips/lib/r3k_dump_tlb.c 1.73 KB
5113f6f70   김현기   kernel add
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
  /*
   * Dump R3000 TLB for debugging purposes.
   *
   * Copyright (C) 1994, 1995 by Waldorf Electronics, written by Ralf Baechle.
   * Copyright (C) 1999 by Silicon Graphics, Inc.
   * Copyright (C) 1999 by Harald Koerfgen
   */
  #include <linux/kernel.h>
  #include <linux/mm.h>
  
  #include <asm/mipsregs.h>
  #include <asm/mmu_context.h>
  #include <asm/page.h>
  #include <asm/pgtable.h>
  #include <asm/tlbdebug.h>
  
  extern int r3k_have_wired_reg;
  
  void dump_tlb_regs(void)
  {
  	pr_info("Index    : %0x
  ", read_c0_index());
  	pr_info("EntryHi  : %0lx
  ", read_c0_entryhi());
  	pr_info("EntryLo  : %0lx
  ", read_c0_entrylo0());
  	if (r3k_have_wired_reg)
  		pr_info("Wired    : %0x
  ", read_c0_wired());
  }
  
  static void dump_tlb(int first, int last)
  {
  	int	i;
  	unsigned int asid;
  	unsigned long entryhi, entrylo0;
  
  	asid = read_c0_entryhi() & ASID_MASK;
  
  	for (i = first; i <= last; i++) {
  		write_c0_index(i<<8);
  		__asm__ __volatile__(
  			".set\tnoreorder
  \t"
  			"tlbr
  \t"
  			"nop
  \t"
  			".set\treorder");
  		entryhi	 = read_c0_entryhi();
  		entrylo0 = read_c0_entrylo0();
  
  		/* Unused entries have a virtual address of KSEG0.  */
  		if ((entryhi & PAGE_MASK) != KSEG0 &&
  		    (entrylo0 & R3K_ENTRYLO_G ||
  		     (entryhi & ASID_MASK) == asid)) {
  			/*
  			 * Only print entries in use
  			 */
  			printk("Index: %2d ", i);
  
  			printk("va=%08lx asid=%08lx"
  			       "  [pa=%06lx n=%d d=%d v=%d g=%d]",
  			       entryhi & PAGE_MASK,
  			       entryhi & ASID_MASK,
  			       entrylo0 & PAGE_MASK,
  			       (entrylo0 & R3K_ENTRYLO_N) ? 1 : 0,
  			       (entrylo0 & R3K_ENTRYLO_D) ? 1 : 0,
  			       (entrylo0 & R3K_ENTRYLO_V) ? 1 : 0,
  			       (entrylo0 & R3K_ENTRYLO_G) ? 1 : 0);
  		}
  	}
  	printk("
  ");
  
  	write_c0_entryhi(asid);
  }
  
  void dump_tlb_all(void)
  {
  	dump_tlb(0, current_cpu_data.tlbsize - 1);
  }