r2300_fpu.S 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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, 1998 by 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. * Further modifications to make this work:
  12. * Copyright (c) 1998 Harald Koerfgen
  13. */
  14. #include <asm/asm.h>
  15. #include <asm/asmmacro.h>
  16. #include <asm/errno.h>
  17. #include <asm/export.h>
  18. #include <asm/fpregdef.h>
  19. #include <asm/mipsregs.h>
  20. #include <asm/asm-offsets.h>
  21. #include <asm/regdef.h>
  22. #define EX(a,b) \
  23. 9: a,##b; \
  24. .section __ex_table,"a"; \
  25. PTR 9b,fault; \
  26. .previous
  27. #define EX2(a,b) \
  28. 9: a,##b; \
  29. .section __ex_table,"a"; \
  30. PTR 9b,bad_stack; \
  31. PTR 9b+4,bad_stack; \
  32. .previous
  33. .set mips1
  34. /*
  35. * Save a thread's fp context.
  36. */
  37. LEAF(_save_fp)
  38. EXPORT_SYMBOL(_save_fp)
  39. fpu_save_single a0, t1 # clobbers t1
  40. jr ra
  41. END(_save_fp)
  42. /*
  43. * Restore a thread's fp context.
  44. */
  45. LEAF(_restore_fp)
  46. fpu_restore_single a0, t1 # clobbers t1
  47. jr ra
  48. END(_restore_fp)
  49. /*
  50. * Load the FPU with signalling NANS. This bit pattern we're using has
  51. * the property that no matter whether considered as single or as double
  52. * precision represents signaling NANS.
  53. *
  54. * The value to initialize fcr31 to comes in $a0.
  55. */
  56. .set push
  57. SET_HARDFLOAT
  58. LEAF(_init_fpu)
  59. mfc0 t0, CP0_STATUS
  60. li t1, ST0_CU1
  61. or t0, t1
  62. mtc0 t0, CP0_STATUS
  63. ctc1 a0, fcr31
  64. li t0, -1
  65. mtc1 t0, $f0
  66. mtc1 t0, $f1
  67. mtc1 t0, $f2
  68. mtc1 t0, $f3
  69. mtc1 t0, $f4
  70. mtc1 t0, $f5
  71. mtc1 t0, $f6
  72. mtc1 t0, $f7
  73. mtc1 t0, $f8
  74. mtc1 t0, $f9
  75. mtc1 t0, $f10
  76. mtc1 t0, $f11
  77. mtc1 t0, $f12
  78. mtc1 t0, $f13
  79. mtc1 t0, $f14
  80. mtc1 t0, $f15
  81. mtc1 t0, $f16
  82. mtc1 t0, $f17
  83. mtc1 t0, $f18
  84. mtc1 t0, $f19
  85. mtc1 t0, $f20
  86. mtc1 t0, $f21
  87. mtc1 t0, $f22
  88. mtc1 t0, $f23
  89. mtc1 t0, $f24
  90. mtc1 t0, $f25
  91. mtc1 t0, $f26
  92. mtc1 t0, $f27
  93. mtc1 t0, $f28
  94. mtc1 t0, $f29
  95. mtc1 t0, $f30
  96. mtc1 t0, $f31
  97. jr ra
  98. END(_init_fpu)
  99. .set pop
  100. .set noreorder
  101. /**
  102. * _save_fp_context() - save FP context from the FPU
  103. * @a0 - pointer to fpregs field of sigcontext
  104. * @a1 - pointer to fpc_csr field of sigcontext
  105. *
  106. * Save FP context, including the 32 FP data registers and the FP
  107. * control & status register, from the FPU to signal context.
  108. */
  109. LEAF(_save_fp_context)
  110. .set push
  111. SET_HARDFLOAT
  112. li v0, 0 # assume success
  113. cfc1 t1, fcr31
  114. EX2(s.d $f0, 0(a0))
  115. EX2(s.d $f2, 16(a0))
  116. EX2(s.d $f4, 32(a0))
  117. EX2(s.d $f6, 48(a0))
  118. EX2(s.d $f8, 64(a0))
  119. EX2(s.d $f10, 80(a0))
  120. EX2(s.d $f12, 96(a0))
  121. EX2(s.d $f14, 112(a0))
  122. EX2(s.d $f16, 128(a0))
  123. EX2(s.d $f18, 144(a0))
  124. EX2(s.d $f20, 160(a0))
  125. EX2(s.d $f22, 176(a0))
  126. EX2(s.d $f24, 192(a0))
  127. EX2(s.d $f26, 208(a0))
  128. EX2(s.d $f28, 224(a0))
  129. EX2(s.d $f30, 240(a0))
  130. jr ra
  131. EX(sw t1, (a1))
  132. .set pop
  133. END(_save_fp_context)
  134. /**
  135. * _restore_fp_context() - restore FP context to the FPU
  136. * @a0 - pointer to fpregs field of sigcontext
  137. * @a1 - pointer to fpc_csr field of sigcontext
  138. *
  139. * Restore FP context, including the 32 FP data registers and the FP
  140. * control & status register, from signal context to the FPU.
  141. */
  142. LEAF(_restore_fp_context)
  143. .set push
  144. SET_HARDFLOAT
  145. li v0, 0 # assume success
  146. EX(lw t0, (a1))
  147. EX2(l.d $f0, 0(a0))
  148. EX2(l.d $f2, 16(a0))
  149. EX2(l.d $f4, 32(a0))
  150. EX2(l.d $f6, 48(a0))
  151. EX2(l.d $f8, 64(a0))
  152. EX2(l.d $f10, 80(a0))
  153. EX2(l.d $f12, 96(a0))
  154. EX2(l.d $f14, 112(a0))
  155. EX2(l.d $f16, 128(a0))
  156. EX2(l.d $f18, 144(a0))
  157. EX2(l.d $f20, 160(a0))
  158. EX2(l.d $f22, 176(a0))
  159. EX2(l.d $f24, 192(a0))
  160. EX2(l.d $f26, 208(a0))
  161. EX2(l.d $f28, 224(a0))
  162. EX2(l.d $f30, 240(a0))
  163. jr ra
  164. ctc1 t0, fcr31
  165. .set pop
  166. END(_restore_fp_context)
  167. .set reorder
  168. .type fault, @function
  169. .ent fault
  170. fault: li v0, -EFAULT
  171. jr ra
  172. .end fault