mmu_context.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:3k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. #ifndef __M68K_MMU_CONTEXT_H
  2. #define __M68K_MMU_CONTEXT_H
  3. #include <linux/config.h>
  4. static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk, unsigned cpu)
  5. {
  6. }
  7. #ifndef CONFIG_SUN3
  8. #include <asm/setup.h>
  9. #include <asm/page.h>
  10. #include <asm/pgalloc.h>
  11. extern inline int
  12. init_new_context(struct task_struct *tsk, struct mm_struct *mm)
  13. {
  14. mm->context = virt_to_phys(mm->pgd);
  15. return 0;
  16. }
  17. #define destroy_context(mm) do { } while(0)
  18. extern inline void switch_mm_0230(struct mm_struct *mm)
  19. {
  20. unsigned long crp[2] = {
  21. 0x80000000 | _PAGE_TABLE, mm->context
  22. };
  23. unsigned long tmp;
  24. asm volatile (".chip 68030");
  25. /* flush MC68030/MC68020 caches (they are virtually addressed) */
  26. asm volatile (
  27. "movec %%cacr,%0;"
  28. "orw %1,%0; "
  29. "movec %0,%%cacr"
  30. : "=d" (tmp) : "di" (FLUSH_I_AND_D));
  31. /* Switch the root pointer. For a 030-only kernel,
  32.  * avoid flushing the whole ATC, we only need to
  33.  * flush the user entries. The 68851 does this by
  34.  * itself. Avoid a runtime check here.
  35.  */
  36. asm volatile (
  37. #ifdef CPU_M68030_ONLY
  38. "pmovefd %0,%%crp; "
  39. "pflush #0,#4"
  40. #else
  41. "pmove %0,%%crp"
  42. #endif
  43. : : "m" (crp[0]));
  44. asm volatile (".chip 68k");
  45. }
  46. extern inline void switch_mm_0460(struct mm_struct *mm)
  47. {
  48. asm volatile (".chip 68040");
  49. /* flush address translation cache (user entries) */
  50. asm volatile ("pflushan");
  51. /* switch the root pointer */
  52. asm volatile ("movec %0,%%urp" : : "r" (mm->context));
  53. if (CPU_IS_060) {
  54. unsigned long tmp;
  55. /* clear user entries in the branch cache */
  56. asm volatile (
  57. "movec %%cacr,%0; "
  58.         "orl %1,%0; "
  59.         "movec %0,%%cacr"
  60. : "=d" (tmp): "di" (0x00200000));
  61. }
  62. asm volatile (".chip 68k");
  63. }
  64. static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk, unsigned cpu)
  65. {
  66. if (prev != next) {
  67. if (CPU_IS_020_OR_030)
  68. switch_mm_0230(next);
  69. else
  70. switch_mm_0460(next);
  71. }
  72. }
  73. extern inline void activate_mm(struct mm_struct *prev_mm,
  74.        struct mm_struct *next_mm)
  75. {
  76. next_mm->context = virt_to_phys(next_mm->pgd);
  77. if (CPU_IS_020_OR_030)
  78. switch_mm_0230(next_mm);
  79. else
  80. switch_mm_0460(next_mm);
  81. }
  82. #else  /* CONFIG_SUN3 */
  83. #include <asm/sun3mmu.h>
  84. #include <linux/sched.h>
  85. extern unsigned long get_free_context(struct mm_struct *mm);
  86. extern void clear_context(unsigned long context);
  87. /* set the context for a new task to unmapped */
  88. static inline int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
  89. {
  90. mm->context = SUN3_INVALID_CONTEXT;
  91. return 0;
  92. }
  93. /* find the context given to this process, and if it hasn't already
  94.    got one, go get one for it. */
  95. static inline void get_mmu_context(struct mm_struct *mm)
  96. {
  97. if(mm->context == SUN3_INVALID_CONTEXT)
  98. mm->context = get_free_context(mm);
  99. }
  100. /* flush context if allocated... */
  101. static inline void destroy_context(struct mm_struct *mm)
  102. {
  103. if(mm->context != SUN3_INVALID_CONTEXT)
  104. clear_context(mm->context);
  105. }
  106. static inline void activate_context(struct mm_struct *mm)
  107. {
  108. get_mmu_context(mm);
  109. sun3_put_context(mm->context);
  110. }
  111. static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk, unsigned cpu)
  112. {
  113. activate_context(tsk->mm);
  114. }
  115. extern inline void activate_mm(struct mm_struct *prev_mm,
  116.        struct mm_struct *next_mm)
  117. {
  118. activate_context(next_mm);
  119. }
  120. #endif 
  121. #endif