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=63480f62a9a5257f01afc32b9362de7ee36ec6cb;hp=c3a9c734b88a8b42efe9ab48f53e73d065dc50db;hb=a9292c1363437b081ea72fd8f3b2ed075e2a7ef3;hpb=a2d111ed2563fb02fdd9a4cc08047ef4d1c58b35 diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c index c3a9c734b8..63480f62a9 100644 --- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c +++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c @@ -45,8 +45,6 @@ EFI_DRIVER_BINDING_PROTOCOL mUsbBusDriverBinding = { NULL }; -UINT16 mMaxUsbDeviceNum = USB_MAX_DEVICES; - /** USB_IO function to execute a control transfer. This function will execute the USB transfer. If transfer @@ -112,7 +110,7 @@ UsbIoControlTransfer ( // Clear TT buffer when CTRL/BULK split transaction failes // Clear the TRANSLATOR TT buffer, not parent's buffer // - ASSERT (Dev->Translator.TranslatorHubAddress < mMaxUsbDeviceNum); + ASSERT (Dev->Translator.TranslatorHubAddress < Dev->Bus->MaxDevices); if (Dev->Translator.TranslatorHubAddress != 0) { UsbHubCtrlClearTTBuffer ( Dev->Bus->Devices[Dev->Translator.TranslatorHubAddress], @@ -285,7 +283,7 @@ UsbIoBulkTransfer ( // Clear TT buffer when CTRL/BULK split transaction failes. // Clear the TRANSLATOR TT buffer, not parent's buffer // - ASSERT (Dev->Translator.TranslatorHubAddress < mMaxUsbDeviceNum); + ASSERT (Dev->Translator.TranslatorHubAddress < Dev->Bus->MaxDevices); if (Dev->Translator.TranslatorHubAddress != 0) { UsbHubCtrlClearTTBuffer ( Dev->Bus->Devices[Dev->Translator.TranslatorHubAddress], @@ -913,8 +911,9 @@ UsbBusBuildProtocol ( return EFI_OUT_OF_RESOURCES; } - UsbBus->Signature = USB_BUS_SIGNATURE; - UsbBus->HostHandle = Controller; + UsbBus->Signature = USB_BUS_SIGNATURE; + UsbBus->HostHandle = Controller; + UsbBus->MaxDevices = USB_MAX_DEVICES; Status = gBS->OpenProtocol ( Controller, @@ -966,12 +965,12 @@ UsbBusBuildProtocol ( } if (!EFI_ERROR (Status)) { + // + // The EFI_USB2_HC_PROTOCOL is produced for XHCI support. + // Then its max supported devices are 256. Otherwise it's 128. + // if (UsbBus->Usb2Hc->MajorRevision == 0x3) { - // - // The EFI_USB2_HC_PROTOCOL is produced for XHCI support. - // Then its max supported devices are 256. - // - mMaxUsbDeviceNum = 256; + UsbBus->MaxDevices = 256; } } @@ -1444,7 +1443,8 @@ UsbBusControllerDriverStop ( mUsbRootHubApi.Release (RootIf); - for (Index = 1; Index < mMaxUsbDeviceNum; Index++) { + ASSERT (Bus->MaxDevices <= 256); + for (Index = 1; Index < Bus->MaxDevices; Index++) { if (Bus->Devices[Index] != NULL) { UsbRemoveDevice (Bus->Devices[Index]); }