c-r4k.c 33 KB

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