1 #ifndef _M68K_TLBFLUSH_H
2 #define _M68K_TLBFLUSH_H
6 #include <asm/current.h>
8 static inline void flush_tlb_kernel_page(void *addr
)
10 if (CPU_IS_040_OR_060
) {
11 mm_segment_t old_fs
= get_fs();
13 __asm__
__volatile__(".chip 68040\n\t"
19 __asm__
__volatile__("pflush #4,#4,(%0)" : : "a" (addr
));
23 * flush all user-space atc entries.
25 static inline void __flush_tlb(void)
27 if (CPU_IS_040_OR_060
)
28 __asm__
__volatile__(".chip 68040\n\t"
32 __asm__
__volatile__("pflush #0,#4");
35 static inline void __flush_tlb040_one(unsigned long addr
)
37 __asm__
__volatile__(".chip 68040\n\t"
43 static inline void __flush_tlb_one(unsigned long addr
)
45 if (CPU_IS_040_OR_060
)
46 __flush_tlb040_one(addr
);
48 __asm__
__volatile__("pflush #0,#4,(%0)" : : "a" (addr
));
51 #define flush_tlb() __flush_tlb()
54 * flush all atc entries (both kernel and user-space entries).
56 static inline void flush_tlb_all(void)
58 if (CPU_IS_040_OR_060
)
59 __asm__
__volatile__(".chip 68040\n\t"
63 __asm__
__volatile__("pflusha");
66 static inline void flush_tlb_mm(struct mm_struct
*mm
)
68 if (mm
== current
->active_mm
)
72 static inline void flush_tlb_page(struct vm_area_struct
*vma
, unsigned long addr
)
74 if (vma
->vm_mm
== current
->active_mm
) {
75 mm_segment_t old_fs
= get_fs();
77 __flush_tlb_one(addr
);
82 static inline void flush_tlb_range(struct vm_area_struct
*vma
,
83 unsigned long start
, unsigned long end
)
85 if (vma
->vm_mm
== current
->active_mm
)
89 static inline void flush_tlb_kernel_range(unsigned long start
, unsigned long end
)
94 static inline void flush_tlb_pgtables(struct mm_struct
*mm
,
95 unsigned long start
, unsigned long end
)
102 /* Reserved PMEGs. */
103 extern char sun3_reserved_pmeg
[SUN3_PMEGS_NUM
];
104 extern unsigned long pmeg_vaddr
[SUN3_PMEGS_NUM
];
105 extern unsigned char pmeg_alloc
[SUN3_PMEGS_NUM
];
106 extern unsigned char pmeg_ctx
[SUN3_PMEGS_NUM
];
108 /* Flush all userspace mappings one by one... (why no flush command,
110 static inline void flush_tlb_all(void)
113 unsigned char ctx
, oldctx
;
115 oldctx
= sun3_get_context();
116 for(addr
= 0x00000000; addr
< TASK_SIZE
; addr
+= SUN3_PMEG_SIZE
) {
117 for(ctx
= 0; ctx
< 8; ctx
++) {
118 sun3_put_context(ctx
);
119 sun3_put_segmap(addr
, SUN3_INVALID_PMEG
);
123 sun3_put_context(oldctx
);
124 /* erase all of the userspace pmeg maps, we've clobbered them
126 for(addr
= 0; addr
< SUN3_INVALID_PMEG
; addr
++) {
127 if(pmeg_alloc
[addr
] == 1) {
128 pmeg_alloc
[addr
] = 0;
130 pmeg_vaddr
[addr
] = 0;
136 /* Clear user TLB entries within the context named in mm */
137 static inline void flush_tlb_mm (struct mm_struct
*mm
)
139 unsigned char oldctx
;
143 oldctx
= sun3_get_context();
144 sun3_put_context(mm
->context
);
146 for(i
= 0; i
< TASK_SIZE
; i
+= SUN3_PMEG_SIZE
) {
147 seg
= sun3_get_segmap(i
);
148 if(seg
== SUN3_INVALID_PMEG
)
151 sun3_put_segmap(i
, SUN3_INVALID_PMEG
);
157 sun3_put_context(oldctx
);
161 /* Flush a single TLB page. In this case, we're limited to flushing a
163 static inline void flush_tlb_page (struct vm_area_struct
*vma
,
166 unsigned char oldctx
;
169 oldctx
= sun3_get_context();
170 sun3_put_context(vma
->vm_mm
->context
);
171 addr
&= ~SUN3_PMEG_MASK
;
172 if((i
= sun3_get_segmap(addr
)) != SUN3_INVALID_PMEG
)
177 sun3_put_segmap (addr
, SUN3_INVALID_PMEG
);
179 sun3_put_context(oldctx
);
182 /* Flush a range of pages from TLB. */
184 static inline void flush_tlb_range (struct vm_area_struct
*vma
,
185 unsigned long start
, unsigned long end
)
187 struct mm_struct
*mm
= vma
->vm_mm
;
188 unsigned char seg
, oldctx
;
190 start
&= ~SUN3_PMEG_MASK
;
192 oldctx
= sun3_get_context();
193 sun3_put_context(mm
->context
);
197 if((seg
= sun3_get_segmap(start
)) == SUN3_INVALID_PMEG
)
199 if(pmeg_ctx
[seg
] == mm
->context
) {
204 sun3_put_segmap(start
, SUN3_INVALID_PMEG
);
206 start
+= SUN3_PMEG_SIZE
;
210 static inline void flush_tlb_kernel_range(unsigned long start
, unsigned long end
)
215 /* Flush kernel page from TLB. */
216 static inline void flush_tlb_kernel_page (unsigned long addr
)
218 sun3_put_segmap (addr
& ~(SUN3_PMEG_SIZE
- 1), SUN3_INVALID_PMEG
);
221 static inline void flush_tlb_pgtables(struct mm_struct
*mm
,
222 unsigned long start
, unsigned long end
)
228 #endif /* _M68K_TLBFLUSH_H */