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.

123 lines
3.1 KiB

  1. title "Asynchronous Procedure Call Interrupt"
  2. ;++
  3. ;
  4. ; Copyright (c) 2000 Microsoft Corporation
  5. ;
  6. ; Module Name:
  7. ;
  8. ; apcint.asm
  9. ;
  10. ; Abstract:
  11. ;
  12. ; This module implements the code necessary to process the Asynchronous
  13. ; Procedure Call interrupt request.
  14. ;
  15. ; Author:
  16. ;
  17. ; David N. Cutler (davec) 10-Nov-2000
  18. ;
  19. ; Environment:
  20. ;
  21. ; Kernel mode only.
  22. ;
  23. ;--
  24. extern KiDeliverApc:proc
  25. extern __imp_HalEndSystemInterrupt:qword
  26. include ksamd64.inc
  27. subttl "Asynchronous Procedure Call Interrupt"
  28. ;++
  29. ;
  30. ; VOID
  31. ; KiApcInterrupt (
  32. ; VOID
  33. ; )
  34. ;
  35. ; Routine Description:
  36. ;
  37. ; This routine is entered as the result of a software interrupt generated
  38. ; at APC_LEVEL. Its function is to save the machine state and call the APC
  39. ; delivery routine.
  40. ;
  41. ; N.B. This is a directly connected interrupt that does not use an interrupt
  42. ; object.
  43. ;
  44. ; N.B. APC interrupts are never requested for user mode APCs.
  45. ;
  46. ; Arguments:
  47. ;
  48. ; None.
  49. ;
  50. ; Return Value:
  51. ;
  52. ; None.
  53. ;
  54. ;--
  55. NESTED_ENTRY KiApcInterrupt, _TEXT$00
  56. .pushframe ; mark machine frame
  57. push_reg rbp ; push dummy vector
  58. push_reg rbp ; save nonvolatile register
  59. GENERATE_INTERRUPT_FRAME ; generate interrupt frame
  60. mov ecx, APC_LEVEL ; set new IRQL level
  61. ENTER_INTERRUPT ; raise IRQL, do EOI, enable interrupts
  62. mov cl, KernelMode ; set APC processor mode
  63. xor edx, edx ; set exception frame address
  64. lea r8, (-128)[rbp] ; set trap frame address
  65. call KiDeliverApc ; initiate APC execution
  66. EXIT_INTERRUPT <NoEOI> ; lower IRQL and restore state
  67. NESTED_END KiApcInterrupt, _TEXT$00
  68. subttl "Initiate User APC Execution"
  69. ;++
  70. ;
  71. ; Routine Description:
  72. ;
  73. ; This routine generates an exception frame and attempts to deliver a user
  74. ; APC.
  75. ;
  76. ; Arguments:
  77. ;
  78. ; rbp - Supplies the address of the trap frame.
  79. ;
  80. ; rsp - Supplies the address of the trap frame.
  81. ;
  82. ; Return value:
  83. ;
  84. ; None.
  85. ;
  86. ;--
  87. NESTED_ENTRY KiInitiateUserApc, _TEXT$00
  88. GENERATE_EXCEPTION_FRAME ; generate exception frame
  89. lea rbx, (KTRAP_FRAME_LENGTH - 128)[rbp] ; get save area address
  90. fnsaved [rbx] ; save legacy floating state
  91. mov cl, UserMode ; set APC processor mode
  92. mov rdx, rsp ; set exception frame address
  93. lea r8, (-128)[rbp] ; set trap frame address
  94. call KiDeliverApc ; deliver APC
  95. mov ax, LfControlWord[rbx] ; save current control word
  96. mov word ptr LfControlWord[rbx], 03fh ; set to mask all exceptions
  97. frstord [rbx] ; restore legacy floating state
  98. mov LfControlWord[rbx], ax ; restore control word
  99. fldcw word ptr LfControlWord[rbx] ; load legacy control word
  100. RESTORE_EXCEPTION_STATE ; restore exception state/deallocate
  101. ret ; return
  102. NESTED_END KiInitiateUserApc, _TEXT$00
  103. end