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.

226 lines
4.9 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. selSusp.h
  5. Abstract:
  6. Environment:
  7. Kernel mode
  8. Notes:
  9. Copyright (c) 2000 Microsoft Corporation.
  10. All Rights Reserved.
  11. --*/
  12. #include <initguid.h>
  13. #include <wdm.h>
  14. #include <wmilib.h>
  15. #include <wmistr.h>
  16. #include "usbdi.h"
  17. #include "usbdlib.h"
  18. #ifndef _SUSPEND_LOCAL_H
  19. #define _SUSPEND_LOCAL_H
  20. #define SSTAG (ULONG) 'SleS'
  21. #undef ExAllocatePool
  22. #define ExAllocatePool(type, size) \
  23. ExAllocatePoolWithTag(type, size, SSTAG);
  24. #if DBG
  25. #define SSDbgPrint(level, _x_) \
  26. if((level) <= DebugLevel) { \
  27. DbgPrint _x_; \
  28. }
  29. #else
  30. #define SSDbgPrint(level, _x_)
  31. #endif
  32. typedef struct _GLOBALS {
  33. UNICODE_STRING SSRegistryPath;
  34. } GLOBALS;
  35. #define IDLE_INTERVAL 5000
  36. typedef enum _DEVSTATE {
  37. NotStarted, // not started
  38. Stopped, // device stopped
  39. Working, // started and working
  40. PendingStop, // stop pending
  41. PendingRemove, // remove pending
  42. SurpriseRemoved, // removed by surprise
  43. Removed // removed
  44. } DEVSTATE;
  45. typedef enum _QUEUE_STATE {
  46. HoldRequests, // device is not started yet
  47. AllowRequests, // device is ready to process
  48. FailRequests // fail both existing and queued up requests
  49. } QUEUE_STATE;
  50. typedef enum _WDM_VERSION {
  51. WinXpOrBetter,
  52. Win2kOrBetter,
  53. WinMeOrBetter,
  54. Win98OrBetter
  55. } WDM_VERSION;
  56. #define INITIALIZE_PNP_STATE(_Data_) \
  57. (_Data_)->DeviceState = NotStarted;\
  58. (_Data_)->PrevDevState = NotStarted;
  59. #define SET_NEW_PNP_STATE(_Data_, _state_) \
  60. (_Data_)->PrevDevState = (_Data_)->DeviceState;\
  61. (_Data_)->DeviceState = (_state_);
  62. #define RESTORE_PREVIOUS_PNP_STATE(_Data_) \
  63. (_Data_)->DeviceState = (_Data_)->PrevDevState;
  64. //
  65. // registry path used for parameters
  66. // global to all instances of the driver
  67. //
  68. #define SELSUSP_REGISTRY_PARAMETERS_PATH \
  69. L"\\REGISTRY\\Machine\\System\\CurrentControlSet\\SERVICES\\SELSUSP\\Parameters"
  70. //
  71. // A structure representing the instance information associated with
  72. // this particular device.
  73. //
  74. typedef struct _DEVICE_EXTENSION {
  75. // Functional Device Object
  76. PDEVICE_OBJECT FunctionalDeviceObject;
  77. // Device object we call when submitting Urbs
  78. PDEVICE_OBJECT TopOfStackDeviceObject;
  79. // The bus driver object
  80. PDEVICE_OBJECT PhysicalDeviceObject;
  81. // Name buffer for our named Functional device object link
  82. // The name is generated based on the driver's class GUID
  83. UNICODE_STRING InterfaceName;
  84. //Bus drivers set the appropriate values in this structure in response
  85. //to an IRP_MN_QUERY_CAPABILITIES IRP. Function and filter drivers might
  86. //alter the capabilities set by the bus driver.
  87. DEVICE_CAPABILITIES DeviceCapabilities;
  88. // current state of device
  89. DEVSTATE DeviceState;
  90. // state prior to removal query
  91. DEVSTATE PrevDevState;
  92. // obtain and hold this lock while changing the device state,
  93. // the queue state and while processing the queue.
  94. KSPIN_LOCK DevStateLock;
  95. // current system power state
  96. SYSTEM_POWER_STATE SysPower;
  97. // current device power state
  98. DEVICE_POWER_STATE DevPower;
  99. // Pending I/O queue state
  100. QUEUE_STATE QueueState;
  101. // Pending I/O queue
  102. LIST_ENTRY NewRequestsQueue;
  103. // I/O Queue Lock
  104. KSPIN_LOCK QueueLock;
  105. KEVENT RemoveEvent;
  106. KEVENT StopEvent;
  107. ULONG OutStandingIO;
  108. KSPIN_LOCK IOCountLock;
  109. // selective suspend variables
  110. LONG SSEnable;
  111. LONG SSRegistryEnable;
  112. PUSB_IDLE_CALLBACK_INFO IdleCallbackInfo;
  113. PIRP PendingIdleIrp;
  114. LONG IdleReqPend;
  115. LONG FreeIdleIrpCount;
  116. KSPIN_LOCK IdleReqStateLock;
  117. KEVENT NoIdleReqPendEvent;
  118. // default power state to power down to on self-susped
  119. ULONG PowerDownLevel;
  120. // remote wakeup variables
  121. PIRP WaitWakeIrp;
  122. LONG FlagWWCancel;
  123. LONG FlagWWOutstanding;
  124. LONG WaitWakeEnable;
  125. // open handle count
  126. LONG OpenHandleCount;
  127. // selective suspend model uses timers, dpcs and work item.
  128. KTIMER Timer;
  129. KDPC DeferredProcCall;
  130. // This event is cleared when a DPC/Work Item is queued.
  131. // and signaled when the work-item completes.
  132. // This is essential to prevent the driver from unloading
  133. // while we have DPC or work-item queued up.
  134. KEVENT NoDpcWorkItemPendingEvent;
  135. // WMI information
  136. WMILIB_CONTEXT WmiLibInfo;
  137. // WDM version
  138. WDM_VERSION WdmVersion;
  139. } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
  140. typedef struct _IRP_COMPLETION_CONTEXT {
  141. PDEVICE_EXTENSION DeviceExtension;
  142. PKEVENT Event;
  143. } IRP_COMPLETION_CONTEXT, *PIRP_COMPLETION_CONTEXT;
  144. extern GLOBALS Globals;
  145. extern ULONG DebugLevel;
  146. #endif