r3k_dump_tlb.c 1.5 KB

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