aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/asm-mips/r4kcache.h74
1 files changed, 41 insertions, 33 deletions
diff --git a/include/asm-mips/r4kcache.h b/include/asm-mips/r4kcache.h
index cc53196efa40..9632c27dad15 100644
--- a/include/asm-mips/r4kcache.h
+++ b/include/asm-mips/r4kcache.h
@@ -14,6 +14,7 @@
14 14
15#include <asm/asm.h> 15#include <asm/asm.h>
16#include <asm/cacheops.h> 16#include <asm/cacheops.h>
17#include <asm/cpu-features.h>
17 18
18/* 19/*
19 * This macro return a properly sign-extended address suitable as base address 20 * This macro return a properly sign-extended address suitable as base address
@@ -78,22 +79,25 @@ static inline void flush_scache_line(unsigned long addr)
78 cache_op(Hit_Writeback_Inv_SD, addr); 79 cache_op(Hit_Writeback_Inv_SD, addr);
79} 80}
80 81
82#define protected_cache_op(op,addr) \
83 __asm__ __volatile__( \
84 " .set push \n" \
85 " .set noreorder \n" \
86 " .set mips3 \n" \
87 "1: cache %0, (%1) \n" \
88 "2: .set pop \n" \
89 " .section __ex_table,\"a\" \n" \
90 " "STR(PTR)" 1b, 2b \n" \
91 " .previous" \
92 : \
93 : "i" (op), "r" (addr))
94
81/* 95/*
82 * The next two are for badland addresses like signal trampolines. 96 * The next two are for badland addresses like signal trampolines.
83 */ 97 */
84static inline void protected_flush_icache_line(unsigned long addr) 98static inline void protected_flush_icache_line(unsigned long addr)
85{ 99{
86 __asm__ __volatile__( 100 protected_cache_op(Hit_Invalidate_I, addr);
87 " .set push \n"
88 " .set noreorder \n"
89 " .set mips3 \n"
90 "1: cache %0, (%1) \n"
91 "2: .set pop \n"
92 " .section __ex_table,\"a\" \n"
93 " "STR(PTR)" 1b, 2b \n"
94 " .previous"
95 :
96 : "i" (Hit_Invalidate_I), "r" (addr));
97} 101}
98 102
99/* 103/*
@@ -104,32 +108,12 @@ static inline void protected_flush_icache_line(unsigned long addr)
104 */ 108 */
105static inline void protected_writeback_dcache_line(unsigned long addr) 109static inline void protected_writeback_dcache_line(unsigned long addr)
106{ 110{
107 __asm__ __volatile__( 111 protected_cache_op(Hit_Writeback_Inv_D, addr);
108 " .set push \n"
109 " .set noreorder \n"
110 " .set mips3 \n"
111 "1: cache %0, (%1) \n"
112 "2: .set pop \n"
113 " .section __ex_table,\"a\" \n"
114 " "STR(PTR)" 1b, 2b \n"
115 " .previous"
116 :
117 : "i" (Hit_Writeback_Inv_D), "r" (addr));
118} 112}
119 113
120static inline void protected_writeback_scache_line(unsigned long addr) 114static inline void protected_writeback_scache_line(unsigned long addr)
121{ 115{
122 __asm__ __volatile__( 116 protected_cache_op(Hit_Writeback_Inv_SD, addr);
123 " .set push \n"
124 " .set noreorder \n"
125 " .set mips3 \n"
126 "1: cache %0, (%1) \n"
127 "2: .set pop \n"
128 " .section __ex_table,\"a\" \n"
129 " "STR(PTR)" 1b, 2b \n"
130 " .previous"
131 :
132 : "i" (Hit_Writeback_Inv_SD), "r" (addr));
133} 117}
134 118
135/* 119/*
@@ -295,4 +279,28 @@ __BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 64)
295__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 64) 279__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 64)
296__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 128) 280__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 128)
297 281
282/* build blast_xxx_range, protected_blast_xxx_range */
283#define __BUILD_BLAST_CACHE_RANGE(pfx, desc, hitop, prot) \
284static inline void prot##blast_##pfx##cache##_range(unsigned long start, \
285 unsigned long end) \
286{ \
287 unsigned long lsize = cpu_##desc##_line_size(); \
288 unsigned long addr = start & ~(lsize - 1); \
289 unsigned long aend = (end - 1) & ~(lsize - 1); \
290 while (1) { \
291 prot##cache_op(hitop, addr); \
292 if (addr == aend) \
293 break; \
294 addr += lsize; \
295 } \
296}
297
298__BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, protected_)
299__BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, protected_)
300__BUILD_BLAST_CACHE_RANGE(i, icache, Hit_Invalidate_I, protected_)
301__BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, )
302__BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, )
303/* blast_inv_dcache_range */
304__BUILD_BLAST_CACHE_RANGE(inv_d, dcache, Hit_Invalidate_D, )
305
298#endif /* _ASM_R4KCACHE_H */ 306#endif /* _ASM_R4KCACHE_H */