Home | History | Annotate | Download | only in include
      1 /*
      2  * usb.h
      3  *
      4  * This file is part of the mingw-w64 runtime package.
      5  * No warranty is given; refer to the file DISCLAIMER within this package.
      6  *
      7  * This file is based on the ReactOS PSDK package file usb.h header.
      8  * It was contributors by Casper S. Hornstrup <chorns (at) users.sourceforge.net>
      9  *
     10  * Additions for Windows 8 and winapi-family by Kai Tietz.
     11  * Replace dependecy of usb200.h header by usbspec.h header.
     12  */
     13 
     14 #ifdef OSR21_COMPAT
     15 #pragma message("WARNING: OSR21_COMPAT SWITCH NOT SUPPORTED")
     16 #endif
     17 
     18 #ifndef __USB_H__
     19 #define __USB_H__
     20 
     21 #include <winapifamily.h>
     22 
     23 #if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
     24 
     25 #ifndef _NTDDK_
     26 #ifndef _WDMDDK_
     27 typedef PVOID PIRP;
     28 typedef PVOID PMDL;
     29 #endif
     30 #endif
     31 
     32 #define USBDI_VERSION 0x00000600
     33 
     34 #include "usbspec.h"
     35 #include "usb200.h"
     36 
     37 #define USB_PORTATTR_NO_CONNECTOR 0x00000001
     38 #define USB_PORTATTR_SHARED_USB2 0x00000002
     39 #define USB_PORTATTR_MINI_CONNECTOR 0x00000004
     40 #define USB_PORTATTR_OEM_CONNECTOR 0x00000008
     41 #define USB_PORTATTR_OWNED_BY_CC 0x01000000
     42 #define USB_PORTATTR_NO_OVERCURRENT_UI 0x02000000
     43 
     44 typedef enum _USB_CONTROLLER_FLAVOR {
     45   USB_HcGeneric = 0,
     46   OHCI_Generic = 100,
     47   OHCI_Hydra,
     48   OHCI_NEC,
     49   UHCI_Generic = 200,
     50   UHCI_Piix4 = 201,
     51   UHCI_Piix3 = 202,
     52   UHCI_Ich2 = 203,
     53   UHCI_Reserved204 = 204,
     54   UHCI_Ich1 = 205,
     55   UHCI_Ich3m = 206,
     56   UHCI_Ich4 = 207,
     57   UHCI_Ich5 = 208,
     58   UHCI_Ich6 = 209,
     59   UHCI_Intel = 249,
     60   UHCI_VIA = 250,
     61   UHCI_VIA_x01 = 251,
     62   UHCI_VIA_x02 = 252,
     63   UHCI_VIA_x03 = 253,
     64   UHCI_VIA_x04 = 254,
     65   UHCI_VIA_x0E_FIFO = 264,
     66   EHCI_Generic = 1000,
     67   EHCI_NEC = 2000,
     68   EHCI_Lucent = 3000,
     69   EHCI_NVIDIA_Tegra2 = 4000,
     70   EHCI_NVIDIA_Tegra3 = 4001,
     71   EHCI_Intel_Medfield = 5001
     72 } USB_CONTROLLER_FLAVOR;
     73 
     74 #define USB_DEFAULT_DEVICE_ADDRESS 0
     75 #define USB_DEFAULT_ENDPOINT_ADDRESS 0
     76 
     77 #define USB_DEFAULT_MAX_PACKET 64
     78 
     79 #define URB_FROM_IRP(Irp) ((IoGetCurrentIrpStackLocation (Irp))->Parameters.Others.Argument1)
     80 
     81 #define URB_FUNCTION_SELECT_CONFIGURATION 0x0000
     82 #define URB_FUNCTION_SELECT_INTERFACE 0x0001
     83 #define URB_FUNCTION_ABORT_PIPE 0x0002
     84 #define URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL 0x0003
     85 #define URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL 0x0004
     86 #define URB_FUNCTION_GET_FRAME_LENGTH 0x0005
     87 #define URB_FUNCTION_SET_FRAME_LENGTH 0x0006
     88 #define URB_FUNCTION_GET_CURRENT_FRAME_NUMBER 0x0007
     89 #define URB_FUNCTION_CONTROL_TRANSFER 0x0008
     90 #define URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER 0x0009
     91 #define URB_FUNCTION_ISOCH_TRANSFER 0x000a
     92 #define URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE 0x000b
     93 #define URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE 0x000c
     94 #define URB_FUNCTION_SET_FEATURE_TO_DEVICE 0x000d
     95 #define URB_FUNCTION_SET_FEATURE_TO_INTERFACE 0x000e
     96 #define URB_FUNCTION_SET_FEATURE_TO_ENDPOINT 0x000f
     97 #define URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE 0x0010
     98 #define URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE 0x0011
     99 #define URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT 0x0012
    100 #define URB_FUNCTION_GET_STATUS_FROM_DEVICE 0x0013
    101 #define URB_FUNCTION_GET_STATUS_FROM_INTERFACE 0x0014
    102 #define URB_FUNCTION_GET_STATUS_FROM_ENDPOINT 0x0015
    103 #define URB_FUNCTION_RESERVED_0X0016 0x0016
    104 #define URB_FUNCTION_VENDOR_DEVICE 0x0017
    105 #define URB_FUNCTION_VENDOR_INTERFACE 0x0018
    106 #define URB_FUNCTION_VENDOR_ENDPOINT 0x0019
    107 #define URB_FUNCTION_CLASS_DEVICE 0x001a
    108 #define URB_FUNCTION_CLASS_INTERFACE 0x001b
    109 #define URB_FUNCTION_CLASS_ENDPOINT 0x001c
    110 #define URB_FUNCTION_RESERVE_0X001D 0x001d
    111 #define URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL 0x001e
    112 #define URB_FUNCTION_CLASS_OTHER 0x001f
    113 #define URB_FUNCTION_VENDOR_OTHER 0x0020
    114 #define URB_FUNCTION_GET_STATUS_FROM_OTHER 0x0021
    115 #define URB_FUNCTION_CLEAR_FEATURE_TO_OTHER 0x0022
    116 #define URB_FUNCTION_SET_FEATURE_TO_OTHER 0x0023
    117 #define URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT 0x0024
    118 #define URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT 0x0025
    119 #define URB_FUNCTION_GET_CONFIGURATION 0x0026
    120 #define URB_FUNCTION_GET_INTERFACE 0x0027
    121 #define URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE 0x0028
    122 #define URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE 0x0029
    123 #define URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR 0x002a
    124 #define URB_FUNCTION_RESERVE_0X002B 0x002b
    125 #define URB_FUNCTION_RESERVE_0X002C 0x002c
    126 #define URB_FUNCTION_RESERVE_0X002D 0x002d
    127 #define URB_FUNCTION_RESERVE_0X002E 0x002e
    128 #define URB_FUNCTION_RESERVE_0X002F 0x002f
    129 #define URB_FUNCTION_SYNC_RESET_PIPE 0x0030
    130 #define URB_FUNCTION_SYNC_CLEAR_STALL 0x0031
    131 #if _WIN32_WINNT >= 0x0600
    132 #define URB_FUNCTION_CONTROL_TRANSFER_EX 0x0032
    133 #define URB_FUNCTION_RESERVE_0X0033 0x0033
    134 #define URB_FUNCTION_RESERVE_0X0034 0x0034
    135 #endif
    136 #if NTDDI_VERSION >= 0x06020000
    137 #define URB_FUNCTION_OPEN_STATIC_STREAMS 0x0035
    138 #define URB_FUNCTION_CLOSE_STATIC_STREAMS 0x0036
    139 #define URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER_USING_CHAINED_MDL 0x0037
    140 #define URB_FUNCTION_ISOCH_TRANSFER_USING_CHAINED_MDL 0x0038
    141 #endif
    142 
    143 #define URB_FUNCTION_RESET_PIPE URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL
    144 
    145 #define USBD_TRANSFER_DIRECTION 0x00000001
    146 #define USBD_SHORT_TRANSFER_OK 0x00000002
    147 #define USBD_START_ISO_TRANSFER_ASAP 0x00000004
    148 #define USBD_DEFAULT_PIPE_TRANSFER 0x00000008
    149 #define USBD_TRANSFER_DIRECTION_FLAG(flags) ((flags) &USBD_TRANSFER_DIRECTION)
    150 
    151 #define USBD_TRANSFER_DIRECTION_OUT 0
    152 #define USBD_TRANSFER_DIRECTION_IN 1
    153 #define VALID_TRANSFER_FLAGS_MASK (USBD_SHORT_TRANSFER_OK | USBD_TRANSFER_DIRECTION | USBD_START_ISO_TRANSFER_ASAP | USBD_DEFAULT_PIPE_TRANSFER)
    154 #define USBD_ISO_START_FRAME_RANGE 1024
    155 
    156 typedef LONG USBD_STATUS;
    157 
    158 #define USBD_SUCCESS(Status) ((USBD_STATUS) (Status) >= 0)
    159 #define USBD_PENDING(Status) ((ULONG) (Status) >> 30 == 1)
    160 #define USBD_ERROR(Status) ((USBD_STATUS) (Status) < 0)
    161 #define USBD_STATUS_SUCCESS ((USBD_STATUS) 0x00000000)
    162 #define USBD_STATUS_PENDING ((USBD_STATUS) 0x40000000)
    163 #define USBD_STATUS_CRC ((USBD_STATUS) 0xc0000001)
    164 #define USBD_STATUS_BTSTUFF ((USBD_STATUS) 0xc0000002)
    165 #define USBD_STATUS_DATA_TOGGLE_MISMATCH ((USBD_STATUS) 0xc0000003)
    166 #define USBD_STATUS_STALL_PID ((USBD_STATUS) 0xc0000004)
    167 #define USBD_STATUS_DEV_NOT_RESPONDING ((USBD_STATUS) 0xc0000005)
    168 #define USBD_STATUS_PID_CHECK_FAILURE ((USBD_STATUS) 0xc0000006)
    169 #define USBD_STATUS_UNEXPECTED_PID ((USBD_STATUS) 0xc0000007)
    170 #define USBD_STATUS_DATA_OVERRUN ((USBD_STATUS) 0xc0000008)
    171 #define USBD_STATUS_DATA_UNDERRUN ((USBD_STATUS) 0xc0000009)
    172 #define USBD_STATUS_RESERVED1 ((USBD_STATUS) 0xc000000a)
    173 #define USBD_STATUS_RESERVED2 ((USBD_STATUS) 0xc000000b)
    174 #define USBD_STATUS_BUFFER_OVERRUN ((USBD_STATUS) 0xc000000c)
    175 #define USBD_STATUS_BUFFER_UNDERRUN ((USBD_STATUS) 0xc000000d)
    176 #define USBD_STATUS_NOT_ACCESSED ((USBD_STATUS) 0xc000000f)
    177 #define USBD_STATUS_FIFO ((USBD_STATUS) 0xc0000010)
    178 #define USBD_STATUS_XACT_ERROR ((USBD_STATUS) 0xc0000011)
    179 #define USBD_STATUS_BABBLE_DETECTED ((USBD_STATUS) 0xc0000012)
    180 #define USBD_STATUS_DATA_BUFFER_ERROR ((USBD_STATUS) 0xc0000013)
    181 #define USBD_STATUS_NO_PING_RESPONSE ((USBD_STATUS) 0xc0000014)
    182 #define USBD_STATUS_INVALID_STREAM_TYPE ((USBD_STATUS) 0xc0000015)
    183 #define USBD_STATUS_INVALID_STREAM_ID ((USBD_STATUS) 0xc0000016)
    184 #define USBD_STATUS_ENDPOINT_HALTED ((USBD_STATUS) 0xc0000030)
    185 #define USBD_STATUS_INVALID_URB_FUNCTION ((USBD_STATUS) 0x80000200)
    186 #define USBD_STATUS_INVALID_PARAMETER ((USBD_STATUS) 0x80000300)
    187 #define USBD_STATUS_ERROR_BUSY ((USBD_STATUS) 0x80000400)
    188 #define USBD_STATUS_INVALID_PIPE_HANDLE ((USBD_STATUS) 0x80000600)
    189 #define USBD_STATUS_NO_BANDWIDTH ((USBD_STATUS) 0x80000700)
    190 #define USBD_STATUS_INTERNAL_HC_ERROR ((USBD_STATUS) 0x80000800)
    191 #define USBD_STATUS_ERROR_SHORT_TRANSFER ((USBD_STATUS) 0x80000900)
    192 #define USBD_STATUS_BAD_START_FRAME ((USBD_STATUS) 0xc0000a00)
    193 #define USBD_STATUS_ISOCH_REQUEST_FAILED ((USBD_STATUS) 0xc0000b00)
    194 #define USBD_STATUS_FRAME_CONTROL_OWNED ((USBD_STATUS) 0xc0000c00)
    195 #define USBD_STATUS_FRAME_CONTROL_NOT_OWNED ((USBD_STATUS) 0xc0000d00)
    196 #define USBD_STATUS_NOT_SUPPORTED ((USBD_STATUS) 0xc0000e00)
    197 #define USBD_STATUS_INAVLID_CONFIGURATION_DESCRIPTOR ((USBD_STATUS) 0xc0000f00)
    198 #define USBD_STATUS_INSUFFICIENT_RESOURCES ((USBD_STATUS) 0xc0001000)
    199 #define USBD_STATUS_SET_CONFIG_FAILED ((USBD_STATUS) 0xc0002000)
    200 #define USBD_STATUS_BUFFER_TOO_SMALL ((USBD_STATUS) 0xc0003000)
    201 #define USBD_STATUS_INTERFACE_NOT_FOUND ((USBD_STATUS) 0xc0004000)
    202 #define USBD_STATUS_INAVLID_PIPE_FLAGS ((USBD_STATUS) 0xc0005000)
    203 #define USBD_STATUS_TIMEOUT ((USBD_STATUS) 0xc0006000)
    204 #define USBD_STATUS_DEVICE_GONE ((USBD_STATUS) 0xc0007000)
    205 #define USBD_STATUS_STATUS_NOT_MAPPED ((USBD_STATUS) 0xc0008000)
    206 #define USBD_STATUS_HUB_INTERNAL_ERROR ((USBD_STATUS) 0xc0009000)
    207 #define USBD_STATUS_CANCELED ((USBD_STATUS) 0xc0010000)
    208 #define USBD_STATUS_ISO_NOT_ACCESSED_BY_HW ((USBD_STATUS) 0xc0020000)
    209 #define USBD_STATUS_ISO_TD_ERROR ((USBD_STATUS) 0xc0030000)
    210 #define USBD_STATUS_ISO_NA_LATE_USBPORT ((USBD_STATUS) 0xc0040000)
    211 #define USBD_STATUS_ISO_NOT_ACCESSED_LATE ((USBD_STATUS) 0xc0050000)
    212 #define USBD_STATUS_BAD_DESCRIPTOR ((USBD_STATUS) 0xc0100000)
    213 #define USBD_STATUS_BAD_DESCRIPTOR_BLEN ((USBD_STATUS) 0xc0100001)
    214 #define USBD_STATUS_BAD_DESCRIPTOR_TYPE ((USBD_STATUS) 0xc0100002)
    215 #define USBD_STATUS_BAD_INTERFACE_DESCRIPTOR ((USBD_STATUS) 0xc0100003)
    216 #define USBD_STATUS_BAD_ENDPOINT_DESCRIPTOR ((USBD_STATUS) 0xc0100004)
    217 #define USBD_STATUS_BAD_INTERFACE_ASSOC_DESCRIPTOR ((USBD_STATUS) 0xc0100005)
    218 #define USBD_STATUS_BAD_CONFIG_DESC_LENGTH ((USBD_STATUS) 0xc0100006)
    219 #define USBD_STATUS_BAD_NUMBER_OF_INTERFACES ((USBD_STATUS) 0xc0100007)
    220 #define USBD_STATUS_BAD_NUMBER_OF_ENDPOINTS ((USBD_STATUS) 0xc0100008)
    221 #define USBD_STATUS_BAD_ENDPOINT_ADDRESS ((USBD_STATUS) 0xc0100009)
    222 
    223 typedef PVOID USBD_PIPE_HANDLE;
    224 typedef PVOID USBD_CONFIGURATION_HANDLE;
    225 typedef PVOID USBD_INTERFACE_HANDLE;
    226 
    227 #define USBD_DEFAULT_MAXIMUM_TRANSFER_SIZE 0xffffffff
    228 
    229 typedef struct _USBD_VERSION_INFORMATION {
    230   ULONG USBDI_Version;
    231   ULONG Supported_USB_Version;
    232 } USBD_VERSION_INFORMATION,*PUSBD_VERSION_INFORMATION;
    233 
    234 typedef enum _USBD_PIPE_TYPE {
    235   UsbdPipeTypeControl,
    236   UsbdPipeTypeIsochronous,
    237   UsbdPipeTypeBulk,
    238   UsbdPipeTypeInterrupt
    239 } USBD_PIPE_TYPE;
    240 
    241 #define USBD_PIPE_DIRECTION_IN(pipeInformation) ((pipeInformation)->EndpointAddress &USB_ENDPOINT_DIRECTION_MASK)
    242 
    243 typedef struct _USBD_DEVICE_INFORMATION {
    244   ULONG OffsetNext;
    245   PVOID UsbdDeviceHandle;
    246   USB_DEVICE_DESCRIPTOR DeviceDescriptor;
    247 } USBD_DEVICE_INFORMATION,*PUSBD_DEVICE_INFORMATION;
    248 
    249 typedef struct _USBD_PIPE_INFORMATION {
    250   USHORT MaximumPacketSize;
    251   UCHAR EndpointAddress;
    252   UCHAR Interval;
    253   USBD_PIPE_TYPE PipeType;
    254   USBD_PIPE_HANDLE PipeHandle;
    255   ULONG MaximumTransferSize;
    256   ULONG PipeFlags;
    257 } USBD_PIPE_INFORMATION,*PUSBD_PIPE_INFORMATION;
    258 
    259 #define USBD_PF_CHANGE_MAX_PACKET 0x00000001
    260 #define USBD_PF_SHORT_PACKET_OPT 0x00000002
    261 #define USBD_PF_ENABLE_RT_THREAD_ACCESS 0x00000004
    262 #define USBD_PF_MAP_ADD_TRANSFERS 0x00000008
    263 #define USBD_PF_VALID_MASK (USBD_PF_CHANGE_MAX_PACKET | USBD_PF_SHORT_PACKET_OPT | USBD_PF_ENABLE_RT_THREAD_ACCESS | USBD_PF_MAP_ADD_TRANSFERS)
    264 
    265 typedef struct _USBD_INTERFACE_INFORMATION {
    266   USHORT Length;
    267   UCHAR InterfaceNumber;
    268   UCHAR AlternateSetting;
    269   UCHAR Class;
    270   UCHAR SubClass;
    271   UCHAR Protocol;
    272   UCHAR Reserved;
    273   USBD_INTERFACE_HANDLE InterfaceHandle;
    274   ULONG NumberOfPipes;
    275   USBD_PIPE_INFORMATION Pipes[1];
    276 } USBD_INTERFACE_INFORMATION,*PUSBD_INTERFACE_INFORMATION;
    277 
    278 struct _URB_HCD_AREA {
    279   PVOID Reserved8[8];
    280 };
    281 
    282 struct _URB_HEADER {
    283   USHORT Length;
    284   USHORT Function;
    285   USBD_STATUS Status;
    286   PVOID UsbdDeviceHandle;
    287   ULONG UsbdFlags;
    288 };
    289 
    290 struct _URB_SELECT_INTERFACE {
    291   struct _URB_HEADER Hdr;
    292   USBD_CONFIGURATION_HANDLE ConfigurationHandle;
    293   USBD_INTERFACE_INFORMATION Interface;
    294 };
    295 
    296 struct _URB_SELECT_CONFIGURATION {
    297   struct _URB_HEADER Hdr;
    298   PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor;
    299   USBD_CONFIGURATION_HANDLE ConfigurationHandle;
    300   USBD_INTERFACE_INFORMATION Interface;
    301 };
    302 
    303 struct _URB_PIPE_REQUEST {
    304   struct _URB_HEADER Hdr;
    305   USBD_PIPE_HANDLE PipeHandle;
    306   ULONG Reserved;
    307 };
    308 
    309 struct _URB_FRAME_LENGTH_CONTROL {
    310   struct _URB_HEADER Hdr;
    311 };
    312 
    313 struct _URB_GET_FRAME_LENGTH {
    314   struct _URB_HEADER Hdr;
    315   ULONG FrameLength;
    316   ULONG FrameNumber;
    317 };
    318 
    319 struct _URB_SET_FRAME_LENGTH {
    320   struct _URB_HEADER Hdr;
    321   LONG FrameLengthDelta;
    322 };
    323 
    324 struct _URB_GET_CURRENT_FRAME_NUMBER {
    325   struct _URB_HEADER Hdr;
    326   ULONG FrameNumber;
    327 };
    328 
    329 struct _URB_CONTROL_DESCRIPTOR_REQUEST {
    330   struct _URB_HEADER Hdr;
    331   PVOID Reserved;
    332   ULONG Reserved0;
    333   ULONG TransferBufferLength;
    334   PVOID TransferBuffer;
    335   PMDL TransferBufferMDL;
    336   struct _URB *UrbLink;
    337   struct _URB_HCD_AREA hca;
    338   USHORT Reserved1;
    339   UCHAR Index;
    340   UCHAR DescriptorType;
    341   USHORT LanguageId;
    342   USHORT Reserved2;
    343 };
    344 
    345 struct _URB_CONTROL_GET_STATUS_REQUEST {
    346   struct _URB_HEADER Hdr;
    347   PVOID Reserved;
    348   ULONG Reserved0;
    349   ULONG TransferBufferLength;
    350   PVOID TransferBuffer;
    351   PMDL TransferBufferMDL;
    352   struct _URB *UrbLink;
    353   struct _URB_HCD_AREA hca;
    354   UCHAR Reserved1[4];
    355   USHORT Index;
    356   USHORT Reserved2;
    357 };
    358 
    359 struct _URB_CONTROL_FEATURE_REQUEST {
    360   struct _URB_HEADER Hdr;
    361   PVOID Reserved;
    362   ULONG Reserved2;
    363   ULONG Reserved3;
    364   PVOID Reserved4;
    365   PMDL Reserved5;
    366   struct _URB *UrbLink;
    367   struct _URB_HCD_AREA hca;
    368   USHORT Reserved0;
    369   USHORT FeatureSelector;
    370   USHORT Index;
    371   USHORT Reserved1;
    372 };
    373 
    374 struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST {
    375   struct _URB_HEADER Hdr;
    376   PVOID Reserved;
    377   ULONG TransferFlags;
    378   ULONG TransferBufferLength;
    379   PVOID TransferBuffer;
    380   PMDL TransferBufferMDL;
    381   struct _URB *UrbLink;
    382   struct _URB_HCD_AREA hca;
    383   UCHAR RequestTypeReservedBits;
    384   UCHAR Request;
    385   USHORT Value;
    386   USHORT Index;
    387   USHORT Reserved1;
    388 };
    389 
    390 struct _URB_CONTROL_GET_INTERFACE_REQUEST {
    391   struct _URB_HEADER Hdr;
    392   PVOID Reserved;
    393   ULONG Reserved0;
    394   ULONG TransferBufferLength;
    395   PVOID TransferBuffer;
    396   PMDL TransferBufferMDL;
    397   struct _URB *UrbLink;
    398   struct _URB_HCD_AREA hca;
    399   UCHAR Reserved1[4];
    400   USHORT Interface;
    401   USHORT Reserved2;
    402 };
    403 
    404 struct _URB_CONTROL_GET_CONFIGURATION_REQUEST {
    405   struct _URB_HEADER Hdr;
    406   PVOID Reserved;
    407   ULONG Reserved0;
    408   ULONG TransferBufferLength;
    409   PVOID TransferBuffer;
    410   PMDL TransferBufferMDL;
    411   struct _URB *UrbLink;
    412   struct _URB_HCD_AREA hca;
    413   UCHAR Reserved1[8];
    414 };
    415 
    416 #define OS_STRING_DESCRIPTOR_INDEX 0xee
    417 
    418 #define MS_GENRE_DESCRIPTOR_INDEX 0x0001
    419 #define MS_POWER_DESCRIPTOR_INDEX 0x0002
    420 
    421 #define MS_OS_STRING_SIGNATURE L"MSFT100"
    422 
    423 #define MS_OS_FLAGS_CONTAINERID 0x02
    424 
    425 typedef struct _OS_STRING {
    426   UCHAR bLength;
    427   UCHAR bDescriptorType;
    428   WCHAR MicrosoftString[7];
    429   UCHAR bVendorCode;
    430   __C89_NAMELESS union {
    431     UCHAR bPad;
    432     UCHAR bFlags;
    433   };
    434 } OS_STRING,*POS_STRING;
    435 
    436 struct _URB_OS_FEATURE_DESCRIPTOR_REQUEST {
    437   struct _URB_HEADER Hdr;
    438   PVOID Reserved;
    439   ULONG Reserved0;
    440   ULONG TransferBufferLength;
    441   PVOID TransferBuffer;
    442   PMDL TransferBufferMDL;
    443   struct _URB *UrbLink;
    444   struct _URB_HCD_AREA hca;
    445   UCHAR Recipient:5;
    446   UCHAR Reserved1:3;
    447   UCHAR Reserved2;
    448   UCHAR InterfaceNumber;
    449   UCHAR MS_PageIndex;
    450   USHORT MS_FeatureDescriptorIndex;
    451   USHORT Reserved3;
    452 };
    453 
    454 struct _URB_CONTROL_TRANSFER {
    455   struct _URB_HEADER Hdr;
    456   USBD_PIPE_HANDLE PipeHandle;
    457   ULONG TransferFlags;
    458   ULONG TransferBufferLength;
    459   PVOID TransferBuffer;
    460   PMDL TransferBufferMDL;
    461   struct _URB *UrbLink;
    462   struct _URB_HCD_AREA hca;
    463   UCHAR SetupPacket[8];
    464 };
    465 
    466 #if _WIN32_WINNT >= 0x0600
    467 struct _URB_CONTROL_TRANSFER_EX {
    468   struct _URB_HEADER Hdr;
    469   USBD_PIPE_HANDLE PipeHandle;
    470   ULONG TransferFlags;
    471   ULONG TransferBufferLength;
    472   PVOID TransferBuffer;
    473   PMDL TransferBufferMDL;
    474   ULONG Timeout;
    475 #ifdef _WIN64
    476   ULONG Pad;
    477 #endif
    478   struct _URB_HCD_AREA hca;
    479   UCHAR SetupPacket[8];
    480 };
    481 #endif
    482 
    483 struct _URB_BULK_OR_INTERRUPT_TRANSFER {
    484   struct _URB_HEADER Hdr;
    485   USBD_PIPE_HANDLE PipeHandle;
    486   ULONG TransferFlags;
    487   ULONG TransferBufferLength;
    488   PVOID TransferBuffer;
    489   PMDL TransferBufferMDL;
    490   struct _URB *UrbLink;
    491   struct _URB_HCD_AREA hca;
    492 };
    493 
    494 typedef struct _USBD_ISO_PACKET_DESCRIPTOR {
    495   ULONG Offset;
    496   ULONG Length;
    497   USBD_STATUS Status;
    498 } USBD_ISO_PACKET_DESCRIPTOR,*PUSBD_ISO_PACKET_DESCRIPTOR;
    499 
    500 struct _URB_ISOCH_TRANSFER {
    501   struct _URB_HEADER Hdr;
    502   USBD_PIPE_HANDLE PipeHandle;
    503   ULONG TransferFlags;
    504   ULONG TransferBufferLength;
    505   PVOID TransferBuffer;
    506   PMDL TransferBufferMDL;
    507   struct _URB *UrbLink;
    508   struct _URB_HCD_AREA hca;
    509   ULONG StartFrame;
    510   ULONG NumberOfPackets;
    511   ULONG ErrorCount;
    512   USBD_ISO_PACKET_DESCRIPTOR IsoPacket[1];
    513 };
    514 
    515 #if NTDDI_VERSION >= 0x06020000
    516 #define URB_OPEN_STATIC_STREAMS_VERSION_100 0x100
    517 
    518 typedef struct _USBD_STREAM_INFORMATION {
    519   USBD_PIPE_HANDLE PipeHandle;
    520   ULONG StreamID;
    521   ULONG MaximumTransferSize;
    522   ULONG PipeFlags;
    523 } USBD_STREAM_INFORMATION,*PUSBD_STREAM_INFORMATION;
    524 struct _URB_OPEN_STATIC_STREAMS {
    525   struct _URB_HEADER Hdr;
    526   USBD_PIPE_HANDLE PipeHandle;
    527   ULONG NumberOfStreams;
    528   USHORT StreamInfoVersion;
    529   USHORT StreamInfoSize;
    530   PUSBD_STREAM_INFORMATION Streams;
    531 };
    532 #endif
    533 
    534 typedef struct _URB {
    535   __C89_NAMELESS union {
    536     struct _URB_HEADER UrbHeader;
    537     struct _URB_SELECT_INTERFACE UrbSelectInterface;
    538     struct _URB_SELECT_CONFIGURATION UrbSelectConfiguration;
    539     struct _URB_PIPE_REQUEST UrbPipeRequest;
    540     struct _URB_FRAME_LENGTH_CONTROL UrbFrameLengthControl;
    541     struct _URB_GET_FRAME_LENGTH UrbGetFrameLength;
    542     struct _URB_SET_FRAME_LENGTH UrbSetFrameLength;
    543     struct _URB_GET_CURRENT_FRAME_NUMBER UrbGetCurrentFrameNumber;
    544     struct _URB_CONTROL_TRANSFER UrbControlTransfer;
    545 #if _WIN32_WINNT >= 0x0600
    546     struct _URB_CONTROL_TRANSFER_EX UrbControlTransferEx;
    547 #endif
    548     struct _URB_BULK_OR_INTERRUPT_TRANSFER UrbBulkOrInterruptTransfer;
    549     struct _URB_ISOCH_TRANSFER UrbIsochronousTransfer;
    550     struct _URB_CONTROL_DESCRIPTOR_REQUEST UrbControlDescriptorRequest;
    551     struct _URB_CONTROL_GET_STATUS_REQUEST UrbControlGetStatusRequest;
    552     struct _URB_CONTROL_FEATURE_REQUEST UrbControlFeatureRequest;
    553     struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST UrbControlVendorClassRequest;
    554     struct _URB_CONTROL_GET_INTERFACE_REQUEST UrbControlGetInterfaceRequest;
    555     struct _URB_CONTROL_GET_CONFIGURATION_REQUEST UrbControlGetConfigurationRequest;
    556     struct _URB_OS_FEATURE_DESCRIPTOR_REQUEST UrbOSFeatureDescriptorRequest;
    557 #if NTDDI_VERSION >= 0x06020000
    558     struct _URB_OPEN_STATIC_STREAMS UrbOpenStaticStreams;
    559 #endif
    560   };
    561 } URB,*PURB;
    562 #endif
    563 #endif
    564