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.

101 lines
2.5 KiB

  1. //++
  2. //
  3. // Copyright (c) 1996 Intel Corporation
  4. // Copyright (c) 1989 Microsoft Corporation
  5. //
  6. // Module Name:
  7. //
  8. // ldrthunk.s
  9. //
  10. // Abstract:
  11. //
  12. // This module implements the thunk for the LdrpInitialize APC routine.
  13. //
  14. // Author:
  15. //
  16. // William K. Cheung (wcheung) 19-Sep-95
  17. //
  18. // Revision History:
  19. //
  20. // 08-Feb-96 Updated to EAS2.1
  21. //
  22. //--
  23. #include "ksia64.h"
  24. .file "ldrthunk.s"
  25. PublicFunction(LdrpInitialize)
  26. //++
  27. //
  28. // VOID
  29. // LdrInitializeThunk(
  30. // IN PVOID NormalContext,
  31. // IN PVOID SystemArgument1,
  32. // IN PVOID SystemArgument2
  33. // )
  34. //
  35. // Routine Description:
  36. //
  37. // This function computes a pointer to the context record on the stack
  38. // and jumps to the LdrpInitialize function with that pointer as its
  39. // parameter.
  40. //
  41. // Arguments:
  42. //
  43. // NormalContext (a0) - User Mode APC context parameter
  44. //
  45. // SystemArgument1 (a1) - User Mode APC system argument 1
  46. //
  47. // SystemArgument2 (a2) - User Mode APC system argument 2
  48. //
  49. // Return Value:
  50. //
  51. // None.
  52. //
  53. //--
  54. NESTED_ENTRY(LdrInitializeThunk)
  55. NESTED_SETUP(3,2,3,0)
  56. mov out2 = a2
  57. ;;
  58. PROLOGUE_END
  59. //
  60. // SP points at stack scratch area followed by context record.
  61. //
  62. add out0 = STACK_SCRATCH_AREA, sp // pointer to context
  63. mov out1 = a1 // copy args
  64. br.call.sptk.many brp = LdrpInitialize
  65. //
  66. // S0 in the context record contains the PLabel. Fix IIP/GP in the context
  67. // record with the entry point and gp values pointed to by S0.
  68. //
  69. add t7 = CxIntGp+STACK_SCRATCH_AREA, sp // -> global pointer
  70. add t2 = CxIntS0+STACK_SCRATCH_AREA, sp // -> PLabel pointer
  71. add t11 = CxStIIP+STACK_SCRATCH_AREA, sp // -> func pointer
  72. ;;
  73. ld8 t8 = [t2] // get the function pointer
  74. mov brp = savedbrp // restore brp
  75. mov ar.pfs = savedpfs // restore pfs
  76. ;;
  77. ld8 t5 = [t8], PlGlobalPointer-PlEntryPoint // get entry point
  78. ;;
  79. ld8 t6 = [t8] // get gp
  80. nop.i 0
  81. ;;
  82. st8 [t11] = t5 // set iip to entry point
  83. st8 [t7] = t6 // set gp
  84. br.ret.sptk.clr brp
  85. NESTED_EXIT(LdrInitializeThunk)