From nobody Mon Feb 9 20:12:08 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+89704+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+89704+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1652352920; cv=none; d=zohomail.com; s=zohoarc; b=MxNs/QOQza7XVWiROdnC5cBpWKu3XTMFoWuStXl2d3loM/5sG5s4A3YB10K5n3tdLSYqf4d/cE2vg7g7gUlIFWm+ztW5yh2J0LGfbGSwf/D9XmAogyt0tWFDOAmMDrf8gRrESWwl7xv83sf5xohkflMrD+fx0/LoqBDLycUIt9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652352920; 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=AyCp4tLBjNYNjy0Yrji8EQwLqbRK6hvwVCMOE2O3hvY=; b=iNP5h4V/Ibe0M3JexLrWu8dh+LhBScqLd+MPwQKb/lNWcdhKnIGGtBFL0AkJ/KpNplGxzn1dXdY44s4iiY8UUE5IRoNUmU8oZW0+7m6nSbraCXK257lntxxbhfsfxl1jxruidomIVL08IT3YqInLnX1bJwDXzaccQcQnRkW0YN8= 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+89704+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 1652352920735908.4000797105916; Thu, 12 May 2022 03:55:20 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id vh5fYY1788612xka6UO1xIGV; Thu, 12 May 2022 03:55:20 -0700 X-Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web08.2661.1652352917194448306 for ; Thu, 12 May 2022 03:55:19 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10344"; a="270094643" X-IronPort-AV: E=Sophos;i="5.91,219,1647327600"; d="scan'208";a="270094643" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2022 03:55:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,219,1647327600"; d="scan'208";a="566627458" X-Received: from shwdesfp01.ccr.corp.intel.com ([10.239.158.158]) by orsmga007.jf.intel.com with ESMTP; 12 May 2022 03:55:16 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Guo Dong , Ray Ni , Maurice Ma , Benjamin You , Sean Rhodes Subject: [edk2-devel] [PATCH v2 2/3] UefiPayloadPkg: Add Serial IO device path according to related protocol Date: Thu, 12 May 2022 18:54:58 +0800 Message-Id: <03aeca65da52907434e14d1f9fbd1c0651874257.1652351830.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: YOm7gFW6v86ED4KkKz022Vq3x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1652352920; bh=kexVWa1N2n63WcrWUCx2Ea9CYi+kGSKrriLkq+gyrP8=; h=Cc:Date:From:Reply-To:Subject:To; b=HTsmwBp1bQnjQOkEmtLIk5SfkxjKlrm99qfx0gSjsAqVYU3OkP1UOyP7NiiXBbIoPvD SDgKXi6BCR9obtYs+bCS9SgyaYlC/K5vMK8sU+6oIbxX3VHNzw0uXFDfch6wYQaizn8jp ps6a0Wa7m1BEWgf+8BGC2ZZTrEEyaeX6IsA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1652352922496100008 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 Reviewed-by: Guo Dong --- .../PlatformBootManagerLib.inf | 1 + .../PlatformBootManagerLib/PlatformConsole.c | 146 +++++------------- .../PlatformBootManagerLib/PlatformConsole.h | 1 - 3 files changed, 41 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 75aafebccd..5aece6636f 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 @@ -447,18 +360,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 // @@ -476,6 +377,39 @@ 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 + + @retval EFI_STATUS - Callback function failed. + +**/ +EFI_STATUS +EFIAPI +AddDevicePathForOneSerialIoInstance ( + IN EFI_HANDLE Handle, + IN VOID *Instance + ) +{ + 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 @@ -500,6 +434,11 @@ DetectAndPreparePlatformPciDevicePaths ( NULL ); =20 + VisitAllInstancesOfProtocol ( + &gEfiSerialIoProtocolGuid, + AddDevicePathForOneSerialIoInstance + ); + Status =3D VisitAllInstancesOfProtocol ( &gEfiPciIoProtocolGuid, DetectAndPreparePlatformPciDevicePath @@ -552,11 +491,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 3713c21c45..6889c897ad 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 (#89704): https://edk2.groups.io/g/devel/message/89704 Mute This Topic: https://groups.io/mt/91055223/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-