octeon_switch.S 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  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. #include <asm/asm.h>
  14. #include <asm/cachectl.h>
  15. #include <asm/fpregdef.h>
  16. #include <asm/mipsregs.h>
  17. #include <asm/asm-offsets.h>
  18. #include <asm/pgtable-bits.h>
  19. #include <asm/regdef.h>
  20. #include <asm/stackframe.h>
  21. #include <asm/thread_info.h>
  22. #include <asm/asmmacro.h>
  23. /*
  24. * Offset to the current process status flags, the first 32 bytes of the
  25. * stack are not used.
  26. */
  27. #define ST_OFF (_THREAD_SIZE - 32 - PT_SIZE + PT_STATUS)
  28. /*
  29. * task_struct *resume(task_struct *prev, task_struct *next,
  30. * struct thread_info *next_ti, int usedfpu)
  31. */
  32. .align 7
  33. LEAF(resume)
  34. .set arch=octeon
  35. mfc0 t1, CP0_STATUS
  36. LONG_S t1, THREAD_STATUS(a0)
  37. cpu_save_nonscratch a0
  38. LONG_S ra, THREAD_REG31(a0)
  39. /* check if we need to save COP2 registers */
  40. PTR_L t2, TASK_THREAD_INFO(a0)
  41. LONG_L t0, ST_OFF(t2)
  42. bbit0 t0, 30, 1f
  43. /* Disable COP2 in the stored process state */
  44. li t1, ST0_CU2
  45. xor t0, t1
  46. LONG_S t0, ST_OFF(t2)
  47. /* Enable COP2 so we can save it */
  48. mfc0 t0, CP0_STATUS
  49. or t0, t1
  50. mtc0 t0, CP0_STATUS
  51. /* Save COP2 */
  52. daddu a0, THREAD_CP2
  53. jal octeon_cop2_save
  54. dsubu a0, THREAD_CP2
  55. /* Disable COP2 now that we are done */
  56. mfc0 t0, CP0_STATUS
  57. li t1, ST0_CU2
  58. xor t0, t1
  59. mtc0 t0, CP0_STATUS
  60. 1:
  61. #if CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0
  62. /* Check if we need to store CVMSEG state */
  63. mfc0 t0, $11,7 /* CvmMemCtl */
  64. bbit0 t0, 6, 3f /* Is user access enabled? */
  65. /* Store the CVMSEG state */
  66. /* Extract the size of CVMSEG */
  67. andi t0, 0x3f
  68. /* Multiply * (cache line size/sizeof(long)/2) */
  69. sll t0, 7-LONGLOG-1
  70. li t1, -32768 /* Base address of CVMSEG */
  71. LONG_ADDI t2, a0, THREAD_CVMSEG /* Where to store CVMSEG to */
  72. synciobdma
  73. 2:
  74. .set noreorder
  75. LONG_L t8, 0(t1) /* Load from CVMSEG */
  76. subu t0, 1 /* Decrement loop var */
  77. LONG_L t9, LONGSIZE(t1)/* Load from CVMSEG */
  78. LONG_ADDU t1, LONGSIZE*2 /* Increment loc in CVMSEG */
  79. LONG_S t8, 0(t2) /* Store CVMSEG to thread storage */
  80. LONG_ADDU t2, LONGSIZE*2 /* Increment loc in thread storage */
  81. bnez t0, 2b /* Loop until we've copied it all */
  82. LONG_S t9, -LONGSIZE(t2)/* Store CVMSEG to thread storage */
  83. .set reorder
  84. /* Disable access to CVMSEG */
  85. mfc0 t0, $11,7 /* CvmMemCtl */
  86. xori t0, t0, 0x40 /* Bit 6 is CVMSEG user enable */
  87. mtc0 t0, $11,7 /* CvmMemCtl */
  88. #endif
  89. 3:
  90. /*
  91. * The order of restoring the registers takes care of the race
  92. * updating $28, $29 and kernelsp without disabling ints.
  93. */
  94. move $28, a2
  95. cpu_restore_nonscratch a1
  96. #if (_THREAD_SIZE - 32) < 0x8000
  97. PTR_ADDIU t0, $28, _THREAD_SIZE - 32
  98. #else
  99. PTR_LI t0, _THREAD_SIZE - 32
  100. PTR_ADDU t0, $28
  101. #endif
  102. set_saved_sp t0, t1, t2
  103. mfc0 t1, CP0_STATUS /* Do we really need this? */
  104. li a3, 0xff01
  105. and t1, a3
  106. LONG_L a2, THREAD_STATUS(a1)
  107. nor a3, $0, a3
  108. and a2, a3
  109. or a2, t1
  110. mtc0 a2, CP0_STATUS
  111. move v0, a0
  112. jr ra
  113. END(resume)
  114. /*
  115. * void octeon_cop2_save(struct octeon_cop2_state *a0)
  116. */
  117. .align 7
  118. LEAF(octeon_cop2_save)
  119. dmfc0 t9, $9,7 /* CvmCtl register. */
  120. /* Save the COP2 CRC state */
  121. dmfc2 t0, 0x0201
  122. dmfc2 t1, 0x0202
  123. dmfc2 t2, 0x0200
  124. sd t0, OCTEON_CP2_CRC_IV(a0)
  125. sd t1, OCTEON_CP2_CRC_LENGTH(a0)
  126. sd t2, OCTEON_CP2_CRC_POLY(a0)
  127. /* Skip next instructions if CvmCtl[NODFA_CP2] set */
  128. bbit1 t9, 28, 1f
  129. /* Save the LLM state */
  130. dmfc2 t0, 0x0402
  131. dmfc2 t1, 0x040A
  132. sd t0, OCTEON_CP2_LLM_DAT(a0)
  133. sd t1, OCTEON_CP2_LLM_DAT+8(a0)
  134. 1: bbit1 t9, 26, 3f /* done if CvmCtl[NOCRYPTO] set */
  135. /* Save the COP2 crypto state */
  136. /* this part is mostly common to both pass 1 and later revisions */
  137. dmfc2 t0, 0x0084
  138. dmfc2 t1, 0x0080
  139. dmfc2 t2, 0x0081
  140. dmfc2 t3, 0x0082
  141. sd t0, OCTEON_CP2_3DES_IV(a0)
  142. dmfc2 t0, 0x0088
  143. sd t1, OCTEON_CP2_3DES_KEY(a0)
  144. dmfc2 t1, 0x0111 /* only necessary for pass 1 */
  145. sd t2, OCTEON_CP2_3DES_KEY+8(a0)
  146. dmfc2 t2, 0x0102
  147. sd t3, OCTEON_CP2_3DES_KEY+16(a0)
  148. dmfc2 t3, 0x0103
  149. sd t0, OCTEON_CP2_3DES_RESULT(a0)
  150. dmfc2 t0, 0x0104
  151. sd t1, OCTEON_CP2_AES_INP0(a0) /* only necessary for pass 1 */
  152. dmfc2 t1, 0x0105
  153. sd t2, OCTEON_CP2_AES_IV(a0)
  154. dmfc2 t2, 0x0106
  155. sd t3, OCTEON_CP2_AES_IV+8(a0)
  156. dmfc2 t3, 0x0107
  157. sd t0, OCTEON_CP2_AES_KEY(a0)
  158. dmfc2 t0, 0x0110
  159. sd t1, OCTEON_CP2_AES_KEY+8(a0)
  160. dmfc2 t1, 0x0100
  161. sd t2, OCTEON_CP2_AES_KEY+16(a0)
  162. dmfc2 t2, 0x0101
  163. sd t3, OCTEON_CP2_AES_KEY+24(a0)
  164. mfc0 t3, $15,0 /* Get the processor ID register */
  165. sd t0, OCTEON_CP2_AES_KEYLEN(a0)
  166. li t0, 0x000d0000 /* This is the processor ID of Octeon Pass1 */
  167. sd t1, OCTEON_CP2_AES_RESULT(a0)
  168. sd t2, OCTEON_CP2_AES_RESULT+8(a0)
  169. /* Skip to the Pass1 version of the remainder of the COP2 state */
  170. beq t3, t0, 2f
  171. /* the non-pass1 state when !CvmCtl[NOCRYPTO] */
  172. dmfc2 t1, 0x0240
  173. dmfc2 t2, 0x0241
  174. dmfc2 t3, 0x0242
  175. dmfc2 t0, 0x0243
  176. sd t1, OCTEON_CP2_HSH_DATW(a0)
  177. dmfc2 t1, 0x0244
  178. sd t2, OCTEON_CP2_HSH_DATW+8(a0)
  179. dmfc2 t2, 0x0245
  180. sd t3, OCTEON_CP2_HSH_DATW+16(a0)
  181. dmfc2 t3, 0x0246
  182. sd t0, OCTEON_CP2_HSH_DATW+24(a0)
  183. dmfc2 t0, 0x0247
  184. sd t1, OCTEON_CP2_HSH_DATW+32(a0)
  185. dmfc2 t1, 0x0248
  186. sd t2, OCTEON_CP2_HSH_DATW+40(a0)
  187. dmfc2 t2, 0x0249
  188. sd t3, OCTEON_CP2_HSH_DATW+48(a0)
  189. dmfc2 t3, 0x024A
  190. sd t0, OCTEON_CP2_HSH_DATW+56(a0)
  191. dmfc2 t0, 0x024B
  192. sd t1, OCTEON_CP2_HSH_DATW+64(a0)
  193. dmfc2 t1, 0x024C
  194. sd t2, OCTEON_CP2_HSH_DATW+72(a0)
  195. dmfc2 t2, 0x024D
  196. sd t3, OCTEON_CP2_HSH_DATW+80(a0)
  197. dmfc2 t3, 0x024E
  198. sd t0, OCTEON_CP2_HSH_DATW+88(a0)
  199. dmfc2 t0, 0x0250
  200. sd t1, OCTEON_CP2_HSH_DATW+96(a0)
  201. dmfc2 t1, 0x0251
  202. sd t2, OCTEON_CP2_HSH_DATW+104(a0)
  203. dmfc2 t2, 0x0252
  204. sd t3, OCTEON_CP2_HSH_DATW+112(a0)
  205. dmfc2 t3, 0x0253
  206. sd t0, OCTEON_CP2_HSH_IVW(a0)
  207. dmfc2 t0, 0x0254
  208. sd t1, OCTEON_CP2_HSH_IVW+8(a0)
  209. dmfc2 t1, 0x0255
  210. sd t2, OCTEON_CP2_HSH_IVW+16(a0)
  211. dmfc2 t2, 0x0256
  212. sd t3, OCTEON_CP2_HSH_IVW+24(a0)
  213. dmfc2 t3, 0x0257
  214. sd t0, OCTEON_CP2_HSH_IVW+32(a0)
  215. dmfc2 t0, 0x0258
  216. sd t1, OCTEON_CP2_HSH_IVW+40(a0)
  217. dmfc2 t1, 0x0259
  218. sd t2, OCTEON_CP2_HSH_IVW+48(a0)
  219. dmfc2 t2, 0x025E
  220. sd t3, OCTEON_CP2_HSH_IVW+56(a0)
  221. dmfc2 t3, 0x025A
  222. sd t0, OCTEON_CP2_GFM_MULT(a0)
  223. dmfc2 t0, 0x025B
  224. sd t1, OCTEON_CP2_GFM_MULT+8(a0)
  225. sd t2, OCTEON_CP2_GFM_POLY(a0)
  226. sd t3, OCTEON_CP2_GFM_RESULT(a0)
  227. sd t0, OCTEON_CP2_GFM_RESULT+8(a0)
  228. jr ra
  229. 2: /* pass 1 special stuff when !CvmCtl[NOCRYPTO] */
  230. dmfc2 t3, 0x0040
  231. dmfc2 t0, 0x0041
  232. dmfc2 t1, 0x0042
  233. dmfc2 t2, 0x0043
  234. sd t3, OCTEON_CP2_HSH_DATW(a0)
  235. dmfc2 t3, 0x0044
  236. sd t0, OCTEON_CP2_HSH_DATW+8(a0)
  237. dmfc2 t0, 0x0045
  238. sd t1, OCTEON_CP2_HSH_DATW+16(a0)
  239. dmfc2 t1, 0x0046
  240. sd t2, OCTEON_CP2_HSH_DATW+24(a0)
  241. dmfc2 t2, 0x0048
  242. sd t3, OCTEON_CP2_HSH_DATW+32(a0)
  243. dmfc2 t3, 0x0049
  244. sd t0, OCTEON_CP2_HSH_DATW+40(a0)
  245. dmfc2 t0, 0x004A
  246. sd t1, OCTEON_CP2_HSH_DATW+48(a0)
  247. sd t2, OCTEON_CP2_HSH_IVW(a0)
  248. sd t3, OCTEON_CP2_HSH_IVW+8(a0)
  249. sd t0, OCTEON_CP2_HSH_IVW+16(a0)
  250. 3: /* pass 1 or CvmCtl[NOCRYPTO] set */
  251. jr ra
  252. END(octeon_cop2_save)
  253. /*
  254. * void octeon_cop2_restore(struct octeon_cop2_state *a0)
  255. */
  256. .align 7
  257. .set push
  258. .set noreorder
  259. LEAF(octeon_cop2_restore)
  260. /* First cache line was prefetched before the call */
  261. pref 4, 128(a0)
  262. dmfc0 t9, $9,7 /* CvmCtl register. */
  263. pref 4, 256(a0)
  264. ld t0, OCTEON_CP2_CRC_IV(a0)
  265. pref 4, 384(a0)
  266. ld t1, OCTEON_CP2_CRC_LENGTH(a0)
  267. ld t2, OCTEON_CP2_CRC_POLY(a0)
  268. /* Restore the COP2 CRC state */
  269. dmtc2 t0, 0x0201
  270. dmtc2 t1, 0x1202
  271. bbit1 t9, 28, 2f /* Skip LLM if CvmCtl[NODFA_CP2] is set */
  272. dmtc2 t2, 0x4200
  273. /* Restore the LLM state */
  274. ld t0, OCTEON_CP2_LLM_DAT(a0)
  275. ld t1, OCTEON_CP2_LLM_DAT+8(a0)
  276. dmtc2 t0, 0x0402
  277. dmtc2 t1, 0x040A
  278. 2:
  279. bbit1 t9, 26, done_restore /* done if CvmCtl[NOCRYPTO] set */
  280. nop
  281. /* Restore the COP2 crypto state common to pass 1 and pass 2 */
  282. ld t0, OCTEON_CP2_3DES_IV(a0)
  283. ld t1, OCTEON_CP2_3DES_KEY(a0)
  284. ld t2, OCTEON_CP2_3DES_KEY+8(a0)
  285. dmtc2 t0, 0x0084
  286. ld t0, OCTEON_CP2_3DES_KEY+16(a0)
  287. dmtc2 t1, 0x0080
  288. ld t1, OCTEON_CP2_3DES_RESULT(a0)
  289. dmtc2 t2, 0x0081
  290. ld t2, OCTEON_CP2_AES_INP0(a0) /* only really needed for pass 1 */
  291. dmtc2 t0, 0x0082
  292. ld t0, OCTEON_CP2_AES_IV(a0)
  293. dmtc2 t1, 0x0098
  294. ld t1, OCTEON_CP2_AES_IV+8(a0)
  295. dmtc2 t2, 0x010A /* only really needed for pass 1 */
  296. ld t2, OCTEON_CP2_AES_KEY(a0)
  297. dmtc2 t0, 0x0102
  298. ld t0, OCTEON_CP2_AES_KEY+8(a0)
  299. dmtc2 t1, 0x0103
  300. ld t1, OCTEON_CP2_AES_KEY+16(a0)
  301. dmtc2 t2, 0x0104
  302. ld t2, OCTEON_CP2_AES_KEY+24(a0)
  303. dmtc2 t0, 0x0105
  304. ld t0, OCTEON_CP2_AES_KEYLEN(a0)
  305. dmtc2 t1, 0x0106
  306. ld t1, OCTEON_CP2_AES_RESULT(a0)
  307. dmtc2 t2, 0x0107
  308. ld t2, OCTEON_CP2_AES_RESULT+8(a0)
  309. mfc0 t3, $15,0 /* Get the processor ID register */
  310. dmtc2 t0, 0x0110
  311. li t0, 0x000d0000 /* This is the processor ID of Octeon Pass1 */
  312. dmtc2 t1, 0x0100
  313. bne t0, t3, 3f /* Skip the next stuff for non-pass1 */
  314. dmtc2 t2, 0x0101
  315. /* this code is specific for pass 1 */
  316. ld t0, OCTEON_CP2_HSH_DATW(a0)
  317. ld t1, OCTEON_CP2_HSH_DATW+8(a0)
  318. ld t2, OCTEON_CP2_HSH_DATW+16(a0)
  319. dmtc2 t0, 0x0040
  320. ld t0, OCTEON_CP2_HSH_DATW+24(a0)
  321. dmtc2 t1, 0x0041
  322. ld t1, OCTEON_CP2_HSH_DATW+32(a0)
  323. dmtc2 t2, 0x0042
  324. ld t2, OCTEON_CP2_HSH_DATW+40(a0)
  325. dmtc2 t0, 0x0043
  326. ld t0, OCTEON_CP2_HSH_DATW+48(a0)
  327. dmtc2 t1, 0x0044
  328. ld t1, OCTEON_CP2_HSH_IVW(a0)
  329. dmtc2 t2, 0x0045
  330. ld t2, OCTEON_CP2_HSH_IVW+8(a0)
  331. dmtc2 t0, 0x0046
  332. ld t0, OCTEON_CP2_HSH_IVW+16(a0)
  333. dmtc2 t1, 0x0048
  334. dmtc2 t2, 0x0049
  335. b done_restore /* unconditional branch */
  336. dmtc2 t0, 0x004A
  337. 3: /* this is post-pass1 code */
  338. ld t2, OCTEON_CP2_HSH_DATW(a0)
  339. ld t0, OCTEON_CP2_HSH_DATW+8(a0)
  340. ld t1, OCTEON_CP2_HSH_DATW+16(a0)
  341. dmtc2 t2, 0x0240
  342. ld t2, OCTEON_CP2_HSH_DATW+24(a0)
  343. dmtc2 t0, 0x0241
  344. ld t0, OCTEON_CP2_HSH_DATW+32(a0)
  345. dmtc2 t1, 0x0242
  346. ld t1, OCTEON_CP2_HSH_DATW+40(a0)
  347. dmtc2 t2, 0x0243
  348. ld t2, OCTEON_CP2_HSH_DATW+48(a0)
  349. dmtc2 t0, 0x0244
  350. ld t0, OCTEON_CP2_HSH_DATW+56(a0)
  351. dmtc2 t1, 0x0245
  352. ld t1, OCTEON_CP2_HSH_DATW+64(a0)
  353. dmtc2 t2, 0x0246
  354. ld t2, OCTEON_CP2_HSH_DATW+72(a0)
  355. dmtc2 t0, 0x0247
  356. ld t0, OCTEON_CP2_HSH_DATW+80(a0)
  357. dmtc2 t1, 0x0248
  358. ld t1, OCTEON_CP2_HSH_DATW+88(a0)
  359. dmtc2 t2, 0x0249
  360. ld t2, OCTEON_CP2_HSH_DATW+96(a0)
  361. dmtc2 t0, 0x024A
  362. ld t0, OCTEON_CP2_HSH_DATW+104(a0)
  363. dmtc2 t1, 0x024B
  364. ld t1, OCTEON_CP2_HSH_DATW+112(a0)
  365. dmtc2 t2, 0x024C
  366. ld t2, OCTEON_CP2_HSH_IVW(a0)
  367. dmtc2 t0, 0x024D
  368. ld t0, OCTEON_CP2_HSH_IVW+8(a0)
  369. dmtc2 t1, 0x024E
  370. ld t1, OCTEON_CP2_HSH_IVW+16(a0)
  371. dmtc2 t2, 0x0250
  372. ld t2, OCTEON_CP2_HSH_IVW+24(a0)
  373. dmtc2 t0, 0x0251
  374. ld t0, OCTEON_CP2_HSH_IVW+32(a0)
  375. dmtc2 t1, 0x0252
  376. ld t1, OCTEON_CP2_HSH_IVW+40(a0)
  377. dmtc2 t2, 0x0253
  378. ld t2, OCTEON_CP2_HSH_IVW+48(a0)
  379. dmtc2 t0, 0x0254
  380. ld t0, OCTEON_CP2_HSH_IVW+56(a0)
  381. dmtc2 t1, 0x0255
  382. ld t1, OCTEON_CP2_GFM_MULT(a0)
  383. dmtc2 t2, 0x0256
  384. ld t2, OCTEON_CP2_GFM_MULT+8(a0)
  385. dmtc2 t0, 0x0257
  386. ld t0, OCTEON_CP2_GFM_POLY(a0)
  387. dmtc2 t1, 0x0258
  388. ld t1, OCTEON_CP2_GFM_RESULT(a0)
  389. dmtc2 t2, 0x0259
  390. ld t2, OCTEON_CP2_GFM_RESULT+8(a0)
  391. dmtc2 t0, 0x025E
  392. dmtc2 t1, 0x025A
  393. dmtc2 t2, 0x025B
  394. done_restore:
  395. jr ra
  396. nop
  397. END(octeon_cop2_restore)
  398. .set pop
  399. /*
  400. * void octeon_mult_save()
  401. * sp is assumed to point to a struct pt_regs
  402. *
  403. * NOTE: This is called in SAVE_SOME in stackframe.h. It can only
  404. * safely modify k0 and k1.
  405. */
  406. .align 7
  407. .set push
  408. .set noreorder
  409. LEAF(octeon_mult_save)
  410. dmfc0 k0, $9,7 /* CvmCtl register. */
  411. bbit1 k0, 27, 1f /* Skip CvmCtl[NOMUL] */
  412. nop
  413. /* Save the multiplier state */
  414. v3mulu k0, $0, $0
  415. v3mulu k1, $0, $0
  416. sd k0, PT_MTP(sp) /* PT_MTP has P0 */
  417. v3mulu k0, $0, $0
  418. sd k1, PT_MTP+8(sp) /* PT_MTP+8 has P1 */
  419. ori k1, $0, 1
  420. v3mulu k1, k1, $0
  421. sd k0, PT_MTP+16(sp) /* PT_MTP+16 has P2 */
  422. v3mulu k0, $0, $0
  423. sd k1, PT_MPL(sp) /* PT_MPL has MPL0 */
  424. v3mulu k1, $0, $0
  425. sd k0, PT_MPL+8(sp) /* PT_MPL+8 has MPL1 */
  426. jr ra
  427. sd k1, PT_MPL+16(sp) /* PT_MPL+16 has MPL2 */
  428. 1: /* Resume here if CvmCtl[NOMUL] */
  429. jr ra
  430. END(octeon_mult_save)
  431. .set pop
  432. /*
  433. * void octeon_mult_restore()
  434. * sp is assumed to point to a struct pt_regs
  435. *
  436. * NOTE: This is called in RESTORE_SOME in stackframe.h.
  437. */
  438. .align 7
  439. .set push
  440. .set noreorder
  441. LEAF(octeon_mult_restore)
  442. dmfc0 k1, $9,7 /* CvmCtl register. */
  443. ld v0, PT_MPL(sp) /* MPL0 */
  444. ld v1, PT_MPL+8(sp) /* MPL1 */
  445. ld k0, PT_MPL+16(sp) /* MPL2 */
  446. bbit1 k1, 27, 1f /* Skip CvmCtl[NOMUL] */
  447. /* Normally falls through, so no time wasted here */
  448. nop
  449. /* Restore the multiplier state */
  450. ld k1, PT_MTP+16(sp) /* P2 */
  451. MTM0 v0 /* MPL0 */
  452. ld v0, PT_MTP+8(sp) /* P1 */
  453. MTM1 v1 /* MPL1 */
  454. ld v1, PT_MTP(sp) /* P0 */
  455. MTM2 k0 /* MPL2 */
  456. MTP2 k1 /* P2 */
  457. MTP1 v0 /* P1 */
  458. jr ra
  459. MTP0 v1 /* P0 */
  460. 1: /* Resume here if CvmCtl[NOMUL] */
  461. jr ra
  462. nop
  463. END(octeon_mult_restore)
  464. .set pop