diff options
author | Atsushi Nemoto <anemo@mba.ocn.ne.jp> | 2006-02-09 10:39:06 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2006-02-14 14:13:24 -0500 |
commit | 41700e73995d6c814932cb55e12525bd34be1ca5 (patch) | |
tree | 559759cbda13bb50720cfd0e317fa65a467d59fa /include/asm-mips/r4kcache.h | |
parent | 63077519899721120b61d663a68adced068a459d (diff) |
[MIPS] Add protected_blast_icache_range, blast_icache_range, etc.
Add blast_xxx_range(), protected_blast_xxx_range() etc. for common
use. They are built by __BUILD_BLAST_CACHE_RANGE().
Use protected_cache_op() macro for various protected_ routines.
Output code should be logically same.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'include/asm-mips/r4kcache.h')
-rw-r--r-- | include/asm-mips/r4kcache.h | 74 |
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 | */ |
84 | static inline void protected_flush_icache_line(unsigned long addr) | 98 | static 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 | */ |
105 | static inline void protected_writeback_dcache_line(unsigned long addr) | 109 | static 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 | ||
120 | static inline void protected_writeback_scache_line(unsigned long addr) | 114 | static 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) \ | ||
284 | static 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 */ |