blob: 231d11bd8e320921d6d869eef47edba1c4d52118 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __M68K_MMU_CONTEXT_H
2#define __M68K_MMU_CONTEXT_H
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004
5static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
6{
7}
8
9#ifndef CONFIG_SUN3
10
11#include <asm/setup.h>
12#include <asm/page.h>
13#include <asm/pgalloc.h>
14
15static inline int init_new_context(struct task_struct *tsk,
16 struct mm_struct *mm)
17{
18 mm->context = virt_to_phys(mm->pgd);
19 return 0;
20}
21
22#define destroy_context(mm) do { } while(0)
23
24static inline void switch_mm_0230(struct mm_struct *mm)
25{
26 unsigned long crp[2] = {
27 0x80000000 | _PAGE_TABLE, mm->context
28 };
29 unsigned long tmp;
30
31 asm volatile (".chip 68030");
32
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));
39
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.
44 */
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]));
53
54 asm volatile (".chip 68k");
55}
56
57static inline void switch_mm_0460(struct mm_struct *mm)
58{
59 asm volatile (".chip 68040");
60
61 /* flush address translation cache (user entries) */
62 asm volatile ("pflushan");
63
64 /* switch the root pointer */
65 asm volatile ("movec %0,%%urp" : : "r" (mm->context));
66
67 if (CPU_IS_060) {
68 unsigned long tmp;
69
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));
76 }
77
78 asm volatile (".chip 68k");
79}
80
81static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk)
82{
83 if (prev != next) {
84 if (CPU_IS_020_OR_030)
85 switch_mm_0230(next);
86 else
87 switch_mm_0460(next);
88 }
89}
90
91#define deactivate_mm(tsk,mm) do { } while (0)
92
93static inline void activate_mm(struct mm_struct *prev_mm,
94 struct mm_struct *next_mm)
95{
96 next_mm->context = virt_to_phys(next_mm->pgd);
97
98 if (CPU_IS_020_OR_030)
99 switch_mm_0230(next_mm);
100 else
101 switch_mm_0460(next_mm);
102}
103
104#else /* CONFIG_SUN3 */
105#include <asm/sun3mmu.h>
106#include <linux/sched.h>
107
108extern unsigned long get_free_context(struct mm_struct *mm);
109extern void clear_context(unsigned long context);
110
111/* set the context for a new task to unmapped */
112static inline int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
113{
114 mm->context = SUN3_INVALID_CONTEXT;
115 return 0;
116}
117
118/* find the context given to this process, and if it hasn't already
119 got one, go get one for it. */
120static inline void get_mmu_context(struct mm_struct *mm)
121{
122 if(mm->context == SUN3_INVALID_CONTEXT)
123 mm->context = get_free_context(mm);
124}
125
126/* flush context if allocated... */
127static inline void destroy_context(struct mm_struct *mm)
128{
129 if(mm->context != SUN3_INVALID_CONTEXT)
130 clear_context(mm->context);
131}
132
133static inline void activate_context(struct mm_struct *mm)
134{
135 get_mmu_context(mm);
136 sun3_put_context(mm->context);
137}
138
139static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk)
140{
141 activate_context(tsk->mm);
142}
143
144#define deactivate_mm(tsk,mm) do { } while (0)
145
146static inline void activate_mm(struct mm_struct *prev_mm,
147 struct mm_struct *next_mm)
148{
149 activate_context(next_mm);
150}
151
152#endif
153#endif