VISsave.S 3.0 KB

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