r4kcache.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  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. * Inline assembly cache operations.
  7. *
  8. * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
  9. * Copyright (C) 1997 - 2002 Ralf Baechle (ralf@gnu.org)
  10. * Copyright (C) 2004 Ralf Baechle (ralf@linux-mips.org)
  11. */
  12. #ifndef _ASM_R4KCACHE_H
  13. #define _ASM_R4KCACHE_H
  14. #include <asm/asm.h>
  15. #include <asm/cacheops.h>
  16. /*
  17. * This macro return a properly sign-extended address suitable as base address
  18. * for indexed cache operations. Two issues here:
  19. *
  20. * - The MIPS32 and MIPS64 specs permit an implementation to directly derive
  21. * the index bits from the virtual address. This breaks with tradition
  22. * set by the R4000. To keep unpleasant surprises from happening we pick
  23. * an address in KSEG0 / CKSEG0.
  24. * - We need a properly sign extended address for 64-bit code. To get away
  25. * without ifdefs we let the compiler do it by a type cast.
  26. */
  27. #define INDEX_BASE CKSEG0
  28. #define cache_op(op,addr) \
  29. __asm__ __volatile__( \
  30. " .set push \n" \
  31. " .set noreorder \n" \
  32. " .set mips3\n\t \n" \
  33. " cache %0, %1 \n" \
  34. " .set pop \n" \
  35. : \
  36. : "i" (op), "m" (*(unsigned char *)(addr)))
  37. static inline void flush_icache_line_indexed(unsigned long addr)
  38. {
  39. cache_op(Index_Invalidate_I, addr);
  40. }
  41. static inline void flush_dcache_line_indexed(unsigned long addr)
  42. {
  43. cache_op(Index_Writeback_Inv_D, addr);
  44. }
  45. static inline void flush_scache_line_indexed(unsigned long addr)
  46. {
  47. cache_op(Index_Writeback_Inv_SD, addr);
  48. }
  49. static inline void flush_icache_line(unsigned long addr)
  50. {
  51. cache_op(Hit_Invalidate_I, addr);
  52. }
  53. static inline void flush_dcache_line(unsigned long addr)
  54. {
  55. cache_op(Hit_Writeback_Inv_D, addr);
  56. }
  57. static inline void invalidate_dcache_line(unsigned long addr)
  58. {
  59. cache_op(Hit_Invalidate_D, addr);
  60. }
  61. static inline void invalidate_scache_line(unsigned long addr)
  62. {
  63. cache_op(Hit_Invalidate_SD, addr);
  64. }
  65. static inline void flush_scache_line(unsigned long addr)
  66. {
  67. cache_op(Hit_Writeback_Inv_SD, addr);
  68. }
  69. /*
  70. * The next two are for badland addresses like signal trampolines.
  71. */
  72. static inline void protected_flush_icache_line(unsigned long addr)
  73. {
  74. __asm__ __volatile__(
  75. " .set push \n"
  76. " .set noreorder \n"
  77. " .set mips3 \n"
  78. "1: cache %0, (%1) \n"
  79. "2: .set pop \n"
  80. " .section __ex_table,\"a\" \n"
  81. " "STR(PTR)" 1b, 2b \n"
  82. " .previous"
  83. :
  84. : "i" (Hit_Invalidate_I), "r" (addr));
  85. }
  86. /*
  87. * R10000 / R12000 hazard - these processors don't support the Hit_Writeback_D
  88. * cacheop so we use Hit_Writeback_Inv_D which is supported by all R4000-style
  89. * caches. We're talking about one cacheline unnecessarily getting invalidated
  90. * here so the penalty isn't overly hard.
  91. */
  92. static inline void protected_writeback_dcache_line(unsigned long addr)
  93. {
  94. __asm__ __volatile__(
  95. " .set push \n"
  96. " .set noreorder \n"
  97. " .set mips3 \n"
  98. "1: cache %0, (%1) \n"
  99. "2: .set pop \n"
  100. " .section __ex_table,\"a\" \n"
  101. " "STR(PTR)" 1b, 2b \n"
  102. " .previous"
  103. :
  104. : "i" (Hit_Writeback_Inv_D), "r" (addr));
  105. }
  106. static inline void protected_writeback_scache_line(unsigned long addr)
  107. {
  108. __asm__ __volatile__(
  109. " .set push \n"
  110. " .set noreorder \n"
  111. " .set mips3 \n"
  112. "1: cache %0, (%1) \n"
  113. "2: .set pop \n"
  114. " .section __ex_table,\"a\" \n"
  115. " "STR(PTR)" 1b, 2b \n"
  116. " .previous"
  117. :
  118. : "i" (Hit_Writeback_Inv_SD), "r" (addr));
  119. }
  120. /*
  121. * This one is RM7000-specific
  122. */
  123. static inline void invalidate_tcache_page(unsigned long addr)
  124. {
  125. cache_op(Page_Invalidate_T, addr);
  126. }
  127. #define cache16_unroll32(base,op) \
  128. __asm__ __volatile__( \
  129. " .set push \n" \
  130. " .set noreorder \n" \
  131. " .set mips3 \n" \
  132. " cache %1, 0x000(%0); cache %1, 0x010(%0) \n" \
  133. " cache %1, 0x020(%0); cache %1, 0x030(%0) \n" \
  134. " cache %1, 0x040(%0); cache %1, 0x050(%0) \n" \
  135. " cache %1, 0x060(%0); cache %1, 0x070(%0) \n" \
  136. " cache %1, 0x080(%0); cache %1, 0x090(%0) \n" \
  137. " cache %1, 0x0a0(%0); cache %1, 0x0b0(%0) \n" \
  138. " cache %1, 0x0c0(%0); cache %1, 0x0d0(%0) \n" \
  139. " cache %1, 0x0e0(%0); cache %1, 0x0f0(%0) \n" \
  140. " cache %1, 0x100(%0); cache %1, 0x110(%0) \n" \
  141. " cache %1, 0x120(%0); cache %1, 0x130(%0) \n" \
  142. " cache %1, 0x140(%0); cache %1, 0x150(%0) \n" \
  143. " cache %1, 0x160(%0); cache %1, 0x170(%0) \n" \
  144. " cache %1, 0x180(%0); cache %1, 0x190(%0) \n" \
  145. " cache %1, 0x1a0(%0); cache %1, 0x1b0(%0) \n" \
  146. " cache %1, 0x1c0(%0); cache %1, 0x1d0(%0) \n" \
  147. " cache %1, 0x1e0(%0); cache %1, 0x1f0(%0) \n" \
  148. " .set pop \n" \
  149. : \
  150. : "r" (base), \
  151. "i" (op));
  152. static inline void blast_dcache16(void)
  153. {
  154. unsigned long start = INDEX_BASE;
  155. unsigned long end = start + current_cpu_data.dcache.waysize;
  156. unsigned long ws_inc = 1UL << current_cpu_data.dcache.waybit;
  157. unsigned long ws_end = current_cpu_data.dcache.ways <<
  158. current_cpu_data.dcache.waybit;
  159. unsigned long ws, addr;
  160. for (ws = 0; ws < ws_end; ws += ws_inc)
  161. for (addr = start; addr < end; addr += 0x200)
  162. cache16_unroll32(addr|ws,Index_Writeback_Inv_D);
  163. }
  164. static inline void blast_dcache16_page(unsigned long page)
  165. {
  166. unsigned long start = page;
  167. unsigned long end = start + PAGE_SIZE;
  168. do {
  169. cache16_unroll32(start,Hit_Writeback_Inv_D);
  170. start += 0x200;
  171. } while (start < end);
  172. }
  173. static inline void blast_dcache16_page_indexed(unsigned long page)
  174. {
  175. unsigned long start = page;
  176. unsigned long end = start + PAGE_SIZE;
  177. unsigned long ws_inc = 1UL << current_cpu_data.dcache.waybit;
  178. unsigned long ws_end = current_cpu_data.dcache.ways <<
  179. current_cpu_data.dcache.waybit;
  180. unsigned long ws, addr;
  181. for (ws = 0; ws < ws_end; ws += ws_inc)
  182. for (addr = start; addr < end; addr += 0x200)
  183. cache16_unroll32(addr|ws,Index_Writeback_Inv_D);
  184. }
  185. static inline void blast_icache16(void)
  186. {
  187. unsigned long start = INDEX_BASE;
  188. unsigned long end = start + current_cpu_data.icache.waysize;
  189. unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit;
  190. unsigned long ws_end = current_cpu_data.icache.ways <<
  191. current_cpu_data.icache.waybit;
  192. unsigned long ws, addr;
  193. for (ws = 0; ws < ws_end; ws += ws_inc)
  194. for (addr = start; addr < end; addr += 0x200)
  195. cache16_unroll32(addr|ws,Index_Invalidate_I);
  196. }
  197. static inline void blast_icache16_page(unsigned long page)
  198. {
  199. unsigned long start = page;
  200. unsigned long end = start + PAGE_SIZE;
  201. do {
  202. cache16_unroll32(start,Hit_Invalidate_I);
  203. start += 0x200;
  204. } while (start < end);
  205. }
  206. static inline void blast_icache16_page_indexed(unsigned long page)
  207. {
  208. unsigned long start = page;
  209. unsigned long end = start + PAGE_SIZE;
  210. unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit;
  211. unsigned long ws_end = current_cpu_data.icache.ways <<
  212. current_cpu_data.icache.waybit;
  213. unsigned long ws, addr;
  214. for (ws = 0; ws < ws_end; ws += ws_inc)
  215. for (addr = start; addr < end; addr += 0x200)
  216. cache16_unroll32(addr|ws,Index_Invalidate_I);
  217. }
  218. static inline void blast_scache16(void)
  219. {
  220. unsigned long start = INDEX_BASE;
  221. unsigned long end = start + current_cpu_data.scache.waysize;
  222. unsigned long ws_inc = 1UL << current_cpu_data.scache.waybit;
  223. unsigned long ws_end = current_cpu_data.scache.ways <<
  224. current_cpu_data.scache.waybit;
  225. unsigned long ws, addr;
  226. for (ws = 0; ws < ws_end; ws += ws_inc)
  227. for (addr = start; addr < end; addr += 0x200)
  228. cache16_unroll32(addr|ws,Index_Writeback_Inv_SD);
  229. }
  230. static inline void blast_scache16_page(unsigned long page)
  231. {
  232. unsigned long start = page;
  233. unsigned long end = page + PAGE_SIZE;
  234. do {
  235. cache16_unroll32(start,Hit_Writeback_Inv_SD);
  236. start += 0x200;
  237. } while (start < end);
  238. }
  239. static inline void blast_scache16_page_indexed(unsigned long page)
  240. {
  241. unsigned long start = page;
  242. unsigned long end = start + PAGE_SIZE;
  243. unsigned long ws_inc = 1UL << current_cpu_data.scache.waybit;
  244. unsigned long ws_end = current_cpu_data.scache.ways <<
  245. current_cpu_data.scache.waybit;
  246. unsigned long ws, addr;
  247. for (ws = 0; ws < ws_end; ws += ws_inc)
  248. for (addr = start; addr < end; addr += 0x200)
  249. cache16_unroll32(addr|ws,Index_Writeback_Inv_SD);
  250. }
  251. #define cache32_unroll32(base,op) \
  252. __asm__ __volatile__( \
  253. " .set push \n" \
  254. " .set noreorder \n" \
  255. " .set mips3 \n" \
  256. " cache %1, 0x000(%0); cache %1, 0x020(%0) \n" \
  257. " cache %1, 0x040(%0); cache %1, 0x060(%0) \n" \
  258. " cache %1, 0x080(%0); cache %1, 0x0a0(%0) \n" \
  259. " cache %1, 0x0c0(%0); cache %1, 0x0e0(%0) \n" \
  260. " cache %1, 0x100(%0); cache %1, 0x120(%0) \n" \
  261. " cache %1, 0x140(%0); cache %1, 0x160(%0) \n" \
  262. " cache %1, 0x180(%0); cache %1, 0x1a0(%0) \n" \
  263. " cache %1, 0x1c0(%0); cache %1, 0x1e0(%0) \n" \
  264. " cache %1, 0x200(%0); cache %1, 0x220(%0) \n" \
  265. " cache %1, 0x240(%0); cache %1, 0x260(%0) \n" \
  266. " cache %1, 0x280(%0); cache %1, 0x2a0(%0) \n" \
  267. " cache %1, 0x2c0(%0); cache %1, 0x2e0(%0) \n" \
  268. " cache %1, 0x300(%0); cache %1, 0x320(%0) \n" \
  269. " cache %1, 0x340(%0); cache %1, 0x360(%0) \n" \
  270. " cache %1, 0x380(%0); cache %1, 0x3a0(%0) \n" \
  271. " cache %1, 0x3c0(%0); cache %1, 0x3e0(%0) \n" \
  272. " .set pop \n" \
  273. : \
  274. : "r" (base), \
  275. "i" (op));
  276. static inline void blast_dcache32(void)
  277. {
  278. unsigned long start = INDEX_BASE;
  279. unsigned long end = start + current_cpu_data.dcache.waysize;
  280. unsigned long ws_inc = 1UL << current_cpu_data.dcache.waybit;
  281. unsigned long ws_end = current_cpu_data.dcache.ways <<
  282. current_cpu_data.dcache.waybit;
  283. unsigned long ws, addr;
  284. for (ws = 0; ws < ws_end; ws += ws_inc)
  285. for (addr = start; addr < end; addr += 0x400)
  286. cache32_unroll32(addr|ws,Index_Writeback_Inv_D);
  287. }
  288. static inline void blast_dcache32_page(unsigned long page)
  289. {
  290. unsigned long start = page;
  291. unsigned long end = start + PAGE_SIZE;
  292. do {
  293. cache32_unroll32(start,Hit_Writeback_Inv_D);
  294. start += 0x400;
  295. } while (start < end);
  296. }
  297. static inline void blast_dcache32_page_indexed(unsigned long page)
  298. {
  299. unsigned long start = page;
  300. unsigned long end = start + PAGE_SIZE;
  301. unsigned long ws_inc = 1UL << current_cpu_data.dcache.waybit;
  302. unsigned long ws_end = current_cpu_data.dcache.ways <<
  303. current_cpu_data.dcache.waybit;
  304. unsigned long ws, addr;
  305. for (ws = 0; ws < ws_end; ws += ws_inc)
  306. for (addr = start; addr < end; addr += 0x400)
  307. cache32_unroll32(addr|ws,Index_Writeback_Inv_D);
  308. }
  309. static inline void blast_icache32(void)
  310. {
  311. unsigned long start = INDEX_BASE;
  312. unsigned long end = start + current_cpu_data.icache.waysize;
  313. unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit;
  314. unsigned long ws_end = current_cpu_data.icache.ways <<
  315. current_cpu_data.icache.waybit;
  316. unsigned long ws, addr;
  317. for (ws = 0; ws < ws_end; ws += ws_inc)
  318. for (addr = start; addr < end; addr += 0x400)
  319. cache32_unroll32(addr|ws,Index_Invalidate_I);
  320. }
  321. static inline void blast_icache32_page(unsigned long page)
  322. {
  323. unsigned long start = page;
  324. unsigned long end = start + PAGE_SIZE;
  325. do {
  326. cache32_unroll32(start,Hit_Invalidate_I);
  327. start += 0x400;
  328. } while (start < end);
  329. }
  330. static inline void blast_icache32_page_indexed(unsigned long page)
  331. {
  332. unsigned long start = page;
  333. unsigned long end = start + PAGE_SIZE;
  334. unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit;
  335. unsigned long ws_end = current_cpu_data.icache.ways <<
  336. current_cpu_data.icache.waybit;
  337. unsigned long ws, addr;
  338. for (ws = 0; ws < ws_end; ws += ws_inc)
  339. for (addr = start; addr < end; addr += 0x400)
  340. cache32_unroll32(addr|ws,Index_Invalidate_I);
  341. }
  342. static inline void blast_scache32(void)
  343. {
  344. unsigned long start = INDEX_BASE;
  345. unsigned long end = start + current_cpu_data.scache.waysize;
  346. unsigned long ws_inc = 1UL << current_cpu_data.scache.waybit;
  347. unsigned long ws_end = current_cpu_data.scache.ways <<
  348. current_cpu_data.scache.waybit;
  349. unsigned long ws, addr;
  350. for (ws = 0; ws < ws_end; ws += ws_inc)
  351. for (addr = start; addr < end; addr += 0x400)
  352. cache32_unroll32(addr|ws,Index_Writeback_Inv_SD);
  353. }
  354. static inline void blast_scache32_page(unsigned long page)
  355. {
  356. unsigned long start = page;
  357. unsigned long end = page + PAGE_SIZE;
  358. do {
  359. cache32_unroll32(start,Hit_Writeback_Inv_SD);
  360. start += 0x400;
  361. } while (start < end);
  362. }
  363. static inline void blast_scache32_page_indexed(unsigned long page)
  364. {
  365. unsigned long start = page;
  366. unsigned long end = start + PAGE_SIZE;
  367. unsigned long ws_inc = 1UL << current_cpu_data.scache.waybit;
  368. unsigned long ws_end = current_cpu_data.scache.ways <<
  369. current_cpu_data.scache.waybit;
  370. unsigned long ws, addr;
  371. for (ws = 0; ws < ws_end; ws += ws_inc)
  372. for (addr = start; addr < end; addr += 0x400)
  373. cache32_unroll32(addr|ws,Index_Writeback_Inv_SD);
  374. }
  375. #define cache64_unroll32(base,op) \
  376. __asm__ __volatile__( \
  377. " .set push \n" \
  378. " .set noreorder \n" \
  379. " .set mips3 \n" \
  380. " cache %1, 0x000(%0); cache %1, 0x040(%0) \n" \
  381. " cache %1, 0x080(%0); cache %1, 0x0c0(%0) \n" \
  382. " cache %1, 0x100(%0); cache %1, 0x140(%0) \n" \
  383. " cache %1, 0x180(%0); cache %1, 0x1c0(%0) \n" \
  384. " cache %1, 0x200(%0); cache %1, 0x240(%0) \n" \
  385. " cache %1, 0x280(%0); cache %1, 0x2c0(%0) \n" \
  386. " cache %1, 0x300(%0); cache %1, 0x340(%0) \n" \
  387. " cache %1, 0x380(%0); cache %1, 0x3c0(%0) \n" \
  388. " cache %1, 0x400(%0); cache %1, 0x440(%0) \n" \
  389. " cache %1, 0x480(%0); cache %1, 0x4c0(%0) \n" \
  390. " cache %1, 0x500(%0); cache %1, 0x540(%0) \n" \
  391. " cache %1, 0x580(%0); cache %1, 0x5c0(%0) \n" \
  392. " cache %1, 0x600(%0); cache %1, 0x640(%0) \n" \
  393. " cache %1, 0x680(%0); cache %1, 0x6c0(%0) \n" \
  394. " cache %1, 0x700(%0); cache %1, 0x740(%0) \n" \
  395. " cache %1, 0x780(%0); cache %1, 0x7c0(%0) \n" \
  396. " .set pop \n" \
  397. : \
  398. : "r" (base), \
  399. "i" (op));
  400. static inline void blast_icache64(void)
  401. {
  402. unsigned long start = INDEX_BASE;
  403. unsigned long end = start + current_cpu_data.icache.waysize;
  404. unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit;
  405. unsigned long ws_end = current_cpu_data.icache.ways <<
  406. current_cpu_data.icache.waybit;
  407. unsigned long ws, addr;
  408. for (ws = 0; ws < ws_end; ws += ws_inc)
  409. for (addr = start; addr < end; addr += 0x800)
  410. cache64_unroll32(addr|ws,Index_Invalidate_I);
  411. }
  412. static inline void blast_icache64_page(unsigned long page)
  413. {
  414. unsigned long start = page;
  415. unsigned long end = start + PAGE_SIZE;
  416. do {
  417. cache64_unroll32(start,Hit_Invalidate_I);
  418. start += 0x800;
  419. } while (start < end);
  420. }
  421. static inline void blast_icache64_page_indexed(unsigned long page)
  422. {
  423. unsigned long start = page;
  424. unsigned long end = start + PAGE_SIZE;
  425. unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit;
  426. unsigned long ws_end = current_cpu_data.icache.ways <<
  427. current_cpu_data.icache.waybit;
  428. unsigned long ws, addr;
  429. for (ws = 0; ws < ws_end; ws += ws_inc)
  430. for (addr = start; addr < end; addr += 0x800)
  431. cache64_unroll32(addr|ws,Index_Invalidate_I);
  432. }
  433. static inline void blast_scache64(void)
  434. {
  435. unsigned long start = INDEX_BASE;
  436. unsigned long end = start + current_cpu_data.scache.waysize;
  437. unsigned long ws_inc = 1UL << current_cpu_data.scache.waybit;
  438. unsigned long ws_end = current_cpu_data.scache.ways <<
  439. current_cpu_data.scache.waybit;
  440. unsigned long ws, addr;
  441. for (ws = 0; ws < ws_end; ws += ws_inc)
  442. for (addr = start; addr < end; addr += 0x800)
  443. cache64_unroll32(addr|ws,Index_Writeback_Inv_SD);
  444. }
  445. static inline void blast_scache64_page(unsigned long page)
  446. {
  447. unsigned long start = page;
  448. unsigned long end = page + PAGE_SIZE;
  449. do {
  450. cache64_unroll32(start,Hit_Writeback_Inv_SD);
  451. start += 0x800;
  452. } while (start < end);
  453. }
  454. static inline void blast_scache64_page_indexed(unsigned long page)
  455. {
  456. unsigned long start = page;
  457. unsigned long end = start + PAGE_SIZE;
  458. unsigned long ws_inc = 1UL << current_cpu_data.scache.waybit;
  459. unsigned long ws_end = current_cpu_data.scache.ways <<
  460. current_cpu_data.scache.waybit;
  461. unsigned long ws, addr;
  462. for (ws = 0; ws < ws_end; ws += ws_inc)
  463. for (addr = start; addr < end; addr += 0x800)
  464. cache64_unroll32(addr|ws,Index_Writeback_Inv_SD);
  465. }
  466. #define cache128_unroll32(base,op) \
  467. __asm__ __volatile__( \
  468. " .set push \n" \
  469. " .set noreorder \n" \
  470. " .set mips3 \n" \
  471. " cache %1, 0x000(%0); cache %1, 0x080(%0) \n" \
  472. " cache %1, 0x100(%0); cache %1, 0x180(%0) \n" \
  473. " cache %1, 0x200(%0); cache %1, 0x280(%0) \n" \
  474. " cache %1, 0x300(%0); cache %1, 0x380(%0) \n" \
  475. " cache %1, 0x400(%0); cache %1, 0x480(%0) \n" \
  476. " cache %1, 0x500(%0); cache %1, 0x580(%0) \n" \
  477. " cache %1, 0x600(%0); cache %1, 0x680(%0) \n" \
  478. " cache %1, 0x700(%0); cache %1, 0x780(%0) \n" \
  479. " cache %1, 0x800(%0); cache %1, 0x880(%0) \n" \
  480. " cache %1, 0x900(%0); cache %1, 0x980(%0) \n" \
  481. " cache %1, 0xa00(%0); cache %1, 0xa80(%0) \n" \
  482. " cache %1, 0xb00(%0); cache %1, 0xb80(%0) \n" \
  483. " cache %1, 0xc00(%0); cache %1, 0xc80(%0) \n" \
  484. " cache %1, 0xd00(%0); cache %1, 0xd80(%0) \n" \
  485. " cache %1, 0xe00(%0); cache %1, 0xe80(%0) \n" \
  486. " cache %1, 0xf00(%0); cache %1, 0xf80(%0) \n" \
  487. " .set pop \n" \
  488. : \
  489. : "r" (base), \
  490. "i" (op));
  491. static inline void blast_scache128(void)
  492. {
  493. unsigned long start = INDEX_BASE;
  494. unsigned long end = start + current_cpu_data.scache.waysize;
  495. unsigned long ws_inc = 1UL << current_cpu_data.scache.waybit;
  496. unsigned long ws_end = current_cpu_data.scache.ways <<
  497. current_cpu_data.scache.waybit;
  498. unsigned long ws, addr;
  499. for (ws = 0; ws < ws_end; ws += ws_inc)
  500. for (addr = start; addr < end; addr += 0x1000)
  501. cache128_unroll32(addr|ws,Index_Writeback_Inv_SD);
  502. }
  503. static inline void blast_scache128_page(unsigned long page)
  504. {
  505. unsigned long start = page;
  506. unsigned long end = page + PAGE_SIZE;
  507. do {
  508. cache128_unroll32(start,Hit_Writeback_Inv_SD);
  509. start += 0x1000;
  510. } while (start < end);
  511. }
  512. static inline void blast_scache128_page_indexed(unsigned long page)
  513. {
  514. unsigned long start = page;
  515. unsigned long end = start + PAGE_SIZE;
  516. unsigned long ws_inc = 1UL << current_cpu_data.scache.waybit;
  517. unsigned long ws_end = current_cpu_data.scache.ways <<
  518. current_cpu_data.scache.waybit;
  519. unsigned long ws, addr;
  520. for (ws = 0; ws < ws_end; ws += ws_inc)
  521. for (addr = start; addr < end; addr += 0x1000)
  522. cache128_unroll32(addr|ws,Index_Writeback_Inv_SD);
  523. }
  524. #endif /* _ASM_R4KCACHE_H */