Home | History | Annotate | Download | only in ddk
      1 #pragma once
      2 
      3 #define _HUBBUSIF_
      4 
      5 #include "usbdi.h"
      6 
      7 #if (NTDDI_VERSION >= NTDDI_WINXP)
      8 
      9 #if !defined(_USBBUSIF_)
     10 typedef PVOID PUSB_DEVICE_HANDLE;
     11 #endif
     12 
     13 typedef struct _ROOTHUB_PDO_EXTENSION {
     14   ULONG Signature;
     15 } ROOTHUB_PDO_EXTENSION, *PROOTHUB_PDO_EXTENSION;
     16 
     17 #define USBD_DEVHACK_SLOW_ENUMERATION	0x00000001
     18 #define USBD_DEVHACK_DISABLE_SN		0x00000002
     19 #define USBD_DEVHACK_SET_DIAG_ID	0x00000004
     20 
     21 #ifndef USB_BUSIFFN
     22 #define USB_BUSIFFN __stdcall
     23 #endif
     24 
     25 #define CD_ERR_V1			0x00000001
     26 
     27 #define ID_ERR_V1			0x00000001
     28 
     29 #define USBD_KEEP_DEVICE_DATA		0x00000001
     30 #define USBD_MARK_DEVICE_BUSY		0x00000002
     31 
     32 #define USB_IDLE_NOT_READY		0
     33 #define USB_IDLE_READY			1
     34 
     35 typedef
     36 NTSTATUS
     37 USB_BUSIFFN
     38 USB_BUSIFFN_CREATE_USB_DEVICE (
     39   IN PVOID BusContext,
     40   OUT PUSB_DEVICE_HANDLE *NewDeviceHandle,
     41   IN PUSB_DEVICE_HANDLE HubDeviceHandle,
     42   IN USHORT PortStatus,
     43   IN USHORT PortNumber);
     44 
     45 typedef USB_BUSIFFN_CREATE_USB_DEVICE *PUSB_BUSIFFN_CREATE_USB_DEVICE;
     46 
     47 typedef enum _USBPORT_CREATEDEV_ERROR {
     48   CreateDevErrNotSet = 0,
     49   CreateDevBadHubDevHandle,
     50   CreateDevFailedAllocDevHandle,
     51   CreateDevFailedOpenEndpoint,
     52   CreateDevFailedAllocDsBuff,
     53   CreateDevFailedGetDs,
     54   CreateDevTtNotFound,
     55   CreateDevBadDevHandlePtr
     56 } USBPORT_CREATEDEV_ERROR;
     57 
     58 typedef struct _USB_CD_ERROR_INFORMATION {
     59   ULONG Version;
     60   USBPORT_CREATEDEV_ERROR PathError;
     61   ULONG UlongArg1;
     62   ULONG UlongArg2;
     63   NTSTATUS NtStatus;
     64   UCHAR XtraInfo[64];
     65 } USB_CD_ERROR_INFORMATION, *PUSB_CD_ERROR_INFORMATION;
     66 
     67 typedef
     68 NTSTATUS
     69 USB_BUSIFFN
     70 USB_BUSIFFN_CREATE_USB_DEVICE_EX (
     71   IN PVOID  BusContext,
     72   OUT PUSB_DEVICE_HANDLE  *NewDeviceHandle,
     73   IN PUSB_DEVICE_HANDLE  HsHubDeviceHandle,
     74   IN USHORT  PortStatus,
     75   IN USHORT  PortNumber,
     76   OUT PUSB_CD_ERROR_INFORMATION  CdErrorInfo,
     77   IN USHORT TtPortNumber);
     78 
     79 typedef USB_BUSIFFN_CREATE_USB_DEVICE_EX *PUSB_BUSIFFN_CREATE_USB_DEVICE_EX;
     80 
     81 typedef struct _USB_PORT_PATH {
     82   ULONG  PortPathDepth;
     83   ULONG  PortPath[6];
     84 } USB_PORT_PATH, *PUSB_PORT_PATH;
     85 
     86 typedef
     87 NTSTATUS
     88 USB_BUSIFFN
     89 USB_BUSIFFN_CREATE_USB_DEVICE_V7 (
     90   IN PVOID  BusContext,
     91   OUT PUSB_DEVICE_HANDLE  *NewDeviceHandle,
     92   IN PUSB_DEVICE_HANDLE  HsHubDeviceHandle,
     93   IN USHORT  PortStatus,
     94   IN PUSB_PORT_PATH  PortPath,
     95   OUT PUSB_CD_ERROR_INFORMATION  CdErrorInfo,
     96   IN USHORT  TtPortNumber,
     97   IN PDEVICE_OBJECT  PdoDeviceObject,
     98   IN PUNICODE_STRING  PhysicalDeviceObjectName);
     99 
    100 typedef USB_BUSIFFN_CREATE_USB_DEVICE_V7 *PUSB_BUSIFFN_CREATE_USB_DEVICE_V7;
    101 
    102 typedef enum _USBPORT_INITDEV_ERROR {
    103   InitDevErrNotSet = 0,
    104   InitDevFailedSetAddress,
    105   InitDevFailedPokeEndpoint,
    106   InitDevBadDeviceDescriptor
    107 } USBPORT_INITDEV_ERROR;
    108 
    109 typedef struct _USB_ID_ERROR_INFORMATION {
    110   ULONG Version;
    111   USBPORT_INITDEV_ERROR PathError;
    112   ULONG Arg1;
    113   ULONG UsbAddress;
    114   NTSTATUS NtStatus;
    115   USBD_STATUS UsbdStatus;
    116   UCHAR XtraInfo[64];
    117 } USB_ID_ERROR_INFORMATION, *PUSB_ID_ERROR_INFORMATION;
    118 
    119 typedef
    120 NTSTATUS
    121 USB_BUSIFFN
    122 USB_BUSIFFN_INITIALIZE_USB_DEVICE (
    123   IN PVOID  BusContext,
    124   IN OUT PUSB_DEVICE_HANDLE  DeviceHandle);
    125 
    126 typedef USB_BUSIFFN_INITIALIZE_USB_DEVICE *PUSB_BUSIFFN_INITIALIZE_USB_DEVICE;
    127 
    128 typedef
    129 NTSTATUS
    130 USB_BUSIFFN
    131 USB_BUSIFFN_INITIALIZE_USB_DEVICE_EX (
    132   IN PVOID  BusContext,
    133   IN OUT PUSB_DEVICE_HANDLE  DeviceHandle,
    134   OUT PUSB_ID_ERROR_INFORMATION  IdErrInfo);
    135 
    136 typedef USB_BUSIFFN_INITIALIZE_USB_DEVICE_EX *PUSB_BUSIFFN_INITIALIZE_USB_DEVICE_EX;
    137 
    138 typedef
    139 NTSTATUS
    140 USB_BUSIFFN
    141 USB_BUSIFFN_REMOVE_USB_DEVICE (
    142   IN PVOID  BusContext,
    143   IN OUT PUSB_DEVICE_HANDLE  DeviceHandle,
    144   IN ULONG  Flags);
    145 
    146 typedef USB_BUSIFFN_REMOVE_USB_DEVICE *PUSB_BUSIFFN_REMOVE_USB_DEVICE;
    147 
    148 typedef
    149 NTSTATUS
    150 USB_BUSIFFN
    151 USB_BUSIFFN_GET_USB_DESCRIPTORS (
    152   IN PVOID BusContext,
    153   IN OUT PUSB_DEVICE_HANDLE DeviceHandle,
    154   OUT PUCHAR DeviceDescriptorBuffer,
    155   IN OUT PULONG DeviceDescriptorBufferLength,
    156   OUT PUCHAR ConfigDescriptorBuffer,
    157   IN OUT PULONG ConfigDescriptorBufferLength);
    158 
    159 typedef USB_BUSIFFN_GET_USB_DESCRIPTORS *PUSB_BUSIFFN_GET_USB_DESCRIPTORS;
    160 
    161 typedef
    162 NTSTATUS
    163 USB_BUSIFFN
    164 USB_BUSIFFN_RESTORE_DEVICE (
    165   IN PVOID BusContext,
    166   IN OUT PUSB_DEVICE_HANDLE OldDeviceHandle,
    167   IN OUT PUSB_DEVICE_HANDLE NewDeviceHandle);
    168 
    169 typedef USB_BUSIFFN_RESTORE_DEVICE *PUSB_BUSIFFN_RESTORE_DEVICE;
    170 
    171 typedef
    172 NTSTATUS
    173 USB_BUSIFFN
    174 USB_BUSIFFN_GET_POTRTHACK_FLAGS (
    175   IN PVOID BusContext,
    176   IN OUT PULONG Flags);
    177 
    178 typedef USB_BUSIFFN_GET_POTRTHACK_FLAGS *PUSB_BUSIFFN_GET_POTRTHACK_FLAGS;
    179 
    180 typedef
    181 NTSTATUS
    182 USB_BUSIFFN
    183 USB_BUSIFFN_GET_DEVICE_INFORMATION (
    184   IN PVOID BusContext,
    185   IN PUSB_DEVICE_HANDLE DeviceHandle,
    186   OUT PVOID DeviceInformationBuffer,
    187   IN ULONG DeviceInformationBufferLength,
    188   IN OUT PULONG LengthOfDataCopied);
    189 
    190 typedef USB_BUSIFFN_GET_DEVICE_INFORMATION *PUSB_BUSIFFN_GET_DEVICE_INFORMATION;
    191 
    192 typedef
    193 NTSTATUS
    194 USB_BUSIFFN
    195 USB_BUSIFFN_GET_CONTROLLER_INFORMATION (
    196   IN PVOID BusContext,
    197   IN OUT PVOID ControllerInformationBuffer,
    198   IN ULONG ControllerInformationBufferLength,
    199   IN OUT PULONG LengthOfDataCopied);
    200 
    201 typedef USB_BUSIFFN_GET_CONTROLLER_INFORMATION *PUSB_BUSIFFN_GET_CONTROLLER_INFORMATION;
    202 
    203 typedef
    204 NTSTATUS
    205 USB_BUSIFFN
    206 USB_BUSIFFN_CONTROLLER_SELECTIVE_SUSPEND (
    207   IN PVOID BusContext,
    208   IN BOOLEAN Enable);
    209 
    210 typedef USB_BUSIFFN_CONTROLLER_SELECTIVE_SUSPEND *PUSB_BUSIFFN_CONTROLLER_SELECTIVE_SUSPEND;
    211 
    212 typedef
    213 NTSTATUS
    214 USB_BUSIFFN
    215 USB_BUSIFFN_GET_EXTENDED_HUB_INFO (
    216   IN PVOID BusContext,
    217   IN PDEVICE_OBJECT HubPhysicalDeviceObject,
    218   IN PVOID HubInformationBuffer,
    219   IN ULONG HubInformationBufferLength,
    220   OUT PULONG LengthOfDataCopied);
    221 
    222 typedef USB_BUSIFFN_GET_EXTENDED_HUB_INFO *PUSB_BUSIFFN_GET_EXTENDED_HUB_INFO;
    223 
    224 typedef
    225 NTSTATUS
    226 USB_BUSIFFN
    227 USB_BUSIFFN_GET_ROOTHUB_SYM_NAME (
    228   IN PVOID BusContext,
    229   IN PVOID HubSymNameBuffer,
    230   IN ULONG HubSymNameBufferLength,
    231   OUT PULONG HubSymNameActualLength);
    232 
    233 typedef USB_BUSIFFN_GET_ROOTHUB_SYM_NAME *PUSB_BUSIFFN_GET_ROOTHUB_SYM_NAME;
    234 
    235 typedef
    236 PVOID
    237 USB_BUSIFFN
    238 USB_BUSIFFN_GET_DEVICE_BUSCONTEXT (
    239   IN PVOID HubBusContext,
    240   IN PVOID DeviceHandle);
    241 
    242 typedef USB_BUSIFFN_GET_DEVICE_BUSCONTEXT *PUSB_BUSIFFN_GET_DEVICE_BUSCONTEXT;
    243 
    244 typedef
    245 NTSTATUS
    246 USB_BUSIFFN
    247 USB_BUSIFFN_INITIALIZE_20HUB (
    248   IN PVOID BusContext,
    249   IN PUSB_DEVICE_HANDLE HubDeviceHandle,
    250   IN ULONG TtCount);
    251 
    252 typedef USB_BUSIFFN_INITIALIZE_20HUB *PUSB_BUSIFFN_INITIALIZE_20HUB;
    253 
    254 typedef
    255 BOOLEAN
    256 USB_BUSIFFN
    257 USB_BUSIFFN_IS_ROOT (
    258   IN PVOID BusContext,
    259   IN PVOID DeviceObject);
    260 
    261 typedef USB_BUSIFFN_IS_ROOT *PUSB_BUSIFFN_IS_ROOT;
    262 
    263 typedef
    264 VOID
    265 USB_BUSIFFN
    266 USB_BUSIFFN_ACQUIRE_SEMAPHORE (
    267   IN PVOID BusContext);
    268 
    269 typedef USB_BUSIFFN_ACQUIRE_SEMAPHORE *PUSB_BUSIFFN_ACQUIRE_SEMAPHORE;
    270 
    271 typedef
    272 VOID
    273 USB_BUSIFFN
    274 USB_BUSIFFN_RELEASE_SEMAPHORE (
    275   IN PVOID BusContext);
    276 
    277 typedef USB_BUSIFFN_RELEASE_SEMAPHORE *PUSB_BUSIFFN_RELEASE_SEMAPHORE;
    278 
    279 typedef
    280 VOID
    281 __stdcall
    282 RH_INIT_CALLBACK (
    283   IN PVOID CallBackContext);
    284 
    285 typedef RH_INIT_CALLBACK *PRH_INIT_CALLBACK;
    286 
    287 typedef
    288 NTSTATUS
    289 USB_BUSIFFN
    290 USB_BUSIFFN_ROOTHUB_INIT_NOTIFY (
    291   IN PVOID BusContext,
    292   IN PVOID CallbackContext,
    293   IN PRH_INIT_CALLBACK CallbackRoutine);
    294 
    295 typedef USB_BUSIFFN_ROOTHUB_INIT_NOTIFY *PUSB_BUSIFFN_ROOTHUB_INIT_NOTIFY;
    296 
    297 typedef
    298 VOID
    299 USB_BUSIFFN
    300 USB_BUSIFFN_FLUSH_TRANSFERS (
    301   IN PVOID BusContext,
    302   IN PVOID DeviceHandle);
    303 
    304 typedef USB_BUSIFFN_FLUSH_TRANSFERS *PUSB_BUSIFFN_FLUSH_TRANSFERS;
    305 
    306 typedef
    307 ULONG
    308 USB_BUSIFFN
    309 USB_BUSIFFN_CALC_PIPE_BANDWIDTH (
    310   IN PVOID BusContext,
    311   IN PUSBD_PIPE_INFORMATION PipeInfo,
    312   IN USB_DEVICE_SPEED DeviceSpeed);
    313 
    314 typedef USB_BUSIFFN_CALC_PIPE_BANDWIDTH *PUSB_BUSIFFN_CALC_PIPE_BANDWIDTH;
    315 
    316 typedef
    317 VOID
    318 USB_BUSIFFN
    319 USB_BUSIFFN_SET_BUS_WAKE_MODE (
    320   IN PVOID BusContext,
    321   IN ULONG Mode);
    322 
    323 typedef USB_BUSIFFN_SET_BUS_WAKE_MODE *PUSB_BUSIFFN_SET_BUS_WAKE_MODE;
    324 
    325 typedef
    326 VOID
    327 USB_BUSIFFN
    328 USB_BUSIFFN_SET_DEVICE_FLAG (
    329   IN PVOID BusContext,
    330   IN GUID *DeviceFlagGuid,
    331   IN PVOID ValueData,
    332   IN ULONG ValueLength);
    333 
    334 typedef USB_BUSIFFN_SET_DEVICE_FLAG *PUSB_BUSIFFN_SET_DEVICE_FLAG;
    335 
    336 typedef
    337 VOID
    338 USB_BUSIFFN
    339 USB_BUSIFFN_SET_DEVHANDLE_DATA (
    340   IN PVOID BusContext,
    341   IN PVOID DeviceHandle,
    342   IN PDEVICE_OBJECT UsbDevicePdo);
    343 
    344 typedef USB_BUSIFFN_SET_DEVHANDLE_DATA *PUSB_BUSIFFN_SET_DEVHANDLE_DATA;
    345 
    346 typedef
    347 NTSTATUS
    348 USB_BUSIFFN
    349 USB_BUSIFFN_TEST_POINT (
    350   IN PVOID BusContext,
    351   IN PVOID DeviceHandle,
    352   IN ULONG Opcode,
    353   IN PVOID TestData);
    354 
    355 typedef USB_BUSIFFN_TEST_POINT *PUSB_BUSIFFN_TEST_POINT;
    356 
    357 typedef
    358 NTSTATUS
    359 USB_BUSIFFN
    360 USB_BUSIFFN_GET_DEVICE_PERFORMANCE_INFO (
    361   IN PVOID BusContext,
    362   IN PUSB_DEVICE_HANDLE DeviceHandle,
    363   OUT PVOID DeviceInformationBuffer,
    364   IN ULONG DeviceInformationBufferLength,
    365   IN OUT PULONG LengthOfDataCopied);
    366 
    367 typedef USB_BUSIFFN_GET_DEVICE_PERFORMANCE_INFO *PUSB_BUSIFFN_GET_DEVICE_PERFORMANCE_INFO;
    368 
    369 typedef
    370 NTSTATUS
    371 USB_BUSIFFN
    372 USB_BUSIFFN_WAIT_ASYNC_POWERUP (
    373   IN PVOID BusContext);
    374 
    375 typedef USB_BUSIFFN_WAIT_ASYNC_POWERUP *PUSB_BUSIFFN_WAIT_ASYNC_POWERUP;
    376 
    377 typedef
    378 NTSTATUS
    379 USB_BUSIFFN
    380 USB_BUSIFFN_GET_DEVICE_ADDRESS (
    381   IN PVOID BusContext,
    382   IN PUSB_DEVICE_HANDLE DeviceHandle,
    383   OUT PUSHORT DeviceAddress);
    384 
    385 typedef USB_BUSIFFN_GET_DEVICE_ADDRESS *PUSB_BUSIFFN_GET_DEVICE_ADDRESS;
    386 
    387 typedef
    388 VOID
    389 USB_BUSIFFN
    390 USB_BUSIFFN_DEREF_DEVICE_HANDLE (
    391   IN PVOID BusContext,
    392   IN PUSB_DEVICE_HANDLE DeviceHandle,
    393   IN PVOID Object,
    394   IN ULONG Tag);
    395 
    396 typedef USB_BUSIFFN_DEREF_DEVICE_HANDLE *PUSB_BUSIFFN_DEREF_DEVICE_HANDLE;
    397 
    398 typedef
    399 NTSTATUS
    400 USB_BUSIFFN
    401 USB_BUSIFFN_REF_DEVICE_HANDLE (
    402   IN PVOID BusContext,
    403   IN PUSB_DEVICE_HANDLE DeviceHandle,
    404   IN PVOID Object,
    405   IN ULONG Tag);
    406 
    407 typedef USB_BUSIFFN_REF_DEVICE_HANDLE *PUSB_BUSIFFN_REF_DEVICE_HANDLE;
    408 
    409 typedef
    410 ULONG
    411 USB_BUSIFFN
    412 USB_BUSIFFN_SET_DEVICE_HANDLE_IDLE_READY_STATE (
    413   IN PVOID BusContext,
    414   IN PUSB_DEVICE_HANDLE DeviceHandle,
    415   IN ULONG NewIdleReadyState);
    416 
    417 typedef USB_BUSIFFN_SET_DEVICE_HANDLE_IDLE_READY_STATE *PUSB_BUSIFFN_SET_DEVICE_HANDLE_IDLE_READY_STATE;
    418 
    419 typedef
    420 NTSTATUS
    421 USB_BUSIFFN
    422 USB_BUSIFFN_GET_CONTAINER_ID_FOR_PORT (
    423   IN PVOID BusContext,
    424   IN USHORT PortNumber,
    425   OUT LPGUID ContainerId);
    426 
    427 typedef USB_BUSIFFN_GET_CONTAINER_ID_FOR_PORT *PUSB_BUSIFFN_GET_CONTAINER_ID_FOR_PORT;
    428 
    429 typedef
    430 VOID
    431 USB_BUSIFFN
    432 USB_BUSIFFN_SET_CONTAINER_ID_FOR_PORT (
    433   IN PVOID BusContext,
    434   IN USHORT PortNumber,
    435   IN LPGUID ContainerId);
    436 
    437 typedef USB_BUSIFFN_SET_CONTAINER_ID_FOR_PORT *PUSB_BUSIFFN_SET_CONTAINER_ID_FOR_PORT;
    438 
    439 typedef
    440 NTSTATUS
    441 USB_BUSIFFN
    442 USB_BUSIFFN_ABORT_ALL_DEVICE_PIPES (
    443   IN PVOID BusContext,
    444   IN PUSB_DEVICE_HANDLE DeviceHandle);
    445 
    446 typedef USB_BUSIFFN_ABORT_ALL_DEVICE_PIPES *PUSB_BUSIFFN_ABORT_ALL_DEVICE_PIPES;
    447 
    448 #define ERRATA_FLAG_RESET_TT_ON_CANCEL			1
    449 #define ERRATA_FLAG_NO_CLEAR_TT_BUFFER_ON_CANCEL	2
    450 
    451 #define USB_BUSIF_HUB_VERSION_0		0x0000
    452 #define USB_BUSIF_HUB_VERSION_1		0x0001
    453 #define USB_BUSIF_HUB_VERSION_2		0x0002
    454 #define USB_BUSIF_HUB_VERSION_3		0x0003
    455 #define USB_BUSIF_HUB_VERSION_4		0x0004
    456 #define USB_BUSIF_HUB_VERSION_5		0x0005
    457 #define USB_BUSIF_HUB_VERSION_6		0x0006
    458 #define USB_BUSIF_HUB_VERSION_7		0x0007
    459 
    460 #define USB_BUSIF_HUB_MIDUMP_VERSION_0	0x0000
    461 
    462 #define USB_BUSIF_HUB_SS_VERSION_0	0x0000
    463 
    464 typedef
    465 VOID
    466 USB_BUSIFFN
    467 USB_BUSIFFN_SET_DEVICE_ERRATA_FLAG (
    468   IN PVOID BusContext,
    469   IN PUSB_DEVICE_HANDLE DeviceHandle,
    470   IN ULONG DeviceErrataFlag);
    471 
    472 typedef USB_BUSIFFN_SET_DEVICE_ERRATA_FLAG *PUSB_BUSIFFN_SET_DEVICE_ERRATA_FLAG;
    473 
    474 DEFINE_GUID(USB_BUS_INTERFACE_HUB_GUID,
    475 0xb2bb8c0a, 0x5ab4, 0x11d3, 0xa8, 0xcd, 0x0, 0xc0, 0x4f, 0x68, 0x74, 0x7a);
    476 
    477 typedef struct _USB_BUS_INTERFACE_HUB_V0 {
    478   USHORT Size;
    479   USHORT Version;
    480   PVOID BusContext;
    481   PINTERFACE_REFERENCE InterfaceReference;
    482   PINTERFACE_DEREFERENCE InterfaceDereference;
    483 } USB_BUS_INTERFACE_HUB_V0, *PUSB_BUS_INTERFACE_HUB_V0;
    484 
    485 typedef struct _USB_BUS_INTERFACE_HUB_V1 {
    486   USHORT Size;
    487   USHORT Version;
    488   PVOID BusContext;
    489   PINTERFACE_REFERENCE InterfaceReference;
    490   PINTERFACE_DEREFERENCE InterfaceDereference;
    491   PUSB_BUSIFFN_CREATE_USB_DEVICE CreateUsbDevice;
    492   PUSB_BUSIFFN_INITIALIZE_USB_DEVICE InitializeUsbDevice;
    493   PUSB_BUSIFFN_GET_USB_DESCRIPTORS GetUsbDescriptors;
    494   PUSB_BUSIFFN_REMOVE_USB_DEVICE RemoveUsbDevice;
    495   PUSB_BUSIFFN_RESTORE_DEVICE RestoreUsbDevice;
    496   PUSB_BUSIFFN_GET_POTRTHACK_FLAGS GetPortHackFlags;
    497   PUSB_BUSIFFN_GET_DEVICE_INFORMATION QueryDeviceInformation;
    498 } USB_BUS_INTERFACE_HUB_V1, *PUSB_BUS_INTERFACE_HUB_V1;
    499 
    500 typedef struct _USB_BUS_INTERFACE_HUB_V2 {
    501   USHORT Size;
    502   USHORT Version;
    503   PVOID BusContext;
    504   PINTERFACE_REFERENCE InterfaceReference;
    505   PINTERFACE_DEREFERENCE InterfaceDereference;
    506   PUSB_BUSIFFN_CREATE_USB_DEVICE CreateUsbDevice;
    507   PUSB_BUSIFFN_INITIALIZE_USB_DEVICE InitializeUsbDevice;
    508   PUSB_BUSIFFN_GET_USB_DESCRIPTORS GetUsbDescriptors;
    509   PUSB_BUSIFFN_REMOVE_USB_DEVICE RemoveUsbDevice;
    510   PUSB_BUSIFFN_RESTORE_DEVICE RestoreUsbDevice;
    511   PUSB_BUSIFFN_GET_POTRTHACK_FLAGS GetPortHackFlags;
    512   PUSB_BUSIFFN_GET_DEVICE_INFORMATION QueryDeviceInformation;
    513   PUSB_BUSIFFN_GET_CONTROLLER_INFORMATION GetControllerInformation;
    514   PUSB_BUSIFFN_CONTROLLER_SELECTIVE_SUSPEND ControllerSelectiveSuspend;
    515   PUSB_BUSIFFN_GET_EXTENDED_HUB_INFO GetExtendedHubInformation;
    516   PUSB_BUSIFFN_GET_ROOTHUB_SYM_NAME GetRootHubSymbolicName;
    517   PUSB_BUSIFFN_GET_DEVICE_BUSCONTEXT GetDeviceBusContext;
    518   PUSB_BUSIFFN_INITIALIZE_20HUB Initialize20Hub;
    519 } USB_BUS_INTERFACE_HUB_V2, *PUSB_BUS_INTERFACE_HUB_V2;
    520 
    521 typedef struct _USB_BUS_INTERFACE_HUB_V3 {
    522   USHORT Size;
    523   USHORT Version;
    524   PVOID BusContext;
    525   PINTERFACE_REFERENCE InterfaceReference;
    526   PINTERFACE_DEREFERENCE InterfaceDereference;
    527   PUSB_BUSIFFN_CREATE_USB_DEVICE CreateUsbDevice;
    528   PUSB_BUSIFFN_INITIALIZE_USB_DEVICE InitializeUsbDevice;
    529   PUSB_BUSIFFN_GET_USB_DESCRIPTORS GetUsbDescriptors;
    530   PUSB_BUSIFFN_REMOVE_USB_DEVICE RemoveUsbDevice;
    531   PUSB_BUSIFFN_RESTORE_DEVICE RestoreUsbDevice;
    532   PUSB_BUSIFFN_GET_POTRTHACK_FLAGS GetPortHackFlags;
    533   PUSB_BUSIFFN_GET_DEVICE_INFORMATION QueryDeviceInformation;
    534   PUSB_BUSIFFN_GET_CONTROLLER_INFORMATION GetControllerInformation;
    535   PUSB_BUSIFFN_CONTROLLER_SELECTIVE_SUSPEND ControllerSelectiveSuspend;
    536   PUSB_BUSIFFN_GET_EXTENDED_HUB_INFO GetExtendedHubInformation;
    537   PUSB_BUSIFFN_GET_ROOTHUB_SYM_NAME GetRootHubSymbolicName;
    538   PUSB_BUSIFFN_GET_DEVICE_BUSCONTEXT GetDeviceBusContext;
    539   PUSB_BUSIFFN_INITIALIZE_20HUB Initialize20Hub;
    540   PUSB_BUSIFFN_ROOTHUB_INIT_NOTIFY RootHubInitNotification;
    541 } USB_BUS_INTERFACE_HUB_V3, *PUSB_BUS_INTERFACE_HUB_V3;
    542 
    543 typedef struct _USB_BUS_INTERFACE_HUB_V4 {
    544   USHORT Size;
    545   USHORT Version;
    546   PVOID BusContext;
    547   PINTERFACE_REFERENCE InterfaceReference;
    548   PINTERFACE_DEREFERENCE InterfaceDereference;
    549   PUSB_BUSIFFN_CREATE_USB_DEVICE CreateUsbDevice;
    550   PUSB_BUSIFFN_INITIALIZE_USB_DEVICE InitializeUsbDevice;
    551   PUSB_BUSIFFN_GET_USB_DESCRIPTORS GetUsbDescriptors;
    552   PUSB_BUSIFFN_REMOVE_USB_DEVICE RemoveUsbDevice;
    553   PUSB_BUSIFFN_RESTORE_DEVICE RestoreUsbDevice;
    554   PUSB_BUSIFFN_GET_POTRTHACK_FLAGS GetPortHackFlags;
    555   PUSB_BUSIFFN_GET_DEVICE_INFORMATION QueryDeviceInformation;
    556   PUSB_BUSIFFN_GET_CONTROLLER_INFORMATION GetControllerInformation;
    557   PUSB_BUSIFFN_CONTROLLER_SELECTIVE_SUSPEND ControllerSelectiveSuspend;
    558   PUSB_BUSIFFN_GET_EXTENDED_HUB_INFO GetExtendedHubInformation;
    559   PUSB_BUSIFFN_GET_ROOTHUB_SYM_NAME GetRootHubSymbolicName;
    560   PUSB_BUSIFFN_GET_DEVICE_BUSCONTEXT GetDeviceBusContext;
    561   PUSB_BUSIFFN_INITIALIZE_20HUB Initialize20Hub;
    562   PUSB_BUSIFFN_ROOTHUB_INIT_NOTIFY RootHubInitNotification;
    563   PUSB_BUSIFFN_FLUSH_TRANSFERS FlushTransfers;
    564 } USB_BUS_INTERFACE_HUB_V4, *PUSB_BUS_INTERFACE_HUB_V4;
    565 
    566 typedef struct _USB_BUS_INTERFACE_HUB_V5 {
    567   USHORT Size;
    568   USHORT Version;
    569   PVOID BusContext;
    570   PINTERFACE_REFERENCE InterfaceReference;
    571   PINTERFACE_DEREFERENCE InterfaceDereference;
    572   PUSB_BUSIFFN_CREATE_USB_DEVICE CreateUsbDevice;
    573   PUSB_BUSIFFN_INITIALIZE_USB_DEVICE InitializeUsbDevice;
    574   PUSB_BUSIFFN_GET_USB_DESCRIPTORS GetUsbDescriptors;
    575   PUSB_BUSIFFN_REMOVE_USB_DEVICE RemoveUsbDevice;
    576   PUSB_BUSIFFN_RESTORE_DEVICE RestoreUsbDevice;
    577   PUSB_BUSIFFN_GET_POTRTHACK_FLAGS GetPortHackFlags;
    578   PUSB_BUSIFFN_GET_DEVICE_INFORMATION QueryDeviceInformation;
    579   PUSB_BUSIFFN_GET_CONTROLLER_INFORMATION GetControllerInformation;
    580   PUSB_BUSIFFN_CONTROLLER_SELECTIVE_SUSPEND ControllerSelectiveSuspend;
    581   PUSB_BUSIFFN_GET_EXTENDED_HUB_INFO GetExtendedHubInformation;
    582   PUSB_BUSIFFN_GET_ROOTHUB_SYM_NAME GetRootHubSymbolicName;
    583   PUSB_BUSIFFN_GET_DEVICE_BUSCONTEXT GetDeviceBusContext;
    584   PUSB_BUSIFFN_INITIALIZE_20HUB Initialize20Hub;
    585   PUSB_BUSIFFN_ROOTHUB_INIT_NOTIFY RootHubInitNotification;
    586   PUSB_BUSIFFN_FLUSH_TRANSFERS FlushTransfers;
    587   PUSB_BUSIFFN_SET_DEVHANDLE_DATA SetDeviceHandleData;
    588 } USB_BUS_INTERFACE_HUB_V5, *PUSB_BUS_INTERFACE_HUB_V5;
    589 
    590 typedef struct _USB_BUS_INTERFACE_HUB_V6 {
    591   USHORT Size;
    592   USHORT Version;
    593   PVOID BusContext;
    594   PINTERFACE_REFERENCE InterfaceReference;
    595   PINTERFACE_DEREFERENCE InterfaceDereference;
    596   PUSB_BUSIFFN_CREATE_USB_DEVICE_EX CreateUsbDevice;
    597   PUSB_BUSIFFN_INITIALIZE_USB_DEVICE_EX InitializeUsbDevice;
    598   PUSB_BUSIFFN_GET_USB_DESCRIPTORS GetUsbDescriptors;
    599   PUSB_BUSIFFN_REMOVE_USB_DEVICE RemoveUsbDevice;
    600   PUSB_BUSIFFN_RESTORE_DEVICE RestoreUsbDevice;
    601   PUSB_BUSIFFN_GET_POTRTHACK_FLAGS GetPortHackFlags;
    602   PUSB_BUSIFFN_GET_DEVICE_INFORMATION QueryDeviceInformation;
    603   PUSB_BUSIFFN_GET_CONTROLLER_INFORMATION GetControllerInformation;
    604   PUSB_BUSIFFN_CONTROLLER_SELECTIVE_SUSPEND ControllerSelectiveSuspend;
    605   PUSB_BUSIFFN_GET_EXTENDED_HUB_INFO GetExtendedHubInformation;
    606   PUSB_BUSIFFN_GET_ROOTHUB_SYM_NAME GetRootHubSymbolicName;
    607   PUSB_BUSIFFN_GET_DEVICE_BUSCONTEXT GetDeviceBusContext;
    608   PUSB_BUSIFFN_INITIALIZE_20HUB Initialize20Hub;
    609   PUSB_BUSIFFN_ROOTHUB_INIT_NOTIFY RootHubInitNotification;
    610   PUSB_BUSIFFN_FLUSH_TRANSFERS FlushTransfers;
    611   PUSB_BUSIFFN_SET_DEVHANDLE_DATA SetDeviceHandleData;
    612   PUSB_BUSIFFN_IS_ROOT HubIsRoot;
    613   PUSB_BUSIFFN_ACQUIRE_SEMAPHORE AcquireBusSemaphore;
    614   PUSB_BUSIFFN_RELEASE_SEMAPHORE ReleaseBusSemaphore;
    615   PUSB_BUSIFFN_CALC_PIPE_BANDWIDTH CaculatePipeBandwidth;
    616   PUSB_BUSIFFN_SET_BUS_WAKE_MODE SetBusSystemWakeMode;
    617   PUSB_BUSIFFN_SET_DEVICE_FLAG SetDeviceFlag;
    618   PUSB_BUSIFFN_TEST_POINT HubTestPoint;
    619   PUSB_BUSIFFN_GET_DEVICE_PERFORMANCE_INFO GetDevicePerformanceInfo;
    620   PUSB_BUSIFFN_WAIT_ASYNC_POWERUP WaitAsyncPowerUp;
    621   PUSB_BUSIFFN_GET_DEVICE_ADDRESS GetDeviceAddress;
    622   PUSB_BUSIFFN_REF_DEVICE_HANDLE RefDeviceHandle;
    623   PUSB_BUSIFFN_DEREF_DEVICE_HANDLE DerefDeviceHandle;
    624   PUSB_BUSIFFN_SET_DEVICE_HANDLE_IDLE_READY_STATE SetDeviceHandleIdleReadyState;
    625 } USB_BUS_INTERFACE_HUB_V6, *PUSB_BUS_INTERFACE_HUB_V6;
    626 
    627 typedef struct _USB_BUS_INTERFACE_HUB_V7 {
    628   USHORT Size;
    629   USHORT Version;
    630   PVOID BusContext;
    631   PINTERFACE_REFERENCE InterfaceReference;
    632   PINTERFACE_DEREFERENCE InterfaceDereference;
    633   PUSB_BUSIFFN_CREATE_USB_DEVICE_EX CreateUsbDevice;
    634   PUSB_BUSIFFN_INITIALIZE_USB_DEVICE_EX InitializeUsbDevice;
    635   PUSB_BUSIFFN_GET_USB_DESCRIPTORS GetUsbDescriptors;
    636   PUSB_BUSIFFN_REMOVE_USB_DEVICE RemoveUsbDevice;
    637   PUSB_BUSIFFN_RESTORE_DEVICE RestoreUsbDevice;
    638   PUSB_BUSIFFN_GET_POTRTHACK_FLAGS GetPortHackFlags;
    639   PUSB_BUSIFFN_GET_DEVICE_INFORMATION QueryDeviceInformation;
    640   PUSB_BUSIFFN_GET_CONTROLLER_INFORMATION GetControllerInformation;
    641   PUSB_BUSIFFN_CONTROLLER_SELECTIVE_SUSPEND ControllerSelectiveSuspend;
    642   PUSB_BUSIFFN_GET_EXTENDED_HUB_INFO GetExtendedHubInformation;
    643   PUSB_BUSIFFN_GET_ROOTHUB_SYM_NAME GetRootHubSymbolicName;
    644   PUSB_BUSIFFN_GET_DEVICE_BUSCONTEXT GetDeviceBusContext;
    645   PUSB_BUSIFFN_INITIALIZE_20HUB Initialize20Hub;
    646   PUSB_BUSIFFN_ROOTHUB_INIT_NOTIFY RootHubInitNotification;
    647   PUSB_BUSIFFN_FLUSH_TRANSFERS FlushTransfers;
    648   PUSB_BUSIFFN_SET_DEVHANDLE_DATA SetDeviceHandleData;
    649   PUSB_BUSIFFN_IS_ROOT HubIsRoot;
    650   PUSB_BUSIFFN_ACQUIRE_SEMAPHORE AcquireBusSemaphore;
    651   PUSB_BUSIFFN_RELEASE_SEMAPHORE ReleaseBusSemaphore;
    652   PUSB_BUSIFFN_CALC_PIPE_BANDWIDTH CaculatePipeBandwidth;
    653   PUSB_BUSIFFN_SET_BUS_WAKE_MODE SetBusSystemWakeMode;
    654   PUSB_BUSIFFN_SET_DEVICE_FLAG SetDeviceFlag;
    655   PUSB_BUSIFFN_TEST_POINT HubTestPoint;
    656   PUSB_BUSIFFN_GET_DEVICE_PERFORMANCE_INFO GetDevicePerformanceInfo;
    657   PUSB_BUSIFFN_WAIT_ASYNC_POWERUP WaitAsyncPowerUp;
    658   PUSB_BUSIFFN_GET_DEVICE_ADDRESS GetDeviceAddress;
    659   PUSB_BUSIFFN_REF_DEVICE_HANDLE RefDeviceHandle;
    660   PUSB_BUSIFFN_DEREF_DEVICE_HANDLE DerefDeviceHandle;
    661   PUSB_BUSIFFN_SET_DEVICE_HANDLE_IDLE_READY_STATE SetDeviceHandleIdleReadyState;
    662   PUSB_BUSIFFN_CREATE_USB_DEVICE_V7 CreateUsbDeviceV7;
    663   PUSB_BUSIFFN_GET_CONTAINER_ID_FOR_PORT GetContainerIdForPort;
    664   PUSB_BUSIFFN_SET_CONTAINER_ID_FOR_PORT SetContainerIdForPort;
    665   PUSB_BUSIFFN_ABORT_ALL_DEVICE_PIPES AbortAllDevicePipes;
    666   PUSB_BUSIFFN_SET_DEVICE_ERRATA_FLAG SetDeviceErrataFlag;
    667 } USB_BUS_INTERFACE_HUB_V7, *PUSB_BUS_INTERFACE_HUB_V7;
    668 
    669 DEFINE_GUID(USB_BUS_INTERFACE_HUB_MINIDUMP_GUID,
    670 	0xc5485f21, 0x4e81, 0x4a23, 0xa8, 0xf9, 0xd8, 0x51, 0x8a, 0xf4, 0x5c, 0x38);
    671 
    672 typedef VOID
    673 (USB_BUSIFFN *PUSB_BUSIFFN_SET_MINIDUMP_FLAGS) (
    674   IN PVOID);
    675 
    676 typedef struct _USB_BUS_INTERFACE_HUB_MINIDUMP {
    677   USHORT Size;
    678   USHORT Version;
    679   PVOID BusContext;
    680   PINTERFACE_REFERENCE InterfaceReference;
    681   PINTERFACE_DEREFERENCE InterfaceDereference;
    682   PUSB_BUSIFFN_SET_MINIDUMP_FLAGS SetUsbPortMiniDumpFlags;
    683 } USB_BUS_INTERFACE_HUB_MINIDUMP, *PUSB_BUS_INTERFACE_HUB_MINIDUMP;
    684 
    685 DEFINE_GUID(USB_BUS_INTERFACE_HUB_SS_GUID,
    686 	0xbfc3f363, 0x8ba1, 0x4c7b, 0x97, 0xba, 0x9b, 0x12, 0xb1, 0xca, 0x13, 0x2f);
    687 
    688 typedef NTSTATUS
    689 (USB_BUSIFFN *PUSB_BUSIFFN_SUSPEND_HUB) (
    690   PDEVICE_OBJECT Pdo);
    691 
    692 typedef NTSTATUS
    693 (USB_BUSIFFN *PUSB_BUSIFFN_RESUME_HUB) (
    694   PDEVICE_OBJECT Pdo);
    695 
    696 typedef struct _USB_BUS_INTERFACE_HUB_SELECTIVE_SUSPEND {
    697   USHORT Size;
    698   USHORT Version;
    699   PVOID  BusContext;
    700   PINTERFACE_REFERENCE  InterfaceReference;
    701   PINTERFACE_DEREFERENCE  InterfaceDereference;
    702   PUSB_BUSIFFN_SUSPEND_HUB  SuspendHub;
    703   PUSB_BUSIFFN_RESUME_HUB  ResumeHub;
    704 } USB_BUS_INTERFACE_HUB_SELECTIVE_SUSPEND, *PUSB_BUS_INTERFACE_HUB_SELECTIVE_SUSPEND;
    705 
    706 #include <pshpack1.h>
    707 
    708 typedef struct _USB_PIPE_INFORMATION_0 {
    709   USB_ENDPOINT_DESCRIPTOR  EndpointDescriptor;
    710   UCHAR  ED_Pad[1];
    711   ULONG  ScheduleOffset;
    712 } USB_PIPE_INFORMATION_0, *PUSB_PIPE_INFORMATION_0;
    713 
    714 typedef struct _USB_LEVEL_INFORMATION {
    715   ULONG  InformationLevel;
    716   ULONG  ActualLength;
    717 } USB_LEVEL_INFORMATION, *PUSB_LEVEL_INFORMATION;
    718 
    719 typedef struct _USB_DEVICE_INFORMATION_0 {
    720   ULONG  InformationLevel;
    721   ULONG  ActualLength;
    722   ULONG  PortNumber;
    723   USB_DEVICE_DESCRIPTOR  DeviceDescriptor;
    724   UCHAR  DD_pad[2];
    725   UCHAR  CurrentConfigurationValue;
    726   UCHAR  ReservedMBZ;
    727   USHORT DeviceAddress;
    728   ULONG  HubAddress;
    729   USB_DEVICE_SPEED  DeviceSpeed;
    730   USB_DEVICE_TYPE  DeviceType;
    731   ULONG  NumberOfOpenPipes;
    732   USB_PIPE_INFORMATION_0  PipeList[1];
    733 } USB_DEVICE_INFORMATION_0, *PUSB_DEVICE_INFORMATION_0;
    734 
    735 typedef struct _USB_CONTROLLER_INFORMATION_0 {
    736   ULONG  InformationLevel;
    737   ULONG  ActualLength;
    738   BOOLEAN SelectiveSuspendEnabled;
    739   BOOLEAN IsHighSpeedController;
    740 } USB_CONTROLLER_INFORMATION_0, *PUSB_CONTROLLER_INFORMATION_0;
    741 
    742 typedef struct _USB_CONTROLLER_INFORMATION_1 {
    743   ULONG  InformationLevel;
    744   ULONG  ActualLength;
    745   BOOLEAN SelectiveSuspendEnabled;
    746   BOOLEAN IsHighSpeedController;
    747   ULONG  HcBusNumber;
    748   ULONG  HcBusDevice;
    749   ULONG  HcBusFunction;
    750 } USB_CONTROLLER_INFORMATION_1, *PUSB_CONTROLLER_INFORMATION_1;
    751 
    752 typedef struct _USB_EXTPORT_INFORMATION_0 {
    753   ULONG  PhysicalPortNumber;
    754   ULONG  PortLabelNumber;
    755   USHORT VidOverride;
    756   USHORT PidOverride;
    757   ULONG  PortAttributes;
    758 } USB_EXTPORT_INFORMATION_0, *PUSB_EXTPORT_INFORMATION;
    759 
    760 typedef struct _USB_EXTHUB_INFORMATION_0 {
    761   ULONG  InformationLevel;
    762   ULONG  NumberOfPorts;
    763   USB_EXTPORT_INFORMATION_0  Port[255];
    764 } USB_EXTHUB_INFORMATION_0, *PUSB_EXTHUB_INFORMATION_0;
    765 
    766 typedef struct _USB_DEVICE_PERFORMANCE_INFO_0 {
    767   ULONG  InformationLevel;
    768   ULONG  ActualLength;
    769   ULONG  BulkBytes;
    770   ULONG  BulkUrbCount;
    771   ULONG  ControlDataBytes;
    772   ULONG  ControlUrbCount;
    773   ULONG  IsoBytes;
    774   ULONG  IsoUrbCount;
    775   ULONG  InterruptBytes;
    776   ULONG  InterruptUrbCount;
    777   ULONG  AllocedInterrupt[6];
    778   ULONG  AllocedIso;
    779   ULONG  Total32secBandwidth;
    780   ULONG  TotalTtBandwidth;
    781   ULONG  TotalIsoLatency;
    782   ULONG  DroppedIsoPackets;
    783   ULONG  TransferErrors;
    784 } USB_DEVICE_PERFORMANCE_INFO_0, *PUSB_DEVICE_PERFORMANCE_INFO_0;
    785 
    786 #include <poppack.h>
    787 
    788 #endif /* NTDDI_VERSION >= NTDDI_WINXP */
    789 
    790