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.

270 lines
6.4 KiB

  1. //++
  2. //
  3. // Module Name:
  4. //
  5. // jmpuwind.s
  6. //
  7. // Abstract:
  8. //
  9. // This module implements the IA64 specific routine to jump to the runtime
  10. // time library unwind routine.
  11. //
  12. // Author:
  13. //
  14. // William K. Cheung (wcheung) 4-Jan-1996
  15. //
  16. //
  17. // based on the version by David N. Cutler (davec) 12-Sep-1990
  18. //
  19. // Environment:
  20. //
  21. // Any mode.
  22. //
  23. // Revision History:
  24. //
  25. //--
  26. #include "ksia64.h"
  27. //++
  28. //
  29. // LONG
  30. // __C_ExecuteExceptionFilter (
  31. // ULONGLONG MemoryStack,
  32. // ULONGLONG BackingStore,
  33. // NTSTATUS ExceptionCode,
  34. // PEXCEPTION_POINTERS ExceptionPointers,
  35. // ULONGLONG ExceptionFilter,
  36. // ULONGLONG GlobalPointer
  37. // )
  38. //
  39. // Routine Description:
  40. //
  41. // This function sets the gp register and transfers control to the specified
  42. // exception filter routine.
  43. //
  44. // Arguments:
  45. //
  46. // MemoryStack (a0) - memory stack pointer of establisher frame
  47. //
  48. // BackingStore (a1) - backing store pointer of establisher frame
  49. //
  50. // ExceptionCode (a2) - Exception Code.
  51. //
  52. // ExceptionPointers (a3) - Supplies a pointer to the exception pointers
  53. // structure.
  54. //
  55. // ExceptionFilter (a4) - Entry point of exception filter
  56. //
  57. // GlobalPointer (a5) - GP of exception filter
  58. //
  59. // Return Value:
  60. //
  61. // The value returned by the exception filter routine.
  62. //
  63. //--
  64. LEAF_ENTRY(__C_ExecuteExceptionFilter)
  65. mov gp = a5
  66. mov bt0 = a4
  67. br bt0 // branch to exception filter
  68. ;;
  69. LEAF_EXIT(__C_ExecuteExceptionFilter)
  70. //++
  71. //
  72. // VOID
  73. // __C_ExecuteTerminationHandler (
  74. // ULONGLONG MemoryStack,
  75. // ULONGLONG BackingStore,
  76. // BOOLEAN AbnormalTermination,
  77. // ULONGLONG TerminationHandler,
  78. // ULONGLONG GlobalPointer
  79. // )
  80. //
  81. // Routine Description:
  82. //
  83. // This function sets the gp register and transfers control to the specified
  84. // termination handler routine.
  85. //
  86. // Arguments:
  87. //
  88. // MemoryStack (a0) - memory stack pointer of establisher frame
  89. //
  90. // BackingStore (a1) - backing store pointer of establisher frame
  91. //
  92. // AbnormalTermination (a2) - Supplies a boolean value that determines
  93. // whether the termination is abnormal.
  94. //
  95. // TerminationHandler (a3) - Entry point of termination handler
  96. //
  97. // GlobalPointer (a4) - GP of termination handler
  98. //
  99. // Return Value:
  100. //
  101. // None.
  102. //
  103. //--
  104. LEAF_ENTRY(__C_ExecuteTerminationHandler)
  105. mov gp = a4
  106. mov bt0 = a3
  107. br bt0 // branch to termination handler
  108. ;;
  109. LEAF_EXIT(__C_ExecuteTerminationHandler)
  110. //++
  111. //
  112. // VOID
  113. // __jump_unwind (
  114. // IN PVOID TargetMsFrame,
  115. // IN PVOID TargetBsFrame,
  116. // IN PVOID TargetPc,
  117. // )
  118. //
  119. // Routine Description:
  120. //
  121. // This function transfer control to unwind. It is used by the MIPS
  122. // compiler when a goto out of the body or a try statement occurs.
  123. //
  124. // Arguments:
  125. //
  126. // TargetMsFrame (a0) - Supplies the memory stack frame pointer of the
  127. // target of the unwind.
  128. //
  129. // TargetBsFrame (a1) - Supplies the backing store frame pointer of the
  130. // target of the unwind.
  131. //
  132. // TargetPc (a2) - Supplies the target instruction address where control
  133. // is to be transfered to after the unwind operation is complete.
  134. //
  135. // Return Value:
  136. //
  137. // None.
  138. //
  139. // N.B. The first 2 input registers are reused for local while the third
  140. // input register is reused as output register.
  141. //
  142. //--
  143. .global RtlUnwind2
  144. .type RtlUnwind2, @function
  145. .global RtlPcToFileHeader
  146. .type RtlPcToFileHeader, @function
  147. NESTED_ENTRY(__jump_unwind)
  148. .regstk 3, 2, 6, 0
  149. .prologue 0xC, loc0
  150. .fframe ContextFrameLength, Jn10
  151. alloc loc0 = ar.pfs, 3, 3, 6, 0
  152. .save brp, loc1
  153. mov loc1 = brp
  154. [Jn10:] add sp = -ContextFrameLength, sp
  155. ;;
  156. mov loc2 = gp
  157. PROLOGUE_END
  158. //
  159. // Call RtlPcToFileHeader to get the image base of caller
  160. // The image base is returned in memory location STACK_SCRATCH_AREA, sp
  161. // and also in register v0
  162. //
  163. mov out0 = brp
  164. add out1 = STACK_SCRATCH_AREA, sp
  165. br.call.sptk brp = RtlPcToFileHeader
  166. ;;
  167. mov gp = loc2
  168. //
  169. // Add image base to image relative offset passed in a2
  170. //
  171. add out2 = v0, a2
  172. //
  173. // Setup rest of arguments to RtlUnwind2
  174. //
  175. add out5 = STACK_SCRATCH_AREA, sp
  176. mov out4 = zero
  177. mov out3 = zero
  178. mov out1 = a1
  179. mov out0 = a0
  180. br.call.sptk brp = RtlUnwind2
  181. ;;
  182. .restore Jn20
  183. [Jn20:] add sp = ContextFrameLength, sp
  184. nop.f 0
  185. mov ar.pfs = loc0
  186. nop.m 0
  187. mov brp = loc1
  188. br.ret.sptk brp
  189. NESTED_EXIT(__jump_unwind)
  190. //++
  191. // VOID
  192. // _NLG_Notify(
  193. // IN PVOID Funclet
  194. // IN FRAME_POINTERS EstablisherFrame,
  195. // IN ULONG NLGCode
  196. // )
  197. //
  198. // Routine Description:
  199. //
  200. // Provides the handler/longjmp addresses to the debugger
  201. //
  202. // Arguments:
  203. //
  204. // Funclet (a0) - Supplies the target address of non-local goto
  205. // EstablisherFrame (a1,a2) - Supplies a pointer to frame of the establisher
  206. // function
  207. // NLGCode (a3) - Supplies NLG identifying value
  208. //
  209. // Return Value:
  210. //
  211. // None.
  212. //
  213. //--
  214. .global __NLG_Dispatch
  215. .global __NLG_Destination
  216. .sdata
  217. __NLG_Destination::
  218. data8 0x19930520 // signature
  219. data8 0 // handler address
  220. data8 0 // code
  221. data8 0 // memory stack frame pointer
  222. data8 0 // register stack frame pointer
  223. LEAF_ENTRY(_NLG_Notify)
  224. add t0 = @gprel(__NLG_Destination+0x8), gp
  225. add t1 = @gprel(__NLG_Destination+0x10), gp
  226. nop.i 0
  227. ;;
  228. st8 [t0] = a0, 16
  229. st8 [t1] = a3, 16
  230. nop.i 0
  231. ;;
  232. st8 [t0] = a1
  233. st8 [t1] = a2
  234. nop.i 0
  235. __NLG_Dispatch::
  236. nop.m 0
  237. nop.i 0
  238. br.ret.sptk b0
  239. LEAF_EXIT(_NLG_Notify)