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.

198 lines
5.4 KiB

  1. title "Stubless Support"
  2. ;++
  3. ;
  4. ; Copyright (C) 2000 Microsoft Corporation
  5. ;
  6. ; Module Name:
  7. ;
  8. ; stubless.asm
  9. ;
  10. ; Abstract:
  11. ;
  12. ; This module contains interpreter support routines for the AMD64 platform.
  13. ;
  14. ; Author:
  15. ;
  16. ; David N. Cutler 30-Dec-2000
  17. ;
  18. ; Environment:
  19. ;
  20. ; User mode.
  21. ;
  22. ;--
  23. include ksamd64.inc
  24. extern ObjectStublessClient:proc
  25. extern __chkstk:proc
  26. ;
  27. ; Define object stubless client macro.
  28. ;
  29. STUBLESS_CLIENT macro Method
  30. LEAF_ENTRY ObjectStublessClient&Method, _TEXT$00
  31. mov r10d, Method ; set method number
  32. jmp ObjectStubless ; finish in common code
  33. LEAF_END ObjectStublessClient&Method, _TEXT$00
  34. endm
  35. ;
  36. ; Generate stubless client thunks.
  37. ;
  38. index = 3
  39. rept (1023 - 3 + 1)
  40. STUBLESS_CLIENT %index
  41. index = index + 1
  42. endm
  43. subttl "Common Object Stubless Client Code"
  44. ;++
  45. ;
  46. ; long
  47. ; ObjectStubless (
  48. ; ...
  49. ; )
  50. ;
  51. ; Routine description:
  52. ;
  53. ; This function is jumped to from the corresponding linkage stub and calls
  54. ; the object stubless client routine to invoke the ultimate function.
  55. ;
  56. ; Arguments:
  57. ;
  58. ; ...
  59. ;
  60. ; Implicit Arguments:
  61. ;
  62. ; Method (r10d) - Supplies the method number from the thunk code.
  63. ;
  64. ; Return Value:
  65. ;
  66. ; The value as returned by the target function.
  67. ;
  68. ;--
  69. OsFrame struct
  70. P1Home dq ? ; argument home addresses
  71. P2Home dq ? ;
  72. P3Home dq ? ;
  73. P4Home dq ? ;
  74. SavedXmm0 dq ? ; saved floating argument registers
  75. SavedXmm1 dq ? ;
  76. SavedXmm2 dq ? ;
  77. SavedXmm3 dq ? ;
  78. Fill dq ? ;
  79. OsFrame ends
  80. NESTED_ENTRY ObjectStubless, _TEXT$00
  81. mov 8[rsp], rcx ; save integer argument registers
  82. mov 16[rsp], rdx ;
  83. mov 24[rsp], r8 ;
  84. mov 32[rsp], r9 ;
  85. alloc_stack sizeof OsFrame ; allocate stack frame
  86. END_PROLOGUE
  87. movq OsFrame.SavedXmm0[rsp], xmm0 ; save floating argument registers
  88. movq OsFrame.SavedXmm1[rsp], xmm1 ;
  89. movq OsFrame.SavedXmm2[rsp], xmm2 ;
  90. movq OsFrame.SavedXmm3[rsp], xmm3;
  91. lea rcx, sizeof OsFrame + 8[rsp] ; set integer arguments address
  92. lea rdx, OsFrame.SavedXmm0[rsp] ; set floating arguments address
  93. mov r8d, r10d ; set method number
  94. call ObjectStublessClient ;
  95. add rsp, sizeof OsFrame ; deallocate stack frame
  96. ret ; return
  97. NESTED_END ObjectStubless, _TEXT$00
  98. subttl "Invoke Function with Parameter List"
  99. ;++
  100. ;
  101. ; REGISTER_TYPE
  102. ; Invoke (
  103. ; MANAGER_FUNCTION Function,
  104. ; REGISTER_TYPE *ArgumentList,
  105. ; ULONG FloatArgMask,
  106. ; ULONG Arguments
  107. ; )
  108. ;
  109. ; Routine description:
  110. ;
  111. ; This function builds an appropriate argument list and calls the specified
  112. ; function.
  113. ;
  114. ; Arguments:
  115. ;
  116. ; Function (rcx) - Supplies a pointer to the target function.
  117. ;
  118. ; ArgumentList (rdx) - Supplies a pointer to the argument list.
  119. ;
  120. ; FloatArgMask (r8d) - Supplies the floating argument register mask (not
  121. ; used.
  122. ;
  123. ; Arguments (r9d) - Supplies the number of arguments.
  124. ;
  125. ; Return Value:
  126. ;
  127. ; The value as returned by the target function.
  128. ;
  129. ;--
  130. NESTED_ENTRY Invoke, _TEXT$00
  131. push_reg rdi ; save nonvolatile registers
  132. push_reg rsi ;
  133. push_reg rbp ;
  134. set_frame rbp, 0 ; set frame pointer
  135. END_PROLOGUE
  136. mov eax, r9d ; round to even argument count
  137. inc eax ;
  138. and al, 0feh ;
  139. shl eax, 3 ; compute number of bytes
  140. call __chkstk ; check stack allocation
  141. sub rsp, rax ; allocate argument list
  142. mov r10, rcx ; save address of function
  143. mov rsi, rdx ; set source argument list address
  144. mov rdi, rsp ; set destination argument list address
  145. mov ecx, r9d ; set number of arguments
  146. rep movsq ; copy arguments to the stack
  147. ;
  148. ; N.B. All four argument registers are loaded regardless of the actual number
  149. ; of arguments.
  150. ;
  151. mov rcx, 0[rsp] ; load first four argument registers
  152. movq xmm0, 0[rsp] ;
  153. mov rdx, 8[rsp] ;
  154. movq xmm1, 8[rsp] ;
  155. mov r8, 16[rsp] ;
  156. movq xmm2, 16[rsp] ;
  157. mov r9, 24[rsp] ;
  158. movq xmm3, 24[rsp] ;
  159. call r10 ; call target function
  160. mov rsp, rbp ; deallocate argument list
  161. pop rbp ; restore nonvolatile register
  162. pop rsi ;
  163. pop rdi ;
  164. ret ;
  165. NESTED_END Invoke, _TEXT$00
  166. end