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.

235 lines
4.4 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. // miscs.s
  14. //
  15. // Abstract:
  16. //
  17. // This module implements the IA64 intrinsics.
  18. //
  19. // Author:
  20. //
  21. // William K. Cheung (wcheung) 18-Mar-1996
  22. //
  23. // Environment:
  24. //
  25. // Any mode.
  26. //
  27. // Revision History:
  28. //
  29. //--
  30. #include "ksia64.h"
  31. //++
  32. //
  33. // ULONGLONG
  34. // _P32ToP64 (
  35. // ULONG Pointer
  36. // )
  37. //
  38. // Routine Description:
  39. //
  40. // This function swizzles a pointer.
  41. //
  42. // Arguments:
  43. //
  44. // Pointer (a0) - 32-bit pointer.
  45. //
  46. // Return Value:
  47. //
  48. // Swizzle pointer value.
  49. //
  50. //--
  51. LEAF_ENTRY(_P32ToP64)
  52. nop.m 0
  53. sxt4 v0 = a0
  54. (p0) br.ret.sptk brp
  55. LEAF_EXIT(_P32ToP64)
  56. //++
  57. //
  58. // struct _TEB *
  59. // _read_teb (
  60. // VOID
  61. // )
  62. //
  63. // Routine Description:
  64. //
  65. // This function swizzles a pointer.
  66. //
  67. // Arguments:
  68. //
  69. // None.
  70. //
  71. // Return Value:
  72. //
  73. // TEB pointer.
  74. //
  75. //--
  76. LEAF_ENTRY(_read_teb)
  77. nop.m 0
  78. mov v0 = teb
  79. br.ret.sptk brp
  80. LEAF_EXIT(_read_teb)
  81. LEAF_ENTRY(_mf)
  82. mf
  83. nop.m 0
  84. br.ret.sptk brp
  85. LEAF_EXIT(_mf)
  86. LEAF_ENTRY(InterlockedExchange)
  87. ALTERNATE_ENTRY(_InterlockedExchange)
  88. sxt4 a0 = a0
  89. nop.m 0
  90. nop.i 0
  91. ;;
  92. xchg4.nt1 v0 = [a0], a1
  93. nop.i 0
  94. br.ret.sptk.clr brp
  95. LEAF_EXIT(_InterlockedExchange)
  96. //++
  97. //
  98. // PVOID
  99. // InterlockedCompareExchange (
  100. // IN OUT PVOID *Destination,
  101. // IN PVOID Exchange,
  102. // IN PVOID Comperand
  103. // )
  104. //
  105. // Routine Description:
  106. //
  107. // This function performs an interlocked compare of the destination
  108. // value with the comperand value. If the destination value is equal
  109. // to the comperand value, then the exchange value is stored in the
  110. // destination. Otherwise, no operation is performed.
  111. //
  112. // Arguments:
  113. //
  114. // Destination - Supplies a pointer to destination value.
  115. //
  116. // Exchange - Supplies the exchange value.
  117. //
  118. // Comperand - Supplies the comperand value.
  119. //
  120. // Return Value:
  121. //
  122. // (r8) - The initial destination value.
  123. //
  124. //--
  125. LEAF_ENTRY(InterlockedCompareExchange)
  126. ALTERNATE_ENTRY(_InterlockedCompareExchange)
  127. mov ar.ccv = a2
  128. ARGPTR(a0)
  129. ;;
  130. cmpxchg4.acq v0 = [a0], a1, ar.ccv
  131. br.ret.sptk.clr brp
  132. LEAF_EXIT(_InterlockedCompareExchange)
  133. //++
  134. //
  135. // LONG
  136. // InterlockedIncrement(
  137. // IN PLONG Addend
  138. // )
  139. //
  140. // Routine Description:
  141. //
  142. // This function performs an interlocked add of one to the addend variable.
  143. //
  144. // No checking is done for overflow.
  145. //
  146. // Arguments:
  147. //
  148. // Addend - Supplies a pointer to a variable whose value is to be
  149. // incremented by one.
  150. //
  151. // Return Value:
  152. //
  153. // (v0) < 0 (but not necessarily -1) if result of add < 0
  154. // (v0) == 0 if result of add == 0
  155. // (v0) > 0 (but not necessarily +1) if result of add > 0
  156. //
  157. //--
  158. LEAF_ENTRY(InterlockedIncrement)
  159. ALTERNATE_ENTRY(_InterlockedIncrement)
  160. LEAF_SETUP(1, 0, 0, 0)
  161. rAddend = in0
  162. rRetValue = v0
  163. ARGPTR(rAddend)
  164. fetchadd4.acq rRetValue = [rAddend], 1
  165. ;;
  166. add rRetValue = 1, rRetValue
  167. br.ret.sptk brp
  168. LEAF_EXIT(_InterlockedIncrement)
  169. //++
  170. //
  171. // LONG
  172. // InterlockedDecrement(
  173. // IN PLONG Addend
  174. // )
  175. //
  176. // Routine Description:
  177. //
  178. // This function performs an interlocked add of -1 to the addend variable.
  179. //
  180. // No checking is done for overflow
  181. //
  182. // Arguments:
  183. //
  184. // Addend - Supplies a pointer to a variable whose value is to be
  185. // decremented by one.
  186. //
  187. // Return Value:
  188. //
  189. // (v0) < 0 (but not necessarily -1) if result of dec < 0
  190. // (v0) == 0 if result of dec == 0
  191. // (v0) > 0 (but not necessarily +1) if result of dec > 0
  192. //
  193. //--
  194. LEAF_ENTRY(InterlockedDecrement)
  195. ALTERNATE_ENTRY(_InterlockedDecrement)
  196. LEAF_SETUP(1, 0, 0, 0)
  197. rAddend = in0
  198. rRetValue = v0
  199. ARGPTR(rAddend)
  200. fetchadd4.acq rRetValue = [rAddend], -1
  201. ;;
  202. sub rRetValue = rRetValue, zero, 1
  203. br.ret.sptk brp
  204. LEAF_EXIT(_InterlockedDecrement)