[PATCH] i386: clockevents fix breakage on Geode/Cyrix PIT implementations
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / asm-m68k / mmu_context.h
blob231d11bd8e320921d6d869eef47edba1c4d52118
1 #ifndef __M68K_MMU_CONTEXT_H
2 #define __M68K_MMU_CONTEXT_H
5 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
9 #ifndef CONFIG_SUN3
11 #include <asm/setup.h>
12 #include <asm/page.h>
13 #include <asm/pgalloc.h>
15 static inline int init_new_context(struct task_struct *tsk,
16 struct mm_struct *mm)
18 mm->context = virt_to_phys(mm->pgd);
19 return 0;
22 #define destroy_context(mm) do { } while(0)
24 static inline void switch_mm_0230(struct mm_struct *mm)
26 unsigned long crp[2] = {
27 0x80000000 | _PAGE_TABLE, mm->context
29 unsigned long tmp;
31 asm volatile (".chip 68030");
33 /* flush MC68030/MC68020 caches (they are virtually addressed) */
34 asm volatile (
35 "movec %%cacr,%0;"
36 "orw %1,%0; "
37 "movec %0,%%cacr"
38 : "=d" (tmp) : "di" (FLUSH_I_AND_D));
40 /* Switch the root pointer. For a 030-only kernel,
41 * avoid flushing the whole ATC, we only need to
42 * flush the user entries. The 68851 does this by
43 * itself. Avoid a runtime check here.
45 asm volatile (
46 #ifdef CPU_M68030_ONLY
47 "pmovefd %0,%%crp; "
48 "pflush #0,#4"
49 #else
50 "pmove %0,%%crp"
51 #endif
52 : : "m" (crp[0]));
54 asm volatile (".chip 68k");
57 static inline void switch_mm_0460(struct mm_struct *mm)
59 asm volatile (".chip 68040");
61 /* flush address translation cache (user entries) */
62 asm volatile ("pflushan");
64 /* switch the root pointer */
65 asm volatile ("movec %0,%%urp" : : "r" (mm->context));
67 if (CPU_IS_060) {
68 unsigned long tmp;
70 /* clear user entries in the branch cache */
71 asm volatile (
72 "movec %%cacr,%0; "
73 "orl %1,%0; "
74 "movec %0,%%cacr"
75 : "=d" (tmp): "di" (0x00200000));
78 asm volatile (".chip 68k");
81 static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk)
83 if (prev != next) {
84 if (CPU_IS_020_OR_030)
85 switch_mm_0230(next);
86 else
87 switch_mm_0460(next);
91 #define deactivate_mm(tsk,mm) do { } while (0)
93 static inline void activate_mm(struct mm_struct *prev_mm,
94 struct mm_struct *next_mm)
96 next_mm->context = virt_to_phys(next_mm->pgd);
98 if (CPU_IS_020_OR_030)
99 switch_mm_0230(next_mm);
100 else
101 switch_mm_0460(next_mm);
104 #else /* CONFIG_SUN3 */
105 #include <asm/sun3mmu.h>
106 #include <linux/sched.h>
108 extern unsigned long get_free_context(struct mm_struct *mm);
109 extern void clear_context(unsigned long context);
111 /* set the context for a new task to unmapped */
112 static inline int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
114 mm->context = SUN3_INVALID_CONTEXT;
115 return 0;
118 /* find the context given to this process, and if it hasn't already
119 got one, go get one for it. */
120 static inline void get_mmu_context(struct mm_struct *mm)
122 if(mm->context == SUN3_INVALID_CONTEXT)
123 mm->context = get_free_context(mm);
126 /* flush context if allocated... */
127 static inline void destroy_context(struct mm_struct *mm)
129 if(mm->context != SUN3_INVALID_CONTEXT)
130 clear_context(mm->context);
133 static inline void activate_context(struct mm_struct *mm)
135 get_mmu_context(mm);
136 sun3_put_context(mm->context);
139 static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk)
141 activate_context(tsk->mm);
144 #define deactivate_mm(tsk,mm) do { } while (0)
146 static inline void activate_mm(struct mm_struct *prev_mm,
147 struct mm_struct *next_mm)
149 activate_context(next_mm);
152 #endif
153 #endif