]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiPayloadPkg: Add Serial IO device path according to related protocol
authorLiu, Zhiguang <Zhiguang.Liu@intel.com>
Thu, 12 May 2022 10:54:58 +0000 (18:54 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 13 May 2022 01:47:11 +0000 (01:47 +0000)
Current code follow some rules to check if the PCI device connected to a
serial port device, but some platform or hardware doesn't follow such rule.
By locating gEfiSerialIoProtocolGuid protocol, we can find the related
device path.

Reviewed-by: Guo Dong <guo.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.c
UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.h

index 80390e0d98e83173f5c77dc00258c546d838b3a5..acf2880d2265334c9b9b10fe4eb0ac2fb3b94217 100644 (file)
@@ -60,6 +60,7 @@
   gEfiDxeSmmReadyToLockProtocolGuid\r
   gEfiSmmAccess2ProtocolGuid\r
   gUniversalPayloadPlatformBootManagerOverrideProtocolGuid\r
+  gEfiSerialIoProtocolGuid\r
 \r
 [Pcd]\r
   gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut\r
index 75aafebccd03f0f297b88a44d92f8bff0650d302..5aece6636f6557a9358293fd9f5b0330def29d01 100644 (file)
@@ -47,36 +47,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #define gPnpPs2Keyboard \\r
   PNPID_DEVICE_PATH_NODE(0x0303)\r
 \r
-#define gUartVendor \\r
-  { \\r
-    { \\r
-      HARDWARE_DEVICE_PATH, \\r
-      HW_VENDOR_DP, \\r
-      { \\r
-        (UINT8) (sizeof (VENDOR_DEVICE_PATH)), \\r
-        (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \\r
-      } \\r
-    }, \\r
-    EDKII_SERIAL_PORT_LIB_VENDOR_GUID \\r
-  }\r
-\r
-#define gUart \\r
-  { \\r
-    { \\r
-      MESSAGING_DEVICE_PATH, \\r
-      MSG_UART_DP, \\r
-      { \\r
-        (UINT8) (sizeof (UART_DEVICE_PATH)), \\r
-        (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8) \\r
-      } \\r
-    }, \\r
-    0, \\r
-    115200, \\r
-    8, \\r
-    1, \\r
-    1 \\r
-  }\r
-\r
 #define gPcAnsiTerminal \\r
   { \\r
     { \\r
@@ -92,9 +62,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 \r
 ACPI_HID_DEVICE_PATH  gPnpPs2KeyboardDeviceNode  = gPnpPs2Keyboard;\r
 ACPI_HID_DEVICE_PATH  gPnp16550ComPortDeviceNode = gPnp16550ComPort;\r
-UART_DEVICE_PATH      gUartDeviceNode            = gUart;\r
 VENDOR_DEVICE_PATH    gTerminalTypeDeviceNode    = gPcAnsiTerminal;\r
-VENDOR_DEVICE_PATH    gUartDeviceVendorNode      = gUartVendor;\r
 \r
 //\r
 // Predefined platform root bridge\r
@@ -112,13 +80,11 @@ EFI_DEVICE_PATH_PROTOCOL  *gPlatformRootBridges[] = {
 BOOLEAN  mDetectDisplayOnly;\r
 \r
 /**\r
-  Add IsaKeyboard to ConIn; add IsaSerial to ConOut, ConIn, ErrOut.\r
+  Add IsaKeyboard to ConIn.\r
 \r
   @param[in] DeviceHandle  Handle of the LPC Bridge device.\r
 \r
-  @retval EFI_SUCCESS  Console devices on the LPC bridge have been added to\r
-                       ConOut, ConIn, and ErrOut.\r
-\r
+  @retval EFI_SUCCESS  IsaKeyboard on the LPC bridge have been added to ConIn.\r
   @return              Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing\r
                        from DeviceHandle.\r
 **/\r
@@ -129,7 +95,6 @@ PrepareLpcBridgeDevicePath (
 {\r
   EFI_STATUS                Status;\r
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;\r
 \r
   DevicePath = NULL;\r
   Status     = gBS->HandleProtocol (\r
@@ -141,26 +106,11 @@ PrepareLpcBridgeDevicePath (
     return Status;\r
   }\r
 \r
-  TempDevicePath = DevicePath;\r
-\r
   //\r
   // Register Keyboard\r
   //\r
   DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnpPs2KeyboardDeviceNode);\r
   EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);\r
-\r
-  //\r
-  // Register COM1\r
-  //\r
-  DevicePath = TempDevicePath;\r
-  DevicePath = AppendDevicePathNode ((EFI_DEVICE_PATH_PROTOCOL *)NULL, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceVendorNode);\r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
-\r
-  EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);\r
-  EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);\r
-  EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);\r
-\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -291,43 +241,6 @@ PreparePciVgaDevicePath (
   return EFI_SUCCESS;\r
 }\r
 \r
-/**\r
-  Add PCI Serial to ConOut, ConIn, ErrOut.\r
-\r
-  @param[in]  DeviceHandle - Handle of PciIo protocol.\r
-\r
-  @retval EFI_SUCCESS  - PCI Serial is added to ConOut, ConIn, and ErrOut.\r
-  @retval EFI_STATUS   - No PCI Serial device is added.\r
-\r
-**/\r
-EFI_STATUS\r
-PreparePciSerialDevicePath (\r
-  IN EFI_HANDLE  DeviceHandle\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-\r
-  DevicePath = NULL;\r
-  Status     = gBS->HandleProtocol (\r
-                      DeviceHandle,\r
-                      &gEfiDevicePathProtocolGuid,\r
-                      (VOID *)&DevicePath\r
-                      );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
-\r
-  EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);\r
-  EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);\r
-  EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
 /**\r
   For every PCI instance execute a callback function.\r
 \r
@@ -447,18 +360,6 @@ DetectAndPreparePlatformPciDevicePath (
       PrepareLpcBridgeDevicePath (Handle);\r
       return EFI_SUCCESS;\r
     }\r
-\r
-    //\r
-    // Here we decide which Serial device to enable in PCI bus\r
-    //\r
-    if (IS_PCI_16550SERIAL (&Pci)) {\r
-      //\r
-      // Add them to ConOut, ConIn, ErrOut.\r
-      //\r
-      DEBUG ((DEBUG_INFO, "Found PCI 16550 SERIAL device\n"));\r
-      PreparePciSerialDevicePath (Handle);\r
-      return EFI_SUCCESS;\r
-    }\r
   }\r
 \r
   //\r
@@ -476,6 +377,39 @@ DetectAndPreparePlatformPciDevicePath (
   return Status;\r
 }\r
 \r
+/**\r
+  For every Serial Io instance, add it to ConOut, ConIn, ErrOut.\r
+\r
+  @param[in]  Handle     - The Serial Io device handle\r
+  @param[in]  Instance   - The instance of the SerialIo protocol\r
+\r
+  @retval EFI_STATUS - Callback function failed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AddDevicePathForOneSerialIoInstance (\r
+  IN EFI_HANDLE  Handle,\r
+  IN VOID        *Instance\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+\r
+  DevicePath = NULL;\r
+  Status     = gBS->HandleProtocol (\r
+                      Handle,\r
+                      &gEfiDevicePathProtocolGuid,\r
+                      (VOID *)&DevicePath\r
+                      );\r
+  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
+\r
+  EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);\r
+  EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);\r
+  EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);\r
+  return Status;\r
+}\r
+\r
 /**\r
   Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut\r
 \r
@@ -500,6 +434,11 @@ DetectAndPreparePlatformPciDevicePaths (
     NULL\r
     );\r
 \r
+  VisitAllInstancesOfProtocol (\r
+    &gEfiSerialIoProtocolGuid,\r
+    AddDevicePathForOneSerialIoInstance\r
+    );\r
+\r
   Status = VisitAllInstancesOfProtocol (\r
              &gEfiPciIoProtocolGuid,\r
              DetectAndPreparePlatformPciDevicePath\r
@@ -552,11 +491,6 @@ PlatformConsoleInit (
   VOID\r
   )\r
 {\r
-  gUartDeviceNode.BaudRate = PcdGet64 (PcdUartDefaultBaudRate);\r
-  gUartDeviceNode.DataBits = PcdGet8 (PcdUartDefaultDataBits);\r
-  gUartDeviceNode.Parity   = PcdGet8 (PcdUartDefaultParity);\r
-  gUartDeviceNode.StopBits = PcdGet8 (PcdUartDefaultStopBits);\r
-\r
   ConnectRootBridge ();\r
 \r
   //\r
index 3713c21c45137a6a21a8b053ef9dd1244273dc4e..6889c897ad173b188df03e73691bcd3c1a262991 100644 (file)
@@ -21,7 +21,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Protocol/PciIo.h>\r
 \r
 #define IS_PCI_ISA_PDECODE(_p)  IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0)\r
-#define IS_PCI_16550SERIAL(_p)  IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550)\r
 \r
 //\r
 // Type definitions\r