r3k_dump_tlb.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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;
  29. asid = read_c0_entryhi() & ASID_MASK;
  30. for (i = first; i <= last; i++) {
  31. write_c0_index(i<<8);
  32. __asm__ __volatile__(
  33. ".set\tnoreorder\n\t"
  34. "tlbr\n\t"
  35. "nop\n\t"
  36. ".set\treorder");
  37. entryhi = read_c0_entryhi();
  38. entrylo0 = read_c0_entrylo0();
  39. /* Unused entries have a virtual address of KSEG0. */
  40. if ((entryhi & PAGE_MASK) != KSEG0 &&
  41. (entrylo0 & R3K_ENTRYLO_G ||
  42. (entryhi & ASID_MASK) == asid)) {
  43. /*
  44. * Only print entries in use
  45. */
  46. printk("Index: %2d ", i);
  47. printk("va=%08lx asid=%08lx"
  48. " [pa=%06lx n=%d d=%d v=%d g=%d]",
  49. entryhi & PAGE_MASK,
  50. entryhi & ASID_MASK,
  51. entrylo0 & PAGE_MASK,
  52. (entrylo0 & R3K_ENTRYLO_N) ? 1 : 0,
  53. (entrylo0 & R3K_ENTRYLO_D) ? 1 : 0,
  54. (entrylo0 & R3K_ENTRYLO_V) ? 1 : 0,
  55. (entrylo0 & R3K_ENTRYLO_G) ? 1 : 0);
  56. }
  57. }
  58. printk("\n");
  59. write_c0_entryhi(asid);
  60. }
  61. void dump_tlb_all(void)
  62. {
  63. dump_tlb(0, current_cpu_data.tlbsize - 1);
  64. }