]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/PlatformBootManagerLib: connect non-discoverable USB hosts
authorArd Biesheuvel <ard.biesheuvel@arm.com>
Fri, 22 May 2020 08:40:06 +0000 (10:40 +0200)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sat, 6 Jun 2020 07:49:42 +0000 (07:49 +0000)
The way the BDS handles the short-form USB device path of the console
keyboard relies on USB host controllers to be locatable via their PCI
metadata, which implies that these controllers already have a PCI I/O
protocol installed on their handle.

This is not the case for non-discoverable USB host controllers that are
supported by the NonDiscoverable PCI device driver. These controllers
must be connected first, or the BDS will never notice their existence,
and will not enable any USB keyboards connected through them.

Let's work around this by connecting these handles explicitly. This is
a bit of a stopgap, but it is the cleanest way of dealing with this
without violating the UEFI driver model entirely. This ensures that
platforms that do not rely on ConnectAll() will keep working as
expected.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c
ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf

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
index 87c9b1150c5408c7c64871d42ad9234607a00236..2f726d117d7dfb90b0c6f1e71d6b31f4d1bd02dc 100644 (file)
@@ -66,6 +66,9 @@
   gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut\r
 \r
 [Guids]\r
+  gEdkiiNonDiscoverableEhciDeviceGuid\r
+  gEdkiiNonDiscoverableUhciDeviceGuid\r
+  gEdkiiNonDiscoverableXhciDeviceGuid\r
   gEfiFileInfoGuid\r
   gEfiFileSystemInfoGuid\r
   gEfiFileSystemVolumeLabelInfoIdGuid\r
@@ -74,6 +77,7 @@
   gUefiShellFileGuid\r
 \r
 [Protocols]\r
+  gEdkiiNonDiscoverableDeviceProtocolGuid\r
   gEfiDevicePathProtocolGuid\r
   gEfiGraphicsOutputProtocolGuid\r
   gEfiLoadedImageProtocolGuid\r