Leaked source code of windows server 2003
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.

227 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. //++
  10. //
  11. // Module Name:
  12. //
  13. // setjmp.s
  14. //
  15. // Abstract:
  16. //
  17. // This module implements the IA64 specific routine to perform a setjmp.
  18. //
  19. // N.B. This module has two entry points that provide SAFE and UNSAFE
  20. // handling of setjmp.
  21. //
  22. // Author:
  23. //
  24. // William K. Cheung (wcheung) 27-Jan-1996
  25. //
  26. // Environment:
  27. //
  28. // Any mode.
  29. //
  30. // Revision History:
  31. //
  32. // Modified to support mixed ISA.
  33. //
  34. //--
  35. #include "ksia64.h"
  36. .global _setjmpexused
  37. .common _setjmpexused,8,8
  38. //++
  39. //
  40. // int
  41. // setjmp (
  42. // IN jmp_buf JumpBuffer
  43. // )
  44. //
  45. // Routine Description:
  46. //
  47. // This function saved the current nonvolatile register state in the
  48. // specified jump buffer and returns a function vlaue of zero.
  49. //
  50. // Arguments:
  51. //
  52. // JumpBuffer (a0) - Supplies the address of a jump buffer to store the
  53. // jump information.
  54. //
  55. // MemoryStackFp (a1) - Supplies the memory stack frame pointer (psp)
  56. // of the caller. It's an optional argument.
  57. //
  58. // Return Value:
  59. //
  60. // A value of zero is returned.
  61. //
  62. //--
  63. LEAF_ENTRY(setjmp)
  64. ALTERNATE_ENTRY(_setjmp)
  65. LEAF_SETUP(3, 0, 0, 0)
  66. rUnat = t8
  67. rFpsr = t9
  68. rLc = t10
  69. rPr = t11
  70. rBrp = t21
  71. rPfs = t22
  72. rPsp = a1
  73. rBsp = a2
  74. mov rUnat = ar.unat
  75. add t1 = JbUnwindData, a0
  76. add t0 = @gprel(_setjmpexused), gp
  77. ;;
  78. mov rFpsr = ar.fpsr
  79. ld8 t0 = [t0] // load the entry point of
  80. ;; // the safe setjmp version.
  81. cmp.ne pt1, pt0 = zero, t0
  82. ;;
  83. (pt0) st8.nta [t1] = zero
  84. mov bt0 = t0
  85. (pt1) br.cond.spnt.many bt0 // branch if non-zero
  86. ALTERNATE_ENTRY(_setjmp_common)
  87. //
  88. // rUnat & rFpsr have been set to content of ar.unat and ar.fpsr
  89. //
  90. // Save the non-volatile EM state in the jump buffer
  91. //
  92. // 1) Save preserved floating point registers
  93. // 2) Move preserved branch registers and application registers into general
  94. // registers that are later saved into the corresponding fields in the
  95. // jump buffer.
  96. // 3) Save preserved integer registers.
  97. // 4) At the same time, compute the bit position at which the NaTs of preserved
  98. // integer registers are saved and rotate them such that the bit positions
  99. // of the saved NaTs and corresponding registers have a one-to-one mapping.
  100. //
  101. add t0 = JbFltS0, a0
  102. add t1 = JbFltS1, a0
  103. mov rBrp = brp
  104. ;;
  105. stf.spill.nta [t0] = fs0, JbFltS2 - JbFltS0
  106. stf.spill.nta [t1] = fs1, JbFltS3 - JbFltS1
  107. mov t13 = bs0
  108. ;;
  109. stf.spill.nta [t0] = fs2, JbFltS4 - JbFltS2
  110. stf.spill.nta [t1] = fs3, JbFltS5 - JbFltS3
  111. mov t14 = bs1
  112. ;;
  113. stf.spill.nta [t0] = fs4, JbFltS6 - JbFltS4
  114. stf.spill.nta [t1] = fs5, JbFltS7 - JbFltS5
  115. mov t15 = bs2
  116. ;;
  117. stf.spill.nta [t0] = fs6, JbFltS8 - JbFltS6
  118. stf.spill.nta [t1] = fs7, JbFltS9 - JbFltS7
  119. mov t16 = bs3
  120. ;;
  121. stf.spill.nta [t0] = fs8, JbFltS10 - JbFltS8
  122. stf.spill.nta [t1] = fs9, JbFltS11 - JbFltS9
  123. mov t17 = bs4
  124. ;;
  125. stf.spill.nta [t0] = fs10, JbFltS12 - JbFltS10
  126. stf.spill.nta [t1] = fs11, JbFltS13 - JbFltS11
  127. mov rLc = ar.lc
  128. ;;
  129. stf.spill.nta [t0] = fs12, JbFltS14 - JbFltS12
  130. stf.spill.nta [t1] = fs13, JbFltS15 - JbFltS13
  131. mov rPr = pr
  132. ;;
  133. stf.spill.nta [t0] = fs14, JbFltS16 - JbFltS14
  134. stf.spill.nta [t1] = fs15, JbFltS17 - JbFltS15
  135. add t2 = JbIntS0, a0
  136. ;;
  137. stf.spill.nta [t0] = fs16, JbFltS18 - JbFltS16
  138. stf.spill.nta [t1] = fs17, JbFltS19 - JbFltS17
  139. shr.u t2 = t2, 3
  140. ;;
  141. stf.spill.nta [t0] = fs18, JbIntS0 - JbFltS18
  142. stf.spill.nta [t1] = fs19, JbIntS1 - JbFltS19
  143. and t2 = 0x3f, t2
  144. ;;
  145. .mem.offset 0,0
  146. st8.spill.nta [t0] = s0, JbIntS2 - JbIntS0
  147. .mem.offset 0,8
  148. st8.spill.nta [t1] = s1, JbIntS3 - JbIntS1
  149. cmp4.ge pt1, pt0 = 4, t2
  150. ;;
  151. .mem.offset 0,0
  152. st8.spill.nta [t0] = s2, JbIntSp - JbIntS2
  153. .mem.offset 0,8
  154. st8.spill.nta [t1] = s3, JbPreds - JbIntS3
  155. (pt0) add t5 = -4, t2
  156. ;;
  157. st8.spill.nta [t0] = sp, JbStIIP - JbIntSp
  158. st8.nta [t1] = rPr, JbBrS0 - JbPreds
  159. (pt0) sub t6 = 68, t2
  160. ;;
  161. mov t7 = ar.unat
  162. st8.nta [t0] = rBrp, JbBrS1 - JbStIIP
  163. (pt1) sub t5 = 4, t2
  164. ;;
  165. st8.nta [t1] = t13, JbBrS2 - JbBrS0
  166. mov rPfs = ar.pfs
  167. (pt1) shl t2 = t7, t5
  168. ;;
  169. st8.nta [t0] = t14, JbBrS3 - JbBrS1
  170. st8.nta [t1] = t15, JbBrS4 - JbBrS2
  171. (pt0) shr.u t3 = t7, t5
  172. ;;
  173. st8.nta [t0] = t16, JbRsBSP - JbBrS3
  174. st8.nta [t1] = t17, JbRsPFS - JbBrS4
  175. (pt0) shl t4 = t7, t6
  176. ;;
  177. st8.nta [t0] = rBsp, JbApUNAT - JbRsBSP
  178. st8.nta [t1] = rPfs, JbApLC - JbRsPFS
  179. (pt0) or t2 = t3, t4
  180. ;;
  181. st8.nta [t0] = rUnat, JbIntNats - JbApUNAT
  182. st8.nta [t1] = rLc, JbFPSR-JbApLC
  183. mov v0 = zero
  184. ;;
  185. st8.nta [t0] = t2 // save integer nats.
  186. st8.nta [t1] = rFpsr // save the fpsr
  187. mov ar.unat = rUnat // restore ar.unat
  188. br.ret.sptk brp
  189. LEAF_EXIT(setjmp)