r2300_fpu.S 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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/errno.h>
  16. #include <asm/fpregdef.h>
  17. #include <asm/mipsregs.h>
  18. #include <asm/asm-offsets.h>
  19. #include <asm/regdef.h>
  20. #define EX(a,b) \
  21. 9: a,##b; \
  22. .section __ex_table,"a"; \
  23. PTR 9b,fault; \
  24. .previous
  25. #define EX2(a,b) \
  26. 9: a,##b; \
  27. .section __ex_table,"a"; \
  28. PTR 9b,bad_stack; \
  29. PTR 9b+4,bad_stack; \
  30. .previous
  31. .set noreorder
  32. .set mips1
  33. /**
  34. * _save_fp_context() - save FP context from the FPU
  35. * @a0 - pointer to fpregs field of sigcontext
  36. * @a1 - pointer to fpc_csr field of sigcontext
  37. *
  38. * Save FP context, including the 32 FP data registers and the FP
  39. * control & status register, from the FPU to signal context.
  40. */
  41. LEAF(_save_fp_context)
  42. .set push
  43. SET_HARDFLOAT
  44. li v0, 0 # assume success
  45. cfc1 t1, fcr31
  46. EX2(s.d $f0, 0(a0))
  47. EX2(s.d $f2, 16(a0))
  48. EX2(s.d $f4, 32(a0))
  49. EX2(s.d $f6, 48(a0))
  50. EX2(s.d $f8, 64(a0))
  51. EX2(s.d $f10, 80(a0))
  52. EX2(s.d $f12, 96(a0))
  53. EX2(s.d $f14, 112(a0))
  54. EX2(s.d $f16, 128(a0))
  55. EX2(s.d $f18, 144(a0))
  56. EX2(s.d $f20, 160(a0))
  57. EX2(s.d $f22, 176(a0))
  58. EX2(s.d $f24, 192(a0))
  59. EX2(s.d $f26, 208(a0))
  60. EX2(s.d $f28, 224(a0))
  61. EX2(s.d $f30, 240(a0))
  62. jr ra
  63. EX(sw t1, (a1))
  64. .set pop
  65. END(_save_fp_context)
  66. /**
  67. * _restore_fp_context() - restore FP context to the FPU
  68. * @a0 - pointer to fpregs field of sigcontext
  69. * @a1 - pointer to fpc_csr field of sigcontext
  70. *
  71. * Restore FP context, including the 32 FP data registers and the FP
  72. * control & status register, from signal context to the FPU.
  73. */
  74. LEAF(_restore_fp_context)
  75. .set push
  76. SET_HARDFLOAT
  77. li v0, 0 # assume success
  78. EX(lw t0, (a1))
  79. EX2(l.d $f0, 0(a0))
  80. EX2(l.d $f2, 16(a0))
  81. EX2(l.d $f4, 32(a0))
  82. EX2(l.d $f6, 48(a0))
  83. EX2(l.d $f8, 64(a0))
  84. EX2(l.d $f10, 80(a0))
  85. EX2(l.d $f12, 96(a0))
  86. EX2(l.d $f14, 112(a0))
  87. EX2(l.d $f16, 128(a0))
  88. EX2(l.d $f18, 144(a0))
  89. EX2(l.d $f20, 160(a0))
  90. EX2(l.d $f22, 176(a0))
  91. EX2(l.d $f24, 192(a0))
  92. EX2(l.d $f26, 208(a0))
  93. EX2(l.d $f28, 224(a0))
  94. EX2(l.d $f30, 240(a0))
  95. jr ra
  96. ctc1 t0, fcr31
  97. .set pop
  98. END(_restore_fp_context)
  99. .set reorder
  100. .type fault, @function
  101. .ent fault
  102. fault: li v0, -EFAULT
  103. jr ra
  104. .end fault