pacache.S 24 KB

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