From nobody Sat Feb 7 05:52:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+89638+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+89638+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1652166688; cv=none; d=zohomail.com; s=zohoarc; b=XHYDeTU6bcAQk7aMfTnpuak+8jJTl2OgsPW9pIqR7dmPWejihkbH5K9dylokyQjPXmV+EWe91QeZJ3xNQc4eLqKULiUv7d8p0O3qJEcQvrWqGQTMvIFkPJhmJXCM5FmUe7nKJ3c+K+NXNT2s5HvgfFlVOVSBCVhJ/2ELQAQIYU8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652166688; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=uMaK2AhqaVebCGxN9OYis3PSMFfTxybpgv6t4CmPEPA=; b=Ma1rHN1fma/UrgwFFIFUN2wk2Fk/HsCnJBHNjjG/gIoiMs61/JTAId9CJXgsIGK6ZqIPj0sM2AmY4OBsQpkwZ7xSzxnWXWiaPWC700zKmwoTF23ydCUTmEh6ng4sShZRBh2HSBVjO7rBZQIViQj1RkArt4/FqWhvjTwTSyX184Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+89638+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1652166688253246.67380446539505; Tue, 10 May 2022 00:11:28 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id WCt6YY1788612xXIspumej3a; Tue, 10 May 2022 00:11:27 -0700 X-Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web12.6679.1652166681383551366 for ; Tue, 10 May 2022 00:11:27 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10342"; a="268127951" X-IronPort-AV: E=Sophos;i="5.91,213,1647327600"; d="scan'208";a="268127951" X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2022 00:11:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,213,1647327600"; d="scan'208";a="696953457" X-Received: from shwdesfp01.ccr.corp.intel.com ([10.239.158.158]) by orsmga004.jf.intel.com with ESMTP; 10 May 2022 00:11:24 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Guo Dong , Ray Ni , Maurice Ma , Benjamin You , Sean Rhodes Subject: [edk2-devel] [PATCH 2/3] UefiPayloadPkg: Add Serial IO device path according to related protocol Date: Tue, 10 May 2022 15:11:10 +0800 Message-Id: <3e4cc390c9e7ffe9204b1564329086e7c3fc45cf.1652166437.git.zhiguang.liu@intel.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,zhiguang.liu@intel.com X-Gm-Message-State: n7MKYHDeq1pfN6TUiHUZsK8jx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1652166687; bh=/rEnziUvHUcMOG28vc+3nPvhKEs3U9OSWVS9oLt97pM=; h=Cc:Date:From:Reply-To:Subject:To; b=joR/u72MRXZ4GR1+EYFhHniQmbvdKUprXSgd0tguh/jWlH5/xF3rvoUdaSvGEpl0b6P K6hhD6WckqEFbLJpPYopz3VSOBBZ74BUpY1ppvHHYk1UAU9sxELePpYWHS/2GurjTjMig mqX7k3gn85QliHrF6+yS79EtcHIHQpbI+98= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1652166689856100011 Content-Type: text/plain; charset="utf-8" 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. Cc: Guo Dong Cc: Ray Ni Cc: Maurice Ma Cc: Benjamin You Cc: Sean Rhodes Signed-off-by: Zhiguang Liu --- .../PlatformBootManagerLib.inf | 1 + .../PlatformBootManagerLib/PlatformConsole.c | 149 +++++------------- .../PlatformBootManagerLib/PlatformConsole.h | 1 - 3 files changed, 44 insertions(+), 107 deletions(-) diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMana= gerLib.inf b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMana= gerLib.inf index 80390e0d98..acf2880d22 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.= inf +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.= inf @@ -60,6 +60,7 @@ gEfiDxeSmmReadyToLockProtocolGuid gEfiSmmAccess2ProtocolGuid gUniversalPayloadPlatformBootManagerOverrideProtocolGuid + gEfiSerialIoProtocolGuid =20 [Pcd] gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.= c b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.c index 9887183624..5e1c77d866 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.c +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.c @@ -47,36 +47,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define gPnpPs2Keyboard \ PNPID_DEVICE_PATH_NODE(0x0303) =20 -#define gUartVendor \ - { \ - { \ - HARDWARE_DEVICE_PATH, \ - HW_VENDOR_DP, \ - { \ - (UINT8) (sizeof (VENDOR_DEVICE_PATH)), \ - (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \ - } \ - }, \ - EDKII_SERIAL_PORT_LIB_VENDOR_GUID \ - } - -#define gUart \ - { \ - { \ - MESSAGING_DEVICE_PATH, \ - MSG_UART_DP, \ - { \ - (UINT8) (sizeof (UART_DEVICE_PATH)), \ - (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8) \ - } \ - }, \ - 0, \ - 115200, \ - 8, \ - 1, \ - 1 \ - } - #define gPcAnsiTerminal \ { \ { \ @@ -92,9 +62,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode =3D gPnpPs2Keyboard; ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode =3D gPnp16550ComPort; -UART_DEVICE_PATH gUartDeviceNode =3D gUart; VENDOR_DEVICE_PATH gTerminalTypeDeviceNode =3D gPcAnsiTerminal; -VENDOR_DEVICE_PATH gUartDeviceVendorNode =3D gUartVendor; =20 // // Predefined platform root bridge @@ -112,13 +80,11 @@ EFI_DEVICE_PATH_PROTOCOL *gPlatformRootBridges[] =3D { BOOLEAN mDetectDisplayOnly; =20 /** - Add IsaKeyboard to ConIn; add IsaSerial to ConOut, ConIn, ErrOut. + Add IsaKeyboard to ConIn. =20 @param[in] DeviceHandle Handle of the LPC Bridge device. =20 - @retval EFI_SUCCESS Console devices on the LPC bridge have been added to - ConOut, ConIn, and ErrOut. - + @retval EFI_SUCCESS IsaKeyboard on the LPC bridge have been added to Co= nIn. @return Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing from DeviceHandle. **/ @@ -129,7 +95,6 @@ PrepareLpcBridgeDevicePath ( { EFI_STATUS Status; EFI_DEVICE_PATH_PROTOCOL *DevicePath; - EFI_DEVICE_PATH_PROTOCOL *TempDevicePath; =20 DevicePath =3D NULL; Status =3D gBS->HandleProtocol ( @@ -141,26 +106,11 @@ PrepareLpcBridgeDevicePath ( return Status; } =20 - TempDevicePath =3D DevicePath; - // // Register Keyboard // DevicePath =3D AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOC= OL *)&gPnpPs2KeyboardDeviceNode); EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL); - - // - // Register COM1 - // - DevicePath =3D TempDevicePath; - DevicePath =3D AppendDevicePathNode ((EFI_DEVICE_PATH_PROTOCOL *)NULL, (= EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceVendorNode); - DevicePath =3D AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOC= OL *)&gUartDeviceNode); - DevicePath =3D AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOC= OL *)&gTerminalTypeDeviceNode); - - EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL); - EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL); - EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL); - return EFI_SUCCESS; } =20 @@ -291,43 +241,6 @@ PreparePciVgaDevicePath ( return EFI_SUCCESS; } =20 -/** - Add PCI Serial to ConOut, ConIn, ErrOut. - - @param[in] DeviceHandle - Handle of PciIo protocol. - - @retval EFI_SUCCESS - PCI Serial is added to ConOut, ConIn, and ErrOut. - @retval EFI_STATUS - No PCI Serial device is added. - -**/ -EFI_STATUS -PreparePciSerialDevicePath ( - IN EFI_HANDLE DeviceHandle - ) -{ - EFI_STATUS Status; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - - DevicePath =3D NULL; - Status =3D gBS->HandleProtocol ( - DeviceHandle, - &gEfiDevicePathProtocolGuid, - (VOID *)&DevicePath - ); - if (EFI_ERROR (Status)) { - return Status; - } - - DevicePath =3D AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOC= OL *)&gUartDeviceNode); - DevicePath =3D AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOC= OL *)&gTerminalTypeDeviceNode); - - EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL); - EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL); - EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL); - - return EFI_SUCCESS; -} - /** For every PCI instance execute a callback function. =20 @@ -452,18 +365,6 @@ DetectAndPreparePlatformPciDevicePath ( PrepareLpcBridgeDevicePath (Handle); return EFI_SUCCESS; } - - // - // Here we decide which Serial device to enable in PCI bus - // - if (IS_PCI_16550SERIAL (&Pci)) { - // - // Add them to ConOut, ConIn, ErrOut. - // - DEBUG ((DEBUG_INFO, "Found PCI 16550 SERIAL device\n")); - PreparePciSerialDevicePath (Handle); - return EFI_SUCCESS; - } } =20 // @@ -481,6 +382,41 @@ DetectAndPreparePlatformPciDevicePath ( return Status; } =20 +/** + For every Serial Io instance, add it to ConOut, ConIn, ErrOut. + + @param[in] Handle - The Serial Io device handle + @param[in] Instance - The instance of the SerialIo protocol + @param[in] Context - The context of the callback + + @retval EFI_STATUS - Callback function failed. + +**/ +EFI_STATUS +EFIAPI +AddDevicePathForOneSerialIoInstance ( + IN EFI_HANDLE Handle, + IN VOID *Instance, + IN VOID *Context + ) +{ + EFI_STATUS Status; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + + DevicePath =3D NULL; + Status =3D gBS->HandleProtocol ( + Handle, + &gEfiDevicePathProtocolGuid, + (VOID *)&DevicePath + ); + DevicePath =3D AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOC= OL *)&gTerminalTypeDeviceNode); + + EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL); + EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL); + EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL); + return Status; +} + /** Do platform specific PCI Device check and add them to ConOut, ConIn, Err= Out =20 @@ -505,6 +441,12 @@ DetectAndPreparePlatformPciDevicePaths ( NULL ); =20 + VisitAllInstancesOfProtocol ( + &gEfiSerialIoProtocolGuid, + AddDevicePathForOneSerialIoInstance, + NULL + ); + Status =3D VisitAllInstancesOfProtocol ( &gEfiPciIoProtocolGuid, DetectAndPreparePlatformPciDevicePath, @@ -558,11 +500,6 @@ PlatformConsoleInit ( VOID ) { - gUartDeviceNode.BaudRate =3D PcdGet64 (PcdUartDefaultBaudRate); - gUartDeviceNode.DataBits =3D PcdGet8 (PcdUartDefaultDataBits); - gUartDeviceNode.Parity =3D PcdGet8 (PcdUartDefaultParity); - gUartDeviceNode.StopBits =3D PcdGet8 (PcdUartDefaultStopBits); - ConnectRootBridge (); =20 // diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.= h b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.h index a13f4b8b59..2c7d21cc84 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.h +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.h @@ -21,7 +21,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include =20 #define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS= _BRIDGE_ISA_PDECODE, 0) -#define IS_PCI_16550SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS= _SERIAL, PCI_IF_16550) =20 // // Type definitions --=20 2.32.0.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#89638): https://edk2.groups.io/g/devel/message/89638 Mute This Topic: https://groups.io/mt/91007798/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-