From 68430f1260e04a9fa59ccd1f14876ebdafa2634b Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Sat, 1 Jul 2017 06:06:12 +0000 Subject: [PATCH] [USBPORT] Patch by Vadim Galyant: - Add USBPORT_HUB_CHARACTERISTICS structure - Indicate the USB3 hub descriptor type when the miniport is an XHCI controller svn path=/trunk/; revision=75253 --- reactos/drivers/usb/usbport/roothub.c | 22 ++++++++- .../reactos/drivers/usbport/usbmport.h | 47 ++++++++++++++++++- 2 files changed, 66 insertions(+), 3 deletions(-) diff --git a/reactos/drivers/usb/usbport/roothub.c b/reactos/drivers/usb/usbport/roothub.c index 59f32c05d82..e5057c5f916 100644 --- a/reactos/drivers/usb/usbport/roothub.c +++ b/reactos/drivers/usb/usbport/roothub.c @@ -853,9 +853,27 @@ USBPORT_RootHubCreateDevice(IN PDEVICE_OBJECT FdoDevice, RH_HubDescriptor = &PdoExtension->RootHubDescriptors->Descriptor; RH_HubDescriptor->bDescriptorLength = sizeof(USB_HUB_DESCRIPTOR) + 2 * NumMaskByte; - RH_HubDescriptor->bDescriptorType = 0x29; // USB_20_HUB_DESCRIPTOR_TYPE - need add in .h file + + if (Packet->MiniPortVersion == USB_MINIPORT_VERSION_OHCI || + Packet->MiniPortVersion == USB_MINIPORT_VERSION_UHCI || + Packet->MiniPortVersion == USB_MINIPORT_VERSION_EHCI) + { + RH_HubDescriptor->bDescriptorType = 0x29; // #define USB_20_HUB_DESCRIPTOR_TYPE 0x29 - need add in .h file + } + else if (Packet->MiniPortVersion == USB_MINIPORT_VERSION_XHCI) + { + RH_HubDescriptor->bDescriptorType = 0x2A; // #define USB_30_HUB_DESCRIPTOR_TYPE 0x2A - need add in .h file + } + else + { + DPRINT1("USBPORT_RootHubCreateDevice: Unknown MiniPortVersion - %x\n", + Packet->MiniPortVersion); + + DbgBreakPoint(); + } + RH_HubDescriptor->bNumberOfPorts = RootHubData.NumberOfPorts; - RH_HubDescriptor->wHubCharacteristics = RootHubData.HubCharacteristics; + RH_HubDescriptor->wHubCharacteristics = RootHubData.HubCharacteristics.AsUSHORT; RH_HubDescriptor->bPowerOnToPowerGood = RootHubData.PowerOnToPowerGood; RH_HubDescriptor->bHubControlCurrent = RootHubData.HubControlCurrent; diff --git a/reactos/sdk/include/reactos/drivers/usbport/usbmport.h b/reactos/sdk/include/reactos/drivers/usbport/usbmport.h index 5b25b31b03a..ba45c1505bd 100644 --- a/reactos/sdk/include/reactos/drivers/usbport/usbmport.h +++ b/reactos/sdk/include/reactos/drivers/usbport/usbmport.h @@ -453,6 +453,7 @@ typedef VOID #define USB_MINIPORT_VERSION_OHCI 0x01 #define USB_MINIPORT_VERSION_UHCI 0x02 #define USB_MINIPORT_VERSION_EHCI 0x03 +#define USB_MINIPORT_VERSION_XHCI 0x04 #define USB_MINIPORT_FLAGS_INTERRUPT 0x0001 #define USB_MINIPORT_FLAGS_PORT_IO 0x0002 @@ -625,9 +626,53 @@ typedef struct _USBPORT_TRANSFER_PARAMETERS { C_ASSERT(sizeof(USBPORT_TRANSFER_PARAMETERS) == 28); +/* For USB1.1 or USB3 Hub Descriptors */ +typedef union _USBPORT_HUB_11_CHARACTERISTICS { + struct { + USHORT PowerControlMode :1; + USHORT NoPowerSwitching :1; // Reserved. Used only on 1.0 compliant hubs that implement no power switching. + USHORT PartOfCompoundDevice :1; + USHORT OverCurrentProtectionMode :1; + USHORT NoOverCurrentProtection :1; + USHORT Reserved1 :11; + }; + USHORT AsUSHORT; +} USBPORT_HUB_11_CHARACTERISTICS; + +C_ASSERT(sizeof(USBPORT_HUB_11_CHARACTERISTICS) == sizeof(USHORT)); + +/* For USB2.0 Hub Descriptors */ +typedef union _USBPORT_HUB_20_CHARACTERISTICS { + struct { + USHORT PowerControlMode :1; + USHORT NoPowerSwitching :1; // Reserved. Used only on 1.0 compliant hubs that implement no power switching. + USHORT PartOfCompoundDevice :1; + USHORT OverCurrentProtectionMode :1; + USHORT NoOverCurrentProtection :1; + USHORT TtThinkTime :2; + USHORT PortIndicatorsSupported :1; + USHORT Reserved1 :8; + }; + USHORT AsUSHORT; +} USBPORT_HUB_20_CHARACTERISTICS; + +C_ASSERT(sizeof(USBPORT_HUB_20_CHARACTERISTICS) == sizeof(USHORT)); + +typedef USBPORT_HUB_11_CHARACTERISTICS USBPORT_HUB_30_CHARACTERISTICS; + +typedef union _USBPORT_HUB_CHARACTERISTICS { + USHORT AsUSHORT; + USBPORT_HUB_11_CHARACTERISTICS Usb11HubCharacteristics; + USBPORT_HUB_20_CHARACTERISTICS Usb20HubCharacteristics; + USBPORT_HUB_30_CHARACTERISTICS Usb30HubCharacteristics; +} USBPORT_HUB_CHARACTERISTICS; + +C_ASSERT(sizeof(USBPORT_HUB_CHARACTERISTICS) == sizeof(USHORT)); + typedef struct _USBPORT_ROOT_HUB_DATA { ULONG NumberOfPorts; - ULONG HubCharacteristics; + USBPORT_HUB_CHARACTERISTICS HubCharacteristics; + USHORT Padded1; ULONG PowerOnToPowerGood; ULONG HubControlCurrent; } USBPORT_ROOT_HUB_DATA, *PUSBPORT_ROOT_HUB_DATA;