pacache.S 24 KB

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