From nobody Mon Feb 9 16:19:15 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+76778+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+76778+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1624204046; cv=none; d=zohomail.com; s=zohoarc; b=J86nbkziGiH49L+9coFlyKB+pf6ZQK+4Jj6/rwN9RZgv5XuLVzlG1lCVlXjFkdLVmNHFD4NAPz0jngoSNjsXopupweWN/jGByfOTsbX6Ulh+0c6acP9W93JJTrTrOHLbZIt5NP2hEHthejxj0EYXTcH8z77dMS17J/kxX86iwU0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624204046; 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=xU50LQDuR0wIEdRV8mUmMQF1wTLyLH+cl1VMaJR4XAo=; b=mb+g5kz251sq4Iw00n9R9ir8e0h/r5KuIKNHcrcN/Rmga5nfmp2sdjyjo+qMs0SoTH1V96KVAPqB7Y6LRJULxvLYwC11DVtXNWVPCtrGzE4P5Wq7kISnHIBYyMgZpviD0H1H6iGTrunSwMZwt9nZt21F40+WEvDIAV9s5LawJvc= 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+76778+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 162420404658429.119012635618674; Sun, 20 Jun 2021 08:47:26 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ENU7YY1788612xUilUmCHus0; Sun, 20 Jun 2021 08:47:26 -0700 X-Received: from mga18.intel.com (mga18.intel.com []) by mx.groups.io with SMTP id smtpd.web08.34931.1624204037148521455 for ; Sun, 20 Jun 2021 08:47:20 -0700 IronPort-SDR: hG+mc5N9SXpcwdhW5o0gwVRLeAClmieJTzzB7RmWTpvWhlT0/2b/nA6+d7Q/3BuVODxxZz6R/4 U1joaxZjuhHg== X-IronPort-AV: E=McAfee;i="6200,9189,10021"; a="194044400" X-IronPort-AV: E=Sophos;i="5.83,287,1616482800"; d="scan'208";a="194044400" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2021 08:47:20 -0700 IronPort-SDR: 6VFwWvQYzPMnrdNCZJT8C7yg+6YrMk467JV5HIZXfbJVO94KbYG81u/82o5zbsva0I/8MSNYQH 7SZHfg3fAkLA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,287,1616482800"; d="scan'208";a="451932615" X-Received: from fieedk002.ccr.corp.intel.com ([10.239.158.144]) by orsmga008.jf.intel.com with ESMTP; 20 Jun 2021 08:47:19 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Maurice Ma , Guo Dong , Benjamin You Subject: [edk2-devel] [PATCH 03/12] UefiPayloadPkg: Add a separate PlatformHookLib for Universal Payload Date: Sun, 20 Jun 2021 23:46:53 +0800 Message-Id: <20210620154702.2681-4-zhiguang.liu@intel.com> In-Reply-To: <20210620154702.2681-1-zhiguang.liu@intel.com> References: <20210620154702.2681-1-zhiguang.liu@intel.com> 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: aW5utDWi6Z96DguTBZuanvGox1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1624204046; bh=Y+oGqlXYtRwXUgpRB70vhZ++cAypenwGCPO3tgMAm4Q=; h=Cc:Date:From:Reply-To:Subject:To; b=jW8b04YYZ8+5D6BxtEtCbUvDfS4QJSoOk839GkNTMa82QAfJSimJlqrnuIGjAWmLSCx BmPLWMbqTpBsLG8e5wr7vReyf6JlclFdtInKpBgnejhxH3m3kbZ9uE+NM0gnUyaIM6D+W fJUrMrPhl3rr6FLbCBq/kU+quJM1m3mId3E= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Add a new separate PlatformHookLib for Universal Payload to consume Guid Hob gUniversalPayloadSerialPortInfoGuid to get serial port information Cc: Maurice Ma Cc: Guo Dong Cc: Benjamin You Signed-off-by: Zhiguang Liu Reviewed-by: Guo Dong --- UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.c = | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++ UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf= | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+) diff --git a/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/Platfor= mHookLib.c b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/Platfor= mHookLib.c new file mode 100644 index 0000000000..6705f29505 --- /dev/null +++ b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLi= b.c @@ -0,0 +1,82 @@ +/** @file + Platform Hook Library instance for UART device. + + Copyright (c) 2021, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include + +/** + Performs platform specific initialization required for the CPU to access + the hardware associated with a SerialPortLib instance. This function do= es + not initialize the serial port hardware itself. Instead, it initializes + hardware devices that are required for the CPU to access the serial port + hardware. This function may be called more than once. + + @retval RETURN_SUCCESS The platform specific initialization succee= ded. + @retval RETURN_DEVICE_ERROR The platform specific initialization could = not be completed. + +**/ +RETURN_STATUS +EFIAPI +PlatformHookSerialPortInitialize ( + VOID + ) +{ + RETURN_STATUS Status; + UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *SerialPortInfo; + UINT8 *GuidHob; + UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader; + + GuidHob =3D GetFirstGuidHob (&gUniversalPayloadSerialPortInfoGuid); + if (GuidHob =3D=3D NULL) { + return EFI_NOT_FOUND; + } + + GenericHeader =3D (UNIVERSAL_PAYLOAD_GENERIC_HEADER *) GET_GUID_HOB_DATA= (GuidHob); + if ((sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) > GET_GUID_HOB_DATA_SIZE = (GuidHob)) || (GenericHeader->Length > GET_GUID_HOB_DATA_SIZE (GuidHob))) { + return EFI_NOT_FOUND; + } + + if (GenericHeader->Revision =3D=3D UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_RE= VISION) { + SerialPortInfo =3D (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *) GET_GUID_HOB= _DATA (GuidHob); + if (GenericHeader->Length < UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD (UN= IVERSAL_PAYLOAD_SERIAL_PORT_INFO, RegisterBase)) { + // + // Return if can't find the Serial Port Info Hob with enough length + // + return EFI_NOT_FOUND; + } + + Status =3D PcdSetBoolS (PcdSerialUseMmio, SerialPortInfo->UseMmio); + if (RETURN_ERROR (Status)) { + return Status; + } + Status =3D PcdSet64S (PcdSerialRegisterBase, SerialPortInfo->RegisterB= ase); + if (RETURN_ERROR (Status)) { + return Status; + } + Status =3D PcdSet32S (PcdSerialRegisterStride, SerialPortInfo->Registe= rStride); + if (RETURN_ERROR (Status)) { + return Status; + } + Status =3D PcdSet32S (PcdSerialBaudRate, SerialPortInfo->BaudRate); + if (RETURN_ERROR (Status)) { + return Status; + } + Status =3D PcdSet64S (PcdUartDefaultBaudRate, SerialPortInfo->BaudRate= ); + if (RETURN_ERROR (Status)) { + return Status; + } + + return RETURN_SUCCESS; + } + + return EFI_NOT_FOUND; +} diff --git a/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/Platfor= mHookLib.inf b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/Platf= ormHookLib.inf new file mode 100644 index 0000000000..41e05ddf54 --- /dev/null +++ b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLi= b.inf @@ -0,0 +1,41 @@ +## @file +# Platform Hook Library instance for UART device for Universal Payload. +# +# Copyright (c) 2021, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PlatformHookLib + FILE_GUID =3D 807E05AB-9411-429F-97F0-FE425BF6B094 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D PlatformHookLib + CONSTRUCTOR =3D PlatformHookSerialPortInitialize + +[Sources] + PlatformHookLib.c + +[LibraryClasses] + PcdLib + BaseLib + HobLib + DxeHobListLib + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + UefiPayloadPkg/UefiPayloadPkg.dec + +[Guids] + gUniversalPayloadSerialPortInfoGuid + +[Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio ## PRODUCES + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase ## PRODUCES + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate ## PRODUCES + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride ## PRODUCES + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate ## PRODUCES --=20 2.16.2.windows.1 -=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 (#76778): https://edk2.groups.io/g/devel/message/76778 Mute This Topic: https://groups.io/mt/83669557/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-