1 #ifndef _M68K_TLBFLUSH_H
2 #define _M68K_TLBFLUSH_H
4 #include <linux/config.h>
8 #include <asm/current.h>
10 static inline void flush_tlb_kernel_page(void *addr
)
12 if (CPU_IS_040_OR_060
) {
13 mm_segment_t old_fs
= get_fs();
15 __asm__
__volatile__(".chip 68040\n\t"
21 __asm__
__volatile__("pflush #4,#4,(%0)" : : "a" (addr
));
25 * flush all user-space atc entries.
27 static inline void __flush_tlb(void)
29 if (CPU_IS_040_OR_060
)
30 __asm__
__volatile__(".chip 68040\n\t"
34 __asm__
__volatile__("pflush #0,#4");
37 static inline void __flush_tlb040_one(unsigned long addr
)
39 __asm__
__volatile__(".chip 68040\n\t"
45 static inline void __flush_tlb_one(unsigned long addr
)
47 if (CPU_IS_040_OR_060
)
48 __flush_tlb040_one(addr
);
50 __asm__
__volatile__("pflush #0,#4,(%0)" : : "a" (addr
));
53 #define flush_tlb() __flush_tlb()
56 * flush all atc entries (both kernel and user-space entries).
58 static inline void flush_tlb_all(void)
60 if (CPU_IS_040_OR_060
)
61 __asm__
__volatile__(".chip 68040\n\t"
65 __asm__
__volatile__("pflusha");
68 static inline void flush_tlb_mm(struct mm_struct
*mm
)
70 if (mm
== current
->active_mm
)
74 static inline void flush_tlb_page(struct vm_area_struct
*vma
, unsigned long addr
)
76 if (vma
->vm_mm
== current
->active_mm
) {
77 mm_segment_t old_fs
= get_fs();
79 __flush_tlb_one(addr
);
84 static inline void flush_tlb_range(struct vm_area_struct
*vma
,
85 unsigned long start
, unsigned long end
)
87 if (vma
->vm_mm
== current
->active_mm
)
91 static inline void flush_tlb_kernel_range(unsigned long start
, unsigned long end
)
96 static inline void flush_tlb_pgtables(struct mm_struct
*mm
,
97 unsigned long start
, unsigned long end
)
104 /* Reserved PMEGs. */
105 extern char sun3_reserved_pmeg
[SUN3_PMEGS_NUM
];
106 extern unsigned long pmeg_vaddr
[SUN3_PMEGS_NUM
];
107 extern unsigned char pmeg_alloc
[SUN3_PMEGS_NUM
];
108 extern unsigned char pmeg_ctx
[SUN3_PMEGS_NUM
];
110 /* Flush all userspace mappings one by one... (why no flush command,
112 static inline void flush_tlb_all(void)
115 unsigned char ctx
, oldctx
;
117 oldctx
= sun3_get_context();
118 for(addr
= 0x00000000; addr
< TASK_SIZE
; addr
+= SUN3_PMEG_SIZE
) {
119 for(ctx
= 0; ctx
< 8; ctx
++) {
120 sun3_put_context(ctx
);
121 sun3_put_segmap(addr
, SUN3_INVALID_PMEG
);
125 sun3_put_context(oldctx
);
126 /* erase all of the userspace pmeg maps, we've clobbered them
128 for(addr
= 0; addr
< SUN3_INVALID_PMEG
; addr
++) {
129 if(pmeg_alloc
[addr
] == 1) {
130 pmeg_alloc
[addr
] = 0;
132 pmeg_vaddr
[addr
] = 0;
138 /* Clear user TLB entries within the context named in mm */
139 static inline void flush_tlb_mm (struct mm_struct
*mm
)
141 unsigned char oldctx
;
145 oldctx
= sun3_get_context();
146 sun3_put_context(mm
->context
);
148 for(i
= 0; i
< TASK_SIZE
; i
+= SUN3_PMEG_SIZE
) {
149 seg
= sun3_get_segmap(i
);
150 if(seg
== SUN3_INVALID_PMEG
)
153 sun3_put_segmap(i
, SUN3_INVALID_PMEG
);
159 sun3_put_context(oldctx
);
163 /* Flush a single TLB page. In this case, we're limited to flushing a
165 static inline void flush_tlb_page (struct vm_area_struct
*vma
,
168 unsigned char oldctx
;
171 oldctx
= sun3_get_context();
172 sun3_put_context(vma
->vm_mm
->context
);
173 addr
&= ~SUN3_PMEG_MASK
;
174 if((i
= sun3_get_segmap(addr
)) != SUN3_INVALID_PMEG
)
179 sun3_put_segmap (addr
, SUN3_INVALID_PMEG
);
181 sun3_put_context(oldctx
);
184 /* Flush a range of pages from TLB. */
186 static inline void flush_tlb_range (struct vm_area_struct
*vma
,
187 unsigned long start
, unsigned long end
)
189 struct mm_struct
*mm
= vma
->vm_mm
;
190 unsigned char seg
, oldctx
;
192 start
&= ~SUN3_PMEG_MASK
;
194 oldctx
= sun3_get_context();
195 sun3_put_context(mm
->context
);
199 if((seg
= sun3_get_segmap(start
)) == SUN3_INVALID_PMEG
)
201 if(pmeg_ctx
[seg
] == mm
->context
) {
206 sun3_put_segmap(start
, SUN3_INVALID_PMEG
);
208 start
+= SUN3_PMEG_SIZE
;
212 static inline void flush_tlb_kernel_range(unsigned long start
, unsigned long end
)
217 /* Flush kernel page from TLB. */
218 static inline void flush_tlb_kernel_page (unsigned long addr
)
220 sun3_put_segmap (addr
& ~(SUN3_PMEG_SIZE
- 1), SUN3_INVALID_PMEG
);
223 static inline void flush_tlb_pgtables(struct mm_struct
*mm
,
224 unsigned long start
, unsigned long end
)
230 #endif /* _M68K_TLBFLUSH_H */