13 #include <linux/kernel.h>
14 #include <linux/sched.h>
19 #include <asm/pgtable.h>
20 #include <asm/mmu_context.h>
23 #include <asm/bootinfo.h>
26 static unsigned long icache_size, dcache_size;
27 static unsigned long icache_lsize, dcache_lsize;
32 volatile unsigned long *
p;
34 p = (
volatile unsigned long *)
KSEG0;
45 if (dummy != 0xa5a55a5a || (status &
ST0_CM)) {
48 for (size = 128; size <= 0x40000; size <<= 1)
52 (size <= 0x40000) && (*(p + size) == 0);
61 return size *
sizeof(*p);
67 volatile unsigned long *
p;
69 p = (
volatile unsigned long *)
KSEG0;
76 for (i = 0; i < 128; i++)
78 *(
volatile unsigned char *)p = 0;
79 for (lsize = 1; lsize < 128; lsize <<= 1) {
85 for (i = 0; i < 128; i += lsize)
86 *(
volatile unsigned char *)(p +
i) = 0;
90 return lsize *
sizeof(*p);
93 static void __cpuinit r3k_probe_cache(
void)
104 static void r3k_flush_icache_range(
unsigned long start,
unsigned long end)
107 volatile unsigned char *
p;
110 if (size > icache_size ||
KSEGX(start) !=
KSEG0) {
121 for (i = 0; i <
size; i += 0x080) {
122 asm(
"sb\t$0, 0x000(%0)\n\t"
123 "sb\t$0, 0x004(%0)\n\t"
124 "sb\t$0, 0x008(%0)\n\t"
125 "sb\t$0, 0x00c(%0)\n\t"
126 "sb\t$0, 0x010(%0)\n\t"
127 "sb\t$0, 0x014(%0)\n\t"
128 "sb\t$0, 0x018(%0)\n\t"
129 "sb\t$0, 0x01c(%0)\n\t"
130 "sb\t$0, 0x020(%0)\n\t"
131 "sb\t$0, 0x024(%0)\n\t"
132 "sb\t$0, 0x028(%0)\n\t"
133 "sb\t$0, 0x02c(%0)\n\t"
134 "sb\t$0, 0x030(%0)\n\t"
135 "sb\t$0, 0x034(%0)\n\t"
136 "sb\t$0, 0x038(%0)\n\t"
137 "sb\t$0, 0x03c(%0)\n\t"
138 "sb\t$0, 0x040(%0)\n\t"
139 "sb\t$0, 0x044(%0)\n\t"
140 "sb\t$0, 0x048(%0)\n\t"
141 "sb\t$0, 0x04c(%0)\n\t"
142 "sb\t$0, 0x050(%0)\n\t"
143 "sb\t$0, 0x054(%0)\n\t"
144 "sb\t$0, 0x058(%0)\n\t"
145 "sb\t$0, 0x05c(%0)\n\t"
146 "sb\t$0, 0x060(%0)\n\t"
147 "sb\t$0, 0x064(%0)\n\t"
148 "sb\t$0, 0x068(%0)\n\t"
149 "sb\t$0, 0x06c(%0)\n\t"
150 "sb\t$0, 0x070(%0)\n\t"
151 "sb\t$0, 0x074(%0)\n\t"
152 "sb\t$0, 0x078(%0)\n\t"
153 "sb\t$0, 0x07c(%0)\n\t"
161 static void r3k_flush_dcache_range(
unsigned long start,
unsigned long end)
164 volatile unsigned char *
p;
167 if (size > dcache_size ||
KSEGX(start) !=
KSEG0) {
178 for (i = 0; i <
size; i += 0x080) {
179 asm(
"sb\t$0, 0x000(%0)\n\t"
180 "sb\t$0, 0x004(%0)\n\t"
181 "sb\t$0, 0x008(%0)\n\t"
182 "sb\t$0, 0x00c(%0)\n\t"
183 "sb\t$0, 0x010(%0)\n\t"
184 "sb\t$0, 0x014(%0)\n\t"
185 "sb\t$0, 0x018(%0)\n\t"
186 "sb\t$0, 0x01c(%0)\n\t"
187 "sb\t$0, 0x020(%0)\n\t"
188 "sb\t$0, 0x024(%0)\n\t"
189 "sb\t$0, 0x028(%0)\n\t"
190 "sb\t$0, 0x02c(%0)\n\t"
191 "sb\t$0, 0x030(%0)\n\t"
192 "sb\t$0, 0x034(%0)\n\t"
193 "sb\t$0, 0x038(%0)\n\t"
194 "sb\t$0, 0x03c(%0)\n\t"
195 "sb\t$0, 0x040(%0)\n\t"
196 "sb\t$0, 0x044(%0)\n\t"
197 "sb\t$0, 0x048(%0)\n\t"
198 "sb\t$0, 0x04c(%0)\n\t"
199 "sb\t$0, 0x050(%0)\n\t"
200 "sb\t$0, 0x054(%0)\n\t"
201 "sb\t$0, 0x058(%0)\n\t"
202 "sb\t$0, 0x05c(%0)\n\t"
203 "sb\t$0, 0x060(%0)\n\t"
204 "sb\t$0, 0x064(%0)\n\t"
205 "sb\t$0, 0x068(%0)\n\t"
206 "sb\t$0, 0x06c(%0)\n\t"
207 "sb\t$0, 0x070(%0)\n\t"
208 "sb\t$0, 0x074(%0)\n\t"
209 "sb\t$0, 0x078(%0)\n\t"
210 "sb\t$0, 0x07c(%0)\n\t"
218 static inline void r3k_flush_cache_all(
void)
222 static inline void r3k___flush_cache_all(
void)
224 r3k_flush_dcache_range(
KSEG0,
KSEG0 + dcache_size);
225 r3k_flush_icache_range(
KSEG0,
KSEG0 + icache_size);
228 static void r3k_flush_cache_mm(
struct mm_struct *mm)
233 unsigned long start,
unsigned long end)
238 unsigned long addr,
unsigned long pfn)
264 r3k_flush_dcache_range(kaddr, kaddr +
PAGE_SIZE);
266 r3k_flush_icache_range(kaddr, kaddr +
PAGE_SIZE);
269 static void local_r3k_flush_data_cache_page(
void *addr)
273 static void r3k_flush_data_cache_page(
unsigned long addr)
277 static void r3k_flush_cache_sigtramp(
unsigned long addr)
281 pr_debug(
"csigtramp[%08lx]\n", addr);
288 asm(
"lw\t$0, 0x000(%0)\n\t"
289 "lw\t$0, 0x004(%0)\n\t"
294 asm(
"sb\t$0, 0x000(%0)\n\t"
295 "sb\t$0, 0x004(%0)\n\t"
301 static void r3k_flush_kernel_vmap_range(
unsigned long vaddr,
int size)
306 static void r3k_dma_cache_wback_inv(
unsigned long start,
unsigned long size)
312 r3k_flush_dcache_range(start, start + size);
336 _dma_cache_wback_inv = r3k_dma_cache_wback_inv;
337 _dma_cache_wback = r3k_dma_cache_wback_inv;
338 _dma_cache_inv = r3k_dma_cache_wback_inv;
340 printk(
"Primary instruction cache %ldkB, linesize %ld bytes.\n",
341 icache_size >> 10, icache_lsize);
342 printk(
"Primary data cache %ldkB, linesize %ld bytes.\n",
343 dcache_size >> 10, dcache_lsize);