tlbflush.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. #ifndef _M68K_TLBFLUSH_H
  2. #define _M68K_TLBFLUSH_H
  3. #include <linux/config.h>
  4. #ifndef CONFIG_SUN3
  5. #include <asm/current.h>
  6. static inline void flush_tlb_kernel_page(void *addr)
  7. {
  8. if (CPU_IS_040_OR_060) {
  9. mm_segment_t old_fs = get_fs();
  10. set_fs(KERNEL_DS);
  11. __asm__ __volatile__(".chip 68040\n\t"
  12. "pflush (%0)\n\t"
  13. ".chip 68k"
  14. : : "a" (addr));
  15. set_fs(old_fs);
  16. } else
  17. __asm__ __volatile__("pflush #4,#4,(%0)" : : "a" (addr));
  18. }
  19. /*
  20. * flush all user-space atc entries.
  21. */
  22. static inline void __flush_tlb(void)
  23. {
  24. if (CPU_IS_040_OR_060)
  25. __asm__ __volatile__(".chip 68040\n\t"
  26. "pflushan\n\t"
  27. ".chip 68k");
  28. else
  29. __asm__ __volatile__("pflush #0,#4");
  30. }
  31. static inline void __flush_tlb040_one(unsigned long addr)
  32. {
  33. __asm__ __volatile__(".chip 68040\n\t"
  34. "pflush (%0)\n\t"
  35. ".chip 68k"
  36. : : "a" (addr));
  37. }
  38. static inline void __flush_tlb_one(unsigned long addr)
  39. {
  40. if (CPU_IS_040_OR_060)
  41. __flush_tlb040_one(addr);
  42. else
  43. __asm__ __volatile__("pflush #0,#4,(%0)" : : "a" (addr));
  44. }
  45. #define flush_tlb() __flush_tlb()
  46. /*
  47. * flush all atc entries (both kernel and user-space entries).
  48. */
  49. static inline void flush_tlb_all(void)
  50. {
  51. if (CPU_IS_040_OR_060)
  52. __asm__ __volatile__(".chip 68040\n\t"
  53. "pflusha\n\t"
  54. ".chip 68k");
  55. else
  56. __asm__ __volatile__("pflusha");
  57. }
  58. static inline void flush_tlb_mm(struct mm_struct *mm)
  59. {
  60. if (mm == current->active_mm)
  61. __flush_tlb();
  62. }
  63. static inline void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
  64. {
  65. if (vma->vm_mm == current->active_mm) {
  66. mm_segment_t old_fs = get_fs();
  67. set_fs(USER_DS);
  68. __flush_tlb_one(addr);
  69. set_fs(old_fs);
  70. }
  71. }
  72. static inline void flush_tlb_range(struct vm_area_struct *vma,
  73. unsigned long start, unsigned long end)
  74. {
  75. if (vma->vm_mm == current->active_mm)
  76. __flush_tlb();
  77. }
  78. static inline void flush_tlb_kernel_range(unsigned long start, unsigned long end)
  79. {
  80. flush_tlb_all();
  81. }
  82. static inline void flush_tlb_pgtables(struct mm_struct *mm,
  83. unsigned long start, unsigned long end)
  84. {
  85. }
  86. #else
  87. /* Reserved PMEGs. */
  88. extern char sun3_reserved_pmeg[SUN3_PMEGS_NUM];
  89. extern unsigned long pmeg_vaddr[SUN3_PMEGS_NUM];
  90. extern unsigned char pmeg_alloc[SUN3_PMEGS_NUM];
  91. extern unsigned char pmeg_ctx[SUN3_PMEGS_NUM];
  92. /* Flush all userspace mappings one by one... (why no flush command,
  93. sun?) */
  94. static inline void flush_tlb_all(void)
  95. {
  96. unsigned long addr;
  97. unsigned char ctx, oldctx;
  98. oldctx = sun3_get_context();
  99. for(addr = 0x00000000; addr < TASK_SIZE; addr += SUN3_PMEG_SIZE) {
  100. for(ctx = 0; ctx < 8; ctx++) {
  101. sun3_put_context(ctx);
  102. sun3_put_segmap(addr, SUN3_INVALID_PMEG);
  103. }
  104. }
  105. sun3_put_context(oldctx);
  106. /* erase all of the userspace pmeg maps, we've clobbered them
  107. all anyway */
  108. for(addr = 0; addr < SUN3_INVALID_PMEG; addr++) {
  109. if(pmeg_alloc[addr] == 1) {
  110. pmeg_alloc[addr] = 0;
  111. pmeg_ctx[addr] = 0;
  112. pmeg_vaddr[addr] = 0;
  113. }
  114. }
  115. }
  116. /* Clear user TLB entries within the context named in mm */
  117. static inline void flush_tlb_mm (struct mm_struct *mm)
  118. {
  119. unsigned char oldctx;
  120. unsigned char seg;
  121. unsigned long i;
  122. oldctx = sun3_get_context();
  123. sun3_put_context(mm->context);
  124. for(i = 0; i < TASK_SIZE; i += SUN3_PMEG_SIZE) {
  125. seg = sun3_get_segmap(i);
  126. if(seg == SUN3_INVALID_PMEG)
  127. continue;
  128. sun3_put_segmap(i, SUN3_INVALID_PMEG);
  129. pmeg_alloc[seg] = 0;
  130. pmeg_ctx[seg] = 0;
  131. pmeg_vaddr[seg] = 0;
  132. }
  133. sun3_put_context(oldctx);
  134. }
  135. /* Flush a single TLB page. In this case, we're limited to flushing a
  136. single PMEG */
  137. static inline void flush_tlb_page (struct vm_area_struct *vma,
  138. unsigned long addr)
  139. {
  140. unsigned char oldctx;
  141. unsigned char i;
  142. oldctx = sun3_get_context();
  143. sun3_put_context(vma->vm_mm->context);
  144. addr &= ~SUN3_PMEG_MASK;
  145. if((i = sun3_get_segmap(addr)) != SUN3_INVALID_PMEG)
  146. {
  147. pmeg_alloc[i] = 0;
  148. pmeg_ctx[i] = 0;
  149. pmeg_vaddr[i] = 0;
  150. sun3_put_segmap (addr, SUN3_INVALID_PMEG);
  151. }
  152. sun3_put_context(oldctx);
  153. }
  154. /* Flush a range of pages from TLB. */
  155. static inline void flush_tlb_range (struct vm_area_struct *vma,
  156. unsigned long start, unsigned long end)
  157. {
  158. struct mm_struct *mm = vma->vm_mm;
  159. unsigned char seg, oldctx;
  160. start &= ~SUN3_PMEG_MASK;
  161. oldctx = sun3_get_context();
  162. sun3_put_context(mm->context);
  163. while(start < end)
  164. {
  165. if((seg = sun3_get_segmap(start)) == SUN3_INVALID_PMEG)
  166. goto next;
  167. if(pmeg_ctx[seg] == mm->context) {
  168. pmeg_alloc[seg] = 0;
  169. pmeg_ctx[seg] = 0;
  170. pmeg_vaddr[seg] = 0;
  171. }
  172. sun3_put_segmap(start, SUN3_INVALID_PMEG);
  173. next:
  174. start += SUN3_PMEG_SIZE;
  175. }
  176. }
  177. static inline void flush_tlb_kernel_range(unsigned long start, unsigned long end)
  178. {
  179. flush_tlb_all();
  180. }
  181. /* Flush kernel page from TLB. */
  182. static inline void flush_tlb_kernel_page (unsigned long addr)
  183. {
  184. sun3_put_segmap (addr & ~(SUN3_PMEG_SIZE - 1), SUN3_INVALID_PMEG);
  185. }
  186. static inline void flush_tlb_pgtables(struct mm_struct *mm,
  187. unsigned long start, unsigned long end)
  188. {
  189. }
  190. #endif
  191. #endif /* _M68K_TLBFLUSH_H */