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.

158 lines
3.5 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation All Rights Reserved
  3. Module Name:
  4. interrupt.c
  5. Abstract:
  6. This module contains the functions for handling simulated interrupts
  7. to the hotplug controller.
  8. Environment:
  9. Kernel mode
  10. Revision History:
  11. Davis Walker (dwalker) Sept 6 2000
  12. --*/
  13. #include "hpsp.h"
  14. BOOLEAN HpsInterruptPending = FALSE;
  15. VOID
  16. HpsInterruptExecution(
  17. IN PHPS_DEVICE_EXTENSION Extension
  18. )
  19. {
  20. KIRQL oldIrql;
  21. HpsInterruptPending = TRUE;
  22. oldIrql = KeGetCurrentIrql();
  23. if (oldIrql >= PROFILE_LEVEL-1) {
  24. //
  25. // These interrupts are currently masked. This will
  26. // only happen because we are in HpsSynchronizeExecution.
  27. // So set a flag indicating that there is a pending interrupt
  28. // so that SynchronizeExecution will execute the ISR.
  29. //
  30. return;
  31. } else {
  32. HpsInterruptPending = FALSE;
  33. KeRaiseIrql(PROFILE_LEVEL-1,
  34. &oldIrql
  35. );
  36. KeAcquireSpinLockAtDpcLevel(&Extension->IntSpinLock);
  37. Extension->IntServiceRoutine((PKINTERRUPT)Extension,
  38. Extension->IntServiceContext
  39. );
  40. KeReleaseSpinLockFromDpcLevel(&Extension->IntSpinLock);
  41. KeLowerIrql(oldIrql);
  42. }
  43. }
  44. //
  45. // Interrupt Interface Functions
  46. //
  47. NTSTATUS
  48. HpsConnectInterrupt(
  49. IN PVOID Context,
  50. IN PKSERVICE_ROUTINE ServiceRoutine,
  51. IN PVOID ServiceContext
  52. )
  53. /*++
  54. Routine Description:
  55. This routine is the hps version of IoConnectInterrupt. It has the same
  56. semantics and is called in the same situations. This is called by the
  57. SHPC driver to register an ISR with the simulator so that the SHPC driver
  58. can receive simulated interrupts.
  59. Arguments:
  60. ServiceRoutine - A pointer to the ISR
  61. ServiceContext - The context with which this routine is called. In this
  62. case, it is a device extension.
  63. The rest of the arguments are ignored.
  64. Return Value:
  65. STATUS_SUCCESS
  66. --*/
  67. {
  68. PHPS_DEVICE_EXTENSION deviceExtension;
  69. deviceExtension = (PHPS_DEVICE_EXTENSION) Context;
  70. deviceExtension->IntServiceRoutine = ServiceRoutine;
  71. deviceExtension->IntServiceContext = ServiceContext;
  72. return STATUS_SUCCESS;
  73. }
  74. VOID
  75. HpsDisconnectInterrupt(
  76. IN PVOID Context
  77. )
  78. {
  79. PHPS_DEVICE_EXTENSION deviceExtension = (PHPS_DEVICE_EXTENSION)Context;
  80. deviceExtension->IntServiceRoutine = NULL;
  81. deviceExtension->IntServiceContext = NULL;
  82. }
  83. BOOLEAN
  84. HpsSynchronizeExecution(
  85. IN PVOID Context,
  86. IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine,
  87. IN PVOID SynchronizeContext
  88. )
  89. {
  90. PHPS_DEVICE_EXTENSION Extension = (PHPS_DEVICE_EXTENSION)Context;
  91. KIRQL oldIrql;
  92. KeRaiseIrql(PROFILE_LEVEL-1,
  93. &oldIrql
  94. );
  95. KeAcquireSpinLockAtDpcLevel(&Extension->IntSpinLock);
  96. SynchronizeRoutine(SynchronizeContext);
  97. //
  98. // If there's a pending interrupt, it gets serviced at this
  99. // IRQL as well, so call it.
  100. //
  101. if (HpsInterruptPending) {
  102. HpsInterruptPending = FALSE;
  103. Extension->IntServiceRoutine((PKINTERRUPT)Extension,
  104. Extension->IntServiceContext
  105. );
  106. }
  107. KeReleaseSpinLockFromDpcLevel(&Extension->IntSpinLock);
  108. KeLowerIrql(oldIrql);
  109. return TRUE;
  110. }