1 #ifndef _M68K_TLBFLUSH_H
2 #define _M68K_TLBFLUSH_H
7 #include <asm/current.h>
8 #include <asm/mcfmmu.h>
10 static inline void flush_tlb_kernel_page(void *addr)
12 if (CPU_IS_COLDFIRE) {
13 mmu_write(MMUOR, MMUOR_CNL);
14 } else if (CPU_IS_040_OR_060) {
15 mm_segment_t old_fs = get_fs();
17 __asm__ __volatile__(".chip 68040\n\t"
22 } else if (CPU_IS_020_OR_030)
23 __asm__ __volatile__("pflush #4,#4,(%0)" : : "a" (addr));
27 * flush all user-space atc entries.
29 static inline void __flush_tlb(void)
31 if (CPU_IS_COLDFIRE) {
32 mmu_write(MMUOR, MMUOR_CNL);
33 } else if (CPU_IS_040_OR_060) {
34 __asm__ __volatile__(".chip 68040\n\t"
37 } else if (CPU_IS_020_OR_030) {
38 __asm__ __volatile__("pflush #0,#4");
42 static inline void __flush_tlb040_one(unsigned long addr)
44 __asm__ __volatile__(".chip 68040\n\t"
50 static inline void __flush_tlb_one(unsigned long addr)
53 mmu_write(MMUOR, MMUOR_CNL);
54 else if (CPU_IS_040_OR_060)
55 __flush_tlb040_one(addr);
56 else if (CPU_IS_020_OR_030)
57 __asm__ __volatile__("pflush #0,#4,(%0)" : : "a" (addr));
60 #define flush_tlb() __flush_tlb()
63 * flush all atc entries (both kernel and user-space entries).
65 static inline void flush_tlb_all(void)
67 if (CPU_IS_COLDFIRE) {
68 mmu_write(MMUOR, MMUOR_CNL);
69 } else if (CPU_IS_040_OR_060) {
70 __asm__ __volatile__(".chip 68040\n\t"
73 } else if (CPU_IS_020_OR_030) {
74 __asm__ __volatile__("pflusha");
78 static inline void flush_tlb_mm(struct mm_struct *mm)
80 if (mm == current->active_mm)
84 static inline void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
86 if (vma->vm_mm == current->active_mm) {
87 mm_segment_t old_fs = get_fs();
89 __flush_tlb_one(addr);
94 static inline void flush_tlb_range(struct vm_area_struct *vma,
95 unsigned long start, unsigned long end)
97 if (vma->vm_mm == current->active_mm)
101 static inline void flush_tlb_kernel_range(unsigned long start, unsigned long end)
109 /* Reserved PMEGs. */
110 extern char sun3_reserved_pmeg[SUN3_PMEGS_NUM];
111 extern unsigned long pmeg_vaddr[SUN3_PMEGS_NUM];
112 extern unsigned char pmeg_alloc[SUN3_PMEGS_NUM];
113 extern unsigned char pmeg_ctx[SUN3_PMEGS_NUM];
115 /* Flush all userspace mappings one by one... (why no flush command,
117 static inline void flush_tlb_all(void)
120 unsigned char ctx, oldctx;
122 oldctx = sun3_get_context();
123 for(addr = 0x00000000; addr < TASK_SIZE; addr += SUN3_PMEG_SIZE) {
124 for(ctx = 0; ctx < 8; ctx++) {
125 sun3_put_context(ctx);
126 sun3_put_segmap(addr, SUN3_INVALID_PMEG);
130 sun3_put_context(oldctx);
131 /* erase all of the userspace pmeg maps, we've clobbered them
133 for(addr = 0; addr < SUN3_INVALID_PMEG; addr++) {
134 if(pmeg_alloc[addr] == 1) {
135 pmeg_alloc[addr] = 0;
137 pmeg_vaddr[addr] = 0;
143 /* Clear user TLB entries within the context named in mm */
144 static inline void flush_tlb_mm (struct mm_struct *mm)
146 unsigned char oldctx;
150 oldctx = sun3_get_context();
151 sun3_put_context(mm->context);
153 for(i = 0; i < TASK_SIZE; i += SUN3_PMEG_SIZE) {
154 seg = sun3_get_segmap(i);
155 if(seg == SUN3_INVALID_PMEG)
158 sun3_put_segmap(i, SUN3_INVALID_PMEG);
164 sun3_put_context(oldctx);
168 /* Flush a single TLB page. In this case, we're limited to flushing a
170 static inline void flush_tlb_page (struct vm_area_struct *vma,
173 unsigned char oldctx;
176 oldctx = sun3_get_context();
177 sun3_put_context(vma->vm_mm->context);
178 addr &= ~SUN3_PMEG_MASK;
179 if((i = sun3_get_segmap(addr)) != SUN3_INVALID_PMEG)
184 sun3_put_segmap (addr, SUN3_INVALID_PMEG);
186 sun3_put_context(oldctx);
189 /* Flush a range of pages from TLB. */
191 static inline void flush_tlb_range (struct vm_area_struct *vma,
192 unsigned long start, unsigned long end)
194 struct mm_struct *mm = vma->vm_mm;
195 unsigned char seg, oldctx;
197 start &= ~SUN3_PMEG_MASK;
199 oldctx = sun3_get_context();
200 sun3_put_context(mm->context);
204 if((seg = sun3_get_segmap(start)) == SUN3_INVALID_PMEG)
206 if(pmeg_ctx[seg] == mm->context) {
211 sun3_put_segmap(start, SUN3_INVALID_PMEG);
213 start += SUN3_PMEG_SIZE;
217 static inline void flush_tlb_kernel_range(unsigned long start, unsigned long end)
222 /* Flush kernel page from TLB. */
223 static inline void flush_tlb_kernel_page (unsigned long addr)
225 sun3_put_segmap (addr & ~(SUN3_PMEG_SIZE - 1), SUN3_INVALID_PMEG);
230 #else /* !CONFIG_MMU */
233 * flush all user-space atc entries.
235 static inline void __flush_tlb(void)
240 static inline void __flush_tlb_one(unsigned long addr)
245 #define flush_tlb() __flush_tlb()
248 * flush all atc entries (both kernel and user-space entries).
250 static inline void flush_tlb_all(void)
255 static inline void flush_tlb_mm(struct mm_struct *mm)
260 static inline void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
265 static inline void flush_tlb_range(struct mm_struct *mm,
266 unsigned long start, unsigned long end)
271 static inline void flush_tlb_kernel_page(unsigned long addr)
276 #endif /* CONFIG_MMU */
278 #endif /* _M68K_TLBFLUSH_H */