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.

330 lines
6.7 KiB

  1. title "Software Interrupts"
  2. ;++
  3. ;
  4. ; Copyright (c) 1992 Microsoft Corporation
  5. ; Copyright (c) 1992 Intel Corporation
  6. ; All rights reserved
  7. ;
  8. ; INTEL CORPORATION PROPRIETARY INFORMATION
  9. ;
  10. ; This software is supplied to Microsoft under the terms
  11. ; of a license agreement with Intel Corporation and may not be
  12. ; copied nor disclosed except in accordance with the terms
  13. ; of that agreement.
  14. ;
  15. ; Module Name:
  16. ;
  17. ; mpswint.asm
  18. ;
  19. ; Abstract:
  20. ;
  21. ; This module implements the software interrupt handlers for
  22. ; APIC-based PC+MP multiprocessor systems.
  23. ;
  24. ; Author:
  25. ;
  26. ; John Vert (jvert) 2-Jan-1992
  27. ;
  28. ; Environment:
  29. ;
  30. ; Kernel mode only.
  31. ;
  32. ; Revision History:
  33. ;
  34. ; Ron Mosgrove (Intel) - Modified for PC+MP systems
  35. ;
  36. ;--
  37. .386p
  38. .xlist
  39. include hal386.inc
  40. include callconv.inc ; calling convention macros
  41. include apic.inc
  42. include ntapic.inc
  43. include i386\kimacro.inc
  44. .list
  45. EXTRNP Kei386EoiHelper,0,IMPORT
  46. EXTRNP _KiDeliverApc,3,IMPORT
  47. EXTRNP _KiDispatchInterrupt,0,IMPORT
  48. extrn _HalpIRQLtoTPR:byte
  49. _TEXT SEGMENT DWORD PUBLIC 'CODE'
  50. ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
  51. page ,132
  52. subttl "Request Software Interrupt"
  53. ;++
  54. ;
  55. ; VOID
  56. ; FASTCALL
  57. ; HalRequestSoftwareInterrupt (
  58. ; IN KIRQL RequestIrql
  59. ; )
  60. ;
  61. ; Routine Description:
  62. ;
  63. ; This routine is used to request a software interrupt of
  64. ; the system.
  65. ;
  66. ; Arguments:
  67. ;
  68. ; (cl) = RequestIrql - Supplies the request IRQL value
  69. ;
  70. ; Return Value:
  71. ;
  72. ; None.
  73. ;
  74. ;--
  75. ; equates for accessing arguments
  76. ;
  77. cPublicFastCall HalRequestSoftwareInterrupt ,1
  78. cPublicFpo 0,0
  79. cmp cl, PCR[PcHal.ShortDpc]
  80. je short rsi10
  81. xor eax, eax
  82. mov al, cl ; get irql
  83. ;
  84. ; In an APIC based system the TPR is the IDTEntry
  85. ;
  86. xor ecx, ecx
  87. mov cl, _HalpIRQLtoTPR[eax] ; get IDTEntry for IRQL
  88. ;
  89. ; Build the ICR Command - Fixed Delivery to Self, IDTEntry == al
  90. ;
  91. or ecx, (DELIVER_FIXED OR ICR_SELF)
  92. ;
  93. ; Make sure the ICR is available
  94. ;
  95. pushfd ; save interrupt mode
  96. cli ; disable interrupt
  97. STALL_WHILE_APIC_BUSY
  98. ;
  99. ; Now write the command to the Memory Mapped Register
  100. ;
  101. mov dword ptr APIC[LU_INT_CMD_LOW], ecx
  102. ;
  103. ; We have to wait for the request to be delivered.
  104. ; If we don't wait here, then we will return to the caller
  105. ; before the request has been issued.
  106. ;
  107. STALL_WHILE_APIC_BUSY
  108. popfd ; restore original interrupt mode
  109. fstRET HalRequestSoftwareInterrupt
  110. ;
  111. ; Requesting a DPC interrupt when ShortDpc is set. Just set the
  112. ; DpcPending flag - whomever set ShortDpc will check the flag
  113. ; at the proper time
  114. ;
  115. rsi10: mov PCR[PcHal.DpcPending], 1
  116. fstRET HalRequestSoftwareInterrupt
  117. fstENDP HalRequestSoftwareInterrupt
  118. page ,132
  119. subttl "Clear Software Interrupt"
  120. ;++
  121. ;
  122. ; VOID
  123. ; HalClearSoftwareInterrupt (
  124. ; IN KIRQL RequestIrql
  125. ; )
  126. ;
  127. ; Routine Description:
  128. ;
  129. ; This routine is used to clear a possible pending software interrupt.
  130. ; Support for this function is optional, and allows the kernel to
  131. ; reduce the number of spurious software interrupts it receives/
  132. ;
  133. ; Arguments:
  134. ;
  135. ; (cl) = RequestIrql - Supplies the request IRQL value
  136. ;
  137. ; Return Value:
  138. ;
  139. ; None.
  140. ;
  141. ;--
  142. cPublicFastCall HalClearSoftwareInterrupt ,1
  143. fstRET HalClearSoftwareInterrupt
  144. fstENDP HalClearSoftwareInterrupt
  145. page ,132
  146. subttl "Dispatch Interrupt"
  147. ;++
  148. ;
  149. ; VOID
  150. ; HalpDispatchInterrupt(
  151. ; VOID
  152. ; );
  153. ;
  154. ; Routine Description:
  155. ;
  156. ; This routine is the interrupt handler for a software interrupt generated
  157. ; at DISPATCH_LEVEL. Its function is to save the machine state, raise
  158. ; Irql to DISPATCH_LEVEL, dismiss the interrupt, and call the DPC
  159. ; delivery routine.
  160. ;
  161. ; Arguments:
  162. ;
  163. ; None
  164. ; Interrupt is disabled
  165. ;
  166. ; Return Value:
  167. ;
  168. ; None.
  169. ;
  170. ;--
  171. ENTER_DR_ASSIST hdpi_a, hdpi_t
  172. cPublicProc _HalpDispatchInterrupt ,0
  173. ;
  174. ; Save machine state on trap frame
  175. ;
  176. ENTER_INTERRUPT hdpi_a, hdpi_t
  177. mov eax, DPC_VECTOR
  178. mov esi, dword ptr APIC[LU_TPR] ; get the old TPR
  179. mov dword ptr APIC[LU_TPR], eax ; set the TPR
  180. sti ; and allow interrupts
  181. APICFIX edx
  182. mov dword ptr APIC[LU_EOI], 0 ; send EOI to APIC local unit
  183. APICFIX edx
  184. ;
  185. ; Go do Dispatch Interrupt processing
  186. ;
  187. di10: stdCall _KiDispatchInterrupt
  188. cli
  189. mov dword ptr APIC[LU_TPR], esi ; reset the TPR
  190. ;
  191. ; We have to ensure that the requested priority is set before
  192. ; we return. The caller is counting on it.
  193. ;
  194. mov ecx, dword ptr APIC[LU_TPR]
  195. CHECKTPR ecx, esi
  196. ;
  197. ; Do interrupt exit processing without EOI
  198. ;
  199. SPURIOUS_INTERRUPT_EXIT
  200. stdENDP _HalpDispatchInterrupt
  201. page ,132
  202. subttl "APC Interrupt"
  203. ;++
  204. ;
  205. ; HalpApcInterrupt(
  206. ; VOID
  207. ; );
  208. ;
  209. ; Routine Description:
  210. ;
  211. ; This routine is entered as the result of a software interrupt generated
  212. ; at APC_LEVEL. Its function is to save the machine state, raise Irql to
  213. ; APC_LEVEL, dismiss the interrupt, and call the APC delivery routine.
  214. ;
  215. ; Arguments:
  216. ;
  217. ; None
  218. ; Interrupt is Disabled
  219. ;
  220. ; Return Value:
  221. ;
  222. ; None.
  223. ;
  224. ;--
  225. ENTER_DR_ASSIST hapc_a, hapc_t
  226. ;
  227. ; Save machine state in trap frame
  228. ;
  229. cPublicProc _HalpApcInterrupt ,0
  230. ;
  231. ; Save machine state on trap frame
  232. ;
  233. ENTER_INTERRUPT hapc_a, hapc_t
  234. mov eax, APC_VECTOR
  235. mov ecx, dword ptr APIC[LU_TPR] ; get the old TPR
  236. push ecx ; save it
  237. mov dword ptr APIC[LU_TPR], eax ; set the TPR
  238. APICFIX edx
  239. mov dword ptr APIC[LU_EOI], 0 ; send EOI to APIC local unit
  240. APICFIX edx
  241. sti ; and allow interrupts
  242. mov eax, [ebp]+TsSegCs ; get interrupted code's CS
  243. and eax, MODE_MASK ; extract the mode
  244. ; call APC deliver routine
  245. ; Previous mode
  246. ; Null exception frame
  247. ; Trap frame
  248. stdCall _KiDeliverApc, <eax, 0,ebp>
  249. pop eax
  250. cli
  251. mov dword ptr APIC[LU_TPR], eax ; reset the TPR
  252. ;
  253. ; We have to ensure that the requested priority is set before
  254. ; we return. The caller is counting on it.
  255. ;
  256. mov ecx, dword ptr APIC[LU_TPR]
  257. CHECKTPR ecx, eax
  258. ;
  259. ; Do interrupt exit processing without EOI
  260. ;
  261. SPURIOUS_INTERRUPT_EXIT
  262. stdENDP _HalpApcInterrupt
  263. _TEXT ends
  264. end