octeon_switch.S 13 KB

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