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.

185 lines
3.5 KiB

  1. /*++
  2. Copyright (c) 2000-2001 Microsoft Corporation
  3. Module Name:
  4. util.c
  5. Abstract:
  6. ACPI BIOS Simulator / Generic 3rd Party Operation Region Provider
  7. Utility module
  8. Author(s):
  9. Vincent Geglia
  10. Michael T. Murphy
  11. Chris Burgess
  12. Environment:
  13. Kernel mode
  14. Notes:
  15. Revision History:
  16. --*/
  17. //
  18. // General includes
  19. //
  20. #include "ntddk.h"
  21. //
  22. // Specific includes
  23. //
  24. #include "acpisim.h"
  25. #include "util.h"
  26. //
  27. // Private function prototypes
  28. //
  29. VOID
  30. AcpisimSetDevExtFlags
  31. (
  32. IN PDEVICE_OBJECT DeviceObject,
  33. IN DEV_EXT_FLAGS Flags
  34. )
  35. {
  36. PDEVICE_EXTENSION deviceextension = AcpisimGetDeviceExtension (DeviceObject);
  37. deviceextension->Flags &= Flags;
  38. }
  39. VOID
  40. AcpisimClearDevExtFlags
  41. (
  42. IN PDEVICE_OBJECT DeviceObject,
  43. IN DEV_EXT_FLAGS Flags
  44. )
  45. {
  46. PDEVICE_EXTENSION deviceextension = AcpisimGetDeviceExtension (DeviceObject);
  47. deviceextension->Flags &= ~Flags;
  48. }
  49. VOID
  50. AcpisimUpdatePnpState
  51. (
  52. IN PDEVICE_OBJECT DeviceObject,
  53. IN PNP_STATE PnpState
  54. )
  55. {
  56. PDEVICE_EXTENSION deviceextension = AcpisimGetDeviceExtension (DeviceObject);
  57. deviceextension->PnpState = PnpState;
  58. }
  59. VOID
  60. AcpisimUpdateDevicePowerState
  61. (
  62. IN PDEVICE_OBJECT DeviceObject,
  63. IN DEVICE_POWER_STATE DevicePowerState
  64. )
  65. {
  66. PDEVICE_EXTENSION deviceextension = AcpisimGetDeviceExtension (DeviceObject);
  67. deviceextension->DevicePowerState = DevicePowerState;
  68. }
  69. VOID
  70. AcpisimUpdatePowerState
  71. (
  72. IN PDEVICE_OBJECT DeviceObject,
  73. IN PWR_STATE PowerState
  74. )
  75. {
  76. PDEVICE_EXTENSION deviceextension = AcpisimGetDeviceExtension (DeviceObject);
  77. deviceextension->PowerState = PowerState;
  78. }
  79. NTSTATUS
  80. AcpisimEnableDisableDeviceInterface
  81. (
  82. IN PDEVICE_OBJECT DeviceObject,
  83. IN BOOLEAN Enable
  84. )
  85. {
  86. PDEVICE_EXTENSION deviceextension = AcpisimGetDeviceExtension (DeviceObject);
  87. NTSTATUS status = STATUS_UNSUCCESSFUL;
  88. status = IoSetDeviceInterfaceState (&deviceextension->InterfaceString, Enable);
  89. return status;
  90. }
  91. VOID
  92. AcpisimDecrementIrpCount
  93. (
  94. PDEVICE_OBJECT DeviceObject
  95. )
  96. {
  97. PDEVICE_EXTENSION deviceextension = AcpisimGetDeviceExtension (DeviceObject);
  98. if (!deviceextension->OutstandingIrpCount) {
  99. DBG_PRINT (DBG_ERROR, "*** Internal consistency error - AcpisimDecrementIrpCount called with OutstandingIrpCount at 0!\n");
  100. }
  101. if (!InterlockedDecrement (&deviceextension->OutstandingIrpCount)) {
  102. DBG_PRINT (DBG_INFO, "All IRPs cleared - remove event signalled.\n");
  103. KeSetEvent (&deviceextension->IrpsCompleted, 0, FALSE);
  104. }
  105. return;
  106. }
  107. PDEVICE_EXTENSION
  108. AcpisimGetDeviceExtension
  109. (
  110. PDEVICE_OBJECT DeviceObject
  111. )
  112. {
  113. PDEVICE_EXTENSION deviceextension = DeviceObject->DeviceExtension;
  114. //
  115. // Check to make sure it is OUR extension
  116. //
  117. ASSERT (deviceextension->Signature == ACPISIM_TAG);
  118. return deviceextension;
  119. }
  120. PDEVICE_OBJECT
  121. AcpisimLibGetNextDevice
  122. (
  123. PDEVICE_OBJECT DeviceObject
  124. )
  125. {
  126. PDEVICE_EXTENSION deviceextension = DeviceObject->DeviceExtension;
  127. //
  128. // Check to make sure it is OUR extension
  129. //
  130. ASSERT (deviceextension->Signature == ACPISIM_TAG);
  131. return deviceextension->NextDevice;
  132. }