pacache.S 24 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043
  1. /*
  2. * PARISC TLB and cache flushing support
  3. * Copyright (C) 2000-2001 Hewlett-Packard (John Marvin)
  4. * Copyright (C) 2001 Matthew Wilcox (willy at parisc-linux.org)
  5. * Copyright (C) 2002 Richard Hirst (rhirst with parisc-linux.org)
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2, or (at your option)
  10. * any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. /*
  22. * NOTE: fdc,fic, and pdc instructions that use base register modification
  23. * should only use index and base registers that are not shadowed,
  24. * so that the fast path emulation in the non access miss handler
  25. * can be used.
  26. */
  27. #ifdef CONFIG_64BIT
  28. .level 2.0w
  29. #else
  30. .level 2.0
  31. #endif
  32. #include <asm/psw.h>
  33. #include <asm/assembly.h>
  34. #include <asm/pgtable.h>
  35. #include <asm/cache.h>
  36. #include <linux/linkage.h>
  37. .text
  38. .align 128
  39. ENTRY(flush_tlb_all_local)
  40. .proc
  41. .callinfo NO_CALLS
  42. .entry
  43. /*
  44. * The pitlbe and pdtlbe instructions should only be used to
  45. * flush the entire tlb. Also, there needs to be no intervening
  46. * tlb operations, e.g. tlb misses, so the operation needs
  47. * to happen in real mode with all interruptions disabled.
  48. */
  49. /* pcxt_ssm_bug - relied upon translation! PA 2.0 Arch. F-4 and F-5 */
  50. rsm PSW_SM_I, %r19 /* save I-bit state */
  51. load32 PA(1f), %r1
  52. nop
  53. nop
  54. nop
  55. nop
  56. nop
  57. rsm PSW_SM_Q, %r0 /* prep to load iia queue */
  58. mtctl %r0, %cr17 /* Clear IIASQ tail */
  59. mtctl %r0, %cr17 /* Clear IIASQ head */
  60. mtctl %r1, %cr18 /* IIAOQ head */
  61. ldo 4(%r1), %r1
  62. mtctl %r1, %cr18 /* IIAOQ tail */
  63. load32 REAL_MODE_PSW, %r1
  64. mtctl %r1, %ipsw
  65. rfi
  66. nop
  67. 1: load32 PA(cache_info), %r1
  68. /* Flush Instruction Tlb */
  69. LDREG ITLB_SID_BASE(%r1), %r20
  70. LDREG ITLB_SID_STRIDE(%r1), %r21
  71. LDREG ITLB_SID_COUNT(%r1), %r22
  72. LDREG ITLB_OFF_BASE(%r1), %arg0
  73. LDREG ITLB_OFF_STRIDE(%r1), %arg1
  74. LDREG ITLB_OFF_COUNT(%r1), %arg2
  75. LDREG ITLB_LOOP(%r1), %arg3
  76. addib,COND(=) -1, %arg3, fitoneloop /* Preadjust and test */
  77. movb,<,n %arg3, %r31, fitdone /* If loop < 0, skip */
  78. copy %arg0, %r28 /* Init base addr */
  79. fitmanyloop: /* Loop if LOOP >= 2 */
  80. mtsp %r20, %sr1
  81. add %r21, %r20, %r20 /* increment space */
  82. copy %arg2, %r29 /* Init middle loop count */
  83. fitmanymiddle: /* Loop if LOOP >= 2 */
  84. addib,COND(>) -1, %r31, fitmanymiddle /* Adjusted inner loop decr */
  85. pitlbe 0(%sr1, %r28)
  86. pitlbe,m %arg1(%sr1, %r28) /* Last pitlbe and addr adjust */
  87. addib,COND(>) -1, %r29, fitmanymiddle /* Middle loop decr */
  88. copy %arg3, %r31 /* Re-init inner loop count */
  89. movb,tr %arg0, %r28, fitmanyloop /* Re-init base addr */
  90. addib,COND(<=),n -1, %r22, fitdone /* Outer loop count decr */
  91. fitoneloop: /* Loop if LOOP = 1 */
  92. mtsp %r20, %sr1
  93. copy %arg0, %r28 /* init base addr */
  94. copy %arg2, %r29 /* init middle loop count */
  95. fitonemiddle: /* Loop if LOOP = 1 */
  96. addib,COND(>) -1, %r29, fitonemiddle /* Middle loop count decr */
  97. pitlbe,m %arg1(%sr1, %r28) /* pitlbe for one loop */
  98. addib,COND(>) -1, %r22, fitoneloop /* Outer loop count decr */
  99. add %r21, %r20, %r20 /* increment space */
  100. fitdone:
  101. /* Flush Data Tlb */
  102. LDREG DTLB_SID_BASE(%r1), %r20
  103. LDREG DTLB_SID_STRIDE(%r1), %r21
  104. LDREG DTLB_SID_COUNT(%r1), %r22
  105. LDREG DTLB_OFF_BASE(%r1), %arg0
  106. LDREG DTLB_OFF_STRIDE(%r1), %arg1
  107. LDREG DTLB_OFF_COUNT(%r1), %arg2
  108. LDREG DTLB_LOOP(%r1), %arg3
  109. addib,COND(=) -1, %arg3, fdtoneloop /* Preadjust and test */
  110. movb,<,n %arg3, %r31, fdtdone /* If loop < 0, skip */
  111. copy %arg0, %r28 /* Init base addr */
  112. fdtmanyloop: /* Loop if LOOP >= 2 */
  113. mtsp %r20, %sr1
  114. add %r21, %r20, %r20 /* increment space */
  115. copy %arg2, %r29 /* Init middle loop count */
  116. fdtmanymiddle: /* Loop if LOOP >= 2 */
  117. addib,COND(>) -1, %r31, fdtmanymiddle /* Adjusted inner loop decr */
  118. pdtlbe 0(%sr1, %r28)
  119. pdtlbe,m %arg1(%sr1, %r28) /* Last pdtlbe and addr adjust */
  120. addib,COND(>) -1, %r29, fdtmanymiddle /* Middle loop decr */
  121. copy %arg3, %r31 /* Re-init inner loop count */
  122. movb,tr %arg0, %r28, fdtmanyloop /* Re-init base addr */
  123. addib,COND(<=),n -1, %r22,fdtdone /* Outer loop count decr */
  124. fdtoneloop: /* Loop if LOOP = 1 */
  125. mtsp %r20, %sr1
  126. copy %arg0, %r28 /* init base addr */
  127. copy %arg2, %r29 /* init middle loop count */
  128. fdtonemiddle: /* Loop if LOOP = 1 */
  129. addib,COND(>) -1, %r29, fdtonemiddle /* Middle loop count decr */
  130. pdtlbe,m %arg1(%sr1, %r28) /* pdtlbe for one loop */
  131. addib,COND(>) -1, %r22, fdtoneloop /* Outer loop count decr */
  132. add %r21, %r20, %r20 /* increment space */
  133. fdtdone:
  134. /*
  135. * Switch back to virtual mode
  136. */
  137. /* pcxt_ssm_bug */
  138. rsm PSW_SM_I, %r0
  139. load32 2f, %r1
  140. nop
  141. nop
  142. nop
  143. nop
  144. nop
  145. rsm PSW_SM_Q, %r0 /* prep to load iia queue */
  146. mtctl %r0, %cr17 /* Clear IIASQ tail */
  147. mtctl %r0, %cr17 /* Clear IIASQ head */
  148. mtctl %r1, %cr18 /* IIAOQ head */
  149. ldo 4(%r1), %r1
  150. mtctl %r1, %cr18 /* IIAOQ tail */
  151. load32 KERNEL_PSW, %r1
  152. or %r1, %r19, %r1 /* I-bit to state on entry */
  153. mtctl %r1, %ipsw /* restore I-bit (entire PSW) */
  154. rfi
  155. nop
  156. 2: bv %r0(%r2)
  157. nop
  158. .exit
  159. .procend
  160. ENDPROC(flush_tlb_all_local)
  161. .import cache_info,data
  162. ENTRY(flush_instruction_cache_local)
  163. .proc
  164. .callinfo NO_CALLS
  165. .entry
  166. mtsp %r0, %sr1
  167. load32 cache_info, %r1
  168. /* Flush Instruction Cache */
  169. LDREG ICACHE_BASE(%r1), %arg0
  170. LDREG ICACHE_STRIDE(%r1), %arg1
  171. LDREG ICACHE_COUNT(%r1), %arg2
  172. LDREG ICACHE_LOOP(%r1), %arg3
  173. rsm PSW_SM_I, %r22 /* No mmgt ops during loop*/
  174. addib,COND(=) -1, %arg3, fioneloop /* Preadjust and test */
  175. movb,<,n %arg3, %r31, fisync /* If loop < 0, do sync */
  176. fimanyloop: /* Loop if LOOP >= 2 */
  177. addib,COND(>) -1, %r31, fimanyloop /* Adjusted inner loop decr */
  178. fice %r0(%sr1, %arg0)
  179. fice,m %arg1(%sr1, %arg0) /* Last fice and addr adjust */
  180. movb,tr %arg3, %r31, fimanyloop /* Re-init inner loop count */
  181. addib,COND(<=),n -1, %arg2, fisync /* Outer loop decr */
  182. fioneloop: /* Loop if LOOP = 1 */
  183. addib,COND(>) -1, %arg2, fioneloop /* Outer loop count decr */
  184. fice,m %arg1(%sr1, %arg0) /* Fice for one loop */
  185. fisync:
  186. sync
  187. mtsm %r22 /* restore I-bit */
  188. bv %r0(%r2)
  189. nop
  190. .exit
  191. .procend
  192. ENDPROC(flush_instruction_cache_local)
  193. .import cache_info, data
  194. ENTRY(flush_data_cache_local)
  195. .proc
  196. .callinfo NO_CALLS
  197. .entry
  198. mtsp %r0, %sr1
  199. load32 cache_info, %r1
  200. /* Flush Data Cache */
  201. LDREG DCACHE_BASE(%r1), %arg0
  202. LDREG DCACHE_STRIDE(%r1), %arg1
  203. LDREG DCACHE_COUNT(%r1), %arg2
  204. LDREG DCACHE_LOOP(%r1), %arg3
  205. rsm PSW_SM_I, %r22
  206. addib,COND(=) -1, %arg3, fdoneloop /* Preadjust and test */
  207. movb,<,n %arg3, %r31, fdsync /* If loop < 0, do sync */
  208. fdmanyloop: /* Loop if LOOP >= 2 */
  209. addib,COND(>) -1, %r31, fdmanyloop /* Adjusted inner loop decr */
  210. fdce %r0(%sr1, %arg0)
  211. fdce,m %arg1(%sr1, %arg0) /* Last fdce and addr adjust */
  212. movb,tr %arg3, %r31, fdmanyloop /* Re-init inner loop count */
  213. addib,COND(<=),n -1, %arg2, fdsync /* Outer loop decr */
  214. fdoneloop: /* Loop if LOOP = 1 */
  215. addib,COND(>) -1, %arg2, fdoneloop /* Outer loop count decr */
  216. fdce,m %arg1(%sr1, %arg0) /* Fdce for one loop */
  217. fdsync:
  218. syncdma
  219. sync
  220. mtsm %r22 /* restore I-bit */
  221. bv %r0(%r2)
  222. nop
  223. .exit
  224. .procend
  225. ENDPROC(flush_data_cache_local)
  226. .align 16
  227. ENTRY(copy_user_page_asm)
  228. .proc
  229. .callinfo NO_CALLS
  230. .entry
  231. #ifdef CONFIG_64BIT
  232. /* PA8x00 CPUs can consume 2 loads or 1 store per cycle.
  233. * Unroll the loop by hand and arrange insn appropriately.
  234. * GCC probably can do this just as well.
  235. */
  236. ldd 0(%r25), %r19
  237. ldi (PAGE_SIZE / 128), %r1
  238. ldw 64(%r25), %r0 /* prefetch 1 cacheline ahead */
  239. ldw 128(%r25), %r0 /* prefetch 2 */
  240. 1: ldd 8(%r25), %r20
  241. ldw 192(%r25), %r0 /* prefetch 3 */
  242. ldw 256(%r25), %r0 /* prefetch 4 */
  243. ldd 16(%r25), %r21
  244. ldd 24(%r25), %r22
  245. std %r19, 0(%r26)
  246. std %r20, 8(%r26)
  247. ldd 32(%r25), %r19
  248. ldd 40(%r25), %r20
  249. std %r21, 16(%r26)
  250. std %r22, 24(%r26)
  251. ldd 48(%r25), %r21
  252. ldd 56(%r25), %r22
  253. std %r19, 32(%r26)
  254. std %r20, 40(%r26)
  255. ldd 64(%r25), %r19
  256. ldd 72(%r25), %r20
  257. std %r21, 48(%r26)
  258. std %r22, 56(%r26)
  259. ldd 80(%r25), %r21
  260. ldd 88(%r25), %r22
  261. std %r19, 64(%r26)
  262. std %r20, 72(%r26)
  263. ldd 96(%r25), %r19
  264. ldd 104(%r25), %r20
  265. std %r21, 80(%r26)
  266. std %r22, 88(%r26)
  267. ldd 112(%r25), %r21
  268. ldd 120(%r25), %r22
  269. std %r19, 96(%r26)
  270. std %r20, 104(%r26)
  271. ldo 128(%r25), %r25
  272. std %r21, 112(%r26)
  273. std %r22, 120(%r26)
  274. ldo 128(%r26), %r26
  275. /* conditional branches nullify on forward taken branch, and on
  276. * non-taken backward branch. Note that .+4 is a backwards branch.
  277. * The ldd should only get executed if the branch is taken.
  278. */
  279. addib,COND(>),n -1, %r1, 1b /* bundle 10 */
  280. ldd 0(%r25), %r19 /* start next loads */
  281. #else
  282. /*
  283. * This loop is optimized for PCXL/PCXL2 ldw/ldw and stw/stw
  284. * bundles (very restricted rules for bundling).
  285. * Note that until (if) we start saving
  286. * the full 64 bit register values on interrupt, we can't
  287. * use ldd/std on a 32 bit kernel.
  288. */
  289. ldw 0(%r25), %r19
  290. ldi (PAGE_SIZE / 64), %r1
  291. 1:
  292. ldw 4(%r25), %r20
  293. ldw 8(%r25), %r21
  294. ldw 12(%r25), %r22
  295. stw %r19, 0(%r26)
  296. stw %r20, 4(%r26)
  297. stw %r21, 8(%r26)
  298. stw %r22, 12(%r26)
  299. ldw 16(%r25), %r19
  300. ldw 20(%r25), %r20
  301. ldw 24(%r25), %r21
  302. ldw 28(%r25), %r22
  303. stw %r19, 16(%r26)
  304. stw %r20, 20(%r26)
  305. stw %r21, 24(%r26)
  306. stw %r22, 28(%r26)
  307. ldw 32(%r25), %r19
  308. ldw 36(%r25), %r20
  309. ldw 40(%r25), %r21
  310. ldw 44(%r25), %r22
  311. stw %r19, 32(%r26)
  312. stw %r20, 36(%r26)
  313. stw %r21, 40(%r26)
  314. stw %r22, 44(%r26)
  315. ldw 48(%r25), %r19
  316. ldw 52(%r25), %r20
  317. ldw 56(%r25), %r21
  318. ldw 60(%r25), %r22
  319. stw %r19, 48(%r26)
  320. stw %r20, 52(%r26)
  321. ldo 64(%r25), %r25
  322. stw %r21, 56(%r26)
  323. stw %r22, 60(%r26)
  324. ldo 64(%r26), %r26
  325. addib,COND(>),n -1, %r1, 1b
  326. ldw 0(%r25), %r19
  327. #endif
  328. bv %r0(%r2)
  329. nop
  330. .exit
  331. .procend
  332. ENDPROC(copy_user_page_asm)
  333. /*
  334. * NOTE: Code in clear_user_page has a hard coded dependency on the
  335. * maximum alias boundary being 4 Mb. We've been assured by the
  336. * parisc chip designers that there will not ever be a parisc
  337. * chip with a larger alias boundary (Never say never :-) ).
  338. *
  339. * Subtle: the dtlb miss handlers support the temp alias region by
  340. * "knowing" that if a dtlb miss happens within the temp alias
  341. * region it must have occurred while in clear_user_page. Since
  342. * this routine makes use of processor local translations, we
  343. * don't want to insert them into the kernel page table. Instead,
  344. * we load up some general registers (they need to be registers
  345. * which aren't shadowed) with the physical page numbers (preshifted
  346. * for tlb insertion) needed to insert the translations. When we
  347. * miss on the translation, the dtlb miss handler inserts the
  348. * translation into the tlb using these values:
  349. *
  350. * %r26 physical page (shifted for tlb insert) of "to" translation
  351. * %r23 physical page (shifted for tlb insert) of "from" translation
  352. */
  353. #if 0
  354. /*
  355. * We can't do this since copy_user_page is used to bring in
  356. * file data that might have instructions. Since the data would
  357. * then need to be flushed out so the i-fetch can see it, it
  358. * makes more sense to just copy through the kernel translation
  359. * and flush it.
  360. *
  361. * I'm still keeping this around because it may be possible to
  362. * use it if more information is passed into copy_user_page().
  363. * Have to do some measurements to see if it is worthwhile to
  364. * lobby for such a change.
  365. */
  366. ENTRY(copy_user_page_asm)
  367. .proc
  368. .callinfo NO_CALLS
  369. .entry
  370. ldil L%(__PAGE_OFFSET), %r1
  371. sub %r26, %r1, %r26
  372. sub %r25, %r1, %r23 /* move physical addr into non shadowed reg */
  373. ldil L%(TMPALIAS_MAP_START), %r28
  374. /* FIXME for different page sizes != 4k */
  375. #ifdef CONFIG_64BIT
  376. extrd,u %r26,56,32, %r26 /* convert phys addr to tlb insert format */
  377. extrd,u %r23,56,32, %r23 /* convert phys addr to tlb insert format */
  378. depd %r24,63,22, %r28 /* Form aliased virtual address 'to' */
  379. depdi 0, 63,12, %r28 /* Clear any offset bits */
  380. copy %r28, %r29
  381. depdi 1, 41,1, %r29 /* Form aliased virtual address 'from' */
  382. #else
  383. extrw,u %r26, 24,25, %r26 /* convert phys addr to tlb insert format */
  384. extrw,u %r23, 24,25, %r23 /* convert phys addr to tlb insert format */
  385. depw %r24, 31,22, %r28 /* Form aliased virtual address 'to' */
  386. depwi 0, 31,12, %r28 /* Clear any offset bits */
  387. copy %r28, %r29
  388. depwi 1, 9,1, %r29 /* Form aliased virtual address 'from' */
  389. #endif
  390. /* Purge any old translations */
  391. pdtlb 0(%r28)
  392. pdtlb 0(%r29)
  393. ldi 64, %r1
  394. /*
  395. * This loop is optimized for PCXL/PCXL2 ldw/ldw and stw/stw
  396. * bundles (very restricted rules for bundling). It probably
  397. * does OK on PCXU and better, but we could do better with
  398. * ldd/std instructions. Note that until (if) we start saving
  399. * the full 64 bit register values on interrupt, we can't
  400. * use ldd/std on a 32 bit kernel.
  401. */
  402. 1:
  403. ldw 0(%r29), %r19
  404. ldw 4(%r29), %r20
  405. ldw 8(%r29), %r21
  406. ldw 12(%r29), %r22
  407. stw %r19, 0(%r28)
  408. stw %r20, 4(%r28)
  409. stw %r21, 8(%r28)
  410. stw %r22, 12(%r28)
  411. ldw 16(%r29), %r19
  412. ldw 20(%r29), %r20
  413. ldw 24(%r29), %r21
  414. ldw 28(%r29), %r22
  415. stw %r19, 16(%r28)
  416. stw %r20, 20(%r28)
  417. stw %r21, 24(%r28)
  418. stw %r22, 28(%r28)
  419. ldw 32(%r29), %r19
  420. ldw 36(%r29), %r20
  421. ldw 40(%r29), %r21
  422. ldw 44(%r29), %r22
  423. stw %r19, 32(%r28)
  424. stw %r20, 36(%r28)
  425. stw %r21, 40(%r28)
  426. stw %r22, 44(%r28)
  427. ldw 48(%r29), %r19
  428. ldw 52(%r29), %r20
  429. ldw 56(%r29), %r21
  430. ldw 60(%r29), %r22
  431. stw %r19, 48(%r28)
  432. stw %r20, 52(%r28)
  433. stw %r21, 56(%r28)
  434. stw %r22, 60(%r28)
  435. ldo 64(%r28), %r28
  436. addib,COND(>) -1, %r1,1b
  437. ldo 64(%r29), %r29
  438. bv %r0(%r2)
  439. nop
  440. .exit
  441. .procend
  442. ENDPROC(copy_user_page_asm)
  443. #endif
  444. ENTRY(__clear_user_page_asm)
  445. .proc
  446. .callinfo NO_CALLS
  447. .entry
  448. tophys_r1 %r26
  449. ldil L%(TMPALIAS_MAP_START), %r28
  450. #ifdef CONFIG_64BIT
  451. #if (TMPALIAS_MAP_START >= 0x80000000)
  452. depdi 0, 31,32, %r28 /* clear any sign extension */
  453. /* FIXME: page size dependend */
  454. #endif
  455. extrd,u %r26, 56,32, %r26 /* convert phys addr to tlb insert format */
  456. depd %r25, 63,22, %r28 /* Form aliased virtual address 'to' */
  457. depdi 0, 63,12, %r28 /* Clear any offset bits */
  458. #else
  459. extrw,u %r26, 24,25, %r26 /* convert phys addr to tlb insert format */
  460. depw %r25, 31,22, %r28 /* Form aliased virtual address 'to' */
  461. depwi 0, 31,12, %r28 /* Clear any offset bits */
  462. #endif
  463. /* Purge any old translation */
  464. pdtlb 0(%r28)
  465. #ifdef CONFIG_64BIT
  466. ldi (PAGE_SIZE / 128), %r1
  467. /* PREFETCH (Write) has not (yet) been proven to help here */
  468. /* #define PREFETCHW_OP ldd 256(%0), %r0 */
  469. 1: std %r0, 0(%r28)
  470. std %r0, 8(%r28)
  471. std %r0, 16(%r28)
  472. std %r0, 24(%r28)
  473. std %r0, 32(%r28)
  474. std %r0, 40(%r28)
  475. std %r0, 48(%r28)
  476. std %r0, 56(%r28)
  477. std %r0, 64(%r28)
  478. std %r0, 72(%r28)
  479. std %r0, 80(%r28)
  480. std %r0, 88(%r28)
  481. std %r0, 96(%r28)
  482. std %r0, 104(%r28)
  483. std %r0, 112(%r28)
  484. std %r0, 120(%r28)
  485. addib,COND(>) -1, %r1, 1b
  486. ldo 128(%r28), %r28
  487. #else /* ! CONFIG_64BIT */
  488. ldi (PAGE_SIZE / 64), %r1
  489. 1:
  490. stw %r0, 0(%r28)
  491. stw %r0, 4(%r28)
  492. stw %r0, 8(%r28)
  493. stw %r0, 12(%r28)
  494. stw %r0, 16(%r28)
  495. stw %r0, 20(%r28)
  496. stw %r0, 24(%r28)
  497. stw %r0, 28(%r28)
  498. stw %r0, 32(%r28)
  499. stw %r0, 36(%r28)
  500. stw %r0, 40(%r28)
  501. stw %r0, 44(%r28)
  502. stw %r0, 48(%r28)
  503. stw %r0, 52(%r28)
  504. stw %r0, 56(%r28)
  505. stw %r0, 60(%r28)
  506. addib,COND(>) -1, %r1, 1b
  507. ldo 64(%r28), %r28
  508. #endif /* CONFIG_64BIT */
  509. bv %r0(%r2)
  510. nop
  511. .exit
  512. .procend
  513. ENDPROC(__clear_user_page_asm)
  514. ENTRY(flush_dcache_page_asm)
  515. .proc
  516. .callinfo NO_CALLS
  517. .entry
  518. ldil L%(TMPALIAS_MAP_START), %r28
  519. #ifdef CONFIG_64BIT
  520. #if (TMPALIAS_MAP_START >= 0x80000000)
  521. depdi 0, 31,32, %r28 /* clear any sign extension */
  522. /* FIXME: page size dependend */
  523. #endif
  524. extrd,u %r26, 56,32, %r26 /* convert phys addr to tlb insert format */
  525. depd %r25, 63,22, %r28 /* Form aliased virtual address 'to' */
  526. depdi 0, 63,12, %r28 /* Clear any offset bits */
  527. #else
  528. extrw,u %r26, 24,25, %r26 /* convert phys addr to tlb insert format */
  529. depw %r25, 31,22, %r28 /* Form aliased virtual address 'to' */
  530. depwi 0, 31,12, %r28 /* Clear any offset bits */
  531. #endif
  532. /* Purge any old translation */
  533. pdtlb 0(%r28)
  534. ldil L%dcache_stride, %r1
  535. ldw R%dcache_stride(%r1), %r1
  536. #ifdef CONFIG_64BIT
  537. depdi,z 1, 63-PAGE_SHIFT,1, %r25
  538. #else
  539. depwi,z 1, 31-PAGE_SHIFT,1, %r25
  540. #endif
  541. add %r28, %r25, %r25
  542. sub %r25, %r1, %r25
  543. 1: fdc,m %r1(%r28)
  544. fdc,m %r1(%r28)
  545. fdc,m %r1(%r28)
  546. fdc,m %r1(%r28)
  547. fdc,m %r1(%r28)
  548. fdc,m %r1(%r28)
  549. fdc,m %r1(%r28)
  550. fdc,m %r1(%r28)
  551. fdc,m %r1(%r28)
  552. fdc,m %r1(%r28)
  553. fdc,m %r1(%r28)
  554. fdc,m %r1(%r28)
  555. fdc,m %r1(%r28)
  556. fdc,m %r1(%r28)
  557. fdc,m %r1(%r28)
  558. cmpb,COND(<<) %r28, %r25,1b
  559. fdc,m %r1(%r28)
  560. sync
  561. bv %r0(%r2)
  562. pdtlb (%r25)
  563. .exit
  564. .procend
  565. ENDPROC(flush_dcache_page_asm)
  566. ENTRY(flush_icache_page_asm)
  567. .proc
  568. .callinfo NO_CALLS
  569. .entry
  570. ldil L%(TMPALIAS_MAP_START), %r28
  571. #ifdef CONFIG_64BIT
  572. #if (TMPALIAS_MAP_START >= 0x80000000)
  573. depdi 0, 31,32, %r28 /* clear any sign extension */
  574. /* FIXME: page size dependend */
  575. #endif
  576. extrd,u %r26, 56,32, %r26 /* convert phys addr to tlb insert format */
  577. depd %r25, 63,22, %r28 /* Form aliased virtual address 'to' */
  578. depdi 0, 63,12, %r28 /* Clear any offset bits */
  579. #else
  580. extrw,u %r26, 24,25, %r26 /* convert phys addr to tlb insert format */
  581. depw %r25, 31,22, %r28 /* Form aliased virtual address 'to' */
  582. depwi 0, 31,12, %r28 /* Clear any offset bits */
  583. #endif
  584. /* Purge any old translation */
  585. pitlb (%sr0,%r28)
  586. ldil L%icache_stride, %r1
  587. ldw R%icache_stride(%r1), %r1
  588. #ifdef CONFIG_64BIT
  589. depdi,z 1, 63-PAGE_SHIFT,1, %r25
  590. #else
  591. depwi,z 1, 31-PAGE_SHIFT,1, %r25
  592. #endif
  593. add %r28, %r25, %r25
  594. sub %r25, %r1, %r25
  595. 1: fic,m %r1(%r28)
  596. fic,m %r1(%r28)
  597. fic,m %r1(%r28)
  598. fic,m %r1(%r28)
  599. fic,m %r1(%r28)
  600. fic,m %r1(%r28)
  601. fic,m %r1(%r28)
  602. fic,m %r1(%r28)
  603. fic,m %r1(%r28)
  604. fic,m %r1(%r28)
  605. fic,m %r1(%r28)
  606. fic,m %r1(%r28)
  607. fic,m %r1(%r28)
  608. fic,m %r1(%r28)
  609. fic,m %r1(%r28)
  610. cmpb,COND(<<) %r28, %r25,1b
  611. fic,m %r1(%r28)
  612. sync
  613. bv %r0(%r2)
  614. pitlb (%sr0,%r25)
  615. .exit
  616. .procend
  617. ENDPROC(flush_icache_page_asm)
  618. ENTRY(flush_kernel_dcache_page_asm)
  619. .proc
  620. .callinfo NO_CALLS
  621. .entry
  622. ldil L%dcache_stride, %r1
  623. ldw R%dcache_stride(%r1), %r23
  624. #ifdef CONFIG_64BIT
  625. depdi,z 1, 63-PAGE_SHIFT,1, %r25
  626. #else
  627. depwi,z 1, 31-PAGE_SHIFT,1, %r25
  628. #endif
  629. add %r26, %r25, %r25
  630. sub %r25, %r23, %r25
  631. 1: fdc,m %r23(%r26)
  632. fdc,m %r23(%r26)
  633. fdc,m %r23(%r26)
  634. fdc,m %r23(%r26)
  635. fdc,m %r23(%r26)
  636. fdc,m %r23(%r26)
  637. fdc,m %r23(%r26)
  638. fdc,m %r23(%r26)
  639. fdc,m %r23(%r26)
  640. fdc,m %r23(%r26)
  641. fdc,m %r23(%r26)
  642. fdc,m %r23(%r26)
  643. fdc,m %r23(%r26)
  644. fdc,m %r23(%r26)
  645. fdc,m %r23(%r26)
  646. cmpb,COND(<<) %r26, %r25,1b
  647. fdc,m %r23(%r26)
  648. sync
  649. bv %r0(%r2)
  650. nop
  651. .exit
  652. .procend
  653. ENDPROC(flush_kernel_dcache_page_asm)
  654. ENTRY(purge_kernel_dcache_page)
  655. .proc
  656. .callinfo NO_CALLS
  657. .entry
  658. ldil L%dcache_stride, %r1
  659. ldw R%dcache_stride(%r1), %r23
  660. #ifdef CONFIG_64BIT
  661. depdi,z 1, 63-PAGE_SHIFT,1, %r25
  662. #else
  663. depwi,z 1, 31-PAGE_SHIFT,1, %r25
  664. #endif
  665. add %r26, %r25, %r25
  666. sub %r25, %r23, %r25
  667. 1: pdc,m %r23(%r26)
  668. pdc,m %r23(%r26)
  669. pdc,m %r23(%r26)
  670. pdc,m %r23(%r26)
  671. pdc,m %r23(%r26)
  672. pdc,m %r23(%r26)
  673. pdc,m %r23(%r26)
  674. pdc,m %r23(%r26)
  675. pdc,m %r23(%r26)
  676. pdc,m %r23(%r26)
  677. pdc,m %r23(%r26)
  678. pdc,m %r23(%r26)
  679. pdc,m %r23(%r26)
  680. pdc,m %r23(%r26)
  681. pdc,m %r23(%r26)
  682. cmpb,COND(<<) %r26, %r25, 1b
  683. pdc,m %r23(%r26)
  684. sync
  685. bv %r0(%r2)
  686. nop
  687. .exit
  688. .procend
  689. ENDPROC(purge_kernel_dcache_page)
  690. ENTRY(flush_user_dcache_range_asm)
  691. .proc
  692. .callinfo NO_CALLS
  693. .entry
  694. ldil L%dcache_stride, %r1
  695. ldw R%dcache_stride(%r1), %r23
  696. ldo -1(%r23), %r21
  697. ANDCM %r26, %r21, %r26
  698. 1: cmpb,COND(<<),n %r26, %r25, 1b
  699. fdc,m %r23(%sr3, %r26)
  700. sync
  701. bv %r0(%r2)
  702. nop
  703. .exit
  704. .procend
  705. ENDPROC(flush_user_dcache_range_asm)
  706. ENTRY(flush_kernel_dcache_range_asm)
  707. .proc
  708. .callinfo NO_CALLS
  709. .entry
  710. ldil L%dcache_stride, %r1
  711. ldw R%dcache_stride(%r1), %r23
  712. ldo -1(%r23), %r21
  713. ANDCM %r26, %r21, %r26
  714. 1: cmpb,COND(<<),n %r26, %r25,1b
  715. fdc,m %r23(%r26)
  716. sync
  717. syncdma
  718. bv %r0(%r2)
  719. nop
  720. .exit
  721. .procend
  722. ENDPROC(flush_kernel_dcache_range_asm)
  723. ENTRY(flush_user_icache_range_asm)
  724. .proc
  725. .callinfo NO_CALLS
  726. .entry
  727. ldil L%icache_stride, %r1
  728. ldw R%icache_stride(%r1), %r23
  729. ldo -1(%r23), %r21
  730. ANDCM %r26, %r21, %r26
  731. 1: cmpb,COND(<<),n %r26, %r25,1b
  732. fic,m %r23(%sr3, %r26)
  733. sync
  734. bv %r0(%r2)
  735. nop
  736. .exit
  737. .procend
  738. ENDPROC(flush_user_icache_range_asm)
  739. ENTRY(flush_kernel_icache_page)
  740. .proc
  741. .callinfo NO_CALLS
  742. .entry
  743. ldil L%icache_stride, %r1
  744. ldw R%icache_stride(%r1), %r23
  745. #ifdef CONFIG_64BIT
  746. depdi,z 1, 63-PAGE_SHIFT,1, %r25
  747. #else
  748. depwi,z 1, 31-PAGE_SHIFT,1, %r25
  749. #endif
  750. add %r26, %r25, %r25
  751. sub %r25, %r23, %r25
  752. 1: fic,m %r23(%sr4, %r26)
  753. fic,m %r23(%sr4, %r26)
  754. fic,m %r23(%sr4, %r26)
  755. fic,m %r23(%sr4, %r26)
  756. fic,m %r23(%sr4, %r26)
  757. fic,m %r23(%sr4, %r26)
  758. fic,m %r23(%sr4, %r26)
  759. fic,m %r23(%sr4, %r26)
  760. fic,m %r23(%sr4, %r26)
  761. fic,m %r23(%sr4, %r26)
  762. fic,m %r23(%sr4, %r26)
  763. fic,m %r23(%sr4, %r26)
  764. fic,m %r23(%sr4, %r26)
  765. fic,m %r23(%sr4, %r26)
  766. fic,m %r23(%sr4, %r26)
  767. cmpb,COND(<<) %r26, %r25, 1b
  768. fic,m %r23(%sr4, %r26)
  769. sync
  770. bv %r0(%r2)
  771. nop
  772. .exit
  773. .procend
  774. ENDPROC(flush_kernel_icache_page)
  775. ENTRY(flush_kernel_icache_range_asm)
  776. .proc
  777. .callinfo NO_CALLS
  778. .entry
  779. ldil L%icache_stride, %r1
  780. ldw R%icache_stride(%r1), %r23
  781. ldo -1(%r23), %r21
  782. ANDCM %r26, %r21, %r26
  783. 1: cmpb,COND(<<),n %r26, %r25, 1b
  784. fic,m %r23(%sr4, %r26)
  785. sync
  786. bv %r0(%r2)
  787. nop
  788. .exit
  789. .procend
  790. ENDPROC(flush_kernel_icache_range_asm)
  791. /* align should cover use of rfi in disable_sr_hashing_asm and
  792. * srdis_done.
  793. */
  794. .align 256
  795. ENTRY(disable_sr_hashing_asm)
  796. .proc
  797. .callinfo NO_CALLS
  798. .entry
  799. /*
  800. * Switch to real mode
  801. */
  802. /* pcxt_ssm_bug */
  803. rsm PSW_SM_I, %r0
  804. load32 PA(1f), %r1
  805. nop
  806. nop
  807. nop
  808. nop
  809. nop
  810. rsm PSW_SM_Q, %r0 /* prep to load iia queue */
  811. mtctl %r0, %cr17 /* Clear IIASQ tail */
  812. mtctl %r0, %cr17 /* Clear IIASQ head */
  813. mtctl %r1, %cr18 /* IIAOQ head */
  814. ldo 4(%r1), %r1
  815. mtctl %r1, %cr18 /* IIAOQ tail */
  816. load32 REAL_MODE_PSW, %r1
  817. mtctl %r1, %ipsw
  818. rfi
  819. nop
  820. 1: cmpib,=,n SRHASH_PCXST, %r26,srdis_pcxs
  821. cmpib,=,n SRHASH_PCXL, %r26,srdis_pcxl
  822. cmpib,=,n SRHASH_PA20, %r26,srdis_pa20
  823. b,n srdis_done
  824. srdis_pcxs:
  825. /* Disable Space Register Hashing for PCXS,PCXT,PCXT' */
  826. .word 0x141c1a00 /* mfdiag %dr0, %r28 */
  827. .word 0x141c1a00 /* must issue twice */
  828. depwi 0,18,1, %r28 /* Clear DHE (dcache hash enable) */
  829. depwi 0,20,1, %r28 /* Clear IHE (icache hash enable) */
  830. .word 0x141c1600 /* mtdiag %r28, %dr0 */
  831. .word 0x141c1600 /* must issue twice */
  832. b,n srdis_done
  833. srdis_pcxl:
  834. /* Disable Space Register Hashing for PCXL */
  835. .word 0x141c0600 /* mfdiag %dr0, %r28 */
  836. depwi 0,28,2, %r28 /* Clear DHASH_EN & IHASH_EN */
  837. .word 0x141c0240 /* mtdiag %r28, %dr0 */
  838. b,n srdis_done
  839. srdis_pa20:
  840. /* Disable Space Register Hashing for PCXU,PCXU+,PCXW,PCXW+,PCXW2 */
  841. .word 0x144008bc /* mfdiag %dr2, %r28 */
  842. depdi 0, 54,1, %r28 /* clear DIAG_SPHASH_ENAB (bit 54) */
  843. .word 0x145c1840 /* mtdiag %r28, %dr2 */
  844. srdis_done:
  845. /* Switch back to virtual mode */
  846. rsm PSW_SM_I, %r0 /* prep to load iia queue */
  847. load32 2f, %r1
  848. nop
  849. nop
  850. nop
  851. nop
  852. nop
  853. rsm PSW_SM_Q, %r0 /* prep to load iia queue */
  854. mtctl %r0, %cr17 /* Clear IIASQ tail */
  855. mtctl %r0, %cr17 /* Clear IIASQ head */
  856. mtctl %r1, %cr18 /* IIAOQ head */
  857. ldo 4(%r1), %r1
  858. mtctl %r1, %cr18 /* IIAOQ tail */
  859. load32 KERNEL_PSW, %r1
  860. mtctl %r1, %ipsw
  861. rfi
  862. nop
  863. 2: bv %r0(%r2)
  864. nop
  865. .exit
  866. .procend
  867. ENDPROC(disable_sr_hashing_asm)
  868. .end