]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c
ArmPkg/PlatformBootManagerLib: connect non-discoverable USB hosts
[mirror_edk2.git] / ArmPkg / Library / PlatformBootManagerLib / PlatformBm.c
index 3411219fbfdb67a1cfe093efe329ff29e43f7ec8..4aca1382b042d366b63cffc8a09e6946d9ebc6fa 100644 (file)
 #include <Protocol/EsrtManagement.h>\r
 #include <Protocol/GraphicsOutput.h>\r
 #include <Protocol/LoadedImage.h>\r
+#include <Protocol/NonDiscoverableDevice.h>\r
 #include <Protocol/PciIo.h>\r
 #include <Protocol/PciRootBridgeIo.h>\r
 #include <Protocol/PlatformBootManager.h>\r
 #include <Guid/EventGroup.h>\r
+#include <Guid/NonDiscoverableDevice.h>\r
 #include <Guid/TtyTerm.h>\r
 #include <Guid/SerialPortLibVendor.h>\r
 \r
@@ -254,6 +256,37 @@ IsPciDisplay (
 }\r
 \r
 \r
+/**\r
+  This FILTER_FUNCTION checks if a handle corresponds to a non-discoverable\r
+  USB host controller.\r
+**/\r
+STATIC\r
+BOOLEAN\r
+EFIAPI\r
+IsUsbHost (\r
+  IN EFI_HANDLE   Handle,\r
+  IN CONST CHAR16 *ReportText\r
+  )\r
+{\r
+  NON_DISCOVERABLE_DEVICE   *Device;\r
+  EFI_STATUS                Status;\r
+\r
+  Status = gBS->HandleProtocol (Handle,\r
+                  &gEdkiiNonDiscoverableDeviceProtocolGuid,\r
+                  (VOID **)&Device);\r
+  if (EFI_ERROR (Status)) {\r
+    return FALSE;\r
+  }\r
+\r
+  if (CompareGuid (Device->Type, &gEdkiiNonDiscoverableUhciDeviceGuid) ||\r
+      CompareGuid (Device->Type, &gEdkiiNonDiscoverableEhciDeviceGuid) ||\r
+      CompareGuid (Device->Type, &gEdkiiNonDiscoverableXhciDeviceGuid)) {\r
+    return TRUE;\r
+  }\r
+  return FALSE;\r
+}\r
+\r
+\r
 /**\r
   This CALLBACK_FUNCTION attempts to connect a handle non-recursively, asking\r
   the matching driver to produce all first-level child handles.\r
@@ -574,6 +607,15 @@ PlatformBootManagerBeforeConsole (
   //\r
   FilterAndProcess (&gEfiGraphicsOutputProtocolGuid, NULL, AddOutput);\r
 \r
+  //\r
+  // The core BDS code connects short-form USB device paths by explicitly\r
+  // looking for handles with PCI I/O installed, and checking the PCI class\r
+  // code whether it matches the one for a USB host controller. This means\r
+  // non-discoverable USB host controllers need to have the non-discoverable\r
+  // PCI driver attached first.\r
+  //\r
+  FilterAndProcess (&gEdkiiNonDiscoverableDeviceProtocolGuid, IsUsbHost, Connect);\r
+\r
   //\r
   // Add the hardcoded short-form USB keyboard device path to ConIn.\r
   //\r