Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[linux-2.6/linux-mips/linux-dm7025.git] / include / asm-m68k / mmu_context.h
blob894dacbcee145df5c79b147393c7282a9edfef06
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)
10 #ifndef CONFIG_SUN3
12 #include <asm/setup.h>
13 #include <asm/page.h>
14 #include <asm/pgalloc.h>
16 static inline int init_new_context(struct task_struct *tsk,
17 struct mm_struct *mm)
19 mm->context = virt_to_phys(mm->pgd);
20 return 0;
23 #define destroy_context(mm) do { } while(0)
25 static inline void switch_mm_0230(struct mm_struct *mm)
27 unsigned long crp[2] = {
28 0x80000000 | _PAGE_TABLE, mm->context
30 unsigned long tmp;
32 asm volatile (".chip 68030");
34 /* flush MC68030/MC68020 caches (they are virtually addressed) */
35 asm volatile (
36 "movec %%cacr,%0;"
37 "orw %1,%0; "
38 "movec %0,%%cacr"
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.
46 asm volatile (
47 #ifdef CPU_M68030_ONLY
48 "pmovefd %0,%%crp; "
49 "pflush #0,#4"
50 #else
51 "pmove %0,%%crp"
52 #endif
53 : : "m" (crp[0]));
55 asm volatile (".chip 68k");
58 static 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));
68 if (CPU_IS_060) {
69 unsigned long tmp;
71 /* clear user entries in the branch cache */
72 asm volatile (
73 "movec %%cacr,%0; "
74 "orl %1,%0; "
75 "movec %0,%%cacr"
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)
84 if (prev != next) {
85 if (CPU_IS_020_OR_030)
86 switch_mm_0230(next);
87 else
88 switch_mm_0460(next);
92 #define deactivate_mm(tsk,mm) do { } while (0)
94 static inline void activate_mm(struct mm_struct *prev_mm,
95 struct mm_struct *next_mm)
97 next_mm->context = virt_to_phys(next_mm->pgd);
99 if (CPU_IS_020_OR_030)
100 switch_mm_0230(next_mm);
101 else
102 switch_mm_0460(next_mm);
105 #else /* CONFIG_SUN3 */
106 #include <asm/sun3mmu.h>
107 #include <linux/sched.h>
109 extern unsigned long get_free_context(struct mm_struct *mm);
110 extern void clear_context(unsigned long context);
112 /* set the context for a new task to unmapped */
113 static inline int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
115 mm->context = SUN3_INVALID_CONTEXT;
116 return 0;
119 /* find the context given to this process, and if it hasn't already
120 got one, go get one for it. */
121 static inline void get_mmu_context(struct mm_struct *mm)
123 if(mm->context == SUN3_INVALID_CONTEXT)
124 mm->context = get_free_context(mm);
127 /* flush context if allocated... */
128 static inline void destroy_context(struct mm_struct *mm)
130 if(mm->context != SUN3_INVALID_CONTEXT)
131 clear_context(mm->context);
134 static inline void activate_context(struct mm_struct *mm)
136 get_mmu_context(mm);
137 sun3_put_context(mm->context);
140 static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk)
142 activate_context(tsk->mm);
145 #define deactivate_mm(tsk,mm) do { } while (0)
147 static inline void activate_mm(struct mm_struct *prev_mm,
148 struct mm_struct *next_mm)
150 activate_context(next_mm);
153 #endif
154 #endif