r2300_fpu.S 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 ([email protected])
  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_WD 9b,fault; \
  26. .previous
  27. #define EX2(a,b) \
  28. 9: a,##b; \
  29. .section __ex_table,"a"; \
  30. PTR_WD 9b,fault; \
  31. PTR_WD 9b+4,fault; \
  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. .set noreorder
  50. /**
  51. * _save_fp_context() - save FP context from the FPU
  52. * @a0 - pointer to fpregs field of sigcontext
  53. * @a1 - pointer to fpc_csr field of sigcontext
  54. *
  55. * Save FP context, including the 32 FP data registers and the FP
  56. * control & status register, from the FPU to signal context.
  57. */
  58. LEAF(_save_fp_context)
  59. .set push
  60. SET_HARDFLOAT
  61. li v0, 0 # assume success
  62. cfc1 t1, fcr31
  63. EX2(s.d $f0, 0(a0))
  64. EX2(s.d $f2, 16(a0))
  65. EX2(s.d $f4, 32(a0))
  66. EX2(s.d $f6, 48(a0))
  67. EX2(s.d $f8, 64(a0))
  68. EX2(s.d $f10, 80(a0))
  69. EX2(s.d $f12, 96(a0))
  70. EX2(s.d $f14, 112(a0))
  71. EX2(s.d $f16, 128(a0))
  72. EX2(s.d $f18, 144(a0))
  73. EX2(s.d $f20, 160(a0))
  74. EX2(s.d $f22, 176(a0))
  75. EX2(s.d $f24, 192(a0))
  76. EX2(s.d $f26, 208(a0))
  77. EX2(s.d $f28, 224(a0))
  78. EX2(s.d $f30, 240(a0))
  79. jr ra
  80. EX(sw t1, (a1))
  81. .set pop
  82. END(_save_fp_context)
  83. /**
  84. * _restore_fp_context() - restore FP context to the FPU
  85. * @a0 - pointer to fpregs field of sigcontext
  86. * @a1 - pointer to fpc_csr field of sigcontext
  87. *
  88. * Restore FP context, including the 32 FP data registers and the FP
  89. * control & status register, from signal context to the FPU.
  90. */
  91. LEAF(_restore_fp_context)
  92. .set push
  93. SET_HARDFLOAT
  94. li v0, 0 # assume success
  95. EX(lw t0, (a1))
  96. EX2(l.d $f0, 0(a0))
  97. EX2(l.d $f2, 16(a0))
  98. EX2(l.d $f4, 32(a0))
  99. EX2(l.d $f6, 48(a0))
  100. EX2(l.d $f8, 64(a0))
  101. EX2(l.d $f10, 80(a0))
  102. EX2(l.d $f12, 96(a0))
  103. EX2(l.d $f14, 112(a0))
  104. EX2(l.d $f16, 128(a0))
  105. EX2(l.d $f18, 144(a0))
  106. EX2(l.d $f20, 160(a0))
  107. EX2(l.d $f22, 176(a0))
  108. EX2(l.d $f24, 192(a0))
  109. EX2(l.d $f26, 208(a0))
  110. EX2(l.d $f28, 224(a0))
  111. EX2(l.d $f30, 240(a0))
  112. jr ra
  113. ctc1 t0, fcr31
  114. .set pop
  115. END(_restore_fp_context)
  116. .set reorder
  117. .type fault, @function
  118. .ent fault
  119. fault: li v0, -EFAULT
  120. jr ra
  121. .end fault