1 #ifndef __M68K_MMU_CONTEXT_H
2 #define __M68K_MMU_CONTEXT_H
4 #include <asm-generic/mm_hooks.h>
6 static inline void enter_lazy_tlb(struct mm_struct
*mm
, struct task_struct
*tsk
)
13 #include <asm/setup.h>
15 #include <asm/pgalloc.h>
17 static inline int init_new_context(struct task_struct
*tsk
,
20 mm
->context
= virt_to_phys(mm
->pgd
);
24 #define destroy_context(mm) do { } while(0)
26 static inline void switch_mm_0230(struct mm_struct
*mm
)
28 unsigned long crp
[2] = {
29 0x80000000 | _PAGE_TABLE
, mm
->context
33 asm volatile (".chip 68030");
35 /* flush MC68030/MC68020 caches (they are virtually addressed) */
40 : "=d" (tmp
) : "di" (FLUSH_I_AND_D
));
42 /* Switch the root pointer. For a 030-only kernel,
43 * avoid flushing the whole ATC, we only need to
44 * flush the user entries. The 68851 does this by
45 * itself. Avoid a runtime check here.
48 #ifdef CPU_M68030_ONLY
56 asm volatile (".chip 68k");
59 static inline void switch_mm_0460(struct mm_struct
*mm
)
61 asm volatile (".chip 68040");
63 /* flush address translation cache (user entries) */
64 asm volatile ("pflushan");
66 /* switch the root pointer */
67 asm volatile ("movec %0,%%urp" : : "r" (mm
->context
));
72 /* clear user entries in the branch cache */
77 : "=d" (tmp
): "di" (0x00200000));
80 asm volatile (".chip 68k");
83 static inline void switch_mm(struct mm_struct
*prev
, struct mm_struct
*next
, struct task_struct
*tsk
)
86 if (CPU_IS_020_OR_030
)
93 #define deactivate_mm(tsk,mm) do { } while (0)
95 static inline void activate_mm(struct mm_struct
*prev_mm
,
96 struct mm_struct
*next_mm
)
98 next_mm
->context
= virt_to_phys(next_mm
->pgd
);
100 if (CPU_IS_020_OR_030
)
101 switch_mm_0230(next_mm
);
103 switch_mm_0460(next_mm
);
106 #else /* CONFIG_SUN3 */
107 #include <asm/sun3mmu.h>
108 #include <linux/sched.h>
110 extern unsigned long get_free_context(struct mm_struct
*mm
);
111 extern void clear_context(unsigned long context
);
113 /* set the context for a new task to unmapped */
114 static inline int init_new_context(struct task_struct
*tsk
, struct mm_struct
*mm
)
116 mm
->context
= SUN3_INVALID_CONTEXT
;
120 /* find the context given to this process, and if it hasn't already
121 got one, go get one for it. */
122 static inline void get_mmu_context(struct mm_struct
*mm
)
124 if(mm
->context
== SUN3_INVALID_CONTEXT
)
125 mm
->context
= get_free_context(mm
);
128 /* flush context if allocated... */
129 static inline void destroy_context(struct mm_struct
*mm
)
131 if(mm
->context
!= SUN3_INVALID_CONTEXT
)
132 clear_context(mm
->context
);
135 static inline void activate_context(struct mm_struct
*mm
)
138 sun3_put_context(mm
->context
);
141 static inline void switch_mm(struct mm_struct
*prev
, struct mm_struct
*next
, struct task_struct
*tsk
)
143 activate_context(tsk
->mm
);
146 #define deactivate_mm(tsk,mm) do { } while (0)
148 static inline void activate_mm(struct mm_struct
*prev_mm
,
149 struct mm_struct
*next_mm
)
151 activate_context(next_mm
);
155 #else /* !CONFIG_MMU */
157 static inline int init_new_context(struct task_struct
*tsk
, struct mm_struct
*mm
)
163 static inline void switch_mm(struct mm_struct
*prev
, struct mm_struct
*next
, struct task_struct
*tsk
)
167 #define destroy_context(mm) do { } while (0)
168 #define deactivate_mm(tsk,mm) do { } while (0)
170 static inline void activate_mm(struct mm_struct
*prev_mm
, struct mm_struct
*next_mm
)
174 #endif /* CONFIG_MMU */
175 #endif /* __M68K_MMU_CONTEXT_H */