VISsave.S 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /* $Id: VISsave.S,v 1.6 2002/02/09 19:49:30 davem Exp $
  2. * VISsave.S: Code for saving FPU register state for
  3. * VIS routines. One should not call this directly,
  4. * but use macros provided in <asm/visasm.h>.
  5. *
  6. * Copyright (C) 1998 Jakub Jelinek (jj@ultra.linux.cz)
  7. */
  8. #include <asm/asi.h>
  9. #include <asm/page.h>
  10. #include <asm/ptrace.h>
  11. #include <asm/visasm.h>
  12. #include <asm/thread_info.h>
  13. .text
  14. .globl VISenter, VISenterhalf
  15. /* On entry: %o5=current FPRS value, %g7 is callers address */
  16. /* May clobber %o5, %g1, %g2, %g3, %g7, %icc, %xcc */
  17. /* Nothing special need be done here to handle pre-emption, this
  18. * FPU save/restore mechanism is already preemption safe.
  19. */
  20. .align 32
  21. VISenter:
  22. ldub [%g6 + TI_FPDEPTH], %g1
  23. brnz,a,pn %g1, 1f
  24. cmp %g1, 1
  25. stb %g0, [%g6 + TI_FPSAVED]
  26. stx %fsr, [%g6 + TI_XFSR]
  27. 9: jmpl %g7 + %g0, %g0
  28. nop
  29. 1: bne,pn %icc, 2f
  30. srl %g1, 1, %g1
  31. vis1: ldub [%g6 + TI_FPSAVED], %g3
  32. stx %fsr, [%g6 + TI_XFSR]
  33. or %g3, %o5, %g3
  34. stb %g3, [%g6 + TI_FPSAVED]
  35. rd %gsr, %g3
  36. clr %g1
  37. ba,pt %xcc, 3f
  38. stx %g3, [%g6 + TI_GSR]
  39. 2: add %g6, %g1, %g3
  40. cmp %o5, FPRS_DU
  41. be,pn %icc, 6f
  42. sll %g1, 3, %g1
  43. stb %o5, [%g3 + TI_FPSAVED]
  44. rd %gsr, %g2
  45. add %g6, %g1, %g3
  46. stx %g2, [%g3 + TI_GSR]
  47. add %g6, %g1, %g2
  48. stx %fsr, [%g2 + TI_XFSR]
  49. sll %g1, 5, %g1
  50. 3: andcc %o5, FPRS_DL|FPRS_DU, %g0
  51. be,pn %icc, 9b
  52. add %g6, TI_FPREGS, %g2
  53. andcc %o5, FPRS_DL, %g0
  54. membar #StoreStore | #LoadStore
  55. be,pn %icc, 4f
  56. add %g6, TI_FPREGS+0x40, %g3
  57. stda %f0, [%g2 + %g1] ASI_BLK_P
  58. stda %f16, [%g3 + %g1] ASI_BLK_P
  59. andcc %o5, FPRS_DU, %g0
  60. be,pn %icc, 5f
  61. 4: add %g1, 128, %g1
  62. stda %f32, [%g2 + %g1] ASI_BLK_P
  63. stda %f48, [%g3 + %g1] ASI_BLK_P
  64. 5: membar #Sync
  65. jmpl %g7 + %g0, %g0
  66. nop
  67. 6: ldub [%g3 + TI_FPSAVED], %o5
  68. or %o5, FPRS_DU, %o5
  69. add %g6, TI_FPREGS+0x80, %g2
  70. stb %o5, [%g3 + TI_FPSAVED]
  71. sll %g1, 5, %g1
  72. add %g6, TI_FPREGS+0xc0, %g3
  73. wr %g0, FPRS_FEF, %fprs
  74. membar #StoreStore | #LoadStore
  75. stda %f32, [%g2 + %g1] ASI_BLK_P
  76. stda %f48, [%g3 + %g1] ASI_BLK_P
  77. membar #Sync
  78. jmpl %g7 + %g0, %g0
  79. nop
  80. .align 32
  81. VISenterhalf:
  82. ldub [%g6 + TI_FPDEPTH], %g1
  83. brnz,a,pn %g1, 1f
  84. cmp %g1, 1
  85. stb %g0, [%g6 + TI_FPSAVED]
  86. stx %fsr, [%g6 + TI_XFSR]
  87. clr %o5
  88. jmpl %g7 + %g0, %g0
  89. wr %g0, FPRS_FEF, %fprs
  90. 1: bne,pn %icc, 2f
  91. srl %g1, 1, %g1
  92. ba,pt %xcc, vis1
  93. sub %g7, 8, %g7
  94. 2: addcc %g6, %g1, %g3
  95. sll %g1, 3, %g1
  96. andn %o5, FPRS_DU, %g2
  97. stb %g2, [%g3 + TI_FPSAVED]
  98. rd %gsr, %g2
  99. add %g6, %g1, %g3
  100. stx %g2, [%g3 + TI_GSR]
  101. add %g6, %g1, %g2
  102. stx %fsr, [%g2 + TI_XFSR]
  103. sll %g1, 5, %g1
  104. 3: andcc %o5, FPRS_DL, %g0
  105. be,pn %icc, 4f
  106. add %g6, TI_FPREGS, %g2
  107. membar #StoreStore | #LoadStore
  108. add %g6, TI_FPREGS+0x40, %g3
  109. stda %f0, [%g2 + %g1] ASI_BLK_P
  110. stda %f16, [%g3 + %g1] ASI_BLK_P
  111. membar #Sync
  112. 4: and %o5, FPRS_DU, %o5
  113. jmpl %g7 + %g0, %g0
  114. wr %o5, FPRS_FEF, %fprs