tlbflush.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #ifndef _ASM_SCORE_TLBFLUSH_H
  2. #define _ASM_SCORE_TLBFLUSH_H
  3. #include <linux/mm.h>
  4. /*
  5. * TLB flushing:
  6. *
  7. * - flush_tlb_all() flushes all processes TLB entries
  8. * - flush_tlb_mm(mm) flushes the specified mm context TLB entries
  9. * - flush_tlb_page(vma, vmaddr) flushes one page
  10. * - flush_tlb_range(vma, start, end) flushes a range of pages
  11. * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
  12. */
  13. extern void local_flush_tlb_all(void);
  14. extern void local_flush_tlb_mm(struct mm_struct *mm);
  15. extern void local_flush_tlb_range(struct vm_area_struct *vma,
  16. unsigned long start, unsigned long end);
  17. extern void local_flush_tlb_kernel_range(unsigned long start,
  18. unsigned long end);
  19. extern void local_flush_tlb_page(struct vm_area_struct *vma,
  20. unsigned long page);
  21. extern void local_flush_tlb_one(unsigned long vaddr);
  22. #define flush_tlb_all() local_flush_tlb_all()
  23. #define flush_tlb_mm(mm) local_flush_tlb_mm(mm)
  24. #define flush_tlb_range(vma, vmaddr, end) \
  25. local_flush_tlb_range(vma, vmaddr, end)
  26. #define flush_tlb_kernel_range(vmaddr, end) \
  27. local_flush_tlb_kernel_range(vmaddr, end)
  28. #define flush_tlb_page(vma, page) local_flush_tlb_page(vma, page)
  29. #define flush_tlb_one(vaddr) local_flush_tlb_one(vaddr)
  30. #ifndef __ASSEMBLY__
  31. static inline unsigned long pevn_get(void)
  32. {
  33. unsigned long val;
  34. __asm__ __volatile__(
  35. "mfcr %0, cr11\n"
  36. "nop\nnop\n"
  37. : "=r" (val));
  38. return val;
  39. }
  40. static inline void pevn_set(unsigned long val)
  41. {
  42. __asm__ __volatile__(
  43. "mtcr %0, cr11\n"
  44. "nop\nnop\nnop\nnop\nnop\n"
  45. : : "r" (val));
  46. }
  47. static inline void pectx_set(unsigned long val)
  48. {
  49. __asm__ __volatile__(
  50. "mtcr %0, cr12\n"
  51. "nop\nnop\nnop\nnop\nnop\n"
  52. : : "r" (val));
  53. }
  54. static inline unsigned long pectx_get(void)
  55. {
  56. unsigned long val;
  57. __asm__ __volatile__(
  58. "mfcr %0, cr12\n"
  59. "nop\nnop\n"
  60. : "=r" (val));
  61. return val;
  62. }
  63. static inline unsigned long tlblock_get(void)
  64. {
  65. unsigned long val;
  66. __asm__ __volatile__(
  67. "mfcr %0, cr7\n"
  68. "nop\nnop\n"
  69. : "=r" (val));
  70. return val;
  71. }
  72. static inline void tlblock_set(unsigned long val)
  73. {
  74. __asm__ __volatile__(
  75. "mtcr %0, cr7\n"
  76. "nop\nnop\nnop\nnop\nnop\n"
  77. : : "r" (val));
  78. }
  79. static inline void tlbpt_set(unsigned long val)
  80. {
  81. __asm__ __volatile__(
  82. "mtcr %0, cr8\n"
  83. "nop\nnop\nnop\nnop\nnop\n"
  84. : : "r" (val));
  85. }
  86. static inline long tlbpt_get(void)
  87. {
  88. long val;
  89. __asm__ __volatile__(
  90. "mfcr %0, cr8\n"
  91. "nop\nnop\n"
  92. : "=r" (val));
  93. return val;
  94. }
  95. static inline void peaddr_set(unsigned long val)
  96. {
  97. __asm__ __volatile__(
  98. "mtcr %0, cr9\n"
  99. "nop\nnop\nnop\nnop\nnop\n"
  100. : : "r" (val));
  101. }
  102. /* TLB operations. */
  103. static inline void tlb_probe(void)
  104. {
  105. __asm__ __volatile__("stlb;nop;nop;nop;nop;nop");
  106. }
  107. static inline void tlb_read(void)
  108. {
  109. __asm__ __volatile__("mftlb;nop;nop;nop;nop;nop");
  110. }
  111. static inline void tlb_write_indexed(void)
  112. {
  113. __asm__ __volatile__("mtptlb;nop;nop;nop;nop;nop");
  114. }
  115. static inline void tlb_write_random(void)
  116. {
  117. __asm__ __volatile__("mtrtlb;nop;nop;nop;nop;nop");
  118. }
  119. #endif /* Not __ASSEMBLY__ */
  120. #endif /* _ASM_SCORE_TLBFLUSH_H */