1 #ifndef __M68K_MMU_CONTEXT_H
2 #define __M68K_MMU_CONTEXT_H
4 #include <linux/config.h>
6 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk, unsigned cpu)
12 #include <asm/setup.h>
14 #include <asm/pgalloc.h>
17 init_new_context(struct task_struct *tsk, struct mm_struct *mm)
19 mm->context = virt_to_phys(mm->pgd);
23 #define destroy_context(mm) do { } while(0)
25 extern inline void switch_mm_0230(struct mm_struct *mm)
27 unsigned long crp[2] = {
28 0x80000000 | _PAGE_TABLE, mm->context
32 asm volatile (".chip 68030");
34 /* flush MC68030/MC68020 caches (they are virtually addressed) */
39 : "=d" (tmp) : "di" (FLUSH_I_AND_D));
41 /* Switch the root pointer. For a 030-only kernel,
42 * avoid flushing the whole ATC, we only need to
43 * flush the user entries. The 68851 does this by
44 * itself. Avoid a runtime check here.
47 #ifdef CPU_M68030_ONLY
55 asm volatile (".chip 68k");
58 extern inline void switch_mm_0460(struct mm_struct *mm)
60 asm volatile (".chip 68040");
62 /* flush address translation cache (user entries) */
63 asm volatile ("pflushan");
65 /* switch the root pointer */
66 asm volatile ("movec %0,%%urp" : : "r" (mm->context));
71 /* clear user entries in the branch cache */
76 : "=d" (tmp): "di" (0x00200000));
79 asm volatile (".chip 68k");
82 static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk, unsigned cpu)
85 if (CPU_IS_020_OR_030)
92 extern inline void activate_mm(struct mm_struct *prev_mm,
93 struct mm_struct *next_mm)
95 next_mm->context = virt_to_phys(next_mm->pgd);
97 if (CPU_IS_020_OR_030)
98 switch_mm_0230(next_mm);
100 switch_mm_0460(next_mm);
103 #else /* CONFIG_SUN3 */
104 #include <asm/sun3mmu.h>
105 #include <linux/sched.h>
107 extern unsigned long get_free_context(struct mm_struct *mm);
108 extern void clear_context(unsigned long context);
110 /* set the context for a new task to unmapped */
111 static inline int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
113 mm->context = SUN3_INVALID_CONTEXT;
117 /* find the context given to this process, and if it hasn't already
118 got one, go get one for it. */
119 static inline void get_mmu_context(struct mm_struct *mm)
121 if(mm->context == SUN3_INVALID_CONTEXT)
122 mm->context = get_free_context(mm);
125 /* flush context if allocated... */
126 static inline void destroy_context(struct mm_struct *mm)
128 if(mm->context != SUN3_INVALID_CONTEXT)
129 clear_context(mm->context);
132 static inline void activate_context(struct mm_struct *mm)
135 sun3_put_context(mm->context);
138 static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk, unsigned cpu)
140 activate_context(tsk->mm);
143 extern inline void activate_mm(struct mm_struct *prev_mm,
144 struct mm_struct *next_mm)
146 activate_context(next_mm);