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.

248 lines
5.4 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. bulkusb.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 _BULKUSB_H
  19. #define _BULKUSB_H
  20. #define BULKTAG (ULONG) 'KluB'
  21. #undef ExAllocatePool
  22. #define ExAllocatePool(type, size) \
  23. ExAllocatePoolWithTag(type, size, BULKTAG);
  24. #if DBG
  25. #define BulkUsb_DbgPrint(level, _x_) \
  26. if((level) <= DebugLevel) { \
  27. DbgPrint _x_; \
  28. }
  29. #else
  30. #define BulkUsb_DbgPrint(level, _x_)
  31. #endif
  32. typedef struct _GLOBALS {
  33. UNICODE_STRING BulkUsb_RegistryPath;
  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. #define BULKUSB_MAX_TRANSFER_SIZE 256
  65. #define BULKUSB_TEST_BOARD_TRANSFER_BUFFER_SIZE (64 *1024 )
  66. //
  67. // registry path used for parameters
  68. // global to all instances of the driver
  69. //
  70. #define BULKUSB_REGISTRY_PARAMETERS_PATH \
  71. L"\\REGISTRY\\Machine\\System\\CurrentControlSet\\SERVICES\\BULKUSB\\Parameters"
  72. typedef struct _BULKUSB_PIPE_CONTEXT {
  73. BOOLEAN PipeOpen;
  74. } BULKUSB_PIPE_CONTEXT, *PBULKUSB_PIPE_CONTEXT;
  75. //
  76. // A structure representing the instance information associated with
  77. // this particular device.
  78. //
  79. typedef struct _DEVICE_EXTENSION {
  80. // Functional Device Object
  81. PDEVICE_OBJECT FunctionalDeviceObject;
  82. // Device object we call when submitting Urbs
  83. PDEVICE_OBJECT TopOfStackDeviceObject;
  84. // The bus driver object
  85. PDEVICE_OBJECT PhysicalDeviceObject;
  86. // Name buffer for our named Functional device object link
  87. // The name is generated based on the driver's class GUID
  88. UNICODE_STRING InterfaceName;
  89. // Bus drivers set the appropriate values in this structure in response
  90. // to an IRP_MN_QUERY_CAPABILITIES IRP. Function and filter drivers might
  91. // alter the capabilities set by the bus driver.
  92. DEVICE_CAPABILITIES DeviceCapabilities;
  93. // Configuration Descriptor
  94. PUSB_CONFIGURATION_DESCRIPTOR UsbConfigurationDescriptor;
  95. // Interface Information structure
  96. PUSBD_INTERFACE_INFORMATION UsbInterface;
  97. // Pipe context for the bulkusb driver
  98. PBULKUSB_PIPE_CONTEXT PipeContext;
  99. // current state of device
  100. DEVSTATE DeviceState;
  101. // state prior to removal query
  102. DEVSTATE PrevDevState;
  103. // obtain and hold this lock while changing the device state,
  104. // the queue state and while processing the queue.
  105. KSPIN_LOCK DevStateLock;
  106. // current system power state
  107. SYSTEM_POWER_STATE SysPower;
  108. // current device power state
  109. DEVICE_POWER_STATE DevPower;
  110. // Pending I/O queue state
  111. QUEUE_STATE QueueState;
  112. // Pending I/O queue
  113. LIST_ENTRY NewRequestsQueue;
  114. // I/O Queue Lock
  115. KSPIN_LOCK QueueLock;
  116. KEVENT RemoveEvent;
  117. KEVENT StopEvent;
  118. ULONG OutStandingIO;
  119. KSPIN_LOCK IOCountLock;
  120. // selective suspend variables
  121. LONG SSEnable;
  122. LONG SSRegistryEnable;
  123. PUSB_IDLE_CALLBACK_INFO IdleCallbackInfo;
  124. PIRP PendingIdleIrp;
  125. LONG IdleReqPend;
  126. LONG FreeIdleIrpCount;
  127. KSPIN_LOCK IdleReqStateLock;
  128. KEVENT NoIdleReqPendEvent;
  129. // default power state to power down to on self-susped
  130. ULONG PowerDownLevel;
  131. // remote wakeup variables
  132. PIRP WaitWakeIrp;
  133. LONG FlagWWCancel;
  134. LONG FlagWWOutstanding;
  135. LONG WaitWakeEnable;
  136. // open handle count
  137. LONG OpenHandleCount;
  138. // selective suspend model uses timers, dpcs and work item.
  139. KTIMER Timer;
  140. KDPC DeferredProcCall;
  141. // This event is cleared when a DPC/Work Item is queued.
  142. // and signaled when the work-item completes.
  143. // This is essential to prevent the driver from unloading
  144. // while we have DPC or work-item queued up.
  145. KEVENT NoDpcWorkItemPendingEvent;
  146. // WMI information
  147. WMILIB_CONTEXT WmiLibInfo;
  148. // WDM version
  149. WDM_VERSION WdmVersion;
  150. } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
  151. typedef struct _IRP_COMPLETION_CONTEXT {
  152. PDEVICE_EXTENSION DeviceExtension;
  153. PKEVENT Event;
  154. } IRP_COMPLETION_CONTEXT, *PIRP_COMPLETION_CONTEXT;
  155. extern GLOBALS Globals;
  156. extern ULONG DebugLevel;
  157. #endif