Source code of Windows XP (NT5)
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.

342 lines
8.8 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. HCDI.H
  5. Abstract:
  6. structures common to the usbd and hcd device drivers.
  7. Environment:
  8. Kernel & user mode
  9. Revision History:
  10. 09-29-95 : created
  11. --*/
  12. #ifndef __HCDI_H__
  13. #define __HCDI_H__
  14. typedef NTSTATUS ROOT_HUB_POWER_FUNCTION(PDEVICE_OBJECT DeviceObject,
  15. PIRP Irp);
  16. typedef NTSTATUS HCD_DEFFERED_START_FUNCTION(PDEVICE_OBJECT DeviceObject,
  17. PIRP Irp);
  18. typedef NTSTATUS HCD_SET_DEVICE_POWER_STATE(PDEVICE_OBJECT DeviceObject,
  19. PIRP Irp,
  20. DEVICE_POWER_STATE DeviceState);
  21. typedef NTSTATUS HCD_GET_CURRENT_FRAME(PDEVICE_OBJECT DeviceObject,
  22. PULONG CurrentFrame);
  23. typedef NTSTATUS HCD_GET_CONSUMED_BW(PDEVICE_OBJECT DeviceObject);
  24. typedef NTSTATUS HCD_SUBMIT_ISO_URB(PDEVICE_OBJECT DeviceObject, PURB Urb);
  25. //
  26. // values for DeviceExtension Flags
  27. //
  28. #define USBDFLAG_PDO_REMOVED 0x00000001
  29. #define USBDFLAG_HCD_SHUTDOWN 0x00000002
  30. #define USBDFLAG_HCD_STARTED 0x00000004
  31. #define USBDFLAG_HCD_D0_COMPLETE_PENDING 0x00000008
  32. #define USBDFLAG_RH_DELAY_SET_D0 0x00000010
  33. #define USBDFLAG_NEED_NEW_HCWAKEIRP 0x00000020
  34. typedef struct _USBD_EXTENSION {
  35. // ptr to true device extension or NULL if this
  36. // is the true extension
  37. PVOID TrueDeviceExtension;
  38. ULONG Flags;
  39. // size of this structure
  40. ULONG Length;
  41. ROOT_HUB_POWER_FUNCTION *RootHubPower;
  42. HCD_DEFFERED_START_FUNCTION *HcdDeferredStartDevice;
  43. HCD_SET_DEVICE_POWER_STATE *HcdSetDevicePowerState;
  44. HCD_GET_CURRENT_FRAME *HcdGetCurrentFrame;
  45. HCD_GET_CONSUMED_BW *HcdGetConsumedBW;
  46. HCD_SUBMIT_ISO_URB *HcdSubmitIsoUrb;
  47. DEVICE_POWER_STATE HcCurrentDevicePowerState;
  48. KEVENT PnpStartEvent;
  49. //
  50. // Owner of frame length control for this HC
  51. //
  52. PVOID FrameLengthControlOwner;
  53. //
  54. // HCD device object we are connected to.
  55. //
  56. PDEVICE_OBJECT HcdDeviceObject;
  57. // wake irp passed to us by the hub driver
  58. // for the root hub
  59. PIRP PendingWakeIrp;
  60. // wakeup irp we send down the HC stack
  61. PIRP HcWakeIrp;
  62. //
  63. // device object for top of the HCD stack
  64. // this = HcdDeviceObject when no filters
  65. // are present.
  66. //
  67. PDEVICE_OBJECT HcdTopOfStackDeviceObject;
  68. PDEVICE_OBJECT HcdTopOfPdoStackDeviceObject;
  69. //
  70. // copy of the host controller device
  71. // capabilities
  72. //
  73. DEVICE_CAPABILITIES HcDeviceCapabilities;
  74. DEVICE_CAPABILITIES RootHubDeviceCapabilities;
  75. PIRP PowerIrp;
  76. //
  77. // Used to serialize open/close endpoint and
  78. // device configuration
  79. //
  80. KSEMAPHORE UsbDeviceMutex;
  81. //
  82. // Bitmap of assigned USB addresses
  83. //
  84. ULONG AddressList[4];
  85. //
  86. // Remember the Root Hub PDO we created.
  87. //
  88. PDEVICE_OBJECT RootHubPDO;
  89. PDRIVER_OBJECT DriverObject;
  90. //
  91. // symbolic link created for HCD stack
  92. //
  93. UNICODE_STRING DeviceLinkUnicodeString;
  94. BOOLEAN DiagnosticMode;
  95. BOOLEAN DiagIgnoreHubs;
  96. BOOLEAN Reserved; // used to be supportNonComp
  97. UCHAR HcWakeFlags;
  98. ULONG DeviceHackFlags;
  99. KSPIN_LOCK WaitWakeSpin;
  100. //
  101. // Store away the PDO
  102. //
  103. PDEVICE_OBJECT HcdPhysicalDeviceObject;
  104. PVOID RootHubDeviceData;
  105. DEVICE_POWER_STATE RootHubDeviceState;
  106. // current USB defined power state of the bus
  107. // during last suspend.
  108. DEVICE_POWER_STATE SuspendPowerState;
  109. UNICODE_STRING RootHubSymbolicLinkName;
  110. KSPIN_LOCK RootHubPowerSpin;
  111. PDEVICE_OBJECT RootHubPowerDeviceObject;
  112. PIRP RootHubPowerIrp;
  113. PIRP IdleNotificationIrp;
  114. BOOLEAN IsPIIX3or4;
  115. BOOLEAN WakeSupported;
  116. } USBD_EXTENSION, *PUSBD_EXTENSION;
  117. #define HC_ENABLED_FOR_WAKEUP 0x01
  118. #define HC_WAKE_PENDING 0x02
  119. // device hack flags, these flags alter the stacks default behavior
  120. // in order to support certain broken "legacy" devices
  121. #define USBD_DEVHACK_SLOW_ENUMERATION 0x00000001
  122. #define USBD_DEVHACK_DISABLE_SN 0x00000002
  123. //
  124. // This macro returns the true device object for the HCD give
  125. // either the true device_object or a PDO owned by the HCD/BUS
  126. // driver.
  127. //
  128. //
  129. // HCD specific URB commands
  130. //
  131. #define URB_FUNCTION_HCD_OPEN_ENDPOINT 0x1000
  132. #define URB_FUNCTION_HCD_CLOSE_ENDPOINT 0x1001
  133. #define URB_FUNCTION_HCD_GET_ENDPOINT_STATE 0x1002
  134. #define URB_FUNCTION_HCD_SET_ENDPOINT_STATE 0x1003
  135. #define URB_FUNCTION_HCD_ABORT_ENDPOINT 0x1004
  136. // this bit is set for all functions that must be handled by HCD
  137. #define HCD_URB_FUNCTION 0x1000
  138. // this bit is set in the function code by USBD to indicate that
  139. // this is an internal call originating from USBD
  140. #define HCD_NO_USBD_CALL 0x2000
  141. //
  142. // values for HcdEndpointState
  143. //
  144. //
  145. // set if the current state of the endpoint in the HCD is 'stalled'
  146. //
  147. #define HCD_ENDPOINT_HALTED_BIT 0
  148. #define HCD_ENDPOINT_HALTED (1<<HCD_ENDPOINT_HALTED_BIT)
  149. //
  150. // set if the HCD has any transfers queued for the endpoint
  151. //
  152. #define HCD_ENDPOINT_TRANSFERS_QUEUED_BIT 1
  153. #define HCD_ENDPOINT_TRANSFERS_QUEUED (1<<HCD_ENDPOINT_TRANSFERS_QUEUED_BIT)
  154. //
  155. // set if the HCD should reset the data toggle on the host side
  156. //
  157. #define HCD_ENDPOINT_RESET_DATA_TOGGLE_BIT 2
  158. #define HCD_ENDPOINT_RESET_DATA_TOGGLE (1<<HCD_ENDPOINT_RESET_DATA_TOGGLE_BIT )
  159. //
  160. // HCD specific URBs
  161. //
  162. #define USBD_EP_FLAG_LOWSPEED 0x0001
  163. #define USBD_EP_FLAG_NEVERHALT 0x0002
  164. #define USBD_EP_FLAG_DOUBLE_BUFFER 0x0004
  165. #define USBD_EP_FLAG_FAST_ISO 0x0008
  166. #define USBD_EP_FLAG_MAP_ADD_IO 0x0010
  167. struct _URB_HCD_OPEN_ENDPOINT {
  168. struct _URB_HEADER;
  169. USHORT DeviceAddress;
  170. USHORT HcdEndpointFlags;
  171. PUSB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
  172. ULONG MaxTransferSize;
  173. PVOID HcdEndpoint;
  174. ULONG ScheduleOffset;
  175. };
  176. struct _URB_HCD_CLOSE_ENDPOINT {
  177. struct _URB_HEADER;
  178. PVOID HcdEndpoint;
  179. };
  180. struct _URB_HCD_ENDPOINT_STATE {
  181. struct _URB_HEADER;
  182. PVOID HcdEndpoint;
  183. ULONG HcdEndpointState;
  184. };
  185. struct _URB_HCD_ABORT_ENDPOINT {
  186. struct _URB_HEADER;
  187. PVOID HcdEndpoint;
  188. };
  189. //
  190. // Common transfer request definition, all transfer
  191. // requests passed to the HCD will be mapped to this
  192. // format. The HCD will can use this structure to
  193. // reference fields that are common to all transfers
  194. // as well as fields specific to isochronous and
  195. // control transfers.
  196. //
  197. typedef struct _COMMON_TRANSFER_EXTENSION {
  198. union {
  199. struct {
  200. ULONG StartFrame;
  201. ULONG NumberOfPackets;
  202. ULONG ErrorCount;
  203. USBD_ISO_PACKET_DESCRIPTOR IsoPacket[0];
  204. } Isoch;
  205. UCHAR SetupPacket[8];
  206. } u;
  207. } COMMON_TRANSFER_EXTENSION, *PCOMMON_TRANSFER_EXTENSION;
  208. struct _URB_HCD_COMMON_TRANSFER {
  209. struct _URB_HEADER;
  210. PVOID UsbdPipeHandle;
  211. ULONG TransferFlags;
  212. ULONG TransferBufferLength;
  213. PVOID TransferBuffer;
  214. PMDL TransferBufferMDL;
  215. struct _HCD_URB *UrbLink; // link to next urb request
  216. // if this is a chain of requests
  217. struct _URB_HCD_AREA hca; // fields for HCD use
  218. COMMON_TRANSFER_EXTENSION Extension;
  219. /*
  220. //add fields for isoch and
  221. //control transfers
  222. UCHAR SetupPacket[8];
  223. ULONG StartFrame;
  224. // number of packets that make up this request
  225. ULONG NumberOfPackets;
  226. // number of packets that completed with errors
  227. ULONG ErrorCount;
  228. USBD_ISO_PACKET_DESCRIPTOR IsoPacket[0];
  229. */
  230. };
  231. typedef struct _HCD_URB {
  232. union {
  233. struct _URB_HEADER UrbHeader;
  234. struct _URB_HCD_OPEN_ENDPOINT HcdUrbOpenEndpoint;
  235. struct _URB_HCD_CLOSE_ENDPOINT HcdUrbCloseEndpoint;
  236. struct _URB_GET_FRAME_LENGTH UrbGetFrameLength;
  237. struct _URB_SET_FRAME_LENGTH UrbSetFrameLength;
  238. struct _URB_GET_CURRENT_FRAME_NUMBER UrbGetCurrentFrameNumber;
  239. struct _URB_HCD_ENDPOINT_STATE HcdUrbEndpointState;
  240. struct _URB_HCD_ABORT_ENDPOINT HcdUrbAbortEndpoint;
  241. //formats for USB transfer requests.
  242. struct _URB_HCD_COMMON_TRANSFER HcdUrbCommonTransfer;
  243. //formats for specific transfer types
  244. //that have fields not contained in
  245. //CommonTransfer.
  246. //this will be merged with commontransfer
  247. struct _URB_ISOCH_TRANSFER UrbIsochronousTransfer;
  248. };
  249. } HCD_URB, *PHCD_URB;
  250. //
  251. // bandwidth related definitions
  252. //
  253. // overhead in bytes/ms
  254. #define USB_ISO_OVERHEAD_BYTES 9
  255. #define USB_INTERRUPT_OVERHEAD_BYTES 13
  256. #endif /* __HCDI_H__ */