cache-sh4.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. /*
  2. * arch/sh/mm/cache-sh4.c
  3. *
  4. * Copyright (C) 1999, 2000, 2002 Niibe Yutaka
  5. * Copyright (C) 2001 - 2007 Paul Mundt
  6. * Copyright (C) 2003 Richard Curnow
  7. * Copyright (c) 2007 STMicroelectronics (R&D) Ltd.
  8. *
  9. * This file is subject to the terms and conditions of the GNU General Public
  10. * License. See the file "COPYING" in the main directory of this archive
  11. * for more details.
  12. */
  13. #include <linux/init.h>
  14. #include <linux/mm.h>
  15. #include <linux/io.h>
  16. #include <linux/mutex.h>
  17. #include <linux/fs.h>
  18. #include <asm/mmu_context.h>
  19. #include <asm/cacheflush.h>
  20. /*
  21. * The maximum number of pages we support up to when doing ranged dcache
  22. * flushing. Anything exceeding this will simply flush the dcache in its
  23. * entirety.
  24. */
  25. #define MAX_DCACHE_PAGES 64 /* XXX: Tune for ways */
  26. #define MAX_ICACHE_PAGES 32
  27. static void __flush_dcache_segment_1way(unsigned long start,
  28. unsigned long extent);
  29. static void __flush_dcache_segment_2way(unsigned long start,
  30. unsigned long extent);
  31. static void __flush_dcache_segment_4way(unsigned long start,
  32. unsigned long extent);
  33. static void __flush_cache_4096(unsigned long addr, unsigned long phys,
  34. unsigned long exec_offset);
  35. /*
  36. * This is initialised here to ensure that it is not placed in the BSS. If
  37. * that were to happen, note that cache_init gets called before the BSS is
  38. * cleared, so this would get nulled out which would be hopeless.
  39. */
  40. static void (*__flush_dcache_segment_fn)(unsigned long, unsigned long) =
  41. (void (*)(unsigned long, unsigned long))0xdeadbeef;
  42. /*
  43. * SH-4 has virtually indexed and physically tagged cache.
  44. */
  45. void __init sh4_cache_init(void)
  46. {
  47. printk("PVR=%08x CVR=%08x PRR=%08x\n",
  48. ctrl_inl(CCN_PVR),
  49. ctrl_inl(CCN_CVR),
  50. ctrl_inl(CCN_PRR));
  51. switch (boot_cpu_data.dcache.ways) {
  52. case 1:
  53. __flush_dcache_segment_fn = __flush_dcache_segment_1way;
  54. break;
  55. case 2:
  56. __flush_dcache_segment_fn = __flush_dcache_segment_2way;
  57. break;
  58. case 4:
  59. __flush_dcache_segment_fn = __flush_dcache_segment_4way;
  60. break;
  61. default:
  62. panic("unknown number of cache ways\n");
  63. break;
  64. }
  65. }
  66. /*
  67. * Write back the range of D-cache, and purge the I-cache.
  68. *
  69. * Called from kernel/module.c:sys_init_module and routine for a.out format,
  70. * signal handler code and kprobes code
  71. */
  72. void flush_icache_range(unsigned long start, unsigned long end)
  73. {
  74. int icacheaddr;
  75. unsigned long flags, v;
  76. int i;
  77. /* If there are too many pages then just blow the caches */
  78. if (((end - start) >> PAGE_SHIFT) >= MAX_ICACHE_PAGES) {
  79. flush_cache_all();
  80. } else {
  81. /* selectively flush d-cache then invalidate the i-cache */
  82. /* this is inefficient, so only use for small ranges */
  83. start &= ~(L1_CACHE_BYTES-1);
  84. end += L1_CACHE_BYTES-1;
  85. end &= ~(L1_CACHE_BYTES-1);
  86. local_irq_save(flags);
  87. jump_to_uncached();
  88. for (v = start; v < end; v+=L1_CACHE_BYTES) {
  89. asm volatile("ocbwb %0"
  90. : /* no output */
  91. : "m" (__m(v)));
  92. icacheaddr = CACHE_IC_ADDRESS_ARRAY | (
  93. v & cpu_data->icache.entry_mask);
  94. for (i = 0; i < cpu_data->icache.ways;
  95. i++, icacheaddr += cpu_data->icache.way_incr)
  96. /* Clear i-cache line valid-bit */
  97. ctrl_outl(0, icacheaddr);
  98. }
  99. back_to_cached();
  100. local_irq_restore(flags);
  101. }
  102. }
  103. static inline void flush_cache_4096(unsigned long start,
  104. unsigned long phys)
  105. {
  106. unsigned long flags, exec_offset = 0;
  107. /*
  108. * All types of SH-4 require PC to be in P2 to operate on the I-cache.
  109. * Some types of SH-4 require PC to be in P2 to operate on the D-cache.
  110. */
  111. if ((boot_cpu_data.flags & CPU_HAS_P2_FLUSH_BUG) ||
  112. (start < CACHE_OC_ADDRESS_ARRAY))
  113. exec_offset = 0x20000000;
  114. local_irq_save(flags);
  115. __flush_cache_4096(start | SH_CACHE_ASSOC,
  116. P1SEGADDR(phys), exec_offset);
  117. local_irq_restore(flags);
  118. }
  119. /*
  120. * Write back & invalidate the D-cache of the page.
  121. * (To avoid "alias" issues)
  122. */
  123. void flush_dcache_page(struct page *page)
  124. {
  125. struct address_space *mapping = page_mapping(page);
  126. #ifndef CONFIG_SMP
  127. if (mapping && !mapping_mapped(mapping))
  128. set_bit(PG_dcache_dirty, &page->flags);
  129. else
  130. #endif
  131. {
  132. unsigned long phys = PHYSADDR(page_address(page));
  133. unsigned long addr = CACHE_OC_ADDRESS_ARRAY;
  134. int i, n;
  135. /* Loop all the D-cache */
  136. n = boot_cpu_data.dcache.n_aliases;
  137. for (i = 0; i < n; i++, addr += 4096)
  138. flush_cache_4096(addr, phys);
  139. }
  140. wmb();
  141. }
  142. /* TODO: Selective icache invalidation through IC address array.. */
  143. static void __uses_jump_to_uncached flush_icache_all(void)
  144. {
  145. unsigned long flags, ccr;
  146. local_irq_save(flags);
  147. jump_to_uncached();
  148. /* Flush I-cache */
  149. ccr = ctrl_inl(CCR);
  150. ccr |= CCR_CACHE_ICI;
  151. ctrl_outl(ccr, CCR);
  152. /*
  153. * back_to_cached() will take care of the barrier for us, don't add
  154. * another one!
  155. */
  156. back_to_cached();
  157. local_irq_restore(flags);
  158. }
  159. void flush_dcache_all(void)
  160. {
  161. (*__flush_dcache_segment_fn)(0UL, boot_cpu_data.dcache.way_size);
  162. wmb();
  163. }
  164. void flush_cache_all(void)
  165. {
  166. flush_dcache_all();
  167. flush_icache_all();
  168. }
  169. static void __flush_cache_mm(struct mm_struct *mm, unsigned long start,
  170. unsigned long end)
  171. {
  172. unsigned long d = 0, p = start & PAGE_MASK;
  173. unsigned long alias_mask = boot_cpu_data.dcache.alias_mask;
  174. unsigned long n_aliases = boot_cpu_data.dcache.n_aliases;
  175. unsigned long select_bit;
  176. unsigned long all_aliases_mask;
  177. unsigned long addr_offset;
  178. pgd_t *dir;
  179. pmd_t *pmd;
  180. pud_t *pud;
  181. pte_t *pte;
  182. int i;
  183. dir = pgd_offset(mm, p);
  184. pud = pud_offset(dir, p);
  185. pmd = pmd_offset(pud, p);
  186. end = PAGE_ALIGN(end);
  187. all_aliases_mask = (1 << n_aliases) - 1;
  188. do {
  189. if (pmd_none(*pmd) || unlikely(pmd_bad(*pmd))) {
  190. p &= PMD_MASK;
  191. p += PMD_SIZE;
  192. pmd++;
  193. continue;
  194. }
  195. pte = pte_offset_kernel(pmd, p);
  196. do {
  197. unsigned long phys;
  198. pte_t entry = *pte;
  199. if (!(pte_val(entry) & _PAGE_PRESENT)) {
  200. pte++;
  201. p += PAGE_SIZE;
  202. continue;
  203. }
  204. phys = pte_val(entry) & PTE_PHYS_MASK;
  205. if ((p ^ phys) & alias_mask) {
  206. d |= 1 << ((p & alias_mask) >> PAGE_SHIFT);
  207. d |= 1 << ((phys & alias_mask) >> PAGE_SHIFT);
  208. if (d == all_aliases_mask)
  209. goto loop_exit;
  210. }
  211. pte++;
  212. p += PAGE_SIZE;
  213. } while (p < end && ((unsigned long)pte & ~PAGE_MASK));
  214. pmd++;
  215. } while (p < end);
  216. loop_exit:
  217. addr_offset = 0;
  218. select_bit = 1;
  219. for (i = 0; i < n_aliases; i++) {
  220. if (d & select_bit) {
  221. (*__flush_dcache_segment_fn)(addr_offset, PAGE_SIZE);
  222. wmb();
  223. }
  224. select_bit <<= 1;
  225. addr_offset += PAGE_SIZE;
  226. }
  227. }
  228. /*
  229. * Note : (RPC) since the caches are physically tagged, the only point
  230. * of flush_cache_mm for SH-4 is to get rid of aliases from the
  231. * D-cache. The assumption elsewhere, e.g. flush_cache_range, is that
  232. * lines can stay resident so long as the virtual address they were
  233. * accessed with (hence cache set) is in accord with the physical
  234. * address (i.e. tag). It's no different here. So I reckon we don't
  235. * need to flush the I-cache, since aliases don't matter for that. We
  236. * should try that.
  237. *
  238. * Caller takes mm->mmap_sem.
  239. */
  240. void flush_cache_mm(struct mm_struct *mm)
  241. {
  242. if (cpu_context(smp_processor_id(), mm) == NO_CONTEXT)
  243. return;
  244. /*
  245. * If cache is only 4k-per-way, there are never any 'aliases'. Since
  246. * the cache is physically tagged, the data can just be left in there.
  247. */
  248. if (boot_cpu_data.dcache.n_aliases == 0)
  249. return;
  250. /*
  251. * Don't bother groveling around the dcache for the VMA ranges
  252. * if there are too many PTEs to make it worthwhile.
  253. */
  254. if (mm->nr_ptes >= MAX_DCACHE_PAGES)
  255. flush_dcache_all();
  256. else {
  257. struct vm_area_struct *vma;
  258. /*
  259. * In this case there are reasonably sized ranges to flush,
  260. * iterate through the VMA list and take care of any aliases.
  261. */
  262. for (vma = mm->mmap; vma; vma = vma->vm_next)
  263. __flush_cache_mm(mm, vma->vm_start, vma->vm_end);
  264. }
  265. /* Only touch the icache if one of the VMAs has VM_EXEC set. */
  266. if (mm->exec_vm)
  267. flush_icache_all();
  268. }
  269. /*
  270. * Write back and invalidate I/D-caches for the page.
  271. *
  272. * ADDR: Virtual Address (U0 address)
  273. * PFN: Physical page number
  274. */
  275. void flush_cache_page(struct vm_area_struct *vma, unsigned long address,
  276. unsigned long pfn)
  277. {
  278. unsigned long phys = pfn << PAGE_SHIFT;
  279. unsigned int alias_mask;
  280. if (cpu_context(smp_processor_id(), vma->vm_mm) == NO_CONTEXT)
  281. return;
  282. alias_mask = boot_cpu_data.dcache.alias_mask;
  283. /* We only need to flush D-cache when we have alias */
  284. if ((address^phys) & alias_mask) {
  285. /* Loop 4K of the D-cache */
  286. flush_cache_4096(
  287. CACHE_OC_ADDRESS_ARRAY | (address & alias_mask),
  288. phys);
  289. /* Loop another 4K of the D-cache */
  290. flush_cache_4096(
  291. CACHE_OC_ADDRESS_ARRAY | (phys & alias_mask),
  292. phys);
  293. }
  294. alias_mask = boot_cpu_data.icache.alias_mask;
  295. if (vma->vm_flags & VM_EXEC) {
  296. /*
  297. * Evict entries from the portion of the cache from which code
  298. * may have been executed at this address (virtual). There's
  299. * no need to evict from the portion corresponding to the
  300. * physical address as for the D-cache, because we know the
  301. * kernel has never executed the code through its identity
  302. * translation.
  303. */
  304. flush_cache_4096(
  305. CACHE_IC_ADDRESS_ARRAY | (address & alias_mask),
  306. phys);
  307. }
  308. }
  309. /*
  310. * Write back and invalidate D-caches.
  311. *
  312. * START, END: Virtual Address (U0 address)
  313. *
  314. * NOTE: We need to flush the _physical_ page entry.
  315. * Flushing the cache lines for U0 only isn't enough.
  316. * We need to flush for P1 too, which may contain aliases.
  317. */
  318. void flush_cache_range(struct vm_area_struct *vma, unsigned long start,
  319. unsigned long end)
  320. {
  321. if (cpu_context(smp_processor_id(), vma->vm_mm) == NO_CONTEXT)
  322. return;
  323. /*
  324. * If cache is only 4k-per-way, there are never any 'aliases'. Since
  325. * the cache is physically tagged, the data can just be left in there.
  326. */
  327. if (boot_cpu_data.dcache.n_aliases == 0)
  328. return;
  329. /*
  330. * Don't bother with the lookup and alias check if we have a
  331. * wide range to cover, just blow away the dcache in its
  332. * entirety instead. -- PFM.
  333. */
  334. if (((end - start) >> PAGE_SHIFT) >= MAX_DCACHE_PAGES)
  335. flush_dcache_all();
  336. else
  337. __flush_cache_mm(vma->vm_mm, start, end);
  338. if (vma->vm_flags & VM_EXEC) {
  339. /*
  340. * TODO: Is this required??? Need to look at how I-cache
  341. * coherency is assured when new programs are loaded to see if
  342. * this matters.
  343. */
  344. flush_icache_all();
  345. }
  346. }
  347. /*
  348. * flush_icache_user_range
  349. * @vma: VMA of the process
  350. * @page: page
  351. * @addr: U0 address
  352. * @len: length of the range (< page size)
  353. */
  354. void flush_icache_user_range(struct vm_area_struct *vma,
  355. struct page *page, unsigned long addr, int len)
  356. {
  357. flush_cache_page(vma, addr, page_to_pfn(page));
  358. mb();
  359. }
  360. /**
  361. * __flush_cache_4096
  362. *
  363. * @addr: address in memory mapped cache array
  364. * @phys: P1 address to flush (has to match tags if addr has 'A' bit
  365. * set i.e. associative write)
  366. * @exec_offset: set to 0x20000000 if flush has to be executed from P2
  367. * region else 0x0
  368. *
  369. * The offset into the cache array implied by 'addr' selects the
  370. * 'colour' of the virtual address range that will be flushed. The
  371. * operation (purge/write-back) is selected by the lower 2 bits of
  372. * 'phys'.
  373. */
  374. static void __flush_cache_4096(unsigned long addr, unsigned long phys,
  375. unsigned long exec_offset)
  376. {
  377. int way_count;
  378. unsigned long base_addr = addr;
  379. struct cache_info *dcache;
  380. unsigned long way_incr;
  381. unsigned long a, ea, p;
  382. unsigned long temp_pc;
  383. dcache = &boot_cpu_data.dcache;
  384. /* Write this way for better assembly. */
  385. way_count = dcache->ways;
  386. way_incr = dcache->way_incr;
  387. /*
  388. * Apply exec_offset (i.e. branch to P2 if required.).
  389. *
  390. * FIXME:
  391. *
  392. * If I write "=r" for the (temp_pc), it puts this in r6 hence
  393. * trashing exec_offset before it's been added on - why? Hence
  394. * "=&r" as a 'workaround'
  395. */
  396. asm volatile("mov.l 1f, %0\n\t"
  397. "add %1, %0\n\t"
  398. "jmp @%0\n\t"
  399. "nop\n\t"
  400. ".balign 4\n\t"
  401. "1: .long 2f\n\t"
  402. "2:\n" : "=&r" (temp_pc) : "r" (exec_offset));
  403. /*
  404. * We know there will be >=1 iteration, so write as do-while to avoid
  405. * pointless nead-of-loop check for 0 iterations.
  406. */
  407. do {
  408. ea = base_addr + PAGE_SIZE;
  409. a = base_addr;
  410. p = phys;
  411. do {
  412. *(volatile unsigned long *)a = p;
  413. /*
  414. * Next line: intentionally not p+32, saves an add, p
  415. * will do since only the cache tag bits need to
  416. * match.
  417. */
  418. *(volatile unsigned long *)(a+32) = p;
  419. a += 64;
  420. p += 64;
  421. } while (a < ea);
  422. base_addr += way_incr;
  423. } while (--way_count != 0);
  424. }
  425. /*
  426. * Break the 1, 2 and 4 way variants of this out into separate functions to
  427. * avoid nearly all the overhead of having the conditional stuff in the function
  428. * bodies (+ the 1 and 2 way cases avoid saving any registers too).
  429. */
  430. static void __flush_dcache_segment_1way(unsigned long start,
  431. unsigned long extent_per_way)
  432. {
  433. unsigned long orig_sr, sr_with_bl;
  434. unsigned long base_addr;
  435. unsigned long way_incr, linesz, way_size;
  436. struct cache_info *dcache;
  437. register unsigned long a0, a0e;
  438. asm volatile("stc sr, %0" : "=r" (orig_sr));
  439. sr_with_bl = orig_sr | (1<<28);
  440. base_addr = ((unsigned long)&empty_zero_page[0]);
  441. /*
  442. * The previous code aligned base_addr to 16k, i.e. the way_size of all
  443. * existing SH-4 D-caches. Whilst I don't see a need to have this
  444. * aligned to any better than the cache line size (which it will be
  445. * anyway by construction), let's align it to at least the way_size of
  446. * any existing or conceivable SH-4 D-cache. -- RPC
  447. */
  448. base_addr = ((base_addr >> 16) << 16);
  449. base_addr |= start;
  450. dcache = &boot_cpu_data.dcache;
  451. linesz = dcache->linesz;
  452. way_incr = dcache->way_incr;
  453. way_size = dcache->way_size;
  454. a0 = base_addr;
  455. a0e = base_addr + extent_per_way;
  456. do {
  457. asm volatile("ldc %0, sr" : : "r" (sr_with_bl));
  458. asm volatile("movca.l r0, @%0\n\t"
  459. "ocbi @%0" : : "r" (a0));
  460. a0 += linesz;
  461. asm volatile("movca.l r0, @%0\n\t"
  462. "ocbi @%0" : : "r" (a0));
  463. a0 += linesz;
  464. asm volatile("movca.l r0, @%0\n\t"
  465. "ocbi @%0" : : "r" (a0));
  466. a0 += linesz;
  467. asm volatile("movca.l r0, @%0\n\t"
  468. "ocbi @%0" : : "r" (a0));
  469. asm volatile("ldc %0, sr" : : "r" (orig_sr));
  470. a0 += linesz;
  471. } while (a0 < a0e);
  472. }
  473. static void __flush_dcache_segment_2way(unsigned long start,
  474. unsigned long extent_per_way)
  475. {
  476. unsigned long orig_sr, sr_with_bl;
  477. unsigned long base_addr;
  478. unsigned long way_incr, linesz, way_size;
  479. struct cache_info *dcache;
  480. register unsigned long a0, a1, a0e;
  481. asm volatile("stc sr, %0" : "=r" (orig_sr));
  482. sr_with_bl = orig_sr | (1<<28);
  483. base_addr = ((unsigned long)&empty_zero_page[0]);
  484. /* See comment under 1-way above */
  485. base_addr = ((base_addr >> 16) << 16);
  486. base_addr |= start;
  487. dcache = &boot_cpu_data.dcache;
  488. linesz = dcache->linesz;
  489. way_incr = dcache->way_incr;
  490. way_size = dcache->way_size;
  491. a0 = base_addr;
  492. a1 = a0 + way_incr;
  493. a0e = base_addr + extent_per_way;
  494. do {
  495. asm volatile("ldc %0, sr" : : "r" (sr_with_bl));
  496. asm volatile("movca.l r0, @%0\n\t"
  497. "movca.l r0, @%1\n\t"
  498. "ocbi @%0\n\t"
  499. "ocbi @%1" : :
  500. "r" (a0), "r" (a1));
  501. a0 += linesz;
  502. a1 += linesz;
  503. asm volatile("movca.l r0, @%0\n\t"
  504. "movca.l r0, @%1\n\t"
  505. "ocbi @%0\n\t"
  506. "ocbi @%1" : :
  507. "r" (a0), "r" (a1));
  508. a0 += linesz;
  509. a1 += linesz;
  510. asm volatile("movca.l r0, @%0\n\t"
  511. "movca.l r0, @%1\n\t"
  512. "ocbi @%0\n\t"
  513. "ocbi @%1" : :
  514. "r" (a0), "r" (a1));
  515. a0 += linesz;
  516. a1 += linesz;
  517. asm volatile("movca.l r0, @%0\n\t"
  518. "movca.l r0, @%1\n\t"
  519. "ocbi @%0\n\t"
  520. "ocbi @%1" : :
  521. "r" (a0), "r" (a1));
  522. asm volatile("ldc %0, sr" : : "r" (orig_sr));
  523. a0 += linesz;
  524. a1 += linesz;
  525. } while (a0 < a0e);
  526. }
  527. static void __flush_dcache_segment_4way(unsigned long start,
  528. unsigned long extent_per_way)
  529. {
  530. unsigned long orig_sr, sr_with_bl;
  531. unsigned long base_addr;
  532. unsigned long way_incr, linesz, way_size;
  533. struct cache_info *dcache;
  534. register unsigned long a0, a1, a2, a3, a0e;
  535. asm volatile("stc sr, %0" : "=r" (orig_sr));
  536. sr_with_bl = orig_sr | (1<<28);
  537. base_addr = ((unsigned long)&empty_zero_page[0]);
  538. /* See comment under 1-way above */
  539. base_addr = ((base_addr >> 16) << 16);
  540. base_addr |= start;
  541. dcache = &boot_cpu_data.dcache;
  542. linesz = dcache->linesz;
  543. way_incr = dcache->way_incr;
  544. way_size = dcache->way_size;
  545. a0 = base_addr;
  546. a1 = a0 + way_incr;
  547. a2 = a1 + way_incr;
  548. a3 = a2 + way_incr;
  549. a0e = base_addr + extent_per_way;
  550. do {
  551. asm volatile("ldc %0, sr" : : "r" (sr_with_bl));
  552. asm volatile("movca.l r0, @%0\n\t"
  553. "movca.l r0, @%1\n\t"
  554. "movca.l r0, @%2\n\t"
  555. "movca.l r0, @%3\n\t"
  556. "ocbi @%0\n\t"
  557. "ocbi @%1\n\t"
  558. "ocbi @%2\n\t"
  559. "ocbi @%3\n\t" : :
  560. "r" (a0), "r" (a1), "r" (a2), "r" (a3));
  561. a0 += linesz;
  562. a1 += linesz;
  563. a2 += linesz;
  564. a3 += linesz;
  565. asm volatile("movca.l r0, @%0\n\t"
  566. "movca.l r0, @%1\n\t"
  567. "movca.l r0, @%2\n\t"
  568. "movca.l r0, @%3\n\t"
  569. "ocbi @%0\n\t"
  570. "ocbi @%1\n\t"
  571. "ocbi @%2\n\t"
  572. "ocbi @%3\n\t" : :
  573. "r" (a0), "r" (a1), "r" (a2), "r" (a3));
  574. a0 += linesz;
  575. a1 += linesz;
  576. a2 += linesz;
  577. a3 += linesz;
  578. asm volatile("movca.l r0, @%0\n\t"
  579. "movca.l r0, @%1\n\t"
  580. "movca.l r0, @%2\n\t"
  581. "movca.l r0, @%3\n\t"
  582. "ocbi @%0\n\t"
  583. "ocbi @%1\n\t"
  584. "ocbi @%2\n\t"
  585. "ocbi @%3\n\t" : :
  586. "r" (a0), "r" (a1), "r" (a2), "r" (a3));
  587. a0 += linesz;
  588. a1 += linesz;
  589. a2 += linesz;
  590. a3 += linesz;
  591. asm volatile("movca.l r0, @%0\n\t"
  592. "movca.l r0, @%1\n\t"
  593. "movca.l r0, @%2\n\t"
  594. "movca.l r0, @%3\n\t"
  595. "ocbi @%0\n\t"
  596. "ocbi @%1\n\t"
  597. "ocbi @%2\n\t"
  598. "ocbi @%3\n\t" : :
  599. "r" (a0), "r" (a1), "r" (a2), "r" (a3));
  600. asm volatile("ldc %0, sr" : : "r" (orig_sr));
  601. a0 += linesz;
  602. a1 += linesz;
  603. a2 += linesz;
  604. a3 += linesz;
  605. } while (a0 < a0e);
  606. }