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.

269 lines
6.1 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. mov loc1 = brp
  153. [Jn10:] add sp = -ContextFrameLength, sp
  154. ;;
  155. mov loc2 = gp
  156. PROLOGUE_END
  157. //
  158. // Call RtlPcToFileHeader to get the image base of caller
  159. // The image base is returned in memory location STACK_SCRATCH_AREA, sp
  160. // and also in register v0
  161. //
  162. mov out0 = brp
  163. add out1 = STACK_SCRATCH_AREA, sp
  164. br.call.sptk brp = RtlPcToFileHeader
  165. ;;
  166. mov gp = loc2
  167. //
  168. // Add image base to image relative offset passed in a2
  169. //
  170. add out2 = v0, a2
  171. //
  172. // Setup rest of arguments to RtlUnwind2
  173. //
  174. add out5 = STACK_SCRATCH_AREA, sp
  175. mov out4 = zero
  176. mov out3 = zero
  177. mov out1 = a1
  178. mov out0 = a0
  179. br.call.sptk brp = RtlUnwind2
  180. ;;
  181. .restore Jn20
  182. [Jn20:] add sp = ContextFrameLength, sp
  183. nop.f 0
  184. mov ar.pfs = loc0
  185. nop.m 0
  186. mov brp = loc1
  187. br.ret.sptk brp
  188. NESTED_EXIT(__jump_unwind)
  189. //++
  190. // VOID
  191. // _NLG_Notify(
  192. // IN PVOID Funclet
  193. // IN FRAME_POINTERS EstablisherFrame,
  194. // IN ULONG NLGCode
  195. // )
  196. //
  197. // Routine Description:
  198. //
  199. // Provides the handler/longjmp addresses to the debugger
  200. //
  201. // Arguments:
  202. //
  203. // Funclet (a0) - Supplies the target address of non-local goto
  204. // EstablisherFrame (a1,a2) - Supplies a pointer to frame of the establisher
  205. // function
  206. // NLGCode (a3) - Supplies NLG identifying value
  207. //
  208. // Return Value:
  209. //
  210. // None.
  211. //
  212. //--
  213. .global __NLG_Dispatch
  214. .global __NLG_Destination
  215. .sdata
  216. __NLG_Destination::
  217. data8 0x19930520 // signature
  218. data8 0 // handler address
  219. data8 0 // code
  220. data8 0 // memory stack frame pointer
  221. data8 0 // register stack frame pointer
  222. LEAF_ENTRY(_NLG_Notify)
  223. add t0 = @gprel(__NLG_Destination+0x8), gp
  224. add t1 = @gprel(__NLG_Destination+0x10), gp
  225. nop.i 0
  226. ;;
  227. st8 [t0] = a0, 16
  228. st8 [t1] = a3, 16
  229. nop.i 0
  230. ;;
  231. st8 [t0] = a1
  232. st8 [t1] = a2
  233. nop.i 0
  234. __NLG_Dispatch::
  235. nop.m 0
  236. nop.i 0
  237. br.ret.sptk b0
  238. LEAF_EXIT(_NLG_Notify)