VISsave.S 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  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. be,pn %icc, 4f
  55. add %g6, TI_FPREGS+0x40, %g3
  56. membar #Sync
  57. stda %f0, [%g2 + %g1] ASI_BLK_P
  58. stda %f16, [%g3 + %g1] ASI_BLK_P
  59. membar #Sync
  60. andcc %o5, FPRS_DU, %g0
  61. be,pn %icc, 5f
  62. 4: add %g1, 128, %g1
  63. membar #Sync
  64. stda %f32, [%g2 + %g1] ASI_BLK_P
  65. stda %f48, [%g3 + %g1] ASI_BLK_P
  66. 5: membar #Sync
  67. ba,pt %xcc, 80f
  68. nop
  69. .align 32
  70. 80: jmpl %g7 + %g0, %g0
  71. nop
  72. 6: ldub [%g3 + TI_FPSAVED], %o5
  73. or %o5, FPRS_DU, %o5
  74. add %g6, TI_FPREGS+0x80, %g2
  75. stb %o5, [%g3 + TI_FPSAVED]
  76. sll %g1, 5, %g1
  77. add %g6, TI_FPREGS+0xc0, %g3
  78. wr %g0, FPRS_FEF, %fprs
  79. membar #Sync
  80. stda %f32, [%g2 + %g1] ASI_BLK_P
  81. stda %f48, [%g3 + %g1] ASI_BLK_P
  82. membar #Sync
  83. ba,pt %xcc, 80f
  84. nop
  85. .align 32
  86. 80: jmpl %g7 + %g0, %g0
  87. nop
  88. .align 32
  89. VISenterhalf:
  90. ldub [%g6 + TI_FPDEPTH], %g1
  91. brnz,a,pn %g1, 1f
  92. cmp %g1, 1
  93. stb %g0, [%g6 + TI_FPSAVED]
  94. stx %fsr, [%g6 + TI_XFSR]
  95. clr %o5
  96. jmpl %g7 + %g0, %g0
  97. wr %g0, FPRS_FEF, %fprs
  98. 1: bne,pn %icc, 2f
  99. srl %g1, 1, %g1
  100. ba,pt %xcc, vis1
  101. sub %g7, 8, %g7
  102. 2: addcc %g6, %g1, %g3
  103. sll %g1, 3, %g1
  104. andn %o5, FPRS_DU, %g2
  105. stb %g2, [%g3 + TI_FPSAVED]
  106. rd %gsr, %g2
  107. add %g6, %g1, %g3
  108. stx %g2, [%g3 + TI_GSR]
  109. add %g6, %g1, %g2
  110. stx %fsr, [%g2 + TI_XFSR]
  111. sll %g1, 5, %g1
  112. 3: andcc %o5, FPRS_DL, %g0
  113. be,pn %icc, 4f
  114. add %g6, TI_FPREGS, %g2
  115. add %g6, TI_FPREGS+0x40, %g3
  116. membar #Sync
  117. stda %f0, [%g2 + %g1] ASI_BLK_P
  118. stda %f16, [%g3 + %g1] ASI_BLK_P
  119. membar #Sync
  120. ba,pt %xcc, 4f
  121. nop
  122. .align 32
  123. 4: and %o5, FPRS_DU, %o5
  124. jmpl %g7 + %g0, %g0
  125. wr %o5, FPRS_FEF, %fprs