Implement IRP_MN_QUERY_CAPABILITIES, IRP_MN_QUERY_RESOURCES, IRP_MN_QUERY_RESOURCE_RE...
authorHervé Poussineau <hpoussin@reactos.org>
Mon, 19 Sep 2005 10:04:07 +0000 (10:04 +0000)
committerHervé Poussineau <hpoussin@reactos.org>
Mon, 19 Sep 2005 10:04:07 +0000 (10:04 +0000)
Fix DeviceID and HardwareIDs identifiers returned for root hub (Vendor and Product IDs are still not initialized by Cromwell code)
Fix handling of removal IRPs for USB controller

svn path=/trunk/; revision=17930

reactos/bootdata/hivesys.inf
reactos/drivers/usb/miniport/common/fdo.c
reactos/drivers/usb/miniport/common/pdo.c
reactos/drivers/usb/usbhub/pdo.c
reactos/drivers/usb/usbport/usbport.def
reactos/media/inf/usbport.inf

index 497c490..d6fa598 100644 (file)
@@ -630,6 +630,7 @@ HKLM,"SYSTEM\CurrentControlSet\Services\usbhub","Tag",0x00010001,0x00000011
 HKLM,"SYSTEM\CurrentControlSet\Services\usbhub","DisplayName",0x00000000,"ReactOS USB HUB cromwell-type driver"
 ;hard coded values
 HKLM,"SYSTEM\CurrentControlSet\Enum\USB\ROOT_HUB\0000","Service",0x0000000,"usbhub"
+HKLM,"SYSTEM\CurrentControlSet\Enum\USB\ROOT_HUB20\0000","Service",0x0000000,"usbhub"
 
 ; ReactOS PCNet NIC driver 
 ; To use the AMD supplied driver change the driver name to pcntn5m.sys
index 14f68d0..936bf38 100644 (file)
@@ -190,7 +190,7 @@ UsbMpPnpFdo(
 
        switch (MinorFunction)
        {
-               case IRP_MN_START_DEVICE:
+               case IRP_MN_START_DEVICE: /* 0x00 */
                {
                        Status = ForwardIrpAndWait(DeviceObject, Irp);
                        if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
@@ -198,12 +198,15 @@ UsbMpPnpFdo(
                        break;
                }
 
-               case IRP_MN_REMOVE_DEVICE:
-               case IRP_MN_QUERY_REMOVE_DEVICE:
-               case IRP_MN_CANCEL_REMOVE_DEVICE:
-               case IRP_MN_SURPRISE_REMOVAL:
+               case IRP_MN_QUERY_REMOVE_DEVICE: /* 0x01 */
+               case IRP_MN_CANCEL_REMOVE_DEVICE: /* 0x03 */
+               {
+                       return ForwardIrpAndForget(DeviceObject, Irp);
+               }
 
-               case IRP_MN_STOP_DEVICE:
+               case IRP_MN_REMOVE_DEVICE: /* 0x02 */
+               case IRP_MN_STOP_DEVICE: /* 0x04 */
+               case IRP_MN_SURPRISE_REMOVAL: /* 0x17 */
                {
                        Status = ForwardIrpAndWait(DeviceObject, Irp);
                        if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
@@ -211,8 +214,9 @@ UsbMpPnpFdo(
                        IoDeleteDevice(DeviceObject); // just delete device for now
                        break;
                }
-               case IRP_MN_QUERY_STOP_DEVICE:
-               case IRP_MN_CANCEL_STOP_DEVICE:
+
+               case IRP_MN_QUERY_STOP_DEVICE: /* 0x05 */
+               case IRP_MN_CANCEL_STOP_DEVICE: /* 0x06 */
                {
                        Status = STATUS_SUCCESS;
                        break;
@@ -244,7 +248,7 @@ UsbMpPnpFdo(
 
                default:
                {
-                       DPRINT1("USBMP: unknown minor function 0x%lx\n", MinorFunction);
+                       DPRINT1("USBMP: IRP_MJ_PNP / unknown minor function 0x%lx\n", MinorFunction);
                        return ForwardIrpAndForget(DeviceObject, Irp);
                }
        }
index ca52d50..f4ee120 100644 (file)
@@ -80,36 +80,49 @@ UsbMpPdoQueryId(
        ULONG IdType;
        UNICODE_STRING SourceString;
        UNICODE_STRING String;
+       struct usb_device *roothub;
        NTSTATUS Status = STATUS_SUCCESS;
 
        IdType = IoGetCurrentIrpStackLocation(Irp)->Parameters.QueryId.IdType;
        DeviceExtension = (PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
        RtlInitUnicodeString(&String, NULL);
+       DeviceExtension = (PUSBMP_DEVICE_EXTENSION)DeviceExtension->FunctionalDeviceObject->DeviceExtension;
+       roothub = ((struct usb_hcd*)DeviceExtension->pdev->data)->self.root_hub;
 
        switch (IdType)
        {
                case BusQueryDeviceID:
                {
                        DPRINT("USBMP: IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryDeviceID\n");
-                       RtlInitUnicodeString(&SourceString, L"USB\\ROOT_HUB");
+                       if (roothub->speed == USB_SPEED_LOW || roothub->speed == USB_SPEED_FULL)
+                               RtlInitUnicodeString(&SourceString, L"USB\\ROOT_HUB"); /* USB 1.1 */
+                       else
+                               RtlInitUnicodeString(&SourceString, L"USB\\ROOT_HUB20"); /* USB 2.0 */
                        break;
                }
                case BusQueryHardwareIDs:
                {
-                       //CHAR Buffer[2][40];
+                       CHAR Buffer[2][40];
+                       PCHAR RootHubName;
+                       USHORT Vendor, Product, Revision;
+
                        DPRINT("USBMP: IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryHardwareIDs\n");
 
-                       /*FIXME: sprintf(Buffer[0], "USB\\VID%04X&PID%04X&REV%04X",
-                               VENDOR,
-                               PRODUCT,
-                               REV);
+                       Vendor = DeviceExtension->pdev->vendor;
+                       Product = DeviceExtension->pdev->device;
+                       Revision = 0; /* FIXME */
+
+                       sprintf(Buffer[0], "USB\\VID%04X&PID%04X&REV%04X",
+                               Vendor, Product, Revision);
                        sprintf(Buffer[1], "USB\\VID%04X&PID%04X",
-                               VENDOR,
-                               PRODUCT);
+                               Vendor, Product);
+                       if (roothub->speed == USB_SPEED_LOW || roothub->speed == USB_SPEED_FULL)
+                               RootHubName = "USB\\ROOT_HUB"; /* USB 1.1 */
+                       else
+                               RootHubName = "USB\\ROOT_HUB20"; /* USB 2.0 */
                        Status = UsbMpInitMultiSzString(
                                &SourceString,
-                               Buffer[0], Buffer[1], "USB\\ROOT_HUB", NULL);*/
-                       Status = UsbMpInitMultiSzString(&SourceString, "USB\\ROOT_HUB", NULL);
+                               Buffer[0], Buffer[1], RootHubName, NULL);
                        break;
                }
                case BusQueryCompatibleIDs:
index 22edfd9..fec7c37 100644 (file)
@@ -133,6 +133,61 @@ UsbhubPdoQueryId(
        return Status;
 }
 
+static NTSTATUS
+UsbhubPdoQueryDeviceText(
+       IN PDEVICE_OBJECT DeviceObject,
+       IN PIRP Irp,
+       OUT ULONG_PTR* Information)
+{
+       PHUB_DEVICE_EXTENSION DeviceExtension;
+       DEVICE_TEXT_TYPE DeviceTextType;
+       LCID LocaleId;
+
+       DeviceTextType = IoGetCurrentIrpStackLocation(Irp)->Parameters.QueryDeviceText.DeviceTextType;
+       LocaleId = IoGetCurrentIrpStackLocation(Irp)->Parameters.QueryDeviceText.LocaleId;
+       DeviceExtension = (PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+       switch (DeviceTextType)
+       {
+               /*case DeviceTextDescription:
+               {
+                       DPRINT1("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / DeviceTextDescription\n");
+                       return STATUS_NOT_IMPLEMENTED;
+               }*/
+               case DeviceTextLocationInformation:
+               {
+                       int size;
+                       char *buf;
+
+                       DPRINT("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / DeviceTextLocationInformation\n");
+                       if (!DeviceExtension->dev->descriptor.iProduct)
+                               return STATUS_NOT_SUPPORTED;
+
+                       size = usb_get_string(DeviceExtension->dev, LocaleId, DeviceExtension->dev->descriptor.iProduct, NULL, 0);
+                       if (size < 2)
+                       {
+                               DPRINT("Usbhub: usb_get_string() failed\n");
+                               return STATUS_IO_DEVICE_ERROR;
+                       }
+                       buf = ExAllocatePool(PagedPool, size);
+                       if (buf == NULL)
+                               return STATUS_INSUFFICIENT_RESOURCES;
+                       size = usb_get_string(DeviceExtension->dev, LocaleId, DeviceExtension->dev->descriptor.iProduct, buf, size);
+                       if (size < 0)
+                       {
+                               DPRINT("Usbhub: usb_get_string() failed\n");
+                               ExFreePool(buf);
+                               return STATUS_IO_DEVICE_ERROR;
+                       }
+                       *Information = (ULONG_PTR)buf;
+                       return STATUS_SUCCESS;
+               }
+               default:
+                       DPRINT1("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / unknown device text type 0x%lx\n", DeviceTextType);
+                       return STATUS_NOT_SUPPORTED;
+       }
+}
+
 NTSTATUS STDCALL
 UsbhubPnpPdo(
        IN PDEVICE_OBJECT DeviceObject,
@@ -154,6 +209,82 @@ UsbhubPnpPdo(
                        Status = UsbhubPdoStartDevice(DeviceObject, Irp);
                        break;
                }
+               case IRP_MN_QUERY_CAPABILITIES: /* 0x09 */
+               {
+                       PDEVICE_CAPABILITIES DeviceCapabilities;
+                       ULONG i;
+                       DPRINT("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_CAPABILITIES\n");
+
+                       DeviceCapabilities = (PDEVICE_CAPABILITIES)Stack->Parameters.DeviceCapabilities.Capabilities;
+                       /* FIXME: capabilities can change with connected device */
+                       DeviceCapabilities->LockSupported = TRUE;
+                       DeviceCapabilities->EjectSupported = FALSE;
+                       DeviceCapabilities->Removable = FALSE;
+                       DeviceCapabilities->DockDevice = FALSE;
+                       DeviceCapabilities->UniqueID = FALSE;
+                       DeviceCapabilities->SilentInstall = TRUE;
+                       DeviceCapabilities->RawDeviceOK = FALSE;
+                       DeviceCapabilities->SurpriseRemovalOK = FALSE;
+                       DeviceCapabilities->HardwareDisabled = FALSE; /* FIXME */
+                       //DeviceCapabilities->NoDisplayInUI = FALSE; /* FIXME */
+                       DeviceCapabilities->DeviceState[0] = PowerDeviceD0; /* FIXME */
+                       for (i = 0; i < PowerSystemMaximum; i++)
+                               DeviceCapabilities->DeviceState[i] = PowerDeviceD3; /* FIXME */
+                       //DeviceCapabilities->DeviceWake = PowerDeviceUndefined; /* FIXME */
+                       DeviceCapabilities->D1Latency = 0; /* FIXME */
+                       DeviceCapabilities->D2Latency = 0; /* FIXME */
+                       DeviceCapabilities->D3Latency = 0; /* FIXME */
+                       Status = STATUS_SUCCESS;
+                       break;
+               }
+               case IRP_MN_QUERY_RESOURCES: /* 0x0a */
+               {
+                       PCM_RESOURCE_LIST ResourceList;
+
+                       DPRINT("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_RESOURCES\n");
+                       ResourceList = ExAllocatePool(PagedPool, sizeof(CM_RESOURCE_LIST));
+                       if (!ResourceList)
+                       {
+                               DPRINT("Usbhub: ExAllocatePool() failed\n");
+                               Status = STATUS_INSUFFICIENT_RESOURCES;
+                       }
+                       else
+                       {
+                               ResourceList->Count = 0;
+                               Information = (ULONG_PTR)ResourceList;
+                               Status = STATUS_SUCCESS;
+                       }
+                       break;
+               }
+               case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: /* 0x0b */
+               {
+                       PIO_RESOURCE_REQUIREMENTS_LIST ResourceList;
+
+                       DPRINT("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n");
+                       ResourceList = ExAllocatePool(PagedPool, sizeof(IO_RESOURCE_REQUIREMENTS_LIST));
+                       if (!ResourceList)
+                       {
+                               DPRINT("Usbhub: ExAllocatePool() failed\n");
+                               Status = STATUS_INSUFFICIENT_RESOURCES;
+                       }
+                       else
+                       {
+                               RtlZeroMemory(ResourceList, sizeof(IO_RESOURCE_REQUIREMENTS_LIST));
+                               ResourceList->ListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST);
+                               ResourceList->AlternativeLists = 1;
+                               ResourceList->List->Version = 1;
+                               ResourceList->List->Revision = 1;
+                               ResourceList->List->Count = 0;
+                               Information = (ULONG_PTR)ResourceList;
+                               Status = STATUS_SUCCESS;
+                       }
+                       break;
+               }
+               case IRP_MN_QUERY_DEVICE_TEXT: /* 0x0c */
+               {
+                       Status = UsbhubPdoQueryDeviceText(DeviceObject, Irp, &Information);
+                       break;
+               }
                case IRP_MN_QUERY_ID: /* 0x13 */
                {
                        Status = UsbhubPdoQueryId(DeviceObject, Irp, &Information);
index 0c8e33f..c1ca326 100644 (file)
@@ -7,6 +7,7 @@ usb_exit@0
 usb_init_urb@4
 usb_alloc_urb@8
 usb_free_urb@4
+usb_get_string
 usb_get_urb@4
 usb_get_dev@4
 usb_submit_urb@8
index 420b1d4..06604d3 100644 (file)
@@ -31,6 +31,7 @@ HKR, , NoInstallClass, 0, 1
 %PCI\CC_0C0310.DeviceDesc%=OHCI_Inst,PCI\CC_0C0310\r
 %PCI\CC_0C0320.DeviceDesc%=EHCI_Inst,PCI\CC_0C0320\r
 %USB\ROOT_HUB.DeviceDesc%=RootHub_Inst,USB\ROOT_HUB\r
+%USB\ROOT_HUB.DeviceDesc%=RootHub_Inst,USB\ROOT_HUB20\r
 \r
 [IntelMfg]\r
 %PCI\VEN_8086&DEV_7112&CC_0C0300.DeviceDesc%=UHCI_Inst,PCI\VEN_8086&DEV_7112&CC_0C0300\r
@@ -41,7 +42,7 @@ HKR, , NoInstallClass, 0, 1
 CopyFiles = UHCI_CopyFiles\r
 \r
 [UHCI_CopyFiles.NT]\r
-usbcore.sys\r
+usbport.sys\r
 usbuhci.sys\r
 \r
 [UHCI_Inst.NT.Services]\r
@@ -60,7 +61,7 @@ LoadOrderGroup = Base
 CopyFiles = OHCI_CopyFiles\r
 \r
 [OHCI_CopyFiles.NT]\r
-usbcore.sys\r
+usbport.sys\r
 usbohci.sys\r
 \r
 [OHCI_Inst.NT.Services]\r
@@ -79,7 +80,7 @@ LoadOrderGroup = Base
 CopyFiles = EHCI_CopyFiles\r
 \r
 [EHCI_CopyFiles.NT]\r
-usbcore.sys\r
+usbport.sys\r
 usbehci.sys\r
 \r
 [EHCI_Inst.NT.Services]\r
@@ -98,6 +99,7 @@ LoadOrderGroup = Base
 CopyFiles = RootHub_CopyFiles\r
 \r
 [RootHub_CopyFiles.NT]\r
+usbport.sys\r
 usbhub.sys\r
 \r
 [RootHub_Inst.NT.Services]\r