octeon_switch.S 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1994, 1995, 1996, 1998, 1999, 2002, 2003 Ralf Baechle
  7. * Copyright (C) 1996 David S. Miller (davem@davemloft.net)
  8. * Copyright (C) 1994, 1995, 1996, by Andreas Busse
  9. * Copyright (C) 1999 Silicon Graphics, Inc.
  10. * Copyright (C) 2000 MIPS Technologies, Inc.
  11. * written by Carsten Langgaard, carstenl@mips.com
  12. */
  13. #define USE_ALTERNATE_RESUME_IMPL 1
  14. .set push
  15. .set arch=mips64r2
  16. #include "r4k_switch.S"
  17. .set pop
  18. /*
  19. * task_struct *resume(task_struct *prev, task_struct *next,
  20. * struct thread_info *next_ti, int usedfpu)
  21. */
  22. .align 7
  23. LEAF(resume)
  24. .set arch=octeon
  25. mfc0 t1, CP0_STATUS
  26. LONG_S t1, THREAD_STATUS(a0)
  27. cpu_save_nonscratch a0
  28. LONG_S ra, THREAD_REG31(a0)
  29. /*
  30. * check if we need to save FPU registers
  31. */
  32. .set push
  33. .set noreorder
  34. beqz a3, 1f
  35. PTR_L t3, TASK_THREAD_INFO(a0)
  36. .set pop
  37. /*
  38. * clear saved user stack CU1 bit
  39. */
  40. LONG_L t0, ST_OFF(t3)
  41. li t1, ~ST0_CU1
  42. and t0, t0, t1
  43. LONG_S t0, ST_OFF(t3)
  44. .set push
  45. .set arch=mips64r2
  46. fpu_save_double a0 t0 t1 # c0_status passed in t0
  47. # clobbers t1
  48. .set pop
  49. 1:
  50. #if CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0
  51. /* Check if we need to store CVMSEG state */
  52. dmfc0 t0, $11,7 /* CvmMemCtl */
  53. bbit0 t0, 6, 3f /* Is user access enabled? */
  54. /* Store the CVMSEG state */
  55. /* Extract the size of CVMSEG */
  56. andi t0, 0x3f
  57. /* Multiply * (cache line size/sizeof(long)/2) */
  58. sll t0, 7-LONGLOG-1
  59. li t1, -32768 /* Base address of CVMSEG */
  60. LONG_ADDI t2, a0, THREAD_CVMSEG /* Where to store CVMSEG to */
  61. synciobdma
  62. 2:
  63. .set noreorder
  64. LONG_L t8, 0(t1) /* Load from CVMSEG */
  65. subu t0, 1 /* Decrement loop var */
  66. LONG_L t9, LONGSIZE(t1)/* Load from CVMSEG */
  67. LONG_ADDU t1, LONGSIZE*2 /* Increment loc in CVMSEG */
  68. LONG_S t8, 0(t2) /* Store CVMSEG to thread storage */
  69. LONG_ADDU t2, LONGSIZE*2 /* Increment loc in thread storage */
  70. bnez t0, 2b /* Loop until we've copied it all */
  71. LONG_S t9, -LONGSIZE(t2)/* Store CVMSEG to thread storage */
  72. .set reorder
  73. /* Disable access to CVMSEG */
  74. dmfc0 t0, $11,7 /* CvmMemCtl */
  75. xori t0, t0, 0x40 /* Bit 6 is CVMSEG user enable */
  76. dmtc0 t0, $11,7 /* CvmMemCtl */
  77. #endif
  78. 3:
  79. #if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
  80. PTR_LA t8, __stack_chk_guard
  81. LONG_L t9, TASK_STACK_CANARY(a1)
  82. LONG_S t9, 0(t8)
  83. #endif
  84. /*
  85. * The order of restoring the registers takes care of the race
  86. * updating $28, $29 and kernelsp without disabling ints.
  87. */
  88. move $28, a2
  89. cpu_restore_nonscratch a1
  90. PTR_ADDU t0, $28, _THREAD_SIZE - 32
  91. set_saved_sp t0, t1, t2
  92. mfc0 t1, CP0_STATUS /* Do we really need this? */
  93. li a3, 0xff01
  94. and t1, a3
  95. LONG_L a2, THREAD_STATUS(a1)
  96. nor a3, $0, a3
  97. and a2, a3
  98. or a2, t1
  99. mtc0 a2, CP0_STATUS
  100. move v0, a0
  101. jr ra
  102. END(resume)
  103. /*
  104. * void octeon_cop2_save(struct octeon_cop2_state *a0)
  105. */
  106. .align 7
  107. .set push
  108. .set noreorder
  109. LEAF(octeon_cop2_save)
  110. dmfc0 t9, $9,7 /* CvmCtl register. */
  111. /* Save the COP2 CRC state */
  112. dmfc2 t0, 0x0201
  113. dmfc2 t1, 0x0202
  114. dmfc2 t2, 0x0200
  115. sd t0, OCTEON_CP2_CRC_IV(a0)
  116. sd t1, OCTEON_CP2_CRC_LENGTH(a0)
  117. /* Skip next instructions if CvmCtl[NODFA_CP2] set */
  118. bbit1 t9, 28, 1f
  119. sd t2, OCTEON_CP2_CRC_POLY(a0)
  120. /* Save the LLM state */
  121. dmfc2 t0, 0x0402
  122. dmfc2 t1, 0x040A
  123. sd t0, OCTEON_CP2_LLM_DAT(a0)
  124. 1: bbit1 t9, 26, 3f /* done if CvmCtl[NOCRYPTO] set */
  125. sd t1, OCTEON_CP2_LLM_DAT+8(a0)
  126. /* Save the COP2 crypto state */
  127. /* this part is mostly common to both pass 1 and later revisions */
  128. dmfc2 t0, 0x0084
  129. dmfc2 t1, 0x0080
  130. dmfc2 t2, 0x0081
  131. dmfc2 t3, 0x0082
  132. sd t0, OCTEON_CP2_3DES_IV(a0)
  133. dmfc2 t0, 0x0088
  134. sd t1, OCTEON_CP2_3DES_KEY(a0)
  135. dmfc2 t1, 0x0111 /* only necessary for pass 1 */
  136. sd t2, OCTEON_CP2_3DES_KEY+8(a0)
  137. dmfc2 t2, 0x0102
  138. sd t3, OCTEON_CP2_3DES_KEY+16(a0)
  139. dmfc2 t3, 0x0103
  140. sd t0, OCTEON_CP2_3DES_RESULT(a0)
  141. dmfc2 t0, 0x0104
  142. sd t1, OCTEON_CP2_AES_INP0(a0) /* only necessary for pass 1 */
  143. dmfc2 t1, 0x0105
  144. sd t2, OCTEON_CP2_AES_IV(a0)
  145. dmfc2 t2, 0x0106
  146. sd t3, OCTEON_CP2_AES_IV+8(a0)
  147. dmfc2 t3, 0x0107
  148. sd t0, OCTEON_CP2_AES_KEY(a0)
  149. dmfc2 t0, 0x0110
  150. sd t1, OCTEON_CP2_AES_KEY+8(a0)
  151. dmfc2 t1, 0x0100
  152. sd t2, OCTEON_CP2_AES_KEY+16(a0)
  153. dmfc2 t2, 0x0101
  154. sd t3, OCTEON_CP2_AES_KEY+24(a0)
  155. mfc0 v0, $15,0 /* Get the processor ID register */
  156. sd t0, OCTEON_CP2_AES_KEYLEN(a0)
  157. li v1, 0x000d0000 /* This is the processor ID of Octeon Pass1 */
  158. sd t1, OCTEON_CP2_AES_RESULT(a0)
  159. /* Skip to the Pass1 version of the remainder of the COP2 state */
  160. beq v0, v1, 2f
  161. sd t2, OCTEON_CP2_AES_RESULT+8(a0)
  162. /* the non-pass1 state when !CvmCtl[NOCRYPTO] */
  163. dmfc2 t1, 0x0240
  164. dmfc2 t2, 0x0241
  165. ori v1, v1, 0x9500 /* lowest OCTEON III PrId*/
  166. dmfc2 t3, 0x0242
  167. subu v1, v0, v1 /* prid - lowest OCTEON III PrId */
  168. dmfc2 t0, 0x0243
  169. sd t1, OCTEON_CP2_HSH_DATW(a0)
  170. dmfc2 t1, 0x0244
  171. sd t2, OCTEON_CP2_HSH_DATW+8(a0)
  172. dmfc2 t2, 0x0245
  173. sd t3, OCTEON_CP2_HSH_DATW+16(a0)
  174. dmfc2 t3, 0x0246
  175. sd t0, OCTEON_CP2_HSH_DATW+24(a0)
  176. dmfc2 t0, 0x0247
  177. sd t1, OCTEON_CP2_HSH_DATW+32(a0)
  178. dmfc2 t1, 0x0248
  179. sd t2, OCTEON_CP2_HSH_DATW+40(a0)
  180. dmfc2 t2, 0x0249
  181. sd t3, OCTEON_CP2_HSH_DATW+48(a0)
  182. dmfc2 t3, 0x024A
  183. sd t0, OCTEON_CP2_HSH_DATW+56(a0)
  184. dmfc2 t0, 0x024B
  185. sd t1, OCTEON_CP2_HSH_DATW+64(a0)
  186. dmfc2 t1, 0x024C
  187. sd t2, OCTEON_CP2_HSH_DATW+72(a0)
  188. dmfc2 t2, 0x024D
  189. sd t3, OCTEON_CP2_HSH_DATW+80(a0)
  190. dmfc2 t3, 0x024E
  191. sd t0, OCTEON_CP2_HSH_DATW+88(a0)
  192. dmfc2 t0, 0x0250
  193. sd t1, OCTEON_CP2_HSH_DATW+96(a0)
  194. dmfc2 t1, 0x0251
  195. sd t2, OCTEON_CP2_HSH_DATW+104(a0)
  196. dmfc2 t2, 0x0252
  197. sd t3, OCTEON_CP2_HSH_DATW+112(a0)
  198. dmfc2 t3, 0x0253
  199. sd t0, OCTEON_CP2_HSH_IVW(a0)
  200. dmfc2 t0, 0x0254
  201. sd t1, OCTEON_CP2_HSH_IVW+8(a0)
  202. dmfc2 t1, 0x0255
  203. sd t2, OCTEON_CP2_HSH_IVW+16(a0)
  204. dmfc2 t2, 0x0256
  205. sd t3, OCTEON_CP2_HSH_IVW+24(a0)
  206. dmfc2 t3, 0x0257
  207. sd t0, OCTEON_CP2_HSH_IVW+32(a0)
  208. dmfc2 t0, 0x0258
  209. sd t1, OCTEON_CP2_HSH_IVW+40(a0)
  210. dmfc2 t1, 0x0259
  211. sd t2, OCTEON_CP2_HSH_IVW+48(a0)
  212. dmfc2 t2, 0x025E
  213. sd t3, OCTEON_CP2_HSH_IVW+56(a0)
  214. dmfc2 t3, 0x025A
  215. sd t0, OCTEON_CP2_GFM_MULT(a0)
  216. dmfc2 t0, 0x025B
  217. sd t1, OCTEON_CP2_GFM_MULT+8(a0)
  218. sd t2, OCTEON_CP2_GFM_POLY(a0)
  219. sd t3, OCTEON_CP2_GFM_RESULT(a0)
  220. bltz v1, 4f
  221. sd t0, OCTEON_CP2_GFM_RESULT+8(a0)
  222. /* OCTEON III things*/
  223. dmfc2 t0, 0x024F
  224. dmfc2 t1, 0x0050
  225. sd t0, OCTEON_CP2_SHA3(a0)
  226. sd t1, OCTEON_CP2_SHA3+8(a0)
  227. 4:
  228. jr ra
  229. nop
  230. 2: /* pass 1 special stuff when !CvmCtl[NOCRYPTO] */
  231. dmfc2 t3, 0x0040
  232. dmfc2 t0, 0x0041
  233. dmfc2 t1, 0x0042
  234. dmfc2 t2, 0x0043
  235. sd t3, OCTEON_CP2_HSH_DATW(a0)
  236. dmfc2 t3, 0x0044
  237. sd t0, OCTEON_CP2_HSH_DATW+8(a0)
  238. dmfc2 t0, 0x0045
  239. sd t1, OCTEON_CP2_HSH_DATW+16(a0)
  240. dmfc2 t1, 0x0046
  241. sd t2, OCTEON_CP2_HSH_DATW+24(a0)
  242. dmfc2 t2, 0x0048
  243. sd t3, OCTEON_CP2_HSH_DATW+32(a0)
  244. dmfc2 t3, 0x0049
  245. sd t0, OCTEON_CP2_HSH_DATW+40(a0)
  246. dmfc2 t0, 0x004A
  247. sd t1, OCTEON_CP2_HSH_DATW+48(a0)
  248. sd t2, OCTEON_CP2_HSH_IVW(a0)
  249. sd t3, OCTEON_CP2_HSH_IVW+8(a0)
  250. sd t0, OCTEON_CP2_HSH_IVW+16(a0)
  251. 3: /* pass 1 or CvmCtl[NOCRYPTO] set */
  252. jr ra
  253. nop
  254. END(octeon_cop2_save)
  255. .set pop
  256. /*
  257. * void octeon_cop2_restore(struct octeon_cop2_state *a0)
  258. */
  259. .align 7
  260. .set push
  261. .set noreorder
  262. LEAF(octeon_cop2_restore)
  263. /* First cache line was prefetched before the call */
  264. pref 4, 128(a0)
  265. dmfc0 t9, $9,7 /* CvmCtl register. */
  266. pref 4, 256(a0)
  267. ld t0, OCTEON_CP2_CRC_IV(a0)
  268. pref 4, 384(a0)
  269. ld t1, OCTEON_CP2_CRC_LENGTH(a0)
  270. ld t2, OCTEON_CP2_CRC_POLY(a0)
  271. /* Restore the COP2 CRC state */
  272. dmtc2 t0, 0x0201
  273. dmtc2 t1, 0x1202
  274. bbit1 t9, 28, 2f /* Skip LLM if CvmCtl[NODFA_CP2] is set */
  275. dmtc2 t2, 0x4200
  276. /* Restore the LLM state */
  277. ld t0, OCTEON_CP2_LLM_DAT(a0)
  278. ld t1, OCTEON_CP2_LLM_DAT+8(a0)
  279. dmtc2 t0, 0x0402
  280. dmtc2 t1, 0x040A
  281. 2:
  282. bbit1 t9, 26, done_restore /* done if CvmCtl[NOCRYPTO] set */
  283. nop
  284. /* Restore the COP2 crypto state common to pass 1 and pass 2 */
  285. ld t0, OCTEON_CP2_3DES_IV(a0)
  286. ld t1, OCTEON_CP2_3DES_KEY(a0)
  287. ld t2, OCTEON_CP2_3DES_KEY+8(a0)
  288. dmtc2 t0, 0x0084
  289. ld t0, OCTEON_CP2_3DES_KEY+16(a0)
  290. dmtc2 t1, 0x0080
  291. ld t1, OCTEON_CP2_3DES_RESULT(a0)
  292. dmtc2 t2, 0x0081
  293. ld t2, OCTEON_CP2_AES_INP0(a0) /* only really needed for pass 1 */
  294. dmtc2 t0, 0x0082
  295. ld t0, OCTEON_CP2_AES_IV(a0)
  296. dmtc2 t1, 0x0098
  297. ld t1, OCTEON_CP2_AES_IV+8(a0)
  298. dmtc2 t2, 0x010A /* only really needed for pass 1 */
  299. ld t2, OCTEON_CP2_AES_KEY(a0)
  300. dmtc2 t0, 0x0102
  301. ld t0, OCTEON_CP2_AES_KEY+8(a0)
  302. dmtc2 t1, 0x0103
  303. ld t1, OCTEON_CP2_AES_KEY+16(a0)
  304. dmtc2 t2, 0x0104
  305. ld t2, OCTEON_CP2_AES_KEY+24(a0)
  306. dmtc2 t0, 0x0105
  307. ld t0, OCTEON_CP2_AES_KEYLEN(a0)
  308. dmtc2 t1, 0x0106
  309. ld t1, OCTEON_CP2_AES_RESULT(a0)
  310. dmtc2 t2, 0x0107
  311. ld t2, OCTEON_CP2_AES_RESULT+8(a0)
  312. mfc0 t3, $15,0 /* Get the processor ID register */
  313. dmtc2 t0, 0x0110
  314. li v0, 0x000d0000 /* This is the processor ID of Octeon Pass1 */
  315. dmtc2 t1, 0x0100
  316. bne v0, t3, 3f /* Skip the next stuff for non-pass1 */
  317. dmtc2 t2, 0x0101
  318. /* this code is specific for pass 1 */
  319. ld t0, OCTEON_CP2_HSH_DATW(a0)
  320. ld t1, OCTEON_CP2_HSH_DATW+8(a0)
  321. ld t2, OCTEON_CP2_HSH_DATW+16(a0)
  322. dmtc2 t0, 0x0040
  323. ld t0, OCTEON_CP2_HSH_DATW+24(a0)
  324. dmtc2 t1, 0x0041
  325. ld t1, OCTEON_CP2_HSH_DATW+32(a0)
  326. dmtc2 t2, 0x0042
  327. ld t2, OCTEON_CP2_HSH_DATW+40(a0)
  328. dmtc2 t0, 0x0043
  329. ld t0, OCTEON_CP2_HSH_DATW+48(a0)
  330. dmtc2 t1, 0x0044
  331. ld t1, OCTEON_CP2_HSH_IVW(a0)
  332. dmtc2 t2, 0x0045
  333. ld t2, OCTEON_CP2_HSH_IVW+8(a0)
  334. dmtc2 t0, 0x0046
  335. ld t0, OCTEON_CP2_HSH_IVW+16(a0)
  336. dmtc2 t1, 0x0048
  337. dmtc2 t2, 0x0049
  338. b done_restore /* unconditional branch */
  339. dmtc2 t0, 0x004A
  340. 3: /* this is post-pass1 code */
  341. ld t2, OCTEON_CP2_HSH_DATW(a0)
  342. ori v0, v0, 0x9500 /* lowest OCTEON III PrId*/
  343. ld t0, OCTEON_CP2_HSH_DATW+8(a0)
  344. ld t1, OCTEON_CP2_HSH_DATW+16(a0)
  345. dmtc2 t2, 0x0240
  346. ld t2, OCTEON_CP2_HSH_DATW+24(a0)
  347. dmtc2 t0, 0x0241
  348. ld t0, OCTEON_CP2_HSH_DATW+32(a0)
  349. dmtc2 t1, 0x0242
  350. ld t1, OCTEON_CP2_HSH_DATW+40(a0)
  351. dmtc2 t2, 0x0243
  352. ld t2, OCTEON_CP2_HSH_DATW+48(a0)
  353. dmtc2 t0, 0x0244
  354. ld t0, OCTEON_CP2_HSH_DATW+56(a0)
  355. dmtc2 t1, 0x0245
  356. ld t1, OCTEON_CP2_HSH_DATW+64(a0)
  357. dmtc2 t2, 0x0246
  358. ld t2, OCTEON_CP2_HSH_DATW+72(a0)
  359. dmtc2 t0, 0x0247
  360. ld t0, OCTEON_CP2_HSH_DATW+80(a0)
  361. dmtc2 t1, 0x0248
  362. ld t1, OCTEON_CP2_HSH_DATW+88(a0)
  363. dmtc2 t2, 0x0249
  364. ld t2, OCTEON_CP2_HSH_DATW+96(a0)
  365. dmtc2 t0, 0x024A
  366. ld t0, OCTEON_CP2_HSH_DATW+104(a0)
  367. dmtc2 t1, 0x024B
  368. ld t1, OCTEON_CP2_HSH_DATW+112(a0)
  369. dmtc2 t2, 0x024C
  370. ld t2, OCTEON_CP2_HSH_IVW(a0)
  371. dmtc2 t0, 0x024D
  372. ld t0, OCTEON_CP2_HSH_IVW+8(a0)
  373. dmtc2 t1, 0x024E
  374. ld t1, OCTEON_CP2_HSH_IVW+16(a0)
  375. dmtc2 t2, 0x0250
  376. ld t2, OCTEON_CP2_HSH_IVW+24(a0)
  377. dmtc2 t0, 0x0251
  378. ld t0, OCTEON_CP2_HSH_IVW+32(a0)
  379. dmtc2 t1, 0x0252
  380. ld t1, OCTEON_CP2_HSH_IVW+40(a0)
  381. dmtc2 t2, 0x0253
  382. ld t2, OCTEON_CP2_HSH_IVW+48(a0)
  383. dmtc2 t0, 0x0254
  384. ld t0, OCTEON_CP2_HSH_IVW+56(a0)
  385. dmtc2 t1, 0x0255
  386. ld t1, OCTEON_CP2_GFM_MULT(a0)
  387. dmtc2 t2, 0x0256
  388. ld t2, OCTEON_CP2_GFM_MULT+8(a0)
  389. dmtc2 t0, 0x0257
  390. ld t0, OCTEON_CP2_GFM_POLY(a0)
  391. dmtc2 t1, 0x0258
  392. ld t1, OCTEON_CP2_GFM_RESULT(a0)
  393. dmtc2 t2, 0x0259
  394. ld t2, OCTEON_CP2_GFM_RESULT+8(a0)
  395. dmtc2 t0, 0x025E
  396. subu v0, t3, v0 /* prid - lowest OCTEON III PrId */
  397. dmtc2 t1, 0x025A
  398. bltz v0, done_restore
  399. dmtc2 t2, 0x025B
  400. /* OCTEON III things*/
  401. ld t0, OCTEON_CP2_SHA3(a0)
  402. ld t1, OCTEON_CP2_SHA3+8(a0)
  403. dmtc2 t0, 0x0051
  404. dmtc2 t1, 0x0050
  405. done_restore:
  406. jr ra
  407. nop
  408. END(octeon_cop2_restore)
  409. .set pop
  410. /*
  411. * void octeon_mult_save()
  412. * sp is assumed to point to a struct pt_regs
  413. *
  414. * NOTE: This is called in SAVE_TEMP in stackframe.h. It can
  415. * safely modify v1,k0, k1,$10-$15, and $24. It will
  416. * be overwritten with a processor specific version of the code.
  417. */
  418. .p2align 7
  419. .set push
  420. .set noreorder
  421. LEAF(octeon_mult_save)
  422. jr ra
  423. nop
  424. .space 30 * 4, 0
  425. octeon_mult_save_end:
  426. EXPORT(octeon_mult_save_end)
  427. END(octeon_mult_save)
  428. LEAF(octeon_mult_save2)
  429. /* Save the multiplier state OCTEON II and earlier*/
  430. v3mulu k0, $0, $0
  431. v3mulu k1, $0, $0
  432. sd k0, PT_MTP(sp) /* PT_MTP has P0 */
  433. v3mulu k0, $0, $0
  434. sd k1, PT_MTP+8(sp) /* PT_MTP+8 has P1 */
  435. ori k1, $0, 1
  436. v3mulu k1, k1, $0
  437. sd k0, PT_MTP+16(sp) /* PT_MTP+16 has P2 */
  438. v3mulu k0, $0, $0
  439. sd k1, PT_MPL(sp) /* PT_MPL has MPL0 */
  440. v3mulu k1, $0, $0
  441. sd k0, PT_MPL+8(sp) /* PT_MPL+8 has MPL1 */
  442. jr ra
  443. sd k1, PT_MPL+16(sp) /* PT_MPL+16 has MPL2 */
  444. octeon_mult_save2_end:
  445. EXPORT(octeon_mult_save2_end)
  446. END(octeon_mult_save2)
  447. LEAF(octeon_mult_save3)
  448. /* Save the multiplier state OCTEON III */
  449. v3mulu $10, $0, $0 /* read P0 */
  450. v3mulu $11, $0, $0 /* read P1 */
  451. v3mulu $12, $0, $0 /* read P2 */
  452. sd $10, PT_MTP+(0*8)(sp) /* store P0 */
  453. v3mulu $10, $0, $0 /* read P3 */
  454. sd $11, PT_MTP+(1*8)(sp) /* store P1 */
  455. v3mulu $11, $0, $0 /* read P4 */
  456. sd $12, PT_MTP+(2*8)(sp) /* store P2 */
  457. ori $13, $0, 1
  458. v3mulu $12, $0, $0 /* read P5 */
  459. sd $10, PT_MTP+(3*8)(sp) /* store P3 */
  460. v3mulu $13, $13, $0 /* P4-P0 = MPL5-MPL1, $13 = MPL0 */
  461. sd $11, PT_MTP+(4*8)(sp) /* store P4 */
  462. v3mulu $10, $0, $0 /* read MPL1 */
  463. sd $12, PT_MTP+(5*8)(sp) /* store P5 */
  464. v3mulu $11, $0, $0 /* read MPL2 */
  465. sd $13, PT_MPL+(0*8)(sp) /* store MPL0 */
  466. v3mulu $12, $0, $0 /* read MPL3 */
  467. sd $10, PT_MPL+(1*8)(sp) /* store MPL1 */
  468. v3mulu $10, $0, $0 /* read MPL4 */
  469. sd $11, PT_MPL+(2*8)(sp) /* store MPL2 */
  470. v3mulu $11, $0, $0 /* read MPL5 */
  471. sd $12, PT_MPL+(3*8)(sp) /* store MPL3 */
  472. sd $10, PT_MPL+(4*8)(sp) /* store MPL4 */
  473. jr ra
  474. sd $11, PT_MPL+(5*8)(sp) /* store MPL5 */
  475. octeon_mult_save3_end:
  476. EXPORT(octeon_mult_save3_end)
  477. END(octeon_mult_save3)
  478. .set pop
  479. /*
  480. * void octeon_mult_restore()
  481. * sp is assumed to point to a struct pt_regs
  482. *
  483. * NOTE: This is called in RESTORE_TEMP in stackframe.h.
  484. */
  485. .p2align 7
  486. .set push
  487. .set noreorder
  488. LEAF(octeon_mult_restore)
  489. jr ra
  490. nop
  491. .space 30 * 4, 0
  492. octeon_mult_restore_end:
  493. EXPORT(octeon_mult_restore_end)
  494. END(octeon_mult_restore)
  495. LEAF(octeon_mult_restore2)
  496. ld v0, PT_MPL(sp) /* MPL0 */
  497. ld v1, PT_MPL+8(sp) /* MPL1 */
  498. ld k0, PT_MPL+16(sp) /* MPL2 */
  499. /* Restore the multiplier state */
  500. ld k1, PT_MTP+16(sp) /* P2 */
  501. mtm0 v0 /* MPL0 */
  502. ld v0, PT_MTP+8(sp) /* P1 */
  503. mtm1 v1 /* MPL1 */
  504. ld v1, PT_MTP(sp) /* P0 */
  505. mtm2 k0 /* MPL2 */
  506. mtp2 k1 /* P2 */
  507. mtp1 v0 /* P1 */
  508. jr ra
  509. mtp0 v1 /* P0 */
  510. octeon_mult_restore2_end:
  511. EXPORT(octeon_mult_restore2_end)
  512. END(octeon_mult_restore2)
  513. LEAF(octeon_mult_restore3)
  514. ld $12, PT_MPL+(0*8)(sp) /* read MPL0 */
  515. ld $13, PT_MPL+(3*8)(sp) /* read MPL3 */
  516. ld $10, PT_MPL+(1*8)(sp) /* read MPL1 */
  517. ld $11, PT_MPL+(4*8)(sp) /* read MPL4 */
  518. .word 0x718d0008
  519. /* mtm0 $12, $13 restore MPL0 and MPL3 */
  520. ld $12, PT_MPL+(2*8)(sp) /* read MPL2 */
  521. .word 0x714b000c
  522. /* mtm1 $10, $11 restore MPL1 and MPL4 */
  523. ld $13, PT_MPL+(5*8)(sp) /* read MPL5 */
  524. ld $10, PT_MTP+(0*8)(sp) /* read P0 */
  525. ld $11, PT_MTP+(3*8)(sp) /* read P3 */
  526. .word 0x718d000d
  527. /* mtm2 $12, $13 restore MPL2 and MPL5 */
  528. ld $12, PT_MTP+(1*8)(sp) /* read P1 */
  529. .word 0x714b0009
  530. /* mtp0 $10, $11 restore P0 and P3 */
  531. ld $13, PT_MTP+(4*8)(sp) /* read P4 */
  532. ld $10, PT_MTP+(2*8)(sp) /* read P2 */
  533. ld $11, PT_MTP+(5*8)(sp) /* read P5 */
  534. .word 0x718d000a
  535. /* mtp1 $12, $13 restore P1 and P4 */
  536. jr ra
  537. .word 0x714b000b
  538. /* mtp2 $10, $11 restore P2 and P5 */
  539. octeon_mult_restore3_end:
  540. EXPORT(octeon_mult_restore3_end)
  541. END(octeon_mult_restore3)
  542. .set pop