r4k_fpu.S 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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) 1996, 98, 99, 2000, 01 Ralf Baechle
  7. *
  8. * Multi-arch abstraction and asm macros for easier reading:
  9. * Copyright (C) 1996 David S. Miller (davem@davemloft.net)
  10. *
  11. * Carsten Langgaard, carstenl@mips.com
  12. * Copyright (C) 2000 MIPS Technologies, Inc.
  13. * Copyright (C) 1999, 2001 Silicon Graphics, Inc.
  14. */
  15. #include <asm/asm.h>
  16. #include <asm/errno.h>
  17. #include <asm/fpregdef.h>
  18. #include <asm/mipsregs.h>
  19. #include <asm/asm-offsets.h>
  20. #include <asm/regdef.h>
  21. /* preprocessor replaces the fp in ".set fp=64" with $30 otherwise */
  22. #undef fp
  23. .macro EX insn, reg, src
  24. .set push
  25. SET_HARDFLOAT
  26. .set nomacro
  27. .ex\@: \insn \reg, \src
  28. .set pop
  29. .section __ex_table,"a"
  30. PTR .ex\@, fault
  31. .previous
  32. .endm
  33. .set noreorder
  34. LEAF(_save_fp_context)
  35. .set push
  36. SET_HARDFLOAT
  37. cfc1 t1, fcr31
  38. .set pop
  39. #if defined(CONFIG_64BIT) || defined(CONFIG_CPU_MIPS32_R2) || \
  40. defined(CONFIG_CPU_MIPS32_R6)
  41. .set push
  42. SET_HARDFLOAT
  43. #ifdef CONFIG_CPU_MIPS32_R2
  44. .set mips32r2
  45. .set fp=64
  46. mfc0 t0, CP0_STATUS
  47. sll t0, t0, 5
  48. bgez t0, 1f # skip storing odd if FR=0
  49. nop
  50. #endif
  51. /* Store the 16 odd double precision registers */
  52. EX sdc1 $f1, SC_FPREGS+8(a0)
  53. EX sdc1 $f3, SC_FPREGS+24(a0)
  54. EX sdc1 $f5, SC_FPREGS+40(a0)
  55. EX sdc1 $f7, SC_FPREGS+56(a0)
  56. EX sdc1 $f9, SC_FPREGS+72(a0)
  57. EX sdc1 $f11, SC_FPREGS+88(a0)
  58. EX sdc1 $f13, SC_FPREGS+104(a0)
  59. EX sdc1 $f15, SC_FPREGS+120(a0)
  60. EX sdc1 $f17, SC_FPREGS+136(a0)
  61. EX sdc1 $f19, SC_FPREGS+152(a0)
  62. EX sdc1 $f21, SC_FPREGS+168(a0)
  63. EX sdc1 $f23, SC_FPREGS+184(a0)
  64. EX sdc1 $f25, SC_FPREGS+200(a0)
  65. EX sdc1 $f27, SC_FPREGS+216(a0)
  66. EX sdc1 $f29, SC_FPREGS+232(a0)
  67. EX sdc1 $f31, SC_FPREGS+248(a0)
  68. 1: .set pop
  69. #endif
  70. .set push
  71. SET_HARDFLOAT
  72. /* Store the 16 even double precision registers */
  73. EX sdc1 $f0, SC_FPREGS+0(a0)
  74. EX sdc1 $f2, SC_FPREGS+16(a0)
  75. EX sdc1 $f4, SC_FPREGS+32(a0)
  76. EX sdc1 $f6, SC_FPREGS+48(a0)
  77. EX sdc1 $f8, SC_FPREGS+64(a0)
  78. EX sdc1 $f10, SC_FPREGS+80(a0)
  79. EX sdc1 $f12, SC_FPREGS+96(a0)
  80. EX sdc1 $f14, SC_FPREGS+112(a0)
  81. EX sdc1 $f16, SC_FPREGS+128(a0)
  82. EX sdc1 $f18, SC_FPREGS+144(a0)
  83. EX sdc1 $f20, SC_FPREGS+160(a0)
  84. EX sdc1 $f22, SC_FPREGS+176(a0)
  85. EX sdc1 $f24, SC_FPREGS+192(a0)
  86. EX sdc1 $f26, SC_FPREGS+208(a0)
  87. EX sdc1 $f28, SC_FPREGS+224(a0)
  88. EX sdc1 $f30, SC_FPREGS+240(a0)
  89. EX sw t1, SC_FPC_CSR(a0)
  90. jr ra
  91. li v0, 0 # success
  92. .set pop
  93. END(_save_fp_context)
  94. #ifdef CONFIG_MIPS32_COMPAT
  95. /* Save 32-bit process floating point context */
  96. LEAF(_save_fp_context32)
  97. .set push
  98. .set MIPS_ISA_ARCH_LEVEL_RAW
  99. SET_HARDFLOAT
  100. cfc1 t1, fcr31
  101. #ifndef CONFIG_CPU_MIPS64_R6
  102. mfc0 t0, CP0_STATUS
  103. sll t0, t0, 5
  104. bgez t0, 1f # skip storing odd if FR=0
  105. nop
  106. #endif
  107. /* Store the 16 odd double precision registers */
  108. EX sdc1 $f1, SC32_FPREGS+8(a0)
  109. EX sdc1 $f3, SC32_FPREGS+24(a0)
  110. EX sdc1 $f5, SC32_FPREGS+40(a0)
  111. EX sdc1 $f7, SC32_FPREGS+56(a0)
  112. EX sdc1 $f9, SC32_FPREGS+72(a0)
  113. EX sdc1 $f11, SC32_FPREGS+88(a0)
  114. EX sdc1 $f13, SC32_FPREGS+104(a0)
  115. EX sdc1 $f15, SC32_FPREGS+120(a0)
  116. EX sdc1 $f17, SC32_FPREGS+136(a0)
  117. EX sdc1 $f19, SC32_FPREGS+152(a0)
  118. EX sdc1 $f21, SC32_FPREGS+168(a0)
  119. EX sdc1 $f23, SC32_FPREGS+184(a0)
  120. EX sdc1 $f25, SC32_FPREGS+200(a0)
  121. EX sdc1 $f27, SC32_FPREGS+216(a0)
  122. EX sdc1 $f29, SC32_FPREGS+232(a0)
  123. EX sdc1 $f31, SC32_FPREGS+248(a0)
  124. /* Store the 16 even double precision registers */
  125. 1: EX sdc1 $f0, SC32_FPREGS+0(a0)
  126. EX sdc1 $f2, SC32_FPREGS+16(a0)
  127. EX sdc1 $f4, SC32_FPREGS+32(a0)
  128. EX sdc1 $f6, SC32_FPREGS+48(a0)
  129. EX sdc1 $f8, SC32_FPREGS+64(a0)
  130. EX sdc1 $f10, SC32_FPREGS+80(a0)
  131. EX sdc1 $f12, SC32_FPREGS+96(a0)
  132. EX sdc1 $f14, SC32_FPREGS+112(a0)
  133. EX sdc1 $f16, SC32_FPREGS+128(a0)
  134. EX sdc1 $f18, SC32_FPREGS+144(a0)
  135. EX sdc1 $f20, SC32_FPREGS+160(a0)
  136. EX sdc1 $f22, SC32_FPREGS+176(a0)
  137. EX sdc1 $f24, SC32_FPREGS+192(a0)
  138. EX sdc1 $f26, SC32_FPREGS+208(a0)
  139. EX sdc1 $f28, SC32_FPREGS+224(a0)
  140. EX sdc1 $f30, SC32_FPREGS+240(a0)
  141. EX sw t1, SC32_FPC_CSR(a0)
  142. cfc1 t0, $0 # implementation/version
  143. EX sw t0, SC32_FPC_EIR(a0)
  144. .set pop
  145. jr ra
  146. li v0, 0 # success
  147. END(_save_fp_context32)
  148. #endif
  149. /*
  150. * Restore FPU state:
  151. * - fp gp registers
  152. * - cp1 status/control register
  153. */
  154. LEAF(_restore_fp_context)
  155. EX lw t1, SC_FPC_CSR(a0)
  156. #if defined(CONFIG_64BIT) || defined(CONFIG_CPU_MIPS32_R2) || \
  157. defined(CONFIG_CPU_MIPS32_R6)
  158. .set push
  159. SET_HARDFLOAT
  160. #ifdef CONFIG_CPU_MIPS32_R2
  161. .set mips32r2
  162. .set fp=64
  163. mfc0 t0, CP0_STATUS
  164. sll t0, t0, 5
  165. bgez t0, 1f # skip loading odd if FR=0
  166. nop
  167. #endif
  168. EX ldc1 $f1, SC_FPREGS+8(a0)
  169. EX ldc1 $f3, SC_FPREGS+24(a0)
  170. EX ldc1 $f5, SC_FPREGS+40(a0)
  171. EX ldc1 $f7, SC_FPREGS+56(a0)
  172. EX ldc1 $f9, SC_FPREGS+72(a0)
  173. EX ldc1 $f11, SC_FPREGS+88(a0)
  174. EX ldc1 $f13, SC_FPREGS+104(a0)
  175. EX ldc1 $f15, SC_FPREGS+120(a0)
  176. EX ldc1 $f17, SC_FPREGS+136(a0)
  177. EX ldc1 $f19, SC_FPREGS+152(a0)
  178. EX ldc1 $f21, SC_FPREGS+168(a0)
  179. EX ldc1 $f23, SC_FPREGS+184(a0)
  180. EX ldc1 $f25, SC_FPREGS+200(a0)
  181. EX ldc1 $f27, SC_FPREGS+216(a0)
  182. EX ldc1 $f29, SC_FPREGS+232(a0)
  183. EX ldc1 $f31, SC_FPREGS+248(a0)
  184. 1: .set pop
  185. #endif
  186. .set push
  187. SET_HARDFLOAT
  188. EX ldc1 $f0, SC_FPREGS+0(a0)
  189. EX ldc1 $f2, SC_FPREGS+16(a0)
  190. EX ldc1 $f4, SC_FPREGS+32(a0)
  191. EX ldc1 $f6, SC_FPREGS+48(a0)
  192. EX ldc1 $f8, SC_FPREGS+64(a0)
  193. EX ldc1 $f10, SC_FPREGS+80(a0)
  194. EX ldc1 $f12, SC_FPREGS+96(a0)
  195. EX ldc1 $f14, SC_FPREGS+112(a0)
  196. EX ldc1 $f16, SC_FPREGS+128(a0)
  197. EX ldc1 $f18, SC_FPREGS+144(a0)
  198. EX ldc1 $f20, SC_FPREGS+160(a0)
  199. EX ldc1 $f22, SC_FPREGS+176(a0)
  200. EX ldc1 $f24, SC_FPREGS+192(a0)
  201. EX ldc1 $f26, SC_FPREGS+208(a0)
  202. EX ldc1 $f28, SC_FPREGS+224(a0)
  203. EX ldc1 $f30, SC_FPREGS+240(a0)
  204. ctc1 t1, fcr31
  205. .set pop
  206. jr ra
  207. li v0, 0 # success
  208. END(_restore_fp_context)
  209. #ifdef CONFIG_MIPS32_COMPAT
  210. LEAF(_restore_fp_context32)
  211. /* Restore an o32 sigcontext. */
  212. .set push
  213. SET_HARDFLOAT
  214. EX lw t1, SC32_FPC_CSR(a0)
  215. #ifndef CONFIG_CPU_MIPS64_R6
  216. mfc0 t0, CP0_STATUS
  217. sll t0, t0, 5
  218. bgez t0, 1f # skip loading odd if FR=0
  219. nop
  220. #endif
  221. EX ldc1 $f1, SC32_FPREGS+8(a0)
  222. EX ldc1 $f3, SC32_FPREGS+24(a0)
  223. EX ldc1 $f5, SC32_FPREGS+40(a0)
  224. EX ldc1 $f7, SC32_FPREGS+56(a0)
  225. EX ldc1 $f9, SC32_FPREGS+72(a0)
  226. EX ldc1 $f11, SC32_FPREGS+88(a0)
  227. EX ldc1 $f13, SC32_FPREGS+104(a0)
  228. EX ldc1 $f15, SC32_FPREGS+120(a0)
  229. EX ldc1 $f17, SC32_FPREGS+136(a0)
  230. EX ldc1 $f19, SC32_FPREGS+152(a0)
  231. EX ldc1 $f21, SC32_FPREGS+168(a0)
  232. EX ldc1 $f23, SC32_FPREGS+184(a0)
  233. EX ldc1 $f25, SC32_FPREGS+200(a0)
  234. EX ldc1 $f27, SC32_FPREGS+216(a0)
  235. EX ldc1 $f29, SC32_FPREGS+232(a0)
  236. EX ldc1 $f31, SC32_FPREGS+248(a0)
  237. 1: EX ldc1 $f0, SC32_FPREGS+0(a0)
  238. EX ldc1 $f2, SC32_FPREGS+16(a0)
  239. EX ldc1 $f4, SC32_FPREGS+32(a0)
  240. EX ldc1 $f6, SC32_FPREGS+48(a0)
  241. EX ldc1 $f8, SC32_FPREGS+64(a0)
  242. EX ldc1 $f10, SC32_FPREGS+80(a0)
  243. EX ldc1 $f12, SC32_FPREGS+96(a0)
  244. EX ldc1 $f14, SC32_FPREGS+112(a0)
  245. EX ldc1 $f16, SC32_FPREGS+128(a0)
  246. EX ldc1 $f18, SC32_FPREGS+144(a0)
  247. EX ldc1 $f20, SC32_FPREGS+160(a0)
  248. EX ldc1 $f22, SC32_FPREGS+176(a0)
  249. EX ldc1 $f24, SC32_FPREGS+192(a0)
  250. EX ldc1 $f26, SC32_FPREGS+208(a0)
  251. EX ldc1 $f28, SC32_FPREGS+224(a0)
  252. EX ldc1 $f30, SC32_FPREGS+240(a0)
  253. ctc1 t1, fcr31
  254. jr ra
  255. li v0, 0 # success
  256. .set pop
  257. END(_restore_fp_context32)
  258. #endif
  259. .set reorder
  260. .type fault@function
  261. .ent fault
  262. fault: li v0, -EFAULT # failure
  263. jr ra
  264. .end fault