c-r4k.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
  7. * Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Ralf Baechle (ralf@gnu.org)
  8. * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
  9. */
  10. #include <linux/config.h>
  11. #include <linux/init.h>
  12. #include <linux/kernel.h>
  13. #include <linux/sched.h>
  14. #include <linux/mm.h>
  15. #include <linux/bitops.h>
  16. #include <asm/bcache.h>
  17. #include <asm/bootinfo.h>
  18. #include <asm/cache.h>
  19. #include <asm/cacheops.h>
  20. #include <asm/cpu.h>
  21. #include <asm/cpu-features.h>
  22. #include <asm/io.h>
  23. #include <asm/page.h>
  24. #include <asm/pgtable.h>
  25. #include <asm/r4kcache.h>
  26. #include <asm/system.h>
  27. #include <asm/mmu_context.h>
  28. #include <asm/war.h>
  29. #include <asm/cacheflush.h> /* for run_uncached() */
  30. /*
  31. * Special Variant of smp_call_function for use by cache functions:
  32. *
  33. * o No return value
  34. * o collapses to normal function call on UP kernels
  35. * o collapses to normal function call on systems with a single shared
  36. * primary cache.
  37. */
  38. static inline void r4k_on_each_cpu(void (*func) (void *info), void *info,
  39. int retry, int wait)
  40. {
  41. preempt_disable();
  42. #if !defined(CONFIG_MIPS_MT_SMP) && !defined(CONFIG_MIPS_MT_SMTC)
  43. smp_call_function(func, info, retry, wait);
  44. #endif
  45. func(info);
  46. preempt_enable();
  47. }
  48. /*
  49. * Must die.
  50. */
  51. static unsigned long icache_size __read_mostly;
  52. static unsigned long dcache_size __read_mostly;
  53. static unsigned long scache_size __read_mostly;
  54. /*
  55. * Dummy cache handling routines for machines without boardcaches
  56. */
  57. static void no_sc_noop(void) {}
  58. static struct bcache_ops no_sc_ops = {
  59. .bc_enable = (void *)no_sc_noop,
  60. .bc_disable = (void *)no_sc_noop,
  61. .bc_wback_inv = (void *)no_sc_noop,
  62. .bc_inv = (void *)no_sc_noop
  63. };
  64. struct bcache_ops *bcops = &no_sc_ops;
  65. #define cpu_is_r4600_v1_x() ((read_c0_prid() & 0xfffffff0) == 0x00002010)
  66. #define cpu_is_r4600_v2_x() ((read_c0_prid() & 0xfffffff0) == 0x00002020)
  67. #define R4600_HIT_CACHEOP_WAR_IMPL \
  68. do { \
  69. if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x()) \
  70. *(volatile unsigned long *)CKSEG1; \
  71. if (R4600_V1_HIT_CACHEOP_WAR) \
  72. __asm__ __volatile__("nop;nop;nop;nop"); \
  73. } while (0)
  74. static void (*r4k_blast_dcache_page)(unsigned long addr);
  75. static inline void r4k_blast_dcache_page_dc32(unsigned long addr)
  76. {
  77. R4600_HIT_CACHEOP_WAR_IMPL;
  78. blast_dcache32_page(addr);
  79. }
  80. static inline void r4k_blast_dcache_page_setup(void)
  81. {
  82. unsigned long dc_lsize = cpu_dcache_line_size();
  83. if (dc_lsize == 16)
  84. r4k_blast_dcache_page = blast_dcache16_page;
  85. else if (dc_lsize == 32)
  86. r4k_blast_dcache_page = r4k_blast_dcache_page_dc32;
  87. }
  88. static void (* r4k_blast_dcache_page_indexed)(unsigned long addr);
  89. static inline void r4k_blast_dcache_page_indexed_setup(void)
  90. {
  91. unsigned long dc_lsize = cpu_dcache_line_size();
  92. if (dc_lsize == 16)
  93. r4k_blast_dcache_page_indexed = blast_dcache16_page_indexed;
  94. else if (dc_lsize == 32)
  95. r4k_blast_dcache_page_indexed = blast_dcache32_page_indexed;
  96. }
  97. static void (* r4k_blast_dcache)(void);
  98. static inline void r4k_blast_dcache_setup(void)
  99. {
  100. unsigned long dc_lsize = cpu_dcache_line_size();
  101. if (dc_lsize == 16)
  102. r4k_blast_dcache = blast_dcache16;
  103. else if (dc_lsize == 32)
  104. r4k_blast_dcache = blast_dcache32;
  105. }
  106. /* force code alignment (used for TX49XX_ICACHE_INDEX_INV_WAR) */
  107. #define JUMP_TO_ALIGN(order) \
  108. __asm__ __volatile__( \
  109. "b\t1f\n\t" \
  110. ".align\t" #order "\n\t" \
  111. "1:\n\t" \
  112. )
  113. #define CACHE32_UNROLL32_ALIGN JUMP_TO_ALIGN(10) /* 32 * 32 = 1024 */
  114. #define CACHE32_UNROLL32_ALIGN2 JUMP_TO_ALIGN(11)
  115. static inline void blast_r4600_v1_icache32(void)
  116. {
  117. unsigned long flags;
  118. local_irq_save(flags);
  119. blast_icache32();
  120. local_irq_restore(flags);
  121. }
  122. static inline void tx49_blast_icache32(void)
  123. {
  124. unsigned long start = INDEX_BASE;
  125. unsigned long end = start + current_cpu_data.icache.waysize;
  126. unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit;
  127. unsigned long ws_end = current_cpu_data.icache.ways <<
  128. current_cpu_data.icache.waybit;
  129. unsigned long ws, addr;
  130. CACHE32_UNROLL32_ALIGN2;
  131. /* I'm in even chunk. blast odd chunks */
  132. for (ws = 0; ws < ws_end; ws += ws_inc)
  133. for (addr = start + 0x400; addr < end; addr += 0x400 * 2)
  134. cache32_unroll32(addr|ws,Index_Invalidate_I);
  135. CACHE32_UNROLL32_ALIGN;
  136. /* I'm in odd chunk. blast even chunks */
  137. for (ws = 0; ws < ws_end; ws += ws_inc)
  138. for (addr = start; addr < end; addr += 0x400 * 2)
  139. cache32_unroll32(addr|ws,Index_Invalidate_I);
  140. }
  141. static inline void blast_icache32_r4600_v1_page_indexed(unsigned long page)
  142. {
  143. unsigned long flags;
  144. local_irq_save(flags);
  145. blast_icache32_page_indexed(page);
  146. local_irq_restore(flags);
  147. }
  148. static inline void tx49_blast_icache32_page_indexed(unsigned long page)
  149. {
  150. unsigned long indexmask = current_cpu_data.icache.waysize - 1;
  151. unsigned long start = INDEX_BASE + (page & indexmask);
  152. unsigned long end = start + PAGE_SIZE;
  153. unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit;
  154. unsigned long ws_end = current_cpu_data.icache.ways <<
  155. current_cpu_data.icache.waybit;
  156. unsigned long ws, addr;
  157. CACHE32_UNROLL32_ALIGN2;
  158. /* I'm in even chunk. blast odd chunks */
  159. for (ws = 0; ws < ws_end; ws += ws_inc)
  160. for (addr = start + 0x400; addr < end; addr += 0x400 * 2)
  161. cache32_unroll32(addr|ws,Index_Invalidate_I);
  162. CACHE32_UNROLL32_ALIGN;
  163. /* I'm in odd chunk. blast even chunks */
  164. for (ws = 0; ws < ws_end; ws += ws_inc)
  165. for (addr = start; addr < end; addr += 0x400 * 2)
  166. cache32_unroll32(addr|ws,Index_Invalidate_I);
  167. }
  168. static void (* r4k_blast_icache_page)(unsigned long addr);
  169. static inline void r4k_blast_icache_page_setup(void)
  170. {
  171. unsigned long ic_lsize = cpu_icache_line_size();
  172. if (ic_lsize == 16)
  173. r4k_blast_icache_page = blast_icache16_page;
  174. else if (ic_lsize == 32)
  175. r4k_blast_icache_page = blast_icache32_page;
  176. else if (ic_lsize == 64)
  177. r4k_blast_icache_page = blast_icache64_page;
  178. }
  179. static void (* r4k_blast_icache_page_indexed)(unsigned long addr);
  180. static inline void r4k_blast_icache_page_indexed_setup(void)
  181. {
  182. unsigned long ic_lsize = cpu_icache_line_size();
  183. if (ic_lsize == 16)
  184. r4k_blast_icache_page_indexed = blast_icache16_page_indexed;
  185. else if (ic_lsize == 32) {
  186. if (R4600_V1_INDEX_ICACHEOP_WAR && cpu_is_r4600_v1_x())
  187. r4k_blast_icache_page_indexed =
  188. blast_icache32_r4600_v1_page_indexed;
  189. else if (TX49XX_ICACHE_INDEX_INV_WAR)
  190. r4k_blast_icache_page_indexed =
  191. tx49_blast_icache32_page_indexed;
  192. else
  193. r4k_blast_icache_page_indexed =
  194. blast_icache32_page_indexed;
  195. } else if (ic_lsize == 64)
  196. r4k_blast_icache_page_indexed = blast_icache64_page_indexed;
  197. }
  198. static void (* r4k_blast_icache)(void);
  199. static inline void r4k_blast_icache_setup(void)
  200. {
  201. unsigned long ic_lsize = cpu_icache_line_size();
  202. if (ic_lsize == 16)
  203. r4k_blast_icache = blast_icache16;
  204. else if (ic_lsize == 32) {
  205. if (R4600_V1_INDEX_ICACHEOP_WAR && cpu_is_r4600_v1_x())
  206. r4k_blast_icache = blast_r4600_v1_icache32;
  207. else if (TX49XX_ICACHE_INDEX_INV_WAR)
  208. r4k_blast_icache = tx49_blast_icache32;
  209. else
  210. r4k_blast_icache = blast_icache32;
  211. } else if (ic_lsize == 64)
  212. r4k_blast_icache = blast_icache64;
  213. }
  214. static void (* r4k_blast_scache_page)(unsigned long addr);
  215. static inline void r4k_blast_scache_page_setup(void)
  216. {
  217. unsigned long sc_lsize = cpu_scache_line_size();
  218. if (scache_size == 0)
  219. r4k_blast_scache_page = (void *)no_sc_noop;
  220. else if (sc_lsize == 16)
  221. r4k_blast_scache_page = blast_scache16_page;
  222. else if (sc_lsize == 32)
  223. r4k_blast_scache_page = blast_scache32_page;
  224. else if (sc_lsize == 64)
  225. r4k_blast_scache_page = blast_scache64_page;
  226. else if (sc_lsize == 128)
  227. r4k_blast_scache_page = blast_scache128_page;
  228. }
  229. static void (* r4k_blast_scache_page_indexed)(unsigned long addr);
  230. static inline void r4k_blast_scache_page_indexed_setup(void)
  231. {
  232. unsigned long sc_lsize = cpu_scache_line_size();
  233. if (scache_size == 0)
  234. r4k_blast_scache_page_indexed = (void *)no_sc_noop;
  235. else if (sc_lsize == 16)
  236. r4k_blast_scache_page_indexed = blast_scache16_page_indexed;
  237. else if (sc_lsize == 32)
  238. r4k_blast_scache_page_indexed = blast_scache32_page_indexed;
  239. else if (sc_lsize == 64)
  240. r4k_blast_scache_page_indexed = blast_scache64_page_indexed;
  241. else if (sc_lsize == 128)
  242. r4k_blast_scache_page_indexed = blast_scache128_page_indexed;
  243. }
  244. static void (* r4k_blast_scache)(void);
  245. static inline void r4k_blast_scache_setup(void)
  246. {
  247. unsigned long sc_lsize = cpu_scache_line_size();
  248. if (scache_size == 0)
  249. r4k_blast_scache = (void *)no_sc_noop;
  250. else if (sc_lsize == 16)
  251. r4k_blast_scache = blast_scache16;
  252. else if (sc_lsize == 32)
  253. r4k_blast_scache = blast_scache32;
  254. else if (sc_lsize == 64)
  255. r4k_blast_scache = blast_scache64;
  256. else if (sc_lsize == 128)
  257. r4k_blast_scache = blast_scache128;
  258. }
  259. /*
  260. * This is former mm's flush_cache_all() which really should be
  261. * flush_cache_vunmap these days ...
  262. */
  263. static inline void local_r4k_flush_cache_all(void * args)
  264. {
  265. r4k_blast_dcache();
  266. r4k_blast_icache();
  267. }
  268. static void r4k_flush_cache_all(void)
  269. {
  270. if (!cpu_has_dc_aliases)
  271. return;
  272. r4k_on_each_cpu(local_r4k_flush_cache_all, NULL, 1, 1);
  273. }
  274. static inline void local_r4k___flush_cache_all(void * args)
  275. {
  276. r4k_blast_dcache();
  277. r4k_blast_icache();
  278. switch (current_cpu_data.cputype) {
  279. case CPU_R4000SC:
  280. case CPU_R4000MC:
  281. case CPU_R4400SC:
  282. case CPU_R4400MC:
  283. case CPU_R10000:
  284. case CPU_R12000:
  285. r4k_blast_scache();
  286. }
  287. }
  288. static void r4k___flush_cache_all(void)
  289. {
  290. r4k_on_each_cpu(local_r4k___flush_cache_all, NULL, 1, 1);
  291. }
  292. static inline void local_r4k_flush_cache_range(void * args)
  293. {
  294. struct vm_area_struct *vma = args;
  295. int exec;
  296. if (!(cpu_context(smp_processor_id(), vma->vm_mm)))
  297. return;
  298. exec = vma->vm_flags & VM_EXEC;
  299. if (cpu_has_dc_aliases || exec)
  300. r4k_blast_dcache();
  301. if (exec)
  302. r4k_blast_icache();
  303. }
  304. static void r4k_flush_cache_range(struct vm_area_struct *vma,
  305. unsigned long start, unsigned long end)
  306. {
  307. r4k_on_each_cpu(local_r4k_flush_cache_range, vma, 1, 1);
  308. }
  309. static inline void local_r4k_flush_cache_mm(void * args)
  310. {
  311. struct mm_struct *mm = args;
  312. if (!cpu_context(smp_processor_id(), mm))
  313. return;
  314. r4k_blast_dcache();
  315. r4k_blast_icache();
  316. /*
  317. * Kludge alert. For obscure reasons R4000SC and R4400SC go nuts if we
  318. * only flush the primary caches but R10000 and R12000 behave sane ...
  319. */
  320. if (current_cpu_data.cputype == CPU_R4000SC ||
  321. current_cpu_data.cputype == CPU_R4000MC ||
  322. current_cpu_data.cputype == CPU_R4400SC ||
  323. current_cpu_data.cputype == CPU_R4400MC)
  324. r4k_blast_scache();
  325. }
  326. static void r4k_flush_cache_mm(struct mm_struct *mm)
  327. {
  328. if (!cpu_has_dc_aliases)
  329. return;
  330. r4k_on_each_cpu(local_r4k_flush_cache_mm, mm, 1, 1);
  331. }
  332. struct flush_cache_page_args {
  333. struct vm_area_struct *vma;
  334. unsigned long addr;
  335. unsigned long pfn;
  336. };
  337. static inline void local_r4k_flush_cache_page(void *args)
  338. {
  339. struct flush_cache_page_args *fcp_args = args;
  340. struct vm_area_struct *vma = fcp_args->vma;
  341. unsigned long addr = fcp_args->addr;
  342. unsigned long paddr = fcp_args->pfn << PAGE_SHIFT;
  343. int exec = vma->vm_flags & VM_EXEC;
  344. struct mm_struct *mm = vma->vm_mm;
  345. pgd_t *pgdp;
  346. pud_t *pudp;
  347. pmd_t *pmdp;
  348. pte_t *ptep;
  349. /*
  350. * If ownes no valid ASID yet, cannot possibly have gotten
  351. * this page into the cache.
  352. */
  353. if (cpu_context(smp_processor_id(), mm) == 0)
  354. return;
  355. addr &= PAGE_MASK;
  356. pgdp = pgd_offset(mm, addr);
  357. pudp = pud_offset(pgdp, addr);
  358. pmdp = pmd_offset(pudp, addr);
  359. ptep = pte_offset(pmdp, addr);
  360. /*
  361. * If the page isn't marked valid, the page cannot possibly be
  362. * in the cache.
  363. */
  364. if (!(pte_val(*ptep) & _PAGE_PRESENT))
  365. return;
  366. /*
  367. * Doing flushes for another ASID than the current one is
  368. * too difficult since stupid R4k caches do a TLB translation
  369. * for every cache flush operation. So we do indexed flushes
  370. * in that case, which doesn't overly flush the cache too much.
  371. */
  372. if ((mm == current->active_mm) && (pte_val(*ptep) & _PAGE_VALID)) {
  373. if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) {
  374. r4k_blast_dcache_page(addr);
  375. if (exec && !cpu_icache_snoops_remote_store)
  376. r4k_blast_scache_page(addr);
  377. }
  378. if (exec)
  379. r4k_blast_icache_page(addr);
  380. return;
  381. }
  382. /*
  383. * Do indexed flush, too much work to get the (possible) TLB refills
  384. * to work correctly.
  385. */
  386. if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) {
  387. r4k_blast_dcache_page_indexed(cpu_has_pindexed_dcache ?
  388. paddr : addr);
  389. if (exec && !cpu_icache_snoops_remote_store) {
  390. r4k_blast_scache_page_indexed(paddr);
  391. }
  392. }
  393. if (exec) {
  394. if (cpu_has_vtag_icache) {
  395. int cpu = smp_processor_id();
  396. if (cpu_context(cpu, mm) != 0)
  397. drop_mmu_context(mm, cpu);
  398. } else
  399. r4k_blast_icache_page_indexed(addr);
  400. }
  401. }
  402. static void r4k_flush_cache_page(struct vm_area_struct *vma,
  403. unsigned long addr, unsigned long pfn)
  404. {
  405. struct flush_cache_page_args args;
  406. args.vma = vma;
  407. args.addr = addr;
  408. args.pfn = pfn;
  409. r4k_on_each_cpu(local_r4k_flush_cache_page, &args, 1, 1);
  410. }
  411. static inline void local_r4k_flush_data_cache_page(void * addr)
  412. {
  413. r4k_blast_dcache_page((unsigned long) addr);
  414. }
  415. static void r4k_flush_data_cache_page(unsigned long addr)
  416. {
  417. r4k_on_each_cpu(local_r4k_flush_data_cache_page, (void *) addr, 1, 1);
  418. }
  419. struct flush_icache_range_args {
  420. unsigned long start;
  421. unsigned long end;
  422. };
  423. static inline void local_r4k_flush_icache_range(void *args)
  424. {
  425. struct flush_icache_range_args *fir_args = args;
  426. unsigned long start = fir_args->start;
  427. unsigned long end = fir_args->end;
  428. if (!cpu_has_ic_fills_f_dc) {
  429. if (end - start > dcache_size) {
  430. r4k_blast_dcache();
  431. } else {
  432. R4600_HIT_CACHEOP_WAR_IMPL;
  433. protected_blast_dcache_range(start, end);
  434. }
  435. if (!cpu_icache_snoops_remote_store && scache_size) {
  436. if (end - start > scache_size)
  437. r4k_blast_scache();
  438. else
  439. protected_blast_scache_range(start, end);
  440. }
  441. }
  442. if (end - start > icache_size)
  443. r4k_blast_icache();
  444. else
  445. protected_blast_icache_range(start, end);
  446. }
  447. static void r4k_flush_icache_range(unsigned long start, unsigned long end)
  448. {
  449. struct flush_icache_range_args args;
  450. args.start = start;
  451. args.end = end;
  452. r4k_on_each_cpu(local_r4k_flush_icache_range, &args, 1, 1);
  453. instruction_hazard();
  454. }
  455. /*
  456. * Ok, this seriously sucks. We use them to flush a user page but don't
  457. * know the virtual address, so we have to blast away the whole icache
  458. * which is significantly more expensive than the real thing. Otoh we at
  459. * least know the kernel address of the page so we can flush it
  460. * selectivly.
  461. */
  462. struct flush_icache_page_args {
  463. struct vm_area_struct *vma;
  464. struct page *page;
  465. };
  466. static inline void local_r4k_flush_icache_page(void *args)
  467. {
  468. struct flush_icache_page_args *fip_args = args;
  469. struct vm_area_struct *vma = fip_args->vma;
  470. struct page *page = fip_args->page;
  471. /*
  472. * Tricky ... Because we don't know the virtual address we've got the
  473. * choice of either invalidating the entire primary and secondary
  474. * caches or invalidating the secondary caches also. With the subset
  475. * enforcment on R4000SC, R4400SC, R10000 and R12000 invalidating the
  476. * secondary cache will result in any entries in the primary caches
  477. * also getting invalidated which hopefully is a bit more economical.
  478. */
  479. if (cpu_has_subset_pcaches) {
  480. unsigned long addr = (unsigned long) page_address(page);
  481. r4k_blast_scache_page(addr);
  482. ClearPageDcacheDirty(page);
  483. return;
  484. }
  485. if (!cpu_has_ic_fills_f_dc) {
  486. unsigned long addr = (unsigned long) page_address(page);
  487. r4k_blast_dcache_page(addr);
  488. if (!cpu_icache_snoops_remote_store)
  489. r4k_blast_scache_page(addr);
  490. ClearPageDcacheDirty(page);
  491. }
  492. /*
  493. * We're not sure of the virtual address(es) involved here, so
  494. * we have to flush the entire I-cache.
  495. */
  496. if (cpu_has_vtag_icache) {
  497. int cpu = smp_processor_id();
  498. if (cpu_context(cpu, vma->vm_mm) != 0)
  499. drop_mmu_context(vma->vm_mm, cpu);
  500. } else
  501. r4k_blast_icache();
  502. }
  503. static void r4k_flush_icache_page(struct vm_area_struct *vma,
  504. struct page *page)
  505. {
  506. struct flush_icache_page_args args;
  507. /*
  508. * If there's no context yet, or the page isn't executable, no I-cache
  509. * flush is needed.
  510. */
  511. if (!(vma->vm_flags & VM_EXEC))
  512. return;
  513. args.vma = vma;
  514. args.page = page;
  515. r4k_on_each_cpu(local_r4k_flush_icache_page, &args, 1, 1);
  516. }
  517. #ifdef CONFIG_DMA_NONCOHERENT
  518. static void r4k_dma_cache_wback_inv(unsigned long addr, unsigned long size)
  519. {
  520. /* Catch bad driver code */
  521. BUG_ON(size == 0);
  522. if (cpu_has_subset_pcaches) {
  523. if (size >= scache_size)
  524. r4k_blast_scache();
  525. else
  526. blast_scache_range(addr, addr + size);
  527. return;
  528. }
  529. /*
  530. * Either no secondary cache or the available caches don't have the
  531. * subset property so we have to flush the primary caches
  532. * explicitly
  533. */
  534. if (size >= dcache_size) {
  535. r4k_blast_dcache();
  536. } else {
  537. R4600_HIT_CACHEOP_WAR_IMPL;
  538. blast_dcache_range(addr, addr + size);
  539. }
  540. bc_wback_inv(addr, size);
  541. }
  542. static void r4k_dma_cache_inv(unsigned long addr, unsigned long size)
  543. {
  544. /* Catch bad driver code */
  545. BUG_ON(size == 0);
  546. if (cpu_has_subset_pcaches) {
  547. if (size >= scache_size)
  548. r4k_blast_scache();
  549. else
  550. blast_scache_range(addr, addr + size);
  551. return;
  552. }
  553. if (size >= dcache_size) {
  554. r4k_blast_dcache();
  555. } else {
  556. R4600_HIT_CACHEOP_WAR_IMPL;
  557. blast_dcache_range(addr, addr + size);
  558. }
  559. bc_inv(addr, size);
  560. }
  561. #endif /* CONFIG_DMA_NONCOHERENT */
  562. /*
  563. * While we're protected against bad userland addresses we don't care
  564. * very much about what happens in that case. Usually a segmentation
  565. * fault will dump the process later on anyway ...
  566. */
  567. static void local_r4k_flush_cache_sigtramp(void * arg)
  568. {
  569. unsigned long ic_lsize = cpu_icache_line_size();
  570. unsigned long dc_lsize = cpu_dcache_line_size();
  571. unsigned long sc_lsize = cpu_scache_line_size();
  572. unsigned long addr = (unsigned long) arg;
  573. R4600_HIT_CACHEOP_WAR_IMPL;
  574. protected_writeback_dcache_line(addr & ~(dc_lsize - 1));
  575. if (!cpu_icache_snoops_remote_store && scache_size)
  576. protected_writeback_scache_line(addr & ~(sc_lsize - 1));
  577. protected_flush_icache_line(addr & ~(ic_lsize - 1));
  578. if (MIPS4K_ICACHE_REFILL_WAR) {
  579. __asm__ __volatile__ (
  580. ".set push\n\t"
  581. ".set noat\n\t"
  582. ".set mips3\n\t"
  583. #ifdef CONFIG_32BIT
  584. "la $at,1f\n\t"
  585. #endif
  586. #ifdef CONFIG_64BIT
  587. "dla $at,1f\n\t"
  588. #endif
  589. "cache %0,($at)\n\t"
  590. "nop; nop; nop\n"
  591. "1:\n\t"
  592. ".set pop"
  593. :
  594. : "i" (Hit_Invalidate_I));
  595. }
  596. if (MIPS_CACHE_SYNC_WAR)
  597. __asm__ __volatile__ ("sync");
  598. }
  599. static void r4k_flush_cache_sigtramp(unsigned long addr)
  600. {
  601. r4k_on_each_cpu(local_r4k_flush_cache_sigtramp, (void *) addr, 1, 1);
  602. }
  603. static void r4k_flush_icache_all(void)
  604. {
  605. if (cpu_has_vtag_icache)
  606. r4k_blast_icache();
  607. }
  608. static inline void rm7k_erratum31(void)
  609. {
  610. const unsigned long ic_lsize = 32;
  611. unsigned long addr;
  612. /* RM7000 erratum #31. The icache is screwed at startup. */
  613. write_c0_taglo(0);
  614. write_c0_taghi(0);
  615. for (addr = INDEX_BASE; addr <= INDEX_BASE + 4096; addr += ic_lsize) {
  616. __asm__ __volatile__ (
  617. ".set push\n\t"
  618. ".set noreorder\n\t"
  619. ".set mips3\n\t"
  620. "cache\t%1, 0(%0)\n\t"
  621. "cache\t%1, 0x1000(%0)\n\t"
  622. "cache\t%1, 0x2000(%0)\n\t"
  623. "cache\t%1, 0x3000(%0)\n\t"
  624. "cache\t%2, 0(%0)\n\t"
  625. "cache\t%2, 0x1000(%0)\n\t"
  626. "cache\t%2, 0x2000(%0)\n\t"
  627. "cache\t%2, 0x3000(%0)\n\t"
  628. "cache\t%1, 0(%0)\n\t"
  629. "cache\t%1, 0x1000(%0)\n\t"
  630. "cache\t%1, 0x2000(%0)\n\t"
  631. "cache\t%1, 0x3000(%0)\n\t"
  632. ".set pop\n"
  633. :
  634. : "r" (addr), "i" (Index_Store_Tag_I), "i" (Fill));
  635. }
  636. }
  637. static char *way_string[] __initdata = { NULL, "direct mapped", "2-way",
  638. "3-way", "4-way", "5-way", "6-way", "7-way", "8-way"
  639. };
  640. static void __init probe_pcache(void)
  641. {
  642. struct cpuinfo_mips *c = &current_cpu_data;
  643. unsigned int config = read_c0_config();
  644. unsigned int prid = read_c0_prid();
  645. unsigned long config1;
  646. unsigned int lsize;
  647. switch (c->cputype) {
  648. case CPU_R4600: /* QED style two way caches? */
  649. case CPU_R4700:
  650. case CPU_R5000:
  651. case CPU_NEVADA:
  652. icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
  653. c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
  654. c->icache.ways = 2;
  655. c->icache.waybit = __ffs(icache_size/2);
  656. dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
  657. c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
  658. c->dcache.ways = 2;
  659. c->dcache.waybit= __ffs(dcache_size/2);
  660. c->options |= MIPS_CPU_CACHE_CDEX_P;
  661. break;
  662. case CPU_R5432:
  663. case CPU_R5500:
  664. icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
  665. c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
  666. c->icache.ways = 2;
  667. c->icache.waybit= 0;
  668. dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
  669. c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
  670. c->dcache.ways = 2;
  671. c->dcache.waybit = 0;
  672. c->options |= MIPS_CPU_CACHE_CDEX_P;
  673. break;
  674. case CPU_TX49XX:
  675. icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
  676. c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
  677. c->icache.ways = 4;
  678. c->icache.waybit= 0;
  679. dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
  680. c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
  681. c->dcache.ways = 4;
  682. c->dcache.waybit = 0;
  683. c->options |= MIPS_CPU_CACHE_CDEX_P;
  684. c->options |= MIPS_CPU_PREFETCH;
  685. break;
  686. case CPU_R4000PC:
  687. case CPU_R4000SC:
  688. case CPU_R4000MC:
  689. case CPU_R4400PC:
  690. case CPU_R4400SC:
  691. case CPU_R4400MC:
  692. case CPU_R4300:
  693. icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
  694. c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
  695. c->icache.ways = 1;
  696. c->icache.waybit = 0; /* doesn't matter */
  697. dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
  698. c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
  699. c->dcache.ways = 1;
  700. c->dcache.waybit = 0; /* does not matter */
  701. c->options |= MIPS_CPU_CACHE_CDEX_P;
  702. break;
  703. case CPU_R10000:
  704. case CPU_R12000:
  705. icache_size = 1 << (12 + ((config & R10K_CONF_IC) >> 29));
  706. c->icache.linesz = 64;
  707. c->icache.ways = 2;
  708. c->icache.waybit = 0;
  709. dcache_size = 1 << (12 + ((config & R10K_CONF_DC) >> 26));
  710. c->dcache.linesz = 32;
  711. c->dcache.ways = 2;
  712. c->dcache.waybit = 0;
  713. c->options |= MIPS_CPU_PREFETCH;
  714. break;
  715. case CPU_VR4133:
  716. write_c0_config(config & ~CONF_EB);
  717. case CPU_VR4131:
  718. /* Workaround for cache instruction bug of VR4131 */
  719. if (c->processor_id == 0x0c80U || c->processor_id == 0x0c81U ||
  720. c->processor_id == 0x0c82U) {
  721. config &= ~0x00000030U;
  722. config |= 0x00410000U;
  723. write_c0_config(config);
  724. }
  725. icache_size = 1 << (10 + ((config & CONF_IC) >> 9));
  726. c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
  727. c->icache.ways = 2;
  728. c->icache.waybit = __ffs(icache_size/2);
  729. dcache_size = 1 << (10 + ((config & CONF_DC) >> 6));
  730. c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
  731. c->dcache.ways = 2;
  732. c->dcache.waybit = __ffs(dcache_size/2);
  733. c->options |= MIPS_CPU_CACHE_CDEX_P;
  734. break;
  735. case CPU_VR41XX:
  736. case CPU_VR4111:
  737. case CPU_VR4121:
  738. case CPU_VR4122:
  739. case CPU_VR4181:
  740. case CPU_VR4181A:
  741. icache_size = 1 << (10 + ((config & CONF_IC) >> 9));
  742. c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
  743. c->icache.ways = 1;
  744. c->icache.waybit = 0; /* doesn't matter */
  745. dcache_size = 1 << (10 + ((config & CONF_DC) >> 6));
  746. c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
  747. c->dcache.ways = 1;
  748. c->dcache.waybit = 0; /* does not matter */
  749. c->options |= MIPS_CPU_CACHE_CDEX_P;
  750. break;
  751. case CPU_RM7000:
  752. rm7k_erratum31();
  753. case CPU_RM9000:
  754. icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
  755. c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
  756. c->icache.ways = 4;
  757. c->icache.waybit = __ffs(icache_size / c->icache.ways);
  758. dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
  759. c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
  760. c->dcache.ways = 4;
  761. c->dcache.waybit = __ffs(dcache_size / c->dcache.ways);
  762. #if !defined(CONFIG_SMP) || !defined(RM9000_CDEX_SMP_WAR)
  763. c->options |= MIPS_CPU_CACHE_CDEX_P;
  764. #endif
  765. c->options |= MIPS_CPU_PREFETCH;
  766. break;
  767. default:
  768. if (!(config & MIPS_CONF_M))
  769. panic("Don't know how to probe P-caches on this cpu.");
  770. /*
  771. * So we seem to be a MIPS32 or MIPS64 CPU
  772. * So let's probe the I-cache ...
  773. */
  774. config1 = read_c0_config1();
  775. if ((lsize = ((config1 >> 19) & 7)))
  776. c->icache.linesz = 2 << lsize;
  777. else
  778. c->icache.linesz = lsize;
  779. c->icache.sets = 64 << ((config1 >> 22) & 7);
  780. c->icache.ways = 1 + ((config1 >> 16) & 7);
  781. icache_size = c->icache.sets *
  782. c->icache.ways *
  783. c->icache.linesz;
  784. c->icache.waybit = __ffs(icache_size/c->icache.ways);
  785. if (config & 0x8) /* VI bit */
  786. c->icache.flags |= MIPS_CACHE_VTAG;
  787. /*
  788. * Now probe the MIPS32 / MIPS64 data cache.
  789. */
  790. c->dcache.flags = 0;
  791. if ((lsize = ((config1 >> 10) & 7)))
  792. c->dcache.linesz = 2 << lsize;
  793. else
  794. c->dcache.linesz= lsize;
  795. c->dcache.sets = 64 << ((config1 >> 13) & 7);
  796. c->dcache.ways = 1 + ((config1 >> 7) & 7);
  797. dcache_size = c->dcache.sets *
  798. c->dcache.ways *
  799. c->dcache.linesz;
  800. c->dcache.waybit = __ffs(dcache_size/c->dcache.ways);
  801. c->options |= MIPS_CPU_PREFETCH;
  802. break;
  803. }
  804. /*
  805. * Processor configuration sanity check for the R4000SC erratum
  806. * #5. With page sizes larger than 32kB there is no possibility
  807. * to get a VCE exception anymore so we don't care about this
  808. * misconfiguration. The case is rather theoretical anyway;
  809. * presumably no vendor is shipping his hardware in the "bad"
  810. * configuration.
  811. */
  812. if ((prid & 0xff00) == PRID_IMP_R4000 && (prid & 0xff) < 0x40 &&
  813. !(config & CONF_SC) && c->icache.linesz != 16 &&
  814. PAGE_SIZE <= 0x8000)
  815. panic("Improper R4000SC processor configuration detected");
  816. /* compute a couple of other cache variables */
  817. c->icache.waysize = icache_size / c->icache.ways;
  818. c->dcache.waysize = dcache_size / c->dcache.ways;
  819. c->icache.sets = icache_size / (c->icache.linesz * c->icache.ways);
  820. c->dcache.sets = dcache_size / (c->dcache.linesz * c->dcache.ways);
  821. /*
  822. * R10000 and R12000 P-caches are odd in a positive way. They're 32kB
  823. * 2-way virtually indexed so normally would suffer from aliases. So
  824. * normally they'd suffer from aliases but magic in the hardware deals
  825. * with that for us so we don't need to take care ourselves.
  826. */
  827. switch (c->cputype) {
  828. case CPU_20KC:
  829. case CPU_25KF:
  830. c->dcache.flags |= MIPS_CACHE_PINDEX;
  831. case CPU_R10000:
  832. case CPU_R12000:
  833. case CPU_SB1:
  834. break;
  835. case CPU_24K:
  836. case CPU_34K:
  837. if (!(read_c0_config7() & (1 << 16)))
  838. default:
  839. if (c->dcache.waysize > PAGE_SIZE)
  840. c->dcache.flags |= MIPS_CACHE_ALIASES;
  841. }
  842. switch (c->cputype) {
  843. case CPU_20KC:
  844. /*
  845. * Some older 20Kc chips doesn't have the 'VI' bit in
  846. * the config register.
  847. */
  848. c->icache.flags |= MIPS_CACHE_VTAG;
  849. break;
  850. case CPU_AU1000:
  851. case CPU_AU1500:
  852. case CPU_AU1100:
  853. case CPU_AU1550:
  854. case CPU_AU1200:
  855. c->icache.flags |= MIPS_CACHE_IC_F_DC;
  856. break;
  857. }
  858. printk("Primary instruction cache %ldkB, %s, %s, linesize %d bytes.\n",
  859. icache_size >> 10,
  860. cpu_has_vtag_icache ? "virtually tagged" : "physically tagged",
  861. way_string[c->icache.ways], c->icache.linesz);
  862. printk("Primary data cache %ldkB, %s, linesize %d bytes.\n",
  863. dcache_size >> 10, way_string[c->dcache.ways], c->dcache.linesz);
  864. }
  865. /*
  866. * If you even _breathe_ on this function, look at the gcc output and make sure
  867. * it does not pop things on and off the stack for the cache sizing loop that
  868. * executes in KSEG1 space or else you will crash and burn badly. You have
  869. * been warned.
  870. */
  871. static int __init probe_scache(void)
  872. {
  873. extern unsigned long stext;
  874. unsigned long flags, addr, begin, end, pow2;
  875. unsigned int config = read_c0_config();
  876. struct cpuinfo_mips *c = &current_cpu_data;
  877. int tmp;
  878. if (config & CONF_SC)
  879. return 0;
  880. begin = (unsigned long) &stext;
  881. begin &= ~((4 * 1024 * 1024) - 1);
  882. end = begin + (4 * 1024 * 1024);
  883. /*
  884. * This is such a bitch, you'd think they would make it easy to do
  885. * this. Away you daemons of stupidity!
  886. */
  887. local_irq_save(flags);
  888. /* Fill each size-multiple cache line with a valid tag. */
  889. pow2 = (64 * 1024);
  890. for (addr = begin; addr < end; addr = (begin + pow2)) {
  891. unsigned long *p = (unsigned long *) addr;
  892. __asm__ __volatile__("nop" : : "r" (*p)); /* whee... */
  893. pow2 <<= 1;
  894. }
  895. /* Load first line with zero (therefore invalid) tag. */
  896. write_c0_taglo(0);
  897. write_c0_taghi(0);
  898. __asm__ __volatile__("nop; nop; nop; nop;"); /* avoid the hazard */
  899. cache_op(Index_Store_Tag_I, begin);
  900. cache_op(Index_Store_Tag_D, begin);
  901. cache_op(Index_Store_Tag_SD, begin);
  902. /* Now search for the wrap around point. */
  903. pow2 = (128 * 1024);
  904. tmp = 0;
  905. for (addr = begin + (128 * 1024); addr < end; addr = begin + pow2) {
  906. cache_op(Index_Load_Tag_SD, addr);
  907. __asm__ __volatile__("nop; nop; nop; nop;"); /* hazard... */
  908. if (!read_c0_taglo())
  909. break;
  910. pow2 <<= 1;
  911. }
  912. local_irq_restore(flags);
  913. addr -= begin;
  914. scache_size = addr;
  915. c->scache.linesz = 16 << ((config & R4K_CONF_SB) >> 22);
  916. c->scache.ways = 1;
  917. c->dcache.waybit = 0; /* does not matter */
  918. return 1;
  919. }
  920. extern int r5k_sc_init(void);
  921. extern int rm7k_sc_init(void);
  922. static void __init setup_scache(void)
  923. {
  924. struct cpuinfo_mips *c = &current_cpu_data;
  925. unsigned int config = read_c0_config();
  926. int sc_present = 0;
  927. /*
  928. * Do the probing thing on R4000SC and R4400SC processors. Other
  929. * processors don't have a S-cache that would be relevant to the
  930. * Linux memory managment.
  931. */
  932. switch (c->cputype) {
  933. case CPU_R4000SC:
  934. case CPU_R4000MC:
  935. case CPU_R4400SC:
  936. case CPU_R4400MC:
  937. sc_present = run_uncached(probe_scache);
  938. if (sc_present)
  939. c->options |= MIPS_CPU_CACHE_CDEX_S;
  940. break;
  941. case CPU_R10000:
  942. case CPU_R12000:
  943. scache_size = 0x80000 << ((config & R10K_CONF_SS) >> 16);
  944. c->scache.linesz = 64 << ((config >> 13) & 1);
  945. c->scache.ways = 2;
  946. c->scache.waybit= 0;
  947. sc_present = 1;
  948. break;
  949. case CPU_R5000:
  950. case CPU_NEVADA:
  951. #ifdef CONFIG_R5000_CPU_SCACHE
  952. r5k_sc_init();
  953. #endif
  954. return;
  955. case CPU_RM7000:
  956. case CPU_RM9000:
  957. #ifdef CONFIG_RM7000_CPU_SCACHE
  958. rm7k_sc_init();
  959. #endif
  960. return;
  961. default:
  962. sc_present = 0;
  963. }
  964. if (!sc_present)
  965. return;
  966. if ((c->isa_level == MIPS_CPU_ISA_M32R1 ||
  967. c->isa_level == MIPS_CPU_ISA_M64R1) &&
  968. !(c->scache.flags & MIPS_CACHE_NOT_PRESENT))
  969. panic("Dunno how to handle MIPS32 / MIPS64 second level cache");
  970. /* compute a couple of other cache variables */
  971. c->scache.waysize = scache_size / c->scache.ways;
  972. c->scache.sets = scache_size / (c->scache.linesz * c->scache.ways);
  973. printk("Unified secondary cache %ldkB %s, linesize %d bytes.\n",
  974. scache_size >> 10, way_string[c->scache.ways], c->scache.linesz);
  975. c->options |= MIPS_CPU_SUBSET_CACHES;
  976. }
  977. static inline void coherency_setup(void)
  978. {
  979. change_c0_config(CONF_CM_CMASK, CONF_CM_DEFAULT);
  980. /*
  981. * c0_status.cu=0 specifies that updates by the sc instruction use
  982. * the coherency mode specified by the TLB; 1 means cachable
  983. * coherent update on write will be used. Not all processors have
  984. * this bit and; some wire it to zero, others like Toshiba had the
  985. * silly idea of putting something else there ...
  986. */
  987. switch (current_cpu_data.cputype) {
  988. case CPU_R4000PC:
  989. case CPU_R4000SC:
  990. case CPU_R4000MC:
  991. case CPU_R4400PC:
  992. case CPU_R4400SC:
  993. case CPU_R4400MC:
  994. clear_c0_config(CONF_CU);
  995. break;
  996. }
  997. }
  998. void __init r4k_cache_init(void)
  999. {
  1000. extern void build_clear_page(void);
  1001. extern void build_copy_page(void);
  1002. extern char except_vec2_generic;
  1003. struct cpuinfo_mips *c = &current_cpu_data;
  1004. /* Default cache error handler for R4000 and R5000 family */
  1005. set_uncached_handler (0x100, &except_vec2_generic, 0x80);
  1006. probe_pcache();
  1007. setup_scache();
  1008. r4k_blast_dcache_page_setup();
  1009. r4k_blast_dcache_page_indexed_setup();
  1010. r4k_blast_dcache_setup();
  1011. r4k_blast_icache_page_setup();
  1012. r4k_blast_icache_page_indexed_setup();
  1013. r4k_blast_icache_setup();
  1014. r4k_blast_scache_page_setup();
  1015. r4k_blast_scache_page_indexed_setup();
  1016. r4k_blast_scache_setup();
  1017. /*
  1018. * Some MIPS32 and MIPS64 processors have physically indexed caches.
  1019. * This code supports virtually indexed processors and will be
  1020. * unnecessarily inefficient on physically indexed processors.
  1021. */
  1022. shm_align_mask = max_t( unsigned long,
  1023. c->dcache.sets * c->dcache.linesz - 1,
  1024. PAGE_SIZE - 1);
  1025. flush_cache_all = r4k_flush_cache_all;
  1026. __flush_cache_all = r4k___flush_cache_all;
  1027. flush_cache_mm = r4k_flush_cache_mm;
  1028. flush_cache_page = r4k_flush_cache_page;
  1029. flush_icache_page = r4k_flush_icache_page;
  1030. flush_cache_range = r4k_flush_cache_range;
  1031. flush_cache_sigtramp = r4k_flush_cache_sigtramp;
  1032. flush_icache_all = r4k_flush_icache_all;
  1033. local_flush_data_cache_page = local_r4k_flush_data_cache_page;
  1034. flush_data_cache_page = r4k_flush_data_cache_page;
  1035. flush_icache_range = r4k_flush_icache_range;
  1036. #ifdef CONFIG_DMA_NONCOHERENT
  1037. _dma_cache_wback_inv = r4k_dma_cache_wback_inv;
  1038. _dma_cache_wback = r4k_dma_cache_wback_inv;
  1039. _dma_cache_inv = r4k_dma_cache_inv;
  1040. #endif
  1041. build_clear_page();
  1042. build_copy_page();
  1043. local_r4k___flush_cache_all(NULL);
  1044. coherency_setup();
  1045. }