r3k_dump_tlb.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  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>
  10. #include <asm/mipsregs.h>
  11. #include <asm/mmu_context.h>
  12. #include <asm/page.h>
  13. #include <asm/pgtable.h>
  14. #include <asm/tlbdebug.h>
  15. extern int r3k_have_wired_reg;
  16. void dump_tlb_regs(void)
  17. {
  18. pr_info("Index : %0x\n", read_c0_index());
  19. pr_info("EntryHi : %0lx\n", read_c0_entryhi());
  20. pr_info("EntryLo : %0lx\n", read_c0_entrylo0());
  21. if (r3k_have_wired_reg)
  22. pr_info("Wired : %0x\n", read_c0_wired());
  23. }
  24. static void dump_tlb(int first, int last)
  25. {
  26. int i;
  27. unsigned int asid;
  28. unsigned long entryhi, entrylo0, asid_mask;
  29. asid_mask = cpu_asid_mask(&current_cpu_data);
  30. asid = read_c0_entryhi() & asid_mask;
  31. for (i = first; i <= last; i++) {
  32. write_c0_index(i<<8);
  33. __asm__ __volatile__(
  34. ".set\tnoreorder\n\t"
  35. "tlbr\n\t"
  36. "nop\n\t"
  37. ".set\treorder");
  38. entryhi = read_c0_entryhi();
  39. entrylo0 = read_c0_entrylo0();
  40. /* Unused entries have a virtual address of KSEG0. */
  41. if ((entryhi & PAGE_MASK) != KSEG0 &&
  42. (entrylo0 & R3K_ENTRYLO_G ||
  43. (entryhi & asid_mask) == asid)) {
  44. /*
  45. * Only print entries in use
  46. */
  47. printk("Index: %2d ", i);
  48. pr_cont("va=%08lx asid=%08lx"
  49. " [pa=%06lx n=%d d=%d v=%d g=%d]",
  50. entryhi & PAGE_MASK,
  51. entryhi & asid_mask,
  52. entrylo0 & PAGE_MASK,
  53. (entrylo0 & R3K_ENTRYLO_N) ? 1 : 0,
  54. (entrylo0 & R3K_ENTRYLO_D) ? 1 : 0,
  55. (entrylo0 & R3K_ENTRYLO_V) ? 1 : 0,
  56. (entrylo0 & R3K_ENTRYLO_G) ? 1 : 0);
  57. }
  58. }
  59. printk("\n");
  60. write_c0_entryhi(asid);
  61. }
  62. void dump_tlb_all(void)
  63. {
  64. dump_tlb(0, current_cpu_data.tlbsize - 1);
  65. }