Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

204 lines
6.2 KiB

  1. /**
  2. *** Copyright (C) 1996-97 Intel Corporation. All rights reserved.
  3. ***
  4. *** The information and source code contained herein is the exclusive
  5. *** property of Intel Corporation and may not be disclosed, examined
  6. *** or reproduced in whole or in part without explicit written authorization
  7. *** from the company.
  8. **/
  9. // TITLE("Context Conversion")
  10. //++
  11. //
  12. // Module Name:
  13. //
  14. // convctx.s
  15. //
  16. // Abstract:
  17. //
  18. // This module implements the code necessary to convert or assign
  19. // the user to kernel transition context to or from iA mode context.
  20. //
  21. // Author:
  22. //
  23. // Edward G. Chron (echron) 01-Apr-1996
  24. //
  25. // Environment:
  26. //
  27. // Kernel mode only.
  28. //
  29. // Revision History:
  30. //
  31. //
  32. //--
  33. #include "ksia64.h"
  34. .file "convctx.s"
  35. //++
  36. //
  37. // VOID
  38. // RtlEmFpToIaFpContext (
  39. // IN PCONTEXT ContextEM,
  40. // IN OUT UCHAR *iAFpArea
  41. // )
  42. //
  43. // Routine Description:
  44. //
  45. // This function takes the values stored for the EM FP registers which
  46. // map the iA mode FP registers and copies them (in iA mode 10 byte
  47. // format) to the targeted 80 byte iA mode FP register context area.
  48. //
  49. // Arguments:
  50. //
  51. // ContextEM (a0) - Pointer to the EM mode Context which contain the FP registers.
  52. // iAFpArea(a1) - Pointer to area to store 8 * 10 byte iA mode FP regs.
  53. //
  54. // Return Value:
  55. //
  56. // None.
  57. //
  58. // N.B. The format iA mode FP registers is 80 bits and will not change.
  59. //
  60. //--
  61. LEAF_ENTRY(RtlEmFpToIaFpContext)
  62. add t5 = -8, r0 // Need to convert 8 EM mode FP Regs
  63. cvtEmFp:
  64. ldfe ft0 = [a0], 16 // Get EM FP reg mapping iA FP reg
  65. add t4 = -4, r0 // Need to store 2 bytes 4 times
  66. ;;
  67. getf.sig t2 = ft0 // floating-point reg significand
  68. getf.exp t3 = ft0 // floating-point sign & exponent
  69. ;;
  70. stIaFpReg:
  71. st2 [a1] = t2, 2 // save 2 bytes of significand
  72. extr.u t2 = t2, 16, 48 // shift to the next two bytes
  73. adds t4 = 0x1, t4 // bump loop count
  74. ;;
  75. cmp.lt p6, p0 = t4, r0 // done?
  76. (p6) br.cond.dpnt.few stIaFpReg // no, store the next two bytes
  77. adds t5 = 0x1, t5 // bump loop count
  78. add t4 = 0, t3 // copy of exponent and sign
  79. ;;
  80. extr.u t4 = t4, 2, 62 // get the sign in bit 15
  81. ;;
  82. cmp.lt p6, p7 = t5, r0 // done?
  83. dep t3 = t3, t4, 0, 15 // just first 16 bits of exponent
  84. ;;
  85. st2 [a1] = t3, 2 // save sign and iA exponent
  86. (p6) br.cond.dpnt.few cvtEmFp // no, process the next register
  87. (p7) br.ret.sptk brp
  88. ;;
  89. LEAF_EXIT(RtlEmFpToIaFpContext)
  90. //++
  91. //
  92. // VOID
  93. // RtlIaFpToEmFpContext (
  94. // IN UCHAR *iAFpArea,
  95. // IN OUT PCONTEXT ContextEM,
  96. // IN OUT FLOAT128 *FpWorkArea
  97. // )
  98. //
  99. // Routine Description:
  100. //
  101. // This function takes the values stored for the EM FP registers which
  102. // map the iA mode FP registers and copies them (in iA mode 10 byte
  103. // format) to the targeted 80 byte iA mode FP register context area.
  104. //
  105. // Arguments:
  106. //
  107. // ContextEM (a0) - Pointer to the EM mode Context registers that map iA mode FP regs.
  108. // iAFpArea(a1) - Pointer to area to store 8 * 10 byte iA mode FP regs.
  109. // alignedFp(a2) - FLOAT128 work area (aligned on 16 byte boundry).
  110. //
  111. // Return Value:
  112. //
  113. // None.
  114. //
  115. // N.B. The format iA mode FP registers is 80 bits and will not change.
  116. //
  117. //--
  118. LEAF_ENTRY(RtlIaFpToEmFpContext)
  119. add t0 = 8, a0 // iA Fp Save Area Pointer
  120. add t5 = -8, r0 // Need to convert 8 iA mode FP Regs
  121. ;;
  122. cvtIaFp:
  123. add t8 = -4, r0 // Need to load 2 bytes 4 times
  124. ld2 t3 = [t0], -2 // load exponent and sign
  125. ;;
  126. add t4 = 0, t3 // copy of exponent and sign
  127. ;;
  128. add t2 = 0, r0
  129. extr.u t4 = t4, 15, 49 // get the sign in bit 17
  130. ;;
  131. dep t3 = t4, t3, 17, 1 // just first 16 bits of exponent
  132. ldIaFpReg:
  133. ld2 t6 = [t0], -2 // load 2 bytes of significand
  134. adds t8 = 0x1, t8 // bump loop count
  135. ;;
  136. or t2 = t2, t6 // retain until complete
  137. cmp.lt p6, p0 = t8, r0 // done?
  138. ;;
  139. (p6) dep.z t2 = t2, 16, 48 // no, shift to the next two bytes
  140. (p6) br.cond.dpnt.few ldIaFpReg // no, get next two bytes
  141. ;;
  142. add t8 = -4, r0 // Need to store 2 bytes 4 times
  143. mov t7 = a2 // get address of aligned save area
  144. ;;
  145. alignIaFp:
  146. st2 [t7] = t2, 2 // save 2 bytes of significand
  147. extr.u t2 = t2, 16, 48 // shift to the next two bytes
  148. adds t8 = 0x1, t8 // bump loop count
  149. ;;
  150. cmp.lt p6, p0 = t8, r0 // done?
  151. add t6 = 0, t3 // copy of exponent and sign
  152. (p6) br.cond.dpnt.few alignIaFp // maybe
  153. ;;
  154. nop.m 0
  155. extr.u t6 = t6, 2, 62 // get the sign in bit 15
  156. ;;
  157. dep t3 = t3, t6, 0, 15 // just first 15 bits of exponent
  158. ;;
  159. st2 [t7] = t3, 2 // save sign and iA exponent
  160. ldfe ft0 = [a2]
  161. adds t5 = 0x1, t5 // bump loop count
  162. ;;
  163. stfe [a1] = ft0, CxFltT3 - CxFltT2 // Store value into EM FP Context
  164. cmp.lt p6, p7 = t5, r0 // done?
  165. ;;
  166. (p6) add t2 = 0, r0 // no, reset significand for next
  167. (p6) add t0 = 20, t0 // no, starting at the high end
  168. (p6) br.cond.dpnt.few cvtIaFp // no, get next context record
  169. (p7) br.ret.sptk brp
  170. ;;
  171. LEAF_EXIT(RtlIaFpToEmFpContext)