Allow more than one USB controller (was a XBOX hack no more needed)
authorHervé Poussineau <hpoussin@reactos.org>
Fri, 4 Nov 2005 20:24:44 +0000 (20:24 +0000)
committerHervé Poussineau <hpoussin@reactos.org>
Fri, 4 Nov 2005 20:24:44 +0000 (20:24 +0000)
Implement IRP_MJ_PNP/IRP_MN_QUERY_DEVICE_TEXT for Root USB hub/USB devices
Add missing initialization which lead to BSOD when connecting a device to a UHCI controller

svn path=/trunk/; revision=19003

reactos/drivers/usb/miniport/common/main.c
reactos/drivers/usb/miniport/common/pdo.c
reactos/drivers/usb/miniport/usb_wrapper.h
reactos/drivers/usb/miniport/usbuhci/uhci.c
reactos/drivers/usb/usbhub/pdo.c

index 38efc99..88785c7 100644 (file)
@@ -199,16 +199,6 @@ AddDevice(
        PUSBMP_DEVICE_EXTENSION DeviceExtension;
        ULONG DeviceNumber;
 
-       /* FIXME: actually, we prevent multiple USB controllers on a computer */
-       static BOOLEAN xbox_workaround = FALSE;
-
-       DPRINT("USBMP: AddDevice called\n");
-       
-       if (xbox_workaround)
-               // Fail for any other host controller than the first
-               return STATUS_INSUFFICIENT_RESOURCES;
-       xbox_workaround = TRUE;
-
        // Allocate driver extension now
        DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
        if (DriverExtension == NULL)
index 10e3beb..4e39430 100644 (file)
@@ -286,37 +286,20 @@ UsbMpPnpPdo(
                        Status = Irp->IoStatus.Status;
                        break;
                }
-#if 0 /* FIXME */
                case IRP_MN_QUERY_DEVICE_TEXT: /* 0x0c */
                {
                        switch (Stack->Parameters.QueryDeviceText.DeviceTextType)
                        {
                                case DeviceTextDescription:
                                {
-                                       ULONG DescriptionSize;
-                                       PWSTR Description;
+                                       UNICODE_STRING SourceString = RTL_CONSTANT_STRING(L"Root USB hub");
+                                       UNICODE_STRING Description;
+                                       
                                        DPRINT("USBMP: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / DeviceTextDescription\n");
                                        
-                                       Status = IoGetDeviceProperty(
-                                               DeviceObject,
-                                               DevicePropertyDeviceDescription,
-                                               0, NULL,
-                                               &DescriptionSize);
-                                       if (Status == STATUS_BUFFER_TOO_SMALL)
-                                       {
-                                               Description = ExAllocatePool(PagedPool, DescriptionSize);
-                                               if (!Description)
-                                                       Status = STATUS_INSUFFICIENT_RESOURCES;
-                                               else
-                                               {
-                                                       Status = IoGetDeviceProperty(
-                                                               DeviceObject,
-                                                               DevicePropertyDeviceDescription,
-                                                               DescriptionSize, Description,
-                                                               &DescriptionSize);
-                                                       Information = DescriptionSize;
-                                               }
-                                       }
+                                       Status = RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, &SourceString, &Description);
+                                       if (NT_SUCCESS(Status))
+                                               Information = (ULONG_PTR)Description.Buffer;
                                        break;
                                }
                                case DeviceTextLocationInformation:
@@ -337,7 +320,6 @@ UsbMpPnpPdo(
                        }
                        break;
                }
-#endif
                case IRP_MN_QUERY_ID: /* 0x13 */
                {
                        Status = UsbMpPdoQueryId(DeviceObject, Irp, &Information);
index 75b56fd..b4b028b 100644 (file)
@@ -7,7 +7,7 @@
         Lots of definitions should go to corresponding files
 */
 
-#include <ddk/ntddk.h>
+#include <ddk/ntifs.h>
 #include <ddk/kbdmou.h>
 #include <debug.h>
 
index 9e21b6f..9c3c3d7 100644 (file)
@@ -26,6 +26,7 @@ InitLinuxWrapper(PDEVICE_OBJECT DeviceObject)
        /* Initialize generic linux structure */
        dev->irq = DeviceExtension->InterruptVector;
        dev->dev_ext = (PVOID)DeviceExtension;
+       dev->dev.dev_ext = (PVOID)DeviceExtension;
        dev->slot_name = ExAllocatePoolWithTag(NonPagedPool, 128, USB_UHCI_TAG); // 128 max len for slot name
        init_wrapper(dev);
        
@@ -48,10 +49,6 @@ InitLinuxWrapper(PDEVICE_OBJECT DeviceObject)
        /* Probe device with real id now */
        uhci_pci_driver.probe(dev, uhci_pci_ids);
 
-//     DPRINT1("UHCI :SysIoBusNumA %d\n",DeviceExtension->SystemIoBusNumber);
-//     DeviceExtension->SystemIoBusNumber = dev->bus->number;
-//     DPRINT1("UHCI: SysIoBusNumB %d\n",DeviceExtension->SystemIoBusNumber);
-
        return Status; 
 }
 
index 79f6a59..1339412 100644 (file)
@@ -149,11 +149,7 @@ UsbhubPdoQueryDeviceText(
 
        switch (DeviceTextType)
        {
-               /*case DeviceTextDescription:
-               {
-                       DPRINT1("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / DeviceTextDescription\n");
-                       return STATUS_NOT_IMPLEMENTED;
-               }*/
+               case DeviceTextDescription:
                case DeviceTextLocationInformation:
                {
                        unsigned short size;
@@ -161,7 +157,11 @@ UsbhubPdoQueryDeviceText(
                        PWCHAR buf;
                        PWCHAR bufret;
 
-                       DPRINT("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / DeviceTextLocationInformation\n");
+                       if (DeviceTextType == DeviceTextDescription)
+                               DPRINT("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / DeviceTextDescription\n");
+                       else
+                               DPRINT("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / DeviceTextLocationInformation\n");
+                       
                        if (!DeviceExtension->dev->descriptor.iProduct)
                                return STATUS_NOT_SUPPORTED;