X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FBus%2FUsb%2FUsbBusDxe%2FUsbBus.c;fp=MdeModulePkg%2FBus%2FUsb%2FUsbBusDxe%2FUsbBus.c;h=b592913bd3b2e80bc0a51437dcfbd7cb13cf3dc3;hp=64aa9d954592ef429106a35de7bca99b63a4deca;hb=92870c983c6d99d31f449d8dcd729090255dda49;hpb=da910a42c0421a9895898537026276acf0935099 diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c index 64aa9d9545..b592913bd3 100644 --- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c +++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c @@ -45,6 +45,7 @@ EFI_DRIVER_BINDING_PROTOCOL mUsbBusDriverBinding = { NULL }; +UINT16 mMaxUsbDeviceNum = USB_MAX_DEVICES; /** USB_IO function to execute a control transfer. This @@ -111,7 +112,7 @@ UsbIoControlTransfer ( // Clear TT buffer when CTRL/BULK split transaction failes // Clear the TRANSLATOR TT buffer, not parent's buffer // - ASSERT (Dev->Translator.TranslatorHubAddress < USB_MAX_DEVICES); + ASSERT (Dev->Translator.TranslatorHubAddress < mMaxUsbDeviceNum); if (Dev->Translator.TranslatorHubAddress != 0) { UsbHubCtrlClearTTBuffer ( Dev->Bus->Devices[Dev->Translator.TranslatorHubAddress], @@ -284,7 +285,7 @@ UsbIoBulkTransfer ( // Clear TT buffer when CTRL/BULK split transaction failes. // Clear the TRANSLATOR TT buffer, not parent's buffer // - ASSERT (Dev->Translator.TranslatorHubAddress < USB_MAX_DEVICES); + ASSERT (Dev->Translator.TranslatorHubAddress < mMaxUsbDeviceNum); if (Dev->Translator.TranslatorHubAddress != 0) { UsbHubCtrlClearTTBuffer ( Dev->Bus->Devices[Dev->Translator.TranslatorHubAddress], @@ -966,6 +967,16 @@ UsbBusBuildProtocol ( goto CLOSE_HC; } + if (!EFI_ERROR (Status)) { + if (UsbBus->Usb2Hc->MajorRevision == 0x3) { + // + // The EFI_USB2_HC_PROTOCOL is produced for XHCI support. + // Then its max supported devices are 256. + // + mMaxUsbDeviceNum = 256; + } + } + UsbHcReset (UsbBus, EFI_USB_HC_RESET_GLOBAL); UsbHcSetState (UsbBus, EfiUsbHcStateOperational); @@ -1011,6 +1022,7 @@ UsbBusBuildProtocol ( RootHub->Bus = UsbBus; RootHub->NumOfInterface = 1; RootHub->Interfaces[0] = RootIf; + RootHub->Tier = 0; RootIf->Signature = USB_INTERFACE_SIGNATURE; RootIf->Device = RootHub; RootIf->DevicePath = UsbBus->DevicePath; @@ -1434,7 +1446,7 @@ UsbBusControllerDriverStop ( mUsbRootHubApi.Release (RootIf); - for (Index = 1; Index < USB_MAX_DEVICES; Index++) { + for (Index = 1; Index < mMaxUsbDeviceNum; Index++) { if (Bus->Devices[Index] != NULL) { UsbRemoveDevice (Bus->Devices[Index]); }