[Wine-patches] [eterhack 17/23] usbhub.sys: Implement IOCTL_USB_GET_NODE_CONNECTION_INFORMATION handling.

Alexander Morozov =?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Пт Июн 5 13:00:17 MSD 2009


---
 dlls/usbhub.sys/usbhub.c |   57 +++++++++++++++++++++++++++++++++++++++++++++-
 include/ddk/usbioctl.h   |   32 +++++++++++++++++++++++++-
 include/ddk/usbiodef.h   |    3 +-
 3 files changed, 89 insertions(+), 3 deletions(-)

diff --git a/dlls/usbhub.sys/usbhub.c b/dlls/usbhub.sys/usbhub.c
index 731e12a..ad1e2f7 100644
--- a/dlls/usbhub.sys/usbhub.c
+++ b/dlls/usbhub.sys/usbhub.c
@@ -57,6 +57,8 @@ extern NTSTATUS CDECL __wine_add_device( DRIVER_OBJECT *driver, DEVICE_OBJECT *d
 extern DRIVER_OBJECT * CDECL __wine_get_driver_object( const WCHAR *service );
 extern NTSTATUS CDECL __wine_start_device( DEVICE_OBJECT *device );
 
+#define NUMBER_OF_PORTS 8
+
 static const WCHAR usbW[] = {'U','S','B',0};
 
 static struct list Devices = LIST_INIT(Devices);
@@ -119,11 +121,64 @@ static NTSTATUS WINAPI usbhub_ioctl( DEVICE_OBJECT *device, IRP *irp )
         RtlZeroMemory( node_info, sizeof(*node_info) );
         node_info->u.HubInformation.HubDescriptor.bDescriptorLength = 9;
         node_info->u.HubInformation.HubDescriptor.bDescriptorType = 41;
-        node_info->u.HubInformation.HubDescriptor.bNumberOfPorts = 8;
+        node_info->u.HubInformation.HubDescriptor.bNumberOfPorts = NUMBER_OF_PORTS;
         status = STATUS_SUCCESS;
         info = sizeof(*node_info);
         break;
     }
+    case IOCTL_USB_GET_NODE_CONNECTION_INFORMATION:
+    {
+        USB_NODE_CONNECTION_INFORMATION *conn_info = irp->AssociatedIrp.SystemBuffer;
+        ULONG index = 0;
+#ifdef HAVE_LIBUSB_H
+        struct DeviceInstance *instance;
+        uint8_t bus_number = libusb_get_bus_number( inst->dev );
+#else
+        struct usb_device *dev;
+#endif
+
+        if (irpsp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(*conn_info))
+        {
+            status = STATUS_BUFFER_TOO_SMALL;
+            break;
+        }
+        if (!conn_info->ConnectionIndex || conn_info->ConnectionIndex > NUMBER_OF_PORTS)
+        {
+            status = STATUS_INVALID_PARAMETER;
+            break;
+        }
+        RtlZeroMemory( (ULONG *)conn_info + 1, sizeof(*conn_info) - sizeof(ULONG) );
+#ifdef HAVE_LIBUSB_H
+        LIST_FOR_EACH_ENTRY( instance, &Devices, struct DeviceInstance, entry )
+        {
+            if (instance->dev && instance->dev != inst->dev &&
+                libusb_get_bus_number( instance->dev ) == bus_number &&
+                ++index == conn_info->ConnectionIndex)
+            {
+                struct libusb_device_descriptor desc;
+
+                if (libusb_get_device_descriptor( instance->dev, &desc ))
+                    break;
+                memcpy( &conn_info->DeviceDescriptor, &desc,
+                        sizeof(USB_DEVICE_DESCRIPTOR) );
+                conn_info->ConnectionStatus = 1;
+                break;
+            }
+        }
+#else
+        for (dev = inst->dev->next; dev; dev = dev->next)
+            if (++index == conn_info->ConnectionIndex)
+            {
+                memcpy( &conn_info->DeviceDescriptor, &dev->descriptor,
+                        sizeof(USB_DEVICE_DESCRIPTOR) );
+                conn_info->ConnectionStatus = 1;
+                break;
+            }
+#endif
+        status = STATUS_SUCCESS;
+        info = sizeof(*conn_info);
+        break;
+    }
     default:
         FIXME( "IOCTL %08x is not implemented\n",
                 irpsp->Parameters.DeviceIoControl.IoControlCode );
diff --git a/include/ddk/usbioctl.h b/include/ddk/usbioctl.h
index e2b914d..5083491 100644
--- a/include/ddk/usbioctl.h
+++ b/include/ddk/usbioctl.h
@@ -22,7 +22,8 @@
 #include <ddk/usb100.h>
 #include <ddk/usbiodef.h>
 
-#define IOCTL_USB_GET_NODE_INFORMATION CTL_CODE(FILE_DEVICE_USB, USB_GET_NODE_INFORMATION, METHOD_BUFFERED, FILE_ANY_ACCESS)
+#define IOCTL_USB_GET_NODE_INFORMATION            CTL_CODE(FILE_DEVICE_USB, USB_GET_NODE_INFORMATION, METHOD_BUFFERED, FILE_ANY_ACCESS)
+#define IOCTL_USB_GET_NODE_CONNECTION_INFORMATION CTL_CODE(FILE_DEVICE_USB, USB_GET_NODE_CONNECTION_INFORMATION, METHOD_BUFFERED, FILE_ANY_ACCESS)
 
 #include <pshpack1.h>
 
@@ -48,6 +49,35 @@ typedef struct _USB_NODE_INFORMATION {
     } u;
 } USB_NODE_INFORMATION, *PUSB_NODE_INFORMATION;
 
+typedef struct _USB_PIPE_INFO {
+    USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
+    ULONG ScheduleOffset;
+} USB_PIPE_INFO, *PUSB_PIPE_INFO;
+
+typedef enum _USB_CONNECTION_STATUS {
+    NoDeviceConnected,
+    DeviceConnected,
+    DeviceFailedEnumeration,
+    DeviceGeneralFailure,
+    DeviceCausedOvercurrent,
+    DeviceNotEnoughPower,
+    DeviceNotEnoughBandwidth,
+    DeviceHubNestedTooDeeply,
+    DeviceInLegacyHub
+} USB_CONNECTION_STATUS, *PUSB_CONNECTION_STATUS;
+
+typedef struct _USB_NODE_CONNECTION_INFORMATION {
+    ULONG ConnectionIndex;
+    USB_DEVICE_DESCRIPTOR DeviceDescriptor;
+    UCHAR CurrentConfigurationValue;
+    BOOLEAN LowSpeed;
+    BOOLEAN DeviceIsHub;
+    USHORT DeviceAddress;
+    ULONG NumberOfOpenPipes;
+    USB_CONNECTION_STATUS ConnectionStatus;
+    USB_PIPE_INFO PipeList[0];
+} USB_NODE_CONNECTION_INFORMATION, *PUSB_NODE_CONNECTION_INFORMATION;
+
 #include <poppack.h>
 
 #endif  /* __USBIOCTL_H__ */
diff --git a/include/ddk/usbiodef.h b/include/ddk/usbiodef.h
index bc4b4da..67d6e7a 100644
--- a/include/ddk/usbiodef.h
+++ b/include/ddk/usbiodef.h
@@ -21,7 +21,8 @@
 
 #define USB_SUBMIT_URB           0
 
-#define USB_GET_NODE_INFORMATION 258
+#define USB_GET_NODE_INFORMATION            258
+#define USB_GET_NODE_CONNECTION_INFORMATION 259
 
 DEFINE_GUID( GUID_DEVINTERFACE_USB_HUB,
   0xF18A0E88, 0xC30C, 0x11D0, 0x88, 0x15, 0x00, 0xA0, 0xC9, 0x06, 0xBE, 0xD8 );
-- 
1.6.3.1



Подробная информация о списке рассылки Wine-patches