More work on USB related definitions
authorAmine Khaldi <amine.khaldi@reactos.org>
Thu, 4 Mar 2010 23:57:29 +0000 (23:57 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Thu, 4 Mar 2010 23:57:29 +0000 (23:57 +0000)
svn path=/branches/header-work/; revision=45848

include/psdk/usb.h [moved from include/ddk/usb.h with 77% similarity]

similarity index 77%
rename from include/ddk/usb.h
rename to include/psdk/usb.h
index 0ac209d..bedc154 100644 (file)
@@ -1,7 +1,4 @@
-
-
-#ifndef   __USB_H__
-#define   __USB_H__
+#pragma once
 
 /* Helper macro to enable gcc's extension.  */
 #ifndef __GNU_EXTENSION
@@ -36,40 +33,46 @@ typedef PVOID USBD_PIPE_HANDLE;
 typedef PVOID USBD_CONFIGURATION_HANDLE;
 typedef PVOID USBD_INTERFACE_HANDLE;
 
-typedef enum _USB_CONTROLLER_FLAVOR
-{
+typedef enum _USB_CONTROLLER_FLAVOR {
   USB_HcGeneric = 0,
   OHCI_Generic = 100,
   OHCI_Hydra,
   OHCI_NEC,
   UHCI_Generic = 200,
-  UHCI_Piix4,
-  UHCI_Piix3,
-  UHCI_Ich2_1,
-  UHCI_Ich2_2,
-  UHCI_Ich1,
+  UHCI_Piix4 = 201,
+  UHCI_Piix3 = 202,
+  UHCI_Ich2 = 203,
+  UHCI_Reserved204 = 204,
+  UHCI_Ich1 = 205,
+  UHCI_Ich3m = 206,
+  UHCI_Ich4 = 207,
+  UHCI_Ich5 = 208,
+  UHCI_Ich6 = 209,
+  UHCI_Intel = 249,
   UHCI_VIA = 250,
+  UHCI_VIA_x01 = 251,
+  UHCI_VIA_x02 = 252,
+  UHCI_VIA_x03 = 253,
+  UHCI_VIA_x04 = 254,
+  UHCI_VIA_x0E_FIFO = 264,
   EHCI_Generic = 1000,
   EHCI_NEC = 2000,
   EHCI_Lucent = 3000
 } USB_CONTROLLER_FLAVOR;
 
-typedef enum _USBD_PIPE_TYPE
-{
+typedef enum _USBD_PIPE_TYPE {
   UsbdPipeTypeControl,
   UsbdPipeTypeIsochronous,
   UsbdPipeTypeBulk,
   UsbdPipeTypeInterrupt
 } USBD_PIPE_TYPE;
 
-typedef struct _USBD_VERSION_INFORMATION
-{
+typedef struct _USBD_VERSION_INFORMATION {
   ULONG USBDI_Version;
   ULONG Supported_USB_Version;
 } USBD_VERSION_INFORMATION, *PUSBD_VERSION_INFORMATION;
 
-typedef struct _USBD_PIPE_INFORMATION
-{
+typedef struct _USBD_PIPE_INFORMATION {
   USHORT MaximumPacketSize;
   UCHAR EndpointAddress;
   UCHAR Interval;
@@ -79,15 +82,13 @@ typedef struct _USBD_PIPE_INFORMATION
   ULONG PipeFlags;
 } USBD_PIPE_INFORMATION, *PUSBD_PIPE_INFORMATION;
 
-typedef struct _USBD_DEVICE_INFORMATION
-{
+typedef struct _USBD_DEVICE_INFORMATION {
   ULONG OffsetNext;
   PVOID UsbdDeviceHandle;
   USB_DEVICE_DESCRIPTOR DeviceDescriptor;
 } USBD_DEVICE_INFORMATION, *PUSBD_DEVICE_INFORMATION;
 
-typedef struct _USBD_INTERFACE_INFORMATION
-{
+typedef struct _USBD_INTERFACE_INFORMATION {
   USHORT Length;
   UCHAR InterfaceNumber;
   UCHAR AlternateSetting;
@@ -100,13 +101,11 @@ typedef struct _USBD_INTERFACE_INFORMATION
   USBD_PIPE_INFORMATION Pipes[1];
 } USBD_INTERFACE_INFORMATION, *PUSBD_INTERFACE_INFORMATION;
 
-struct _URB_HCD_AREA
-{
+struct _URB_HCD_AREA {
   PVOID Reserved8[8];
 };
 
-struct _URB_HEADER
-{
+struct _URB_HEADER {
   USHORT Length;
   USHORT Function;
   USBD_STATUS Status;
@@ -114,54 +113,46 @@ struct _URB_HEADER
   ULONG UsbdFlags;
 };
 
-struct _URB_SELECT_INTERFACE
-{
+struct _URB_SELECT_INTERFACE {
   struct _URB_HEADER Hdr;
   USBD_CONFIGURATION_HANDLE ConfigurationHandle;
   USBD_INTERFACE_INFORMATION Interface;
 };
 
-struct _URB_SELECT_CONFIGURATION
-{
+struct _URB_SELECT_CONFIGURATION {
   struct _URB_HEADER Hdr;
   PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor;
   USBD_CONFIGURATION_HANDLE ConfigurationHandle;
   USBD_INTERFACE_INFORMATION Interface;
 };
 
-struct _URB_PIPE_REQUEST
-{
+struct _URB_PIPE_REQUEST {
   struct _URB_HEADER Hdr;
   USBD_PIPE_HANDLE PipeHandle;
   ULONG Reserved;
 };
 
-struct _URB_FRAME_LENGTH_CONTROL
-{
+struct _URB_FRAME_LENGTH_CONTROL {
   struct _URB_HEADER Hdr;
 };
 
-struct _URB_GET_FRAME_LENGTH
-{
+struct _URB_GET_FRAME_LENGTH {
   struct _URB_HEADER Hdr;
   ULONG FrameLength;
   ULONG FrameNumber;
 };
 
-struct _URB_SET_FRAME_LENGTH
-{
+struct _URB_SET_FRAME_LENGTH {
   struct _URB_HEADER Hdr;
   LONG FrameLengthDelta;
 };
 
-struct _URB_GET_CURRENT_FRAME_NUMBER
-{
+struct _URB_GET_CURRENT_FRAME_NUMBER {
   struct _URB_HEADER Hdr;
   ULONG FrameNumber;
 };
 
-struct _URB_CONTROL_DESCRIPTOR_REQUEST
-{
+struct _URB_CONTROL_DESCRIPTOR_REQUEST {
   struct _URB_HEADER Hdr;
   PVOID Reserved;
   ULONG Reserved0;
@@ -177,8 +168,7 @@ struct _URB_CONTROL_DESCRIPTOR_REQUEST
   USHORT Reserved2;
 };
 
-struct _URB_CONTROL_GET_STATUS_REQUEST
-{
+struct _URB_CONTROL_GET_STATUS_REQUEST {
   struct _URB_HEADER Hdr;
   PVOID Reserved;
   ULONG Reserved0;
@@ -192,8 +182,7 @@ struct _URB_CONTROL_GET_STATUS_REQUEST
   USHORT Reserved2;
 };
 
-struct _URB_CONTROL_FEATURE_REQUEST
-{
+struct _URB_CONTROL_FEATURE_REQUEST {
   struct _URB_HEADER Hdr;
   PVOID Reserved;
   ULONG Reserved2;
@@ -208,8 +197,7 @@ struct _URB_CONTROL_FEATURE_REQUEST
   USHORT Reserved1;
 };
 
-struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST
-{
+struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST {
   struct _URB_HEADER Hdr;
   PVOID Reserved;
   ULONG TransferFlags;
@@ -225,8 +213,7 @@ struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST
   USHORT Reserved1;
 };
 
-struct _URB_CONTROL_GET_INTERFACE_REQUEST
-{
+struct _URB_CONTROL_GET_INTERFACE_REQUEST {
   struct _URB_HEADER Hdr;
   PVOID Reserved;
   ULONG Reserved0;
@@ -240,8 +227,7 @@ struct _URB_CONTROL_GET_INTERFACE_REQUEST
   USHORT Reserved2;
 };
 
-struct _URB_CONTROL_GET_CONFIGURATION_REQUEST
-{
+struct _URB_CONTROL_GET_CONFIGURATION_REQUEST {
   struct _URB_HEADER Hdr;
   PVOID Reserved;
   ULONG Reserved0;
@@ -253,50 +239,38 @@ struct _URB_CONTROL_GET_CONFIGURATION_REQUEST
   UCHAR Reserved1[8];
 };
 
-typedef struct _OS_STRING
-{
-  UCHAR bLength;
-  UCHAR bDescriptorType;
-  WCHAR MicrosoftString[7];
-  UCHAR bVendorCode;
-  UCHAR bPad;
-} OS_STRING, *POS_STRING;
-
-
-struct _URB_OS_FEATURE_DESCRIPTOR_REQUEST
-{
+struct _URB_CONTROL_TRANSFER {
   struct _URB_HEADER Hdr;
-  PVOID Reserved;
-  ULONG Reserved0;
+  USBD_PIPE_HANDLE PipeHandle;
+  ULONG TransferFlags;
   ULONG TransferBufferLength;
   PVOID TransferBuffer;
   PMDL TransferBufferMDL;
   struct _URB *UrbLink;
   struct _URB_HCD_AREA hca;
-  UCHAR   Recipient:5;
-  UCHAR   Reserved1:3;
-  UCHAR   Reserved2;
-  UCHAR   InterfaceNumber;
-  UCHAR   MS_PageIndex;
-  USHORT  MS_FeatureDescriptorIndex;
-  USHORT  Reserved3;
+  UCHAR SetupPacket[8];
 };
 
-struct _URB_CONTROL_TRANSFER
-{
+#if (_WIN32_WINNT >= 0x0600)
+
+struct _URB_CONTROL_TRANSFER_EX {
   struct _URB_HEADER Hdr;
   USBD_PIPE_HANDLE PipeHandle;
   ULONG TransferFlags;
   ULONG TransferBufferLength;
   PVOID TransferBuffer;
   PMDL TransferBufferMDL;
-  struct _URB *UrbLink;
+  ULONG Timeout;
+#ifdef WIN64
+  ULONG Pad;
+#endif
   struct _URB_HCD_AREA hca;
   UCHAR SetupPacket[8];
 };
 
-struct _URB_BULK_OR_INTERRUPT_TRANSFER
-{
+#endif
+
+struct _URB_BULK_OR_INTERRUPT_TRANSFER {
   struct _URB_HEADER Hdr;
   USBD_PIPE_HANDLE PipeHandle;
   ULONG TransferFlags;
@@ -307,15 +281,13 @@ struct _URB_BULK_OR_INTERRUPT_TRANSFER
   struct _URB_HCD_AREA hca;
 };
 
-typedef struct _USBD_ISO_PACKET_DESCRIPTOR
-{
+typedef struct _USBD_ISO_PACKET_DESCRIPTOR {
   ULONG Offset;
   ULONG Length;
   USBD_STATUS Status;
 } USBD_ISO_PACKET_DESCRIPTOR, *PUSBD_ISO_PACKET_DESCRIPTOR;
 
-struct _URB_ISOCH_TRANSFER
-{
+struct _URB_ISOCH_TRANSFER {
   struct _URB_HEADER Hdr;
   USBD_PIPE_HANDLE PipeHandle;
   ULONG TransferFlags;
@@ -330,47 +302,32 @@ struct _URB_ISOCH_TRANSFER
   USBD_ISO_PACKET_DESCRIPTOR IsoPacket[1];
 };
 
-typedef struct _URB
-{
-  __GNU_EXTENSION union
-  {
-      struct _URB_HEADER
-         UrbHeader;
-      struct _URB_SELECT_INTERFACE
-          UrbSelectInterface;
-      struct _URB_SELECT_CONFIGURATION
-          UrbSelectConfiguration;
-      struct _URB_PIPE_REQUEST
-          UrbPipeRequest;
-      struct _URB_FRAME_LENGTH_CONTROL
-          UrbFrameLengthControl;
-      struct _URB_GET_FRAME_LENGTH
-          UrbGetFrameLength;
-      struct _URB_SET_FRAME_LENGTH
-          UrbSetFrameLength;
-      struct _URB_GET_CURRENT_FRAME_NUMBER
-          UrbGetCurrentFrameNumber;
-      struct _URB_CONTROL_TRANSFER
-          UrbControlTransfer;
-      struct _URB_BULK_OR_INTERRUPT_TRANSFER
-          UrbBulkOrInterruptTransfer;
-      struct _URB_ISOCH_TRANSFER
-          UrbIsochronousTransfer;
-      struct _URB_CONTROL_DESCRIPTOR_REQUEST
-          UrbControlDescriptorRequest;
-      struct _URB_CONTROL_GET_STATUS_REQUEST
-          UrbControlGetStatusRequest;
-      struct _URB_CONTROL_FEATURE_REQUEST
-          UrbControlFeatureRequest;
-      struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST
-          UrbControlVendorClassRequest;
-      struct _URB_CONTROL_GET_INTERFACE_REQUEST
-          UrbControlGetInterfaceRequest;
-      struct _URB_CONTROL_GET_CONFIGURATION_REQUEST
-          UrbControlGetConfigurationRequest;
-      struct _URB_OS_FEATURE_DESCRIPTOR_REQUEST
-          UrbOSFeatureDescriptorRequest;
-    };
+typedef struct _URB {
+  __GNU_EXTENSION union {
+    struct _URB_HEADER UrbHeader;
+    struct _URB_SELECT_INTERFACE UrbSelectInterface;
+    struct _URB_SELECT_CONFIGURATION UrbSelectConfiguration;
+    struct _URB_PIPE_REQUEST UrbPipeRequest;
+    struct _URB_FRAME_LENGTH_CONTROL UrbFrameLengthControl;
+    struct _URB_GET_FRAME_LENGTH UrbGetFrameLength;
+    struct _URB_SET_FRAME_LENGTH UrbSetFrameLength;
+    struct _URB_GET_CURRENT_FRAME_NUMBER UrbGetCurrentFrameNumber;
+    struct _URB_CONTROL_TRANSFER UrbControlTransfer;
+#if (_WIN32_WINNT >= 0x0600)
+    struct _URB_CONTROL_TRANSFER_EX UrbControlTransferEx;
+#endif
+    struct _URB_BULK_OR_INTERRUPT_TRANSFER UrbBulkOrInterruptTransfer;
+    struct _URB_ISOCH_TRANSFER UrbIsochronousTransfer;
+    struct _URB_CONTROL_DESCRIPTOR_REQUEST UrbControlDescriptorRequest;
+    struct _URB_CONTROL_GET_STATUS_REQUEST UrbControlGetStatusRequest;
+    struct _URB_CONTROL_FEATURE_REQUEST UrbControlFeatureRequest;
+    struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST UrbControlVendorClassRequest;
+    struct _URB_CONTROL_GET_INTERFACE_REQUEST UrbControlGetInterfaceRequest;
+    struct _URB_CONTROL_GET_CONFIGURATION_REQUEST UrbControlGetConfigurationRequest;
+#if (_WIN32_WINNT >= 0x0501)
+    struct _URB_OS_FEATURE_DESCRIPTOR_REQUEST UrbOSFeatureDescriptorRequest;
+#endif
+  };
 } URB, *PURB;
 
 #define USB_PORTATTR_NO_CONNECTOR                       0x00000001
@@ -425,15 +382,31 @@ typedef struct _URB
 #define URB_FUNCTION_GET_INTERFACE                      0x0027
 #define URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE      0x0028
 #define URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE        0x0029
+
+#if (_WIN32_WINNT >= 0x0501)
+
 #define URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR          0x002A
+#define URB_FUNCTION_SYNC_RESET_PIPE                    0x0030
+#define URB_FUNCTION_SYNC_CLEAR_STALL                   0x0031
+
+#endif
+
+#if (_WIN32_WINNT >= 0x0600)
+
+#define URB_FUNCTION_CONTROL_TRANSFER_EX             0x0032
+#define URB_FUNCTION_RESERVE_0X0033                  0x0033
+#define URB_FUNCTION_RESERVE_0X0034                  0x0034
+
+#endif
+
 #define URB_FUNCTION_RESERVE_0X002B                     0x002B
 #define URB_FUNCTION_RESERVE_0X002C                     0x002C
 #define URB_FUNCTION_RESERVE_0X002D                     0x002D
 #define URB_FUNCTION_RESERVE_0X002E                     0x002E
 #define URB_FUNCTION_RESERVE_0X002F                     0x002F
-#define URB_FUNCTION_SYNC_RESET_PIPE                    0x0030
-#define URB_FUNCTION_SYNC_CLEAR_STALL                   0x0031
+
 #define URB_FUNCTION_RESET_PIPE                         URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL
+
 #define USBD_TRANSFER_DIRECTION                         0x00000001
 #define USBD_SHORT_TRANSFER_OK                          0x00000002
 #define USBD_START_ISO_TRANSFER_ASAP                    0x00000004
@@ -490,22 +463,76 @@ typedef struct _URB
 #define USBD_STATUS_TIMEOUT                             ((USBD_STATUS)0xC0006000L)
 #define USBD_STATUS_DEVICE_GONE                         ((USBD_STATUS)0xC0007000L)
 #define USBD_STATUS_STATUS_NOT_MAPPED                   ((USBD_STATUS)0xC0008000L)
+#define USBD_STATUS_HUB_INTERNAL_ERROR                  ((USBD_STATUS)0xC0009000L)
 #define USBD_STATUS_CANCELED                            ((USBD_STATUS)0xC0010000L)
 #define USBD_STATUS_ISO_NOT_ACCESSED_BY_HW              ((USBD_STATUS)0xC0020000L)
 #define USBD_STATUS_ISO_TD_ERROR                        ((USBD_STATUS)0xC0030000L)
 #define USBD_STATUS_ISO_NA_LATE_USBPORT                 ((USBD_STATUS)0xC0040000L)
 #define USBD_STATUS_ISO_NOT_ACCESSED_LATE               ((USBD_STATUS)0xC0050000L)
+#define USBD_STATUS_BAD_DESCRIPTOR                      ((USBD_STATUS)0xC0100000L)
+#define USBD_STATUS_BAD_DESCRIPTOR_BLEN                 ((USBD_STATUS)0xC0100001L)
+#define USBD_STATUS_BAD_DESCRIPTOR_TYPE                 ((USBD_STATUS)0xC0100002L)
+#define USBD_STATUS_BAD_INTERFACE_DESCRIPTOR            ((USBD_STATUS)0xC0100003L)
+#define USBD_STATUS_BAD_ENDPOINT_DESCRIPTOR             ((USBD_STATUS)0xC0100004L)
+#define USBD_STATUS_BAD_INTERFACE_ASSOC_DESCRIPTOR      ((USBD_STATUS)0xC0100005L)
+#define USBD_STATUS_BAD_CONFIG_DESC_LENGTH              ((USBD_STATUS)0xC0100006L)
+#define USBD_STATUS_BAD_NUMBER_OF_INTERFACES            ((USBD_STATUS)0xC0100007L)
+#define USBD_STATUS_BAD_NUMBER_OF_ENDPOINTS             ((USBD_STATUS)0xC0100008L)
+#define USBD_STATUS_BAD_ENDPOINT_ADDRESS                ((USBD_STATUS)0xC0100009L)
+
+
+#if (_WIN32_WINNT >= 0x0501)
 #define USBD_DEFAULT_MAXIMUM_TRANSFER_SIZE              0xFFFFFFFF
+#else
+#define USBD_DEFAULT_MAXIMUM_TRANSFER_SIZE  PAGE_SIZE
+#endif
+
+
+
 #define USBD_PF_CHANGE_MAX_PACKET                       0x00000001
 #define USBD_PF_SHORT_PACKET_OPT                        0x00000002
 #define USBD_PF_ENABLE_RT_THREAD_ACCESS                 0x00000004
 #define USBD_PF_MAP_ADD_TRANSFERS                       0x00000008
 #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)
+
+#if (_WIN32_WINNT >= 0x0501)
+
 #define OS_STRING_DESCRIPTOR_INDEX                      0xEE
 #define MS_GENRE_DESCRIPTOR_INDEX                       0x0001
 #define MS_POWER_DESCRIPTOR_INDEX                       0x0002
 #define MS_OS_STRING_SIGNATURE                          L"MSFT100"
-#define USBD_PIPE_DIRECTION_IN(pipeInformation)         ((pipeInformation)->EndpointAddress & USB_ENDPOINT_DIRECTION_MASK)
+#define MS_OS_FLAGS_CONTAINERID                         0x02
+
+typedef struct _OS_STRING {
+  UCHAR bLength;
+  UCHAR bDescriptorType;
+  WCHAR MicrosoftString[7];
+  UCHAR bVendorCode;
+  union {
+    UCHAR bPad;
+    UCHAR bFlags;
+  };
+} OS_STRING, *POS_STRING;
+
+struct _URB_OS_FEATURE_DESCRIPTOR_REQUEST {
+  struct _URB_HEADER Hdr;
+  PVOID Reserved;
+  ULONG Reserved0;
+  ULONG TransferBufferLength;
+  PVOID TransferBuffer;
+  PMDL TransferBufferMDL;
+  struct _URB *UrbLink;
+  struct _URB_HCD_AREA hca;
+  UCHAR   Recipient:5;
+  UCHAR   Reserved1:3;
+  UCHAR   Reserved2;
+  UCHAR   InterfaceNumber;
+  UCHAR   MS_PageIndex;
+  USHORT  MS_FeatureDescriptorIndex;
+  USHORT  Reserved3;
+};
+
+#endif
 
-#endif /* __USB_H */
+#define USBD_PIPE_DIRECTION_IN(pipeInformation)         ((pipeInformation)->EndpointAddress & USB_ENDPOINT_DIRECTION_MASK)