2 * r4kcache.h: Inline assembly cache operations.
4 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
6 * $Id: r4kcache.h,v 1.7 1997/12/18 13:00:45 ralf Exp $
8 * FIXME: Handle split L2 caches.
10 #ifndef _MIPS_R4KCACHE_H
11 #define _MIPS_R4KCACHE_H
14 #include <asm/cacheops.h>
16 extern inline void flush_icache_line_indexed(unsigned long addr
)
26 "i" (Index_Invalidate_I
));
29 extern inline void flush_dcache_line_indexed(unsigned long addr
)
39 "i" (Index_Writeback_Inv_D
));
42 extern inline void flush_scache_line_indexed(unsigned long addr
)
52 "i" (Index_Writeback_Inv_SD
));
55 extern inline void flush_icache_line(unsigned long addr
)
65 "i" (Hit_Invalidate_I
));
68 extern inline void flush_dcache_line(unsigned long addr
)
78 "i" (Hit_Writeback_Inv_D
));
81 extern inline void invalidate_dcache_line(unsigned long addr
)
91 "i" (Hit_Invalidate_D
));
94 extern inline void invalidate_scache_line(unsigned long addr
)
104 "i" (Hit_Invalidate_SD
));
107 extern inline void flush_scache_line(unsigned long addr
)
109 __asm__
__volatile__(
117 "i" (Hit_Writeback_Inv_SD
));
121 * The next two are for badland addresses like signal trampolines.
123 extern inline void protected_flush_icache_line(unsigned long addr
)
125 __asm__
__volatile__(
128 "1:\tcache %1,(%0)\n"
131 ".section\t__ex_table,\"a\"\n\t"
132 STR(PTR
)"\t1b,2b\n\t"
136 "i" (Hit_Invalidate_I
));
139 extern inline void protected_writeback_dcache_line(unsigned long addr
)
141 __asm__
__volatile__(
144 "1:\tcache %1,(%0)\n"
147 ".section\t__ex_table,\"a\"\n\t"
148 STR(PTR
)"\t1b,2b\n\t"
152 "i" (Hit_Writeback_D
));
155 #define cache16_unroll32(base,op) \
156 __asm__ __volatile__(" \
159 cache %1, 0x000(%0); cache %1, 0x010(%0); \
160 cache %1, 0x020(%0); cache %1, 0x030(%0); \
161 cache %1, 0x040(%0); cache %1, 0x050(%0); \
162 cache %1, 0x060(%0); cache %1, 0x070(%0); \
163 cache %1, 0x080(%0); cache %1, 0x090(%0); \
164 cache %1, 0x0a0(%0); cache %1, 0x0b0(%0); \
165 cache %1, 0x0c0(%0); cache %1, 0x0d0(%0); \
166 cache %1, 0x0e0(%0); cache %1, 0x0f0(%0); \
167 cache %1, 0x100(%0); cache %1, 0x110(%0); \
168 cache %1, 0x120(%0); cache %1, 0x130(%0); \
169 cache %1, 0x140(%0); cache %1, 0x150(%0); \
170 cache %1, 0x160(%0); cache %1, 0x170(%0); \
171 cache %1, 0x180(%0); cache %1, 0x190(%0); \
172 cache %1, 0x1a0(%0); cache %1, 0x1b0(%0); \
173 cache %1, 0x1c0(%0); cache %1, 0x1d0(%0); \
174 cache %1, 0x1e0(%0); cache %1, 0x1f0(%0); \
181 extern inline void blast_dcache16(void)
183 unsigned long start
= KSEG0
;
184 unsigned long end
= (start
+ dcache_size
);
187 cache16_unroll32(start
,Index_Writeback_Inv_D
);
192 extern inline void blast_dcache16_page(unsigned long page
)
194 unsigned long start
= page
;
195 unsigned long end
= (start
+ PAGE_SIZE
);
198 cache16_unroll32(start
,Hit_Writeback_Inv_D
);
203 extern inline void blast_dcache16_page_indexed(unsigned long page
)
205 unsigned long start
= page
;
206 unsigned long end
= (start
+ PAGE_SIZE
);
209 cache16_unroll32(start
,Index_Writeback_Inv_D
);
214 extern inline void blast_icache16(void)
216 unsigned long start
= KSEG0
;
217 unsigned long end
= (start
+ icache_size
);
220 cache16_unroll32(start
,Index_Invalidate_I
);
225 extern inline void blast_icache16_page(unsigned long page
)
227 unsigned long start
= page
;
228 unsigned long end
= (start
+ PAGE_SIZE
);
231 cache16_unroll32(start
,Hit_Invalidate_I
);
236 extern inline void blast_icache16_page_indexed(unsigned long page
)
238 unsigned long start
= page
;
239 unsigned long end
= (start
+ PAGE_SIZE
);
242 cache16_unroll32(start
,Index_Invalidate_I
);
247 extern inline void blast_scache16(void)
249 unsigned long start
= KSEG0
;
250 unsigned long end
= KSEG0
+ scache_size
;
253 cache16_unroll32(start
,Index_Writeback_Inv_SD
);
258 extern inline void blast_scache16_page(unsigned long page
)
260 unsigned long start
= page
;
261 unsigned long end
= page
+ PAGE_SIZE
;
264 cache16_unroll32(start
,Hit_Writeback_Inv_SD
);
269 extern inline void blast_scache16_page_indexed(unsigned long page
)
271 unsigned long start
= page
;
272 unsigned long end
= page
+ PAGE_SIZE
;
275 cache16_unroll32(start
,Index_Writeback_Inv_SD
);
280 #define cache32_unroll32(base,op) \
281 __asm__ __volatile__(" \
284 cache %1, 0x000(%0); cache %1, 0x020(%0); \
285 cache %1, 0x040(%0); cache %1, 0x060(%0); \
286 cache %1, 0x080(%0); cache %1, 0x0a0(%0); \
287 cache %1, 0x0c0(%0); cache %1, 0x0e0(%0); \
288 cache %1, 0x100(%0); cache %1, 0x120(%0); \
289 cache %1, 0x140(%0); cache %1, 0x160(%0); \
290 cache %1, 0x180(%0); cache %1, 0x1a0(%0); \
291 cache %1, 0x1c0(%0); cache %1, 0x1e0(%0); \
292 cache %1, 0x200(%0); cache %1, 0x220(%0); \
293 cache %1, 0x240(%0); cache %1, 0x260(%0); \
294 cache %1, 0x280(%0); cache %1, 0x2a0(%0); \
295 cache %1, 0x2c0(%0); cache %1, 0x2e0(%0); \
296 cache %1, 0x300(%0); cache %1, 0x320(%0); \
297 cache %1, 0x340(%0); cache %1, 0x360(%0); \
298 cache %1, 0x380(%0); cache %1, 0x3a0(%0); \
299 cache %1, 0x3c0(%0); cache %1, 0x3e0(%0); \
306 extern inline void blast_dcache32(void)
308 unsigned long start
= KSEG0
;
309 unsigned long end
= (start
+ dcache_size
);
312 cache32_unroll32(start
,Index_Writeback_Inv_D
);
318 * Call this function only with interrupts disabled or R4600 V2.0 may blow
321 * R4600 v2.0 bug: "The CACHE instructions Hit_Writeback_Inv_D,
322 * Hit_Writeback_D, Hit_Invalidate_D and Create_Dirty_Excl_D will only
323 * operate correctly if the internal data cache refill buffer is empty. These
324 * CACHE instructions should be separated from any potential data cache miss
325 * by a load instruction to an uncached address to empty the response buffer."
326 * (Revision 2.0 device errata from IDT available on http://www.idt.com/
329 extern inline void blast_dcache32_page(unsigned long page
)
331 unsigned long start
= page
;
332 unsigned long end
= (start
+ PAGE_SIZE
);
335 * Sigh ... workaround for R4600 v1.7 bug. Explanation see above.
337 *(volatile unsigned long *)KSEG1
;
339 __asm__
__volatile__("nop;nop;nop;nop");
341 cache32_unroll32(start
,Hit_Writeback_Inv_D
);
346 extern inline void blast_dcache32_page_indexed(unsigned long page
)
348 unsigned long start
= page
;
349 unsigned long end
= (start
+ PAGE_SIZE
);
352 cache32_unroll32(start
,Index_Writeback_Inv_D
);
357 extern inline void blast_icache32(void)
359 unsigned long start
= KSEG0
;
360 unsigned long end
= (start
+ icache_size
);
363 cache32_unroll32(start
,Index_Invalidate_I
);
368 extern inline void blast_icache32_page(unsigned long page
)
370 unsigned long start
= page
;
371 unsigned long end
= (start
+ PAGE_SIZE
);
374 cache32_unroll32(start
,Hit_Invalidate_I
);
379 extern inline void blast_icache32_page_indexed(unsigned long page
)
381 unsigned long start
= page
;
382 unsigned long end
= (start
+ PAGE_SIZE
);
385 cache32_unroll32(start
,Index_Invalidate_I
);
390 extern inline void blast_scache32(void)
392 unsigned long start
= KSEG0
;
393 unsigned long end
= KSEG0
+ scache_size
;
396 cache32_unroll32(start
,Index_Writeback_Inv_SD
);
401 extern inline void blast_scache32_page(unsigned long page
)
403 unsigned long start
= page
;
404 unsigned long end
= page
+ PAGE_SIZE
;
407 cache32_unroll32(start
,Hit_Writeback_Inv_SD
);
412 extern inline void blast_scache32_page_indexed(unsigned long page
)
414 unsigned long start
= page
;
415 unsigned long end
= page
+ PAGE_SIZE
;
418 cache32_unroll32(start
,Index_Writeback_Inv_SD
);
423 #define cache64_unroll32(base,op) \
424 __asm__ __volatile__(" \
427 cache %1, 0x000(%0); cache %1, 0x040(%0); \
428 cache %1, 0x080(%0); cache %1, 0x0c0(%0); \
429 cache %1, 0x100(%0); cache %1, 0x140(%0); \
430 cache %1, 0x180(%0); cache %1, 0x1c0(%0); \
431 cache %1, 0x200(%0); cache %1, 0x240(%0); \
432 cache %1, 0x280(%0); cache %1, 0x2c0(%0); \
433 cache %1, 0x300(%0); cache %1, 0x340(%0); \
434 cache %1, 0x380(%0); cache %1, 0x3c0(%0); \
435 cache %1, 0x400(%0); cache %1, 0x440(%0); \
436 cache %1, 0x480(%0); cache %1, 0x4c0(%0); \
437 cache %1, 0x500(%0); cache %1, 0x540(%0); \
438 cache %1, 0x580(%0); cache %1, 0x5c0(%0); \
439 cache %1, 0x600(%0); cache %1, 0x640(%0); \
440 cache %1, 0x680(%0); cache %1, 0x6c0(%0); \
441 cache %1, 0x700(%0); cache %1, 0x740(%0); \
442 cache %1, 0x780(%0); cache %1, 0x7c0(%0); \
449 extern inline void blast_scache64(void)
451 unsigned long start
= KSEG0
;
452 unsigned long end
= KSEG0
+ scache_size
;
455 cache64_unroll32(start
,Index_Writeback_Inv_SD
);
460 extern inline void blast_scache64_page(unsigned long page
)
462 unsigned long start
= page
;
463 unsigned long end
= page
+ PAGE_SIZE
;
466 cache64_unroll32(start
,Hit_Writeback_Inv_SD
);
471 extern inline void blast_scache64_page_indexed(unsigned long page
)
473 unsigned long start
= page
;
474 unsigned long end
= page
+ PAGE_SIZE
;
477 cache64_unroll32(start
,Index_Writeback_Inv_SD
);
482 #define cache128_unroll32(base,op) \
483 __asm__ __volatile__(" \
486 cache %1, 0x000(%0); cache %1, 0x080(%0); \
487 cache %1, 0x100(%0); cache %1, 0x180(%0); \
488 cache %1, 0x200(%0); cache %1, 0x280(%0); \
489 cache %1, 0x300(%0); cache %1, 0x380(%0); \
490 cache %1, 0x400(%0); cache %1, 0x480(%0); \
491 cache %1, 0x500(%0); cache %1, 0x580(%0); \
492 cache %1, 0x600(%0); cache %1, 0x680(%0); \
493 cache %1, 0x700(%0); cache %1, 0x780(%0); \
494 cache %1, 0x800(%0); cache %1, 0x880(%0); \
495 cache %1, 0x900(%0); cache %1, 0x980(%0); \
496 cache %1, 0xa00(%0); cache %1, 0xa80(%0); \
497 cache %1, 0xb00(%0); cache %1, 0xb80(%0); \
498 cache %1, 0xc00(%0); cache %1, 0xc80(%0); \
499 cache %1, 0xd00(%0); cache %1, 0xd80(%0); \
500 cache %1, 0xe00(%0); cache %1, 0xe80(%0); \
501 cache %1, 0xf00(%0); cache %1, 0xf80(%0); \
508 extern inline void blast_scache128(void)
510 unsigned long start
= KSEG0
;
511 unsigned long end
= KSEG0
+ scache_size
;
514 cache128_unroll32(start
,Index_Writeback_Inv_SD
);
519 extern inline void blast_scache128_page(unsigned long page
)
521 cache128_unroll32(page
,Hit_Writeback_Inv_SD
);
524 extern inline void blast_scache128_page_indexed(unsigned long page
)
526 cache128_unroll32(page
,Index_Writeback_Inv_SD
);
529 #endif /* !(_MIPS_R4KCACHE_H) */