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.

192 lines
4.5 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. callback.c
  5. Abstract:
  6. This module implements all the callbacks that are NT specific from
  7. the AML Interperter
  8. Environment
  9. Kernel mode only
  10. Revision History:
  11. 04-Jun-97 Initial Revision
  12. 01-Mar-98 Split off all the OSNotify() into osnotify.c
  13. 02-Mar-98 Rewrite to make the notifactions work at DPC level
  14. 13-Mar-00 Rewrite to handle Load()/Unload()
  15. --*/
  16. #include "pch.h"
  17. //
  18. // Keep track of the number of Loads and Unloads present in the system
  19. //
  20. ULONG AcpiTableDelta = 0;
  21. NTSTATUS
  22. EXPORT
  23. ACPICallBackLoad(
  24. IN ULONG EventType,
  25. IN ULONG NotifyType,
  26. IN ULONG EventData,
  27. IN PNSOBJ AcpiObject,
  28. IN ULONG EventParameter
  29. )
  30. /*++
  31. Routine Description:
  32. This routine is called when before we process the Load() and after we
  33. finish the Load() operator.
  34. The purpose of this function is to do the work required to load the
  35. table. We actually split the work to be done at the start of the
  36. load process and the work to be done after the table has been loaded
  37. Arguments:
  38. EventType - EVTYPE_OPCODE_EX
  39. NotifyType - This indicates wether or not we have completed the Load() yet
  40. EventData - OP_LOAD
  41. AcpiObject - the affected name space object (ignored)
  42. EventParam - Supplied information (ignored)
  43. Return Value:
  44. NTSTATUS
  45. --*/
  46. {
  47. ULONG newValue;
  48. if (NotifyType == OPEXF_NOTIFY_PRE) {
  49. //
  50. // We are being called before the load operator. Increment
  51. // the count of Load()'s outstanding. If this value reaches
  52. // 1, then we know that this is the first instance..
  53. //
  54. newValue = InterlockedIncrement( &AcpiTableDelta );
  55. if (newValue == 1) {
  56. //
  57. // We need to get rid of the GPEs...
  58. //
  59. ACPIGpeClearEventMasks();
  60. }
  61. return STATUS_SUCCESS;
  62. }
  63. //
  64. // We are being called after the load operator. Decrement the Load()'s
  65. // outstanding. If this value reaches 0, then we know what we are the
  66. // last instance
  67. //
  68. newValue = InterlockedDecrement( &AcpiTableDelta );
  69. if (newValue == 0) {
  70. //
  71. // We re-enable to re-enable the GPEs
  72. //
  73. ACPIGpeBuildEventMasks();
  74. //
  75. // We also need to process the table...
  76. //
  77. ACPITableLoad();
  78. }
  79. return STATUS_SUCCESS;
  80. }
  81. NTSTATUS
  82. EXPORT
  83. ACPICallBackUnload(
  84. IN ULONG EventType,
  85. IN ULONG NotifyType,
  86. IN ULONG EventData,
  87. IN PNSOBJ AcpiObject,
  88. IN ULONG EventParameter
  89. )
  90. /*++
  91. Routine Description:
  92. This routine is called when the AML interpreter has started unloading
  93. a Differentiated Data Block
  94. Arguments:
  95. EventType - The event type (should be EVTYPE_OPCODE)
  96. NotifyType - This indicates wether or not we have completed the
  97. Unload() yet
  98. EventData - The event subtype (should be OP_UNLOAD)
  99. AcpiObject - The affected name space object (ignored)
  100. EventParamter - The event specific information
  101. Return Value:
  102. NTSTATUS
  103. --*/
  104. {
  105. ULONG newValue;
  106. if (NotifyType == OPEXF_NOTIFY_PRE) {
  107. //
  108. // We are being called before the load operator. Increment
  109. // the count of Load()'s outstanding. If this value reaches
  110. // 1, then we know that this is the first instance..
  111. //
  112. newValue = InterlockedIncrement( &AcpiTableDelta );
  113. if (newValue == 1) {
  114. //
  115. // We need to get rid of the GPEs...
  116. //
  117. ACPIGpeClearEventMasks();
  118. }
  119. //
  120. // Lets try to flush the power and device queues
  121. //
  122. ACPIBuildFlushQueue( RootDeviceExtension );
  123. ACPIDevicePowerFlushQueue( RootDeviceExtension );
  124. return STATUS_SUCCESS;
  125. }
  126. //
  127. // We are being called after the load operator. Decrement the Load()'s
  128. // outstanding. If this value reaches 0, then we know what we are the
  129. // last instance
  130. //
  131. newValue = InterlockedDecrement( &AcpiTableDelta );
  132. if (newValue == 0) {
  133. //
  134. // We re-enable to re-enable the GPEs
  135. //
  136. ACPIGpeBuildEventMasks();
  137. //
  138. // We also need to process the disappearing table...
  139. //
  140. ACPITableUnload();
  141. }
  142. return STATUS_SUCCESS;
  143. }