[PATCH] CREDITS update
[linux-2.6/history.git] / include / asm-m68k / tlbflush.h
blobc989e4fcf37b163c6ba2e2aaaa5e04cfac9ee2da
1 #ifndef _M68K_TLBFLUSH_H
2 #define _M68K_TLBFLUSH_H
4 #ifndef CONFIG_SUN3
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();
12 set_fs(KERNEL_DS);
13 __asm__ __volatile__(".chip 68040\n\t"
14 "pflush (%0)\n\t"
15 ".chip 68k"
16 : : "a" (addr));
17 set_fs(old_fs);
18 } else
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"
29 "pflushan\n\t"
30 ".chip 68k");
31 else
32 __asm__ __volatile__("pflush #0,#4");
35 static inline void __flush_tlb040_one(unsigned long addr)
37 __asm__ __volatile__(".chip 68040\n\t"
38 "pflush (%0)\n\t"
39 ".chip 68k"
40 : : "a" (addr));
43 static inline void __flush_tlb_one(unsigned long addr)
45 if (CPU_IS_040_OR_060)
46 __flush_tlb040_one(addr);
47 else
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"
60 "pflusha\n\t"
61 ".chip 68k");
62 else
63 __asm__ __volatile__("pflusha");
66 static inline void flush_tlb_mm(struct mm_struct *mm)
68 if (mm == current->active_mm)
69 __flush_tlb();
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();
76 set_fs(USER_DS);
77 __flush_tlb_one(addr);
78 set_fs(old_fs);
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)
86 __flush_tlb();
89 static inline void flush_tlb_kernel_range(unsigned long start, unsigned long end)
91 flush_tlb_all();
94 static inline void flush_tlb_pgtables(struct mm_struct *mm,
95 unsigned long start, unsigned long end)
99 #else
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,
109 sun?) */
110 static inline void flush_tlb_all(void)
112 unsigned long addr;
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
125 all anyway */
126 for(addr = 0; addr < SUN3_INVALID_PMEG; addr++) {
127 if(pmeg_alloc[addr] == 1) {
128 pmeg_alloc[addr] = 0;
129 pmeg_ctx[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;
140 unsigned char seg;
141 unsigned long i;
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)
149 continue;
151 sun3_put_segmap(i, SUN3_INVALID_PMEG);
152 pmeg_alloc[seg] = 0;
153 pmeg_ctx[seg] = 0;
154 pmeg_vaddr[seg] = 0;
157 sun3_put_context(oldctx);
161 /* Flush a single TLB page. In this case, we're limited to flushing a
162 single PMEG */
163 static inline void flush_tlb_page (struct vm_area_struct *vma,
164 unsigned long addr)
166 unsigned char oldctx;
167 unsigned char i;
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)
174 pmeg_alloc[i] = 0;
175 pmeg_ctx[i] = 0;
176 pmeg_vaddr[i] = 0;
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);
195 while(start < end)
197 if((seg = sun3_get_segmap(start)) == SUN3_INVALID_PMEG)
198 goto next;
199 if(pmeg_ctx[seg] == mm->context) {
200 pmeg_alloc[seg] = 0;
201 pmeg_ctx[seg] = 0;
202 pmeg_vaddr[seg] = 0;
204 sun3_put_segmap(start, SUN3_INVALID_PMEG);
205 next:
206 start += SUN3_PMEG_SIZE;
210 static inline void flush_tlb_kernel_range(unsigned long start, unsigned long end)
212 flush_tlb_all();
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)
226 #endif
228 #endif /* _M68K_TLBFLUSH_H */