Home | History | Annotate | Download | only in include
      1 /**
      2  * This file is part of the mingw-w64 runtime package.
      3  * No warranty is given; refer to the file DISCLAIMER within this package.
      4  */
      5 
      6 #ifndef __USBSPEC_H__
      7 #define __USBSPEC_H__
      8 
      9 #include <winapifamily.h>
     10 
     11 #if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
     12 #include <pshpack1.h>
     13 
     14 typedef enum _USB_DEVICE_SPEED {
     15   UsbLowSpeed = 0,
     16   UsbFullSpeed,
     17   UsbHighSpeed,
     18   UsbSuperSpeed
     19 } USB_DEVICE_SPEED;
     20 
     21 typedef enum _USB_DEVICE_TYPE {
     22   Usb11Device = 0,
     23   Usb20Device
     24 } USB_DEVICE_TYPE;
     25 
     26 typedef union _BM_REQUEST_TYPE {
     27   __C89_NAMELESS struct _BM {
     28     UCHAR Recipient:2;
     29     UCHAR Reserved:3;
     30     UCHAR Type:2;
     31     UCHAR Dir:1;
     32   };
     33   UCHAR B;
     34 } BM_REQUEST_TYPE,*PBM_REQUEST_TYPE;
     35 
     36 typedef struct _USB_DEFAULT_PIPE_SETUP_PACKET {
     37   BM_REQUEST_TYPE bmRequestType;
     38   UCHAR bRequest;
     39   union _wValue {
     40     __C89_NAMELESS struct {
     41       UCHAR LowByte;
     42       UCHAR HiByte;
     43     };
     44     USHORT W;
     45   } wValue;
     46   union _wIndex {
     47     struct {
     48       UCHAR LowByte;
     49       UCHAR HiByte;
     50     };
     51     USHORT W;
     52   } wIndex;
     53   USHORT wLength;
     54 } USB_DEFAULT_PIPE_SETUP_PACKET,*PUSB_DEFAULT_PIPE_SETUP_PACKET;
     55 
     56 #define BMREQUEST_HOST_TO_DEVICE 0
     57 #define BMREQUEST_DEVICE_TO_HOST 1
     58 
     59 #define BMREQUEST_STANDARD 0
     60 #define BMREQUEST_CLASS 1
     61 #define BMREQUEST_VENDOR 2
     62 
     63 #define BMREQUEST_TO_DEVICE 0
     64 #define BMREQUEST_TO_INTERFACE 1
     65 #define BMREQUEST_TO_ENDPOINT 2
     66 #define BMREQUEST_TO_OTHER 3
     67 
     68 #define USB_DESCRIPTOR_MAKE_TYPE_AND_INDEX(d, i) ((USHORT) (((USHORT) d) << 8 | i))
     69 
     70 #define USB_REQUEST_GET_STATUS 0x00
     71 #define USB_REQUEST_CLEAR_FEATURE 0x01
     72 #define USB_REQUEST_SET_FEATURE 0x03
     73 #define USB_REQUEST_SET_ADDRESS 0x05
     74 #define USB_REQUEST_GET_DESCRIPTOR 0x06
     75 #define USB_REQUEST_SET_DESCRIPTOR 0x07
     76 #define USB_REQUEST_GET_CONFIGURATION 0x08
     77 #define USB_REQUEST_SET_CONFIGURATION 0x09
     78 #define USB_REQUEST_GET_INTERFACE 0x0a
     79 #define USB_REQUEST_SET_INTERFACE 0x0b
     80 #define USB_REQUEST_SYNC_FRAME 0x0c
     81 
     82 #define USB_REQUEST_SET_SEL 0x30
     83 #define USB_REQUEST_ISOCH_DELAY 0x31
     84 
     85 #define USB_DEVICE_DESCRIPTOR_TYPE 0x01
     86 #define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
     87 #define USB_STRING_DESCRIPTOR_TYPE 0x03
     88 #define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
     89 #define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
     90 #define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE 0x06
     91 #define USB_OTHER_SPEED_CONFIGURATION_DESCRIPTOR_TYPE 0x07
     92 #define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 0x08
     93 #define USB_OTG_DESCRIPTOR_TYPE 0x09
     94 #define USB_DEBUG_DESCRIPTOR_TYPE 0x0a
     95 #define USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE 0x0b
     96 #define USB_BOS_DESCRIPTOR_TYPE 0x0f
     97 #define USB_DEVICE_CAPABILITY_DESCRIPTOR_TYPE 0x10
     98 #define USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_TYPE 0x30
     99 
    100 #define USB_RESERVED_DESCRIPTOR_TYPE 0x06
    101 #define USB_CONFIG_POWER_DESCRIPTOR_TYPE 0x07
    102 
    103 #define USB_FEATURE_ENDPOINT_STALL 0x00
    104 #define USB_FEATURE_REMOTE_WAKEUP 0x01
    105 #define USB_FEATURE_TEST_MODE 0x02
    106 
    107 #define USB_FEATURE_FUNCTION_SUSPEND 0x00
    108 #define USB_FEATURE_U1_ENABLE 0x30
    109 #define USB_FEATURE_U2_ENABLE 0x31
    110 #define USB_FEATURE_LTM_ENABLE 0x32
    111 
    112 #define USB_GETSTATUS_SELF_POWERED 0x01
    113 #define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED 0x02
    114 
    115 #define USB_GETSTATUS_U1_ENABLE 0x04
    116 #define USB_GETSTATUS_U2_ENABLE 0x08
    117 #define USB_GETSTATUS_LTM_ENABLE 0x10
    118 
    119 typedef union _USB_DEVICE_STATUS {
    120   USHORT AsUshort16;
    121   __C89_NAMELESS struct {
    122     USHORT SelfPowered : 1;
    123     USHORT RemoteWakeup : 1;
    124     USHORT U1Enable : 1;
    125     USHORT U2Enable : 1;
    126     USHORT LtmEnable : 1;
    127     USHORT Reserved : 11;
    128   };
    129 } USB_DEVICE_STATUS,*PUSB_DEVICE_STATUS;
    130 
    131 typedef union _USB_INTERFACE_STATUS {
    132   USHORT AsUshort16;
    133   __C89_NAMELESS struct {
    134     USHORT RemoteWakeupCapable : 1;
    135     USHORT RemoteWakeupEnabled : 1;
    136     USHORT Reserved : 14;
    137   };
    138 } USB_INTERFACE_STATUS,*PUSB_INTERFACE_STATUS;
    139 ;
    140 
    141 typedef union _USB_ENDPOINT_STATUS {
    142   USHORT AsUshort16;
    143   __C89_NAMELESS struct {
    144     USHORT Halt : 1;
    145     USHORT Reserved : 15;
    146   };
    147 } USB_ENDPOINT_STATUS,*PUSB_ENDPOINT_STATUS;
    148 
    149 typedef struct _USB_COMMON_DESCRIPTOR {
    150   UCHAR bLength;
    151   UCHAR bDescriptorType;
    152 } USB_COMMON_DESCRIPTOR,*PUSB_COMMON_DESCRIPTOR;
    153 
    154 typedef struct _USB_DEVICE_DESCRIPTOR {
    155   UCHAR bLength;
    156   UCHAR bDescriptorType;
    157   USHORT bcdUSB;
    158   UCHAR bDeviceClass;
    159   UCHAR bDeviceSubClass;
    160   UCHAR bDeviceProtocol;
    161   UCHAR bMaxPacketSize0;
    162   USHORT idVendor;
    163   USHORT idProduct;
    164   USHORT bcdDevice;
    165   UCHAR iManufacturer;
    166   UCHAR iProduct;
    167   UCHAR iSerialNumber;
    168   UCHAR bNumConfigurations;
    169 } USB_DEVICE_DESCRIPTOR,*PUSB_DEVICE_DESCRIPTOR;
    170 
    171 #define USB_DEVICE_CLASS_RESERVED 0x00
    172 #define USB_DEVICE_CLASS_AUDIO 0x01
    173 #define USB_DEVICE_CLASS_COMMUNICATIONS 0x02
    174 #define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03
    175 #define USB_DEVICE_CLASS_MONITOR 0x04
    176 #define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05
    177 #define USB_DEVICE_CLASS_POWER 0x06
    178 #define USB_DEVICE_CLASS_IMAGE 0x06
    179 #define USB_DEVICE_CLASS_PRINTER 0x07
    180 #define USB_DEVICE_CLASS_STORAGE 0x08
    181 #define USB_DEVICE_CLASS_HUB 0x09
    182 #define USB_DEVICE_CLASS_CDC_DATA 0x0a
    183 #define USB_DEVICE_CLASS_SMART_CARD 0x0b
    184 #define USB_DEVICE_CLASS_CONTENT_SECURITY 0x0d
    185 #define USB_DEVICE_CLASS_VIDEO 0x0e
    186 #define USB_DEVICE_CLASS_PERSONAL_HEALTHCARE 0x0f
    187 #define USB_DEVICE_CLASS_DIAGNOSTIC_DEVICE 0xdc
    188 #define USB_DEVICE_CLASS_WIRELESS_CONTROLLER 0xe0
    189 #define USB_DEVICE_CLASS_MISCELLANEOUS 0xef
    190 #define USB_DEVICE_CLASS_APPLICATION_SPECIFIC 0xfe
    191 #define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xff
    192 
    193 typedef struct _USB_DEVICE_QUALIFIER_DESCRIPTOR {
    194   UCHAR bLength;
    195   UCHAR bDescriptorType;
    196   USHORT bcdUSB;
    197   UCHAR bDeviceClass;
    198   UCHAR bDeviceSubClass;
    199   UCHAR bDeviceProtocol;
    200   UCHAR bMaxPacketSize0;
    201   UCHAR bNumConfigurations;
    202   UCHAR bReserved;
    203 } USB_DEVICE_QUALIFIER_DESCRIPTOR,*PUSB_DEVICE_QUALIFIER_DESCRIPTOR;
    204 
    205 typedef struct _USB_BOS_DESCRIPTOR {
    206   UCHAR bLength;
    207   UCHAR bDescriptorType;
    208   USHORT wTotalLength;
    209   UCHAR bNumDeviceCaps;
    210 } USB_BOS_DESCRIPTOR,*PUSB_BOS_DESCRIPTOR;
    211 
    212 #define USB_DEVICE_CAPABILITY_WIRELESS_USB 0x01
    213 #define USB_DEVICE_CAPABILITY_USB20_EXTENSION 0x02
    214 #define USB_DEVICE_CAPABILITY_SUPERSPEED_USB 0x03
    215 #define USB_DEVICE_CAPABILITY_CONTAINER_ID 0x04
    216 #define USB_DEVICE_CAPABILITY_BILLBOARD 0x0D
    217 
    218 typedef struct _USB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR {
    219   UCHAR bLength;
    220   UCHAR bDescriptorType;
    221   UCHAR bDevCapabilityType;
    222   union {
    223     ULONG AsUlong;
    224     __C89_NAMELESS struct {
    225       ULONG Reserved:1;
    226       ULONG LPMCapable:1;
    227       ULONG BESLAndAlternateHIRDSupported:1;
    228       ULONG BaselineBESLValid:1;
    229       ULONG DeepBESLValid:1;
    230       ULONG Reserved1:3;
    231       ULONG BaselineBESL:4;
    232       ULONG DeepBESL:4;
    233       ULONG Reserved2:16;
    234     };
    235   } bmAttributes;
    236 } USB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR,*PUSB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR;
    237 
    238 #define USB_DEVICE_CAPABILITY_USB20_EXTENSION_BMATTRIBUTES_RESERVED_MASK 0xffff00e1
    239 
    240 typedef struct _USB_DEVICE_CAPABILITY_SUPERSPEED_USB_DESCRIPTOR {
    241   UCHAR bLength;
    242   UCHAR bDescriptorType;
    243   UCHAR bDevCapabilityType;
    244   UCHAR bmAttributes;
    245   USHORT wSpeedsSupported;
    246   UCHAR bFunctionalitySupport;
    247   UCHAR bU1DevExitLat;
    248   USHORT wU2DevExitLat;
    249 } USB_DEVICE_CAPABILITY_SUPERSPEED_USB_DESCRIPTOR,*PUSB_DEVICE_CAPABILITY_SUPERSPEED_USB_DESCRIPTOR;
    250 
    251 #define USB_DEVICE_CAPABILITY_SUPERSPEED_BMATTRIBUTES_RESERVED_MASK 0xfd
    252 #define USB_DEVICE_CAPABILITY_SUPERSPEED_BMATTRIBUTES_LTM_CAPABLE 0x02
    253 
    254 #define USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_RESERVED_MASK 0xfff0
    255 
    256 #define USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_LOW 0x0001
    257 #define USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_FULL 0x0002
    258 #define USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_HIGH 0x0004
    259 #define USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_SUPER 0x0008
    260 
    261 #define USB_DEVICE_CAPABILITY_SUPERSPEED_U1_DEVICE_EXIT_MAX_VALUE 0x0a
    262 #define USB_DEVICE_CAPABILITY_SUPERSPEED_U2_DEVICE_EXIT_MAX_VALUE 0x07ff
    263 
    264 #define USB_DEVICE_CAPABILITY_MAX_U1_LATENCY 0x0a
    265 #define USB_DEVICE_CAPABILITY_MAX_U2_LATENCY 0x07ff
    266 
    267 typedef struct _USB_DEVICE_CAPABILITY_CONTAINER_ID_DESCRIPTOR {
    268   UCHAR bLength;
    269   UCHAR bDescriptorType;
    270   UCHAR bDevCapabilityType;
    271   UCHAR bReserved;
    272   UCHAR ContainerID[16];
    273 } USB_DEVICE_CAPABILITY_CONTAINER_ID_DESCRIPTOR,*PUSB_DEVICE_CAPABILITY_CONTAINER_ID_DESCRIPTOR;
    274 
    275 typedef struct _USB_DEVICE_CAPABILITY_DESCRIPTOR {
    276   UCHAR bLength;
    277   UCHAR bDescriptorType;
    278   UCHAR bDevCapabilityType;
    279 } USB_DEVICE_CAPABILITY_DESCRIPTOR,*PUSB_DEVICE_CAPABILITY_DESCRIPTOR;
    280 
    281 typedef struct _USB_CONFIGURATION_DESCRIPTOR {
    282   UCHAR bLength;
    283   UCHAR bDescriptorType;
    284   USHORT wTotalLength;
    285   UCHAR bNumInterfaces;
    286   UCHAR bConfigurationValue;
    287   UCHAR iConfiguration;
    288   UCHAR bmAttributes;
    289   UCHAR MaxPower;
    290 } USB_CONFIGURATION_DESCRIPTOR,*PUSB_CONFIGURATION_DESCRIPTOR;
    291 
    292 #define USB_CONFIG_POWERED_MASK 0xc0
    293 #define USB_CONFIG_BUS_POWERED 0x80
    294 #define USB_CONFIG_SELF_POWERED 0x40
    295 #define USB_CONFIG_REMOTE_WAKEUP 0x20
    296 #define USB_CONFIG_RESERVED 0x1f
    297 
    298 typedef struct _USB_INTERFACE_ASSOCIATION_DESCRIPTOR {
    299   UCHAR bLength;
    300   UCHAR bDescriptorType;
    301   UCHAR bFirstInterface;
    302   UCHAR bInterfaceCount;
    303   UCHAR bFunctionClass;
    304   UCHAR bFunctionSubClass;
    305   UCHAR bFunctionProtocol;
    306   UCHAR iFunction;
    307 } USB_INTERFACE_ASSOCIATION_DESCRIPTOR,*PUSB_INTERFACE_ASSOCIATION_DESCRIPTOR;
    308 
    309 typedef struct _USB_INTERFACE_DESCRIPTOR {
    310   UCHAR bLength;
    311   UCHAR bDescriptorType;
    312   UCHAR bInterfaceNumber;
    313   UCHAR bAlternateSetting;
    314   UCHAR bNumEndpoints;
    315   UCHAR bInterfaceClass;
    316   UCHAR bInterfaceSubClass;
    317   UCHAR bInterfaceProtocol;
    318   UCHAR iInterface;
    319 } USB_INTERFACE_DESCRIPTOR,*PUSB_INTERFACE_DESCRIPTOR;
    320 
    321 typedef struct _USB_ENDPOINT_DESCRIPTOR {
    322   UCHAR bLength;
    323   UCHAR bDescriptorType;
    324   UCHAR bEndpointAddress;
    325   UCHAR bmAttributes;
    326   USHORT wMaxPacketSize;
    327   UCHAR bInterval;
    328 } USB_ENDPOINT_DESCRIPTOR,*PUSB_ENDPOINT_DESCRIPTOR;
    329 
    330 #define USB_ENDPOINT_DIRECTION_MASK 0x80
    331 #define USB_ENDPOINT_DIRECTION_OUT(addr) (! ((addr) & USB_ENDPOINT_DIRECTION_MASK))
    332 #define USB_ENDPOINT_DIRECTION_IN(addr) ((addr) & USB_ENDPOINT_DIRECTION_MASK)
    333 
    334 #define USB_ENDPOINT_ADDRESS_MASK 0x0f
    335 
    336 #define USB_ENDPOINT_TYPE_MASK 0x03
    337 #define USB_ENDPOINT_TYPE_CONTROL 0x00
    338 #define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01
    339 #define USB_ENDPOINT_TYPE_BULK 0x02
    340 #define USB_ENDPOINT_TYPE_INTERRUPT 0x03
    341 
    342 #define USB_ENDPOINT_TYPE_BULK_RESERVED_MASK 0xfc
    343 #define USB_ENDPOINT_TYPE_CONTROL_RESERVED_MASK 0xfc
    344 #define USB_20_ENDPOINT_TYPE_INTERRUPT_RESERVED_MASK 0xfc
    345 #define USB_30_ENDPOINT_TYPE_INTERRUPT_RESERVED_MASK 0xcc
    346 #define USB_ENDPOINT_TYPE_ISOCHRONOUS_RESERVED_MASK 0xc0
    347 
    348 #define USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_MASK 0x30
    349 #define USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_PERIODIC 0x00
    350 #define USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_NOTIFICATION 0x10
    351 #define USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_RESERVED10 0x20
    352 #define USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_RESERVED11 0x30
    353 #define USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE(bmAttr) (bmAttr &USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_MASK)
    354 
    355 #define USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_MASK 0x0c
    356 #define USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_NO_SYNCHRONIZATION 0x00
    357 #define USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_ASYNCHRONOUS 0x04
    358 #define USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_ADAPTIVE 0x08
    359 #define USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_SYNCHRONOUS 0x0c
    360 #define USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION(bmAttr) (bmAttr &USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_MASK)
    361 
    362 #define USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_MASK 0x30
    363 #define USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_DATA_ENDOINT 0x00
    364 #define USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_FEEDBACK_ENDPOINT 0x10
    365 #define USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_IMPLICIT_FEEDBACK_DATA_ENDPOINT 0x20
    366 #define USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_RESERVED 0x30
    367 #define USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE(bmAttr) (bmAttr &USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_MASK)
    368 
    369 typedef union _USB_HIGH_SPEED_MAXPACKET {
    370   __C89_NAMELESS struct _MP {
    371     USHORT MaxPacket : 11;
    372     USHORT HSmux : 2;
    373     USHORT Reserved : 3;
    374   };
    375   USHORT us;
    376 } USB_HIGH_SPEED_MAXPACKET,*PUSB_HIGH_SPEED_MAXPACKET;
    377 
    378 #define USB_ENDPOINT_SUPERSPEED_BULK_MAX_PACKET_SIZE 1024
    379 #define USB_ENDPOINT_SUPERSPEED_CONTROL_MAX_PACKET_SIZE 512
    380 #define USB_ENDPOINT_SUPERSPEED_ISO_MAX_PACKET_SIZE 1024
    381 #define USB_ENDPOINT_SUPERSPEED_INTERRUPT_MAX_PACKET_SIZE 1024
    382 
    383 typedef struct _USB_STRING_DESCRIPTOR {
    384   UCHAR bLength;
    385   UCHAR bDescriptorType;
    386   WCHAR bString[1];
    387 } USB_STRING_DESCRIPTOR,*PUSB_STRING_DESCRIPTOR;
    388 
    389 #define MAXIMUM_USB_STRING_LENGTH 255
    390 
    391 typedef struct _USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR {
    392   UCHAR bLength;
    393   UCHAR bDescriptorType;
    394   UCHAR bMaxBurst;
    395   union {
    396     UCHAR AsUchar;
    397     struct {
    398       UCHAR MaxStreams:5;
    399       UCHAR Reserved1:3;
    400     } Bulk;
    401     struct {
    402       UCHAR Mult:2;
    403       UCHAR Reserved2:5;
    404       UCHAR SspCompanion:1;
    405     } Isochronous;
    406   } bmAttributes;
    407   USHORT wBytesPerInterval;
    408 } USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR,*PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR;
    409 
    410 #define USB_SUPERSPEED_ISOCHRONOUS_MAX_MULTIPLIER 2
    411 
    412 typedef struct _USB_HUB_DESCRIPTOR {
    413   UCHAR bDescriptorLength;
    414   UCHAR bDescriptorType;
    415   UCHAR bNumberOfPorts;
    416   USHORT wHubCharacteristics;
    417   UCHAR bPowerOnToPowerGood;
    418   UCHAR bHubControlCurrent;
    419   UCHAR bRemoveAndPowerMask[64];
    420 } USB_HUB_DESCRIPTOR,*PUSB_HUB_DESCRIPTOR;
    421 
    422 #define USB_20_HUB_DESCRIPTOR_TYPE 0x29
    423 
    424 typedef struct _USB_30_HUB_DESCRIPTOR {
    425   UCHAR bLength;
    426   UCHAR bDescriptorType;
    427   UCHAR bNumberOfPorts;
    428   USHORT wHubCharacteristics;
    429   UCHAR bPowerOnToPowerGood;
    430   UCHAR bHubControlCurrent;
    431   UCHAR bHubHdrDecLat;
    432   USHORT wHubDelay;
    433   USHORT DeviceRemovable;
    434 } USB_30_HUB_DESCRIPTOR,*PUSB_30_HUB_DESCRIPTOR;
    435 
    436 #define USB_30_HUB_DESCRIPTOR_TYPE 0x2a
    437 
    438 #define USB_REQUEST_GET_STATE 0x02
    439 
    440 #define USB_REQUEST_CLEAR_TT_BUFFER 0x08
    441 #define USB_REQUEST_RESET_TT 0x09
    442 #define USB_REQUEST_GET_TT_STATE 0x0a
    443 #define USB_REQUEST_STOP_TT 0x0b
    444 
    445 #define USB_REQUEST_SET_HUB_DEPTH 0x0c
    446 #define USB_REQUEST_GET_PORT_ERR_COUNT 0x0d
    447 
    448 typedef union _USB_HUB_STATUS {
    449   USHORT AsUshort16;
    450   __C89_NAMELESS struct {
    451     USHORT LocalPowerLost:1;
    452     USHORT OverCurrent:1;
    453     USHORT Reserved:14;
    454   };
    455 } USB_HUB_STATUS,*PUSB_HUB_STATUS;
    456 
    457 typedef union _USB_HUB_CHANGE {
    458   USHORT AsUshort16;
    459   __C89_NAMELESS struct {
    460     USHORT LocalPowerChange:1;
    461     USHORT OverCurrentChange:1;
    462     USHORT Reserved:14;
    463   };
    464 } USB_HUB_CHANGE,*PUSB_HUB_CHANGE;
    465 
    466 typedef union _USB_HUB_STATUS_AND_CHANGE {
    467   ULONG AsUlong32;
    468   __C89_NAMELESS struct {
    469     USB_HUB_STATUS HubStatus;
    470     USB_HUB_CHANGE HubChange;
    471   };
    472 } USB_HUB_STATUS_AND_CHANGE,*PUSB_HUB_STATUS_AND_CHANGE;
    473 
    474 typedef union _USB_20_PORT_STATUS {
    475   USHORT AsUshort16;
    476   __C89_NAMELESS struct {
    477     USHORT CurrentConnectStatus:1;
    478     USHORT PortEnabledDisabled:1;
    479     USHORT Suspend:1;
    480     USHORT OverCurrent:1;
    481     USHORT Reset:1;
    482     USHORT Reserved0:3;
    483     USHORT PortPower:1;
    484     USHORT LowSpeedDeviceAttached:1;
    485     USHORT HighSpeedDeviceAttached:1;
    486     USHORT PortTestMode:1;
    487     USHORT PortIndicatorControl:1;
    488     USHORT Reserved1:3;
    489   };
    490 } USB_20_PORT_STATUS,*PUSB_20_PORT_STATUS;
    491 
    492 #define USB_PORT_STATUS_CONNECT 0x0001
    493 #define USB_PORT_STATUS_ENABLE 0x0002
    494 #define USB_PORT_STATUS_SUSPEND 0x0004
    495 #define USB_PORT_STATUS_OVER_CURRENT 0x0008
    496 #define USB_PORT_STATUS_RESET 0x0010
    497 #define USB_PORT_STATUS_POWER 0x0100
    498 #define USB_PORT_STATUS_LOW_SPEED 0x0200
    499 #define USB_PORT_STATUS_HIGH_SPEED 0x0400
    500 
    501 typedef union _USB_20_PORT_CHANGE {
    502   USHORT AsUshort16;
    503   __C89_NAMELESS struct {
    504     USHORT ConnectStatusChange:1;
    505     USHORT PortEnableDisableChange:1;
    506     USHORT SuspendChange:1;
    507     USHORT OverCurrentIndicatorChange:1;
    508     USHORT ResetChange:1;
    509     USHORT Reserved2:11;
    510   };
    511 } USB_20_PORT_CHANGE,*PUSB_20_PORT_CHANGE;
    512 
    513 typedef union _USB_30_PORT_STATUS {
    514   USHORT AsUshort16;
    515   __C89_NAMELESS struct {
    516     USHORT CurrentConnectStatus:1;
    517     USHORT PortEnabledDisabled:1;
    518     USHORT Reserved0:1;
    519     USHORT OverCurrent:1;
    520     USHORT Reset:1;
    521     USHORT PortLinkState:4;
    522     USHORT PortPower:1;
    523     USHORT NegotiatedDeviceSpeed:3;
    524     USHORT Reserved1:3;
    525   };
    526 } USB_30_PORT_STATUS,*PUSB_30_PORT_STATUS;
    527 
    528 #define PORT_LINK_STATE_U0 0
    529 #define PORT_LINK_STATE_U1 1
    530 #define PORT_LINK_STATE_U2 2
    531 #define PORT_LINK_STATE_U3 3
    532 #define PORT_LINK_STATE_DISABLED 4
    533 #define PORT_LINK_STATE_RX_DETECT 5
    534 #define PORT_LINK_STATE_INACTIVE 6
    535 #define PORT_LINK_STATE_POLLING 7
    536 #define PORT_LINK_STATE_RECOVERY 8
    537 #define PORT_LINK_STATE_HOT_RESET 9
    538 #define PORT_LINK_STATE_COMPLIANCE_MODE 10
    539 #define PORT_LINK_STATE_LOOPBACK 11
    540 #define PORT_LINK_STATE_TEST_MODE 11
    541 
    542 typedef union _USB_30_PORT_CHANGE {
    543   USHORT AsUshort16;
    544   __C89_NAMELESS struct {
    545     USHORT ConnectStatusChange:1;
    546     USHORT Reserved2:2;
    547     USHORT OverCurrentIndicatorChange:1;
    548     USHORT ResetChange:1;
    549     USHORT BHResetChange:1;
    550     USHORT PortLinkStateChange:1;
    551     USHORT PortConfigErrorChange:1;
    552     USHORT Reserved3:8;
    553   };
    554 } USB_30_PORT_CHANGE,*PUSB_30_PORT_CHANGE;
    555 
    556 typedef union _USB_PORT_STATUS {
    557   USHORT AsUshort16;
    558   USB_20_PORT_STATUS Usb20PortStatus;
    559   USB_30_PORT_STATUS Usb30PortStatus;
    560 } USB_PORT_STATUS,*PUSB_PORT_STATUS;
    561 
    562 typedef union _USB_PORT_CHANGE {
    563   USHORT AsUshort16;
    564   USB_20_PORT_CHANGE Usb20PortChange;
    565   USB_30_PORT_CHANGE Usb30PortChange;
    566 } USB_PORT_CHANGE,*PUSB_PORT_CHANGE;
    567 
    568 typedef union _USB_PORT_STATUS_AND_CHANGE {
    569   ULONG AsUlong32;
    570   __C89_NAMELESS struct {
    571     USB_PORT_STATUS PortStatus;
    572     USB_PORT_CHANGE PortChange;
    573   };
    574 } USB_PORT_STATUS_AND_CHANGE,*PUSB_PORT_STATUS_AND_CHANGE;
    575 
    576 typedef union _USB_HUB_30_PORT_REMOTE_WAKE_MASK {
    577   UCHAR AsUchar8;
    578   __C89_NAMELESS struct {
    579     UCHAR ConnectRemoteWakeEnable:1;
    580     UCHAR DisconnectRemoteWakeEnable:1;
    581     UCHAR OverCurrentRemoteWakeEnable:1;
    582     UCHAR Reserved0:5;
    583   };
    584 } USB_HUB_30_PORT_REMOTE_WAKE_MASK,*PUSB_HUB_30_PORT_REMOTE_WAKE_MASK;
    585 
    586 typedef union _USB_FUNCTION_SUSPEND_OPTIONS {
    587   UCHAR AsUchar;
    588   __C89_NAMELESS struct {
    589     UCHAR PowerState:1;
    590     UCHAR RemoteWakeEnabled:1;
    591     UCHAR Reserved:6;
    592   };
    593 } USB_FUNCTION_SUSPEND_OPTIONS,*PUSB_FUNCTION_SUSPEND_OPTIONS;
    594 
    595 #define USB_FEATURE_INTERFACE_POWER_D0 0x0002
    596 #define USB_FEATURE_INTERFACE_POWER_D1 0x0003
    597 #define USB_FEATURE_INTERFACE_POWER_D2 0x0004
    598 #define USB_FEATURE_INTERFACE_POWER_D3 0x0005
    599 
    600 #define USB_SUPPORT_D0_COMMAND 0x01
    601 #define USB_SUPPORT_D1_COMMAND 0x02
    602 #define USB_SUPPORT_D2_COMMAND 0x04
    603 #define USB_SUPPORT_D3_COMMAND 0x08
    604 #define USB_SUPPORT_D1_WAKEUP 0x10
    605 #define USB_SUPPORT_D2_WAKEUP 0x20
    606 
    607 typedef struct _USB_CONFIGURATION_POWER_DESCRIPTOR {
    608   UCHAR bLength;
    609   UCHAR bDescriptorType;
    610   UCHAR SelfPowerConsumedD0[3];
    611   UCHAR bPowerSummaryId;
    612   UCHAR bBusPowerSavingD1;
    613   UCHAR bSelfPowerSavingD1;
    614   UCHAR bBusPowerSavingD2;
    615   UCHAR bSelfPowerSavingD2;
    616   UCHAR bBusPowerSavingD3;
    617   UCHAR bSelfPowerSavingD3;
    618   USHORT TransitionTimeFromD1;
    619   USHORT TransitionTimeFromD2;
    620   USHORT TransitionTimeFromD3;
    621 } USB_CONFIGURATION_POWER_DESCRIPTOR,*PUSB_CONFIGURATION_POWER_DESCRIPTOR;
    622 
    623 typedef struct _USB_INTERFACE_POWER_DESCRIPTOR {
    624   UCHAR bLength;
    625   UCHAR bDescriptorType;
    626   UCHAR bmCapabilitiesFlags;
    627   UCHAR bBusPowerSavingD1;
    628   UCHAR bSelfPowerSavingD1;
    629   UCHAR bBusPowerSavingD2;
    630   UCHAR bSelfPowerSavingD2;
    631   UCHAR bBusPowerSavingD3;
    632   UCHAR bSelfPowerSavingD3;
    633   USHORT TransitionTimeFromD1;
    634   USHORT TransitionTimeFromD2;
    635   USHORT TransitionTimeFromD3;
    636 } USB_INTERFACE_POWER_DESCRIPTOR,*PUSB_INTERFACE_POWER_DESCRIPTOR;
    637 
    638 typedef struct _USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR {
    639   UCHAR bLength;
    640   UCHAR bDescriptorType;
    641   UCHAR bDevCapabilityType;
    642   UCHAR iAddtionalInfoURL;
    643   UCHAR bNumberOfAlternateModes;
    644   UCHAR bPreferredAlternateMode;
    645   union {
    646     USHORT AsUshort;
    647     struct {
    648       USHORT VConnPowerNeededForFullFunctionality:3;
    649       USHORT Reserved:12;
    650       USHORT NoVconnPowerRequired:1;
    651     };
    652   } VconnPower;
    653   UCHAR bmConfigured[32];
    654   ULONG bReserved;
    655   struct {
    656     USHORT wSVID;
    657     UCHAR bAlternateMode;
    658     UCHAR iAlternateModeSetting;
    659   } AlternateMode[1];
    660 } USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR,*PUSB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR;
    661 
    662 typedef struct _USB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR {
    663   UCHAR bLength;
    664   UCHAR bDescriptorType;
    665   USHORT wReserved;
    666   ULONG dwBytesPerInterval;
    667 } USB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR,*PUSB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR;
    668 
    669 #include <poppack.h>
    670 
    671 #endif
    672 #endif
    673