octeon_switch.S 13 KB

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