From nobody Tue May 14 06:47:38 2024 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+76293+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+76293+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1623288833; cv=none; d=zohomail.com; s=zohoarc; b=SbIg3grhaHFdQgSeoQLCj95PpJjmguW3JKjqH6OF708zbKF+kt/gOdWxFThYW1h1bDYuM8e4A7Exgz+IHHqFmacs/U/Nd0RCoHP/dMbhrZtBV7zP3nQWkWepsciOZ5XcNg8mBY/+LlazmCBVntUejwanaDjR57lBtOpcrXZWrqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623288833; 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=XAbrY3Cu06SlVGCxTpuWobYgOpllXmkjjthveOSfN4A=; b=Q1D74iUv6x9qWEbKVOoa1OPSRHdpLK6xHv0mzH5rVT5tbrBtaY/HakgzPBhh+hqy7fbdqzHev92AFDZ87o48WxxLbu2kkrElfzQu1TVIR/qWZ3X+Sg8OkBTxq/MsDjqG27rpDje8sXcjYykF0Qs00+bXIUi/Md0Boj0PuHBm1SE= 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+76293+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1623288833620529.835201833152; Wed, 9 Jun 2021 18:33:53 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id edhfYY1788612xAwlFGz75ur; Wed, 09 Jun 2021 18:33:53 -0700 X-Received: from mga06.intel.com (mga06.intel.com []) by mx.groups.io with SMTP id smtpd.web11.4374.1623288826156455282 for ; Wed, 09 Jun 2021 18:33:47 -0700 IronPort-SDR: JrBe/kfs2lE7zZAicPCsIekLw+6N9azatPru/BQGLX1hf6NV77LpufjBkCVpsHluhzHPI9J/i0 Y6EZfMKFm7TA== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="266359679" X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="266359679" X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 18:33:46 -0700 IronPort-SDR: aTs2XynLKHQp6skAQ3wyNtKwhjLJKHzBoUhNkbJVE7WCpefLEbnmVn9Cv7lNJVjbpgg4XnF3Kt vSpVJ9qUuz4w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="402630957" X-Received: from fieedk002.ccr.corp.intel.com ([10.239.158.144]) by orsmga003.jf.intel.com with ESMTP; 09 Jun 2021 18:33:45 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Jian J Wang , Hao A Wu Subject: [edk2-devel] [Patch V4 1/9] MdeModulePkg: Add Universal Payload general definition header file Date: Thu, 10 Jun 2021 09:33:10 +0800 Message-Id: <20210610013318.1885-2-zhiguang.liu@intel.com> In-Reply-To: <20210610013318.1885-1-zhiguang.liu@intel.com> References: <20210610013318.1885-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: g6QMK8ZRL0f3B4q5FGHKyYEbx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1623288833; bh=I4TH+7DYu+cgnS8vq2AIfSiSov67sey2CGJACT41HwE=; h=Cc:Date:From:Reply-To:Subject:To; b=l9WgH3RX6sIyyTocPzgDuzP1n8u2RLCj6O0dGzurrGvNPyoncngj/cR59VMchIf7y/O 4AZJLYQnU8fDkuTCVr0E3DySyOCJE4geY5MT8dPGdqlvqPVfCmLpVpjK0LdEztsJw8qm7 Zr+1MLaxb0KwTvOaxZ3FLpQbmFNYj72UOX4= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" V1: Add Universal Payload general definition header file according to Universal Payload's documentation V2: Add a macro function to check the Revision V4: The documentation link https://universalpayload.github.io/documentation/ is= added Change the term "PLD" to "UNIVERSAL_PAYLOAD". Cc: Michael D Kinney Cc: Liming Gao Cc: Jian J Wang Cc: Hao A Wu Reviewed-by: Hao A Wu Signed-off-by: Zhiguang Liu --- MdeModulePkg/Include/UniversalPayload/UniversalPayload.h | 35 ++++++++++++= +++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/MdeModulePkg/Include/UniversalPayload/UniversalPayload.h b/Mde= ModulePkg/Include/UniversalPayload/UniversalPayload.h new file mode 100644 index 0000000000..fd3a2ea262 --- /dev/null +++ b/MdeModulePkg/Include/UniversalPayload/UniversalPayload.h @@ -0,0 +1,35 @@ +/** @file + Universal Payload general definitions. + +Copyright (c) 2021, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Revision Reference: + - Universal Payload Specification 0.75 (https://universalpayload.githu= b.io/documentation/) +**/ + +#ifndef __UNIVERSAL_PAYLOAD_H__ +#define __UNIVERSAL_PAYLOAD_H__ + +#pragma pack(1) + +typedef struct { + UINT8 Revision; + UINT8 Reserved; + UINT16 Length; +} UNIVERSAL_PAYLOAD_GENERIC_HEADER; + +#pragma pack() + +/** + Returns the size of a structure of known type, up through and including = a specified field. + + @param TYPE The name of the data structure that contains the field= specified by Field. + @param Field The name of the field in the data structure. + + @return size, in bytes. + +**/ +#define UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD(TYPE, Field) (OFFSET_OF(TYP= E, Field) + sizeof (((TYPE *) 0)->Field)) + +#endif // __UNIVERSAL_PAYLOAD_H__ --=20 2.30.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 (#76293): https://edk2.groups.io/g/devel/message/76293 Mute This Topic: https://groups.io/mt/83435784/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- From nobody Tue May 14 06:47:38 2024 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+76294+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+76294+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1623288829; cv=none; d=zohomail.com; s=zohoarc; b=X+fT5ZSDCeKqiWaPYBRaRgK/nFZO+2SQIUCjVeujVnXaInw9xZD/nnGz2n6nxq7SrEmIxYybMlzdRT6exAHDNmJlF5zENc7kL3sRJqL9T5agexUGChkD2eI6MfuIg09SSj+SNJAj5pNSH46K5AV3NtLLYho9KMElFI6dSdr5y5Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623288829; 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=6WCYcqufjVQdqtK/Uzwl4Evmo3qEQ+kSJxh67THEYMk=; b=ahbBedpRwuqzrjl9fZ6qNDKKSvt/8vOoaoR3O3T4wJ/jzqHdf9ths+5fupX5AvjUJCoqqyGAwoW8tX4+5UEWgyh+gv8umEuSs5qF8u7B4zq6o09Y3yvkNBUau0M3mG49tsfUfn67EwLMXwdyNTqOqy5/JzU99hSIWwbPUM/GfH0= 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+76294+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1623288829778285.6975693653402; Wed, 9 Jun 2021 18:33:49 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id jjhxYY1788612xQxomqLXJ7a; Wed, 09 Jun 2021 18:33:49 -0700 X-Received: from mga06.intel.com (mga06.intel.com []) by mx.groups.io with SMTP id smtpd.web11.4374.1623288826156455282 for ; Wed, 09 Jun 2021 18:33:48 -0700 IronPort-SDR: Jmn3/7x0YwG4kSHxrSe4ut7RRJHThvGqfWzKkVQuq44hVCG+68VPVKA9iqz6fDBkdubPgzPF03 MnzmwCZSZXPQ== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="266359691" X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="266359691" X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 18:33:48 -0700 IronPort-SDR: X6uivXCUAyd8573fe13yqUGh0Qsuv4pdvZg25J1CAa9f49qoomrqE+kFzduJjeMVlPbT5SyzmM aQ2fLroB0sjA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="402630970" X-Received: from fieedk002.ccr.corp.intel.com ([10.239.158.144]) by orsmga003.jf.intel.com with ESMTP; 09 Jun 2021 18:33:47 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Jian J Wang , Hao A Wu Subject: [edk2-devel] [Patch V4 2/9] MdeModulePkg: Add new structure for the PCI Root Bridge Info Hob Date: Thu, 10 Jun 2021 09:33:11 +0800 Message-Id: <20210610013318.1885-3-zhiguang.liu@intel.com> In-Reply-To: <20210610013318.1885-1-zhiguang.liu@intel.com> References: <20210610013318.1885-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: 2AFcC9HLOBCoHyDrnNaTkH0Hx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1623288829; bh=7tfiYUqQG5vh5gqI25qgn2itjYjvnZE2B3UCyl3tleo=; h=Cc:Date:From:Reply-To:Subject:To; b=H79nPLlM6EJfK4FCQV4hE/7KbgM9kyz9WI2TKHZSFCI+M+fkA+mLL/A1CIzAD1eiKon 5gHF7K2a12qfScsBsnufDKY5quX/Kw5/RDRbhFQmYto0vMi1P8Hd7j+GVm1RprRcp+N8h XPseqHmTroKEkyT23FrfU9UIl2v7INOX318= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Cc: Michael D Kinney Cc: Liming Gao Cc: Jian J Wang Cc: Hao A Wu Reviewed-by: Hao A Wu Signed-off-by: Zhiguang Liu --- MdeModulePkg/Include/UniversalPayload/PciRootBridges.h | 91 ++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++ MdeModulePkg/MdeModulePkg.dec | 6 ++++++ 2 files changed, 97 insertions(+) diff --git a/MdeModulePkg/Include/UniversalPayload/PciRootBridges.h b/MdeMo= dulePkg/Include/UniversalPayload/PciRootBridges.h new file mode 100644 index 0000000000..ea5b87480e --- /dev/null +++ b/MdeModulePkg/Include/UniversalPayload/PciRootBridges.h @@ -0,0 +1,91 @@ +/** @file + This file defines the structure for the PCI Root Bridges. + + Copyright (c) 2021, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Revision Reference: + - Universal Payload Specification 0.75 (https://universalpayload.githu= b.io/documentation/) +**/ + +#ifndef __UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES_H__ +#define __UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES_H__ + +#include + +#pragma pack(1) + +// +// (Base > Limit) indicates an aperture is not available. +// +typedef struct { + // + // Base and Limit are the device address instead of host address when + // Translation is not zero + // + UINT64 Base; + UINT64 Limit; + // + // According to UEFI 2.7, Device Address =3D Host Address + Translation, + // so Translation =3D Device Address - Host Address. + // On platforms where Translation is not zero, the subtraction is probab= ly to + // be performed with UINT64 wrap-around semantics, for we may translate = an + // above-4G host address into a below-4G device address for legacy PCIe = device + // compatibility. + // + // NOTE: The alignment of Translation is required to be larger than any = BAR + // alignment in the same root bridge, so that the same alignment can be + // applied to both device address and host address, which simplifies the + // situation and makes the current resource allocation code in generic P= CI + // host bridge driver still work. + // + UINT64 Translation; +} UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE; + +/// +/// Payload PCI Root Bridge Information HOB +/// +typedef struct { + UINT32 Segment; ///< S= egment number. + UINT64 Supports; ///< S= upported attributes. + ///< R= efer to EFI_PCI_ATTRIBUTE_xxx used by GetAttributes() + ///< a= nd SetAttributes() in EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL. + UINT64 Attributes; ///< I= nitial attributes. + ///< R= efer to EFI_PCI_ATTRIBUTE_xxx used by GetAttributes() + ///< a= nd SetAttributes() in EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL. + BOOLEAN DmaAbove4G; ///< D= MA above 4GB memory. + ///< S= et to TRUE when root bridge supports DMA above 4GB memory. + BOOLEAN NoExtendedConfigSpace; ///< W= hen FALSE, the root bridge supports + ///< E= xtended (4096-byte) Configuration Space. + ///< W= hen TRUE, the root bridge supports + ///< 2= 56-byte Configuration Space only. + UINT64 AllocationAttributes; ///< A= llocation attributes. + ///< R= efer to EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM and + ///< E= FI_PCI_HOST_BRIDGE_MEM64_DECODE used by GetAllocAttributes() + ///< i= n EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL. + UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE Bus; ///< B= us aperture which can be used by the root bridge. + UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE Io; ///< I= O aperture which can be used by the root bridge. + UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE Mem; ///< M= MIO aperture below 4GB which can be used by the root bridge. + UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE MemAbove4G; ///< M= MIO aperture above 4GB which can be used by the root bridge. + UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE PMem; ///< P= refetchable MMIO aperture below 4GB which can be used by the root bridge. + UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE PMemAbove4G; ///< P= refetchable MMIO aperture above 4GB which can be used by the root bridge. + UINT32 HID; ///< P= nP hardware ID of the root bridge. This value must match the corresponding + ///< _= HID in the ACPI name space. + UINT32 UID; ///< U= nique ID that is required by ACPI if two devices have the same _HID. + ///< T= his value must also match the corresponding _UID/_HID pair in the ACPI name= space. +} UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE; + +typedef struct { + UNIVERSAL_PAYLOAD_GENERIC_HEADER Header; + BOOLEAN ResourceAssigned; + UINT8 Count; + UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE RootBridge[0]; +} UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES; + +#pragma pack() + +#define UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES_REVISION 1 + +extern GUID gUniversalPayloadPciRootBridgeInfoGuid; + +#endif // __UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES_H__ diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 8d38383915..5cee4e159a 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -404,6 +404,12 @@ ## Include/Guid/MigratedFvInfo.h gEdkiiMigratedFvInfoGuid =3D { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2, 0xf4,= 0xc6, 0xce, 0xfd, 0x17, 0x98, 0x71 } } =20 + # + # GUID defined in UniversalPayload + # + ## Include/UniversalPayload/PciRootBridges.h + gUniversalPayloadPciRootBridgeInfoGuid =3D { 0xec4ebacb, 0x2638, 0x416e,= { 0xbe, 0x80, 0xe5, 0xfa, 0x4b, 0x51, 0x19, 0x01 }} + [Ppis] ## Include/Ppi/AtaController.h gPeiAtaControllerPpiGuid =3D { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0,= 0x7a, 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }} --=20 2.30.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 (#76294): https://edk2.groups.io/g/devel/message/76294 Mute This Topic: https://groups.io/mt/83435786/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- From nobody Tue May 14 06:47:38 2024 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+76295+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+76295+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1623288832; cv=none; d=zohomail.com; s=zohoarc; b=SbQZtg7uQYtgV/REMl2gEjTNnw442SnGZ/w+CUPwlL0DjFW9k7ePWVPjgTTL9L+QVRbW6D5CHf6zSlWaFnYVlW5EKKs8NBfVz3aFRAZgKcD3cYxbbT/X9pTifDKwcjj1olTtL14bYYLuHxC2KAU6eKlexwObdl1f/q/Ygag1A2c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623288832; 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=CNjWXelf9xoM+bBIn57qR4wWPo0jbjqAbE2l2xfDFvI=; b=frGkKuHe6pLz+TEC4hrkMb5wt6oMP5ctTZUFNJ60+C7lqFaT0dXqIxo79o1AZxVwFQeq+7hNWc+88SYBa6XYB9WOW0gWUxYLmKrK8Yx2UMtW9JsZN1DJ8hjlQp4bK4/vrLjqbPPM4tGO09m0uPeESqJ0Km9yTFcuN/ASsKVNJG0= 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+76295+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1623288832858500.63476688550145; Wed, 9 Jun 2021 18:33:52 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 3Qi0YY1788612xQPMEwui04c; Wed, 09 Jun 2021 18:33:52 -0700 X-Received: from mga06.intel.com (mga06.intel.com []) by mx.groups.io with SMTP id smtpd.web11.4374.1623288826156455282 for ; Wed, 09 Jun 2021 18:33:51 -0700 IronPort-SDR: 4ZPKZWJyyYF+ebvyVLZghp2bF9AN18OggvvB2eS2rYY88pshr2ToAXtvhAqWHNfzQsCG1cEGff KIoO+xGKP+VQ== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="266359694" X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="266359694" X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 18:33:51 -0700 IronPort-SDR: uCujlxkYWVGUk1zJ492RQrM4MVA02tFZ/sNVSEz20wM9I6AbcWYudEB4Xlk1qXuK6ocFkeVBxE 5QcVMdIFnPyA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="402630981" X-Received: from fieedk002.ccr.corp.intel.com ([10.239.158.144]) by orsmga003.jf.intel.com with ESMTP; 09 Jun 2021 18:33:48 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Maurice Ma , Guo Dong , Benjamin You Subject: [edk2-devel] [Patch V4 3/9] UefiPayloadPkg: UefiPayload retrieve PCI root bridge from Guid Hob Date: Thu, 10 Jun 2021 09:33:12 +0800 Message-Id: <20210610013318.1885-4-zhiguang.liu@intel.com> In-Reply-To: <20210610013318.1885-1-zhiguang.liu@intel.com> References: <20210610013318.1885-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: hOZ0kYVhq4LE67fDURoAMsd8x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1623288832; bh=yMjS5bc44qD0SVttW17+EtTF8nWdHOv7+436HJlZpsc=; h=Cc:Date:From:Reply-To:Subject:To; b=puVC2wHVl8Dti+PFM7QXfSb4YL0EQbqGi6FKr8dp99pmPzy+M9mS/6GfYazeiok68g3 kYGmprIRqcykHCMgGC/ra1V3dHkwA6rKjCIwxp0Lrw09da/nNBihThGNzKsdG3jO2colP EFDw7tdaemVZj85qAlireInyoPBVkrcghp8= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" UefiPayload parse gPldPciRootBridgeInfoGuid Guid Hob to retrieve PCI root b= ridges information. gPldPciRootBridgeInfoGuid Guid Hob should be created by Bootlo= ader. Cc: Maurice Ma Cc: Guo Dong Cc: Benjamin You Signed-off-by: Zhiguang Liu --- UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridge.h | 40 ++++++= ++++++++++++++++++++++++++++++++-- UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 47 ++++++= ++++++++++++++++++++++++++++++++++++++--- UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf | 8 ++++++= +- UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSupport.c | 73 ++++++= ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- UefiPayloadPkg/UefiPayloadPkg.dsc | 2 +- 5 files changed, 162 insertions(+), 8 deletions(-) diff --git a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridge.h b/Uefi= PayloadPkg/Library/PciHostBridgeLib/PciHostBridge.h index c2961b3bee..3eee1fbeac 100644 --- a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridge.h +++ b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridge.h @@ -2,7 +2,7 @@ Header file of PciHostBridgeLib. =20 Copyright (C) 2016, Red Hat, Inc. - Copyright (c) 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2021, Intel Corporation. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -11,14 +11,38 @@ #ifndef _PCI_HOST_BRIDGE_H #define _PCI_HOST_BRIDGE_H =20 +#include + typedef struct { ACPI_HID_DEVICE_PATH AcpiDevicePath; EFI_DEVICE_PATH_PROTOCOL EndDevicePath; } CB_PCI_ROOT_BRIDGE_DEVICE_PATH; =20 +/** + Scan for all root bridges in platform. + + @param[out] NumberOfRootBridges Number of root bridges detected + + @retval Pointer to the allocated PCI_ROOT_BRIDGE structure array. +**/ PCI_ROOT_BRIDGE * ScanForRootBridges ( - UINTN *NumberOfRootBridges + OUT UINTN *NumberOfRootBridges +); + +/** + Scan for all root bridges from Universal Payload PciRootBridgeInfoHob + + @param[in] PciRootBridgeInfo Pointer of Universal Payload PCI Root B= ridge Info Hob + @param[out] NumberOfRootBridges Number of root bridges detected + + @retval Pointer to the allocated PCI_ROOT_BRIDGE structure array. + +**/ +PCI_ROOT_BRIDGE * +RetrieveRootBridgeInfoFromHob ( + IN UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridgeInfo, + OUT UINTN *NumberOfRootBridges ); =20 /** @@ -77,4 +101,16 @@ InitRootBridge ( OUT PCI_ROOT_BRIDGE *RootBus ); =20 +/** + Initialize DevicePath for a PCI_ROOT_BRIDGE. + @param[in] HID HID for device path + @param[in] UID UID for device path + + @retval A pointer to the new created device patch. +**/ +EFI_DEVICE_PATH_PROTOCOL * +CreateRootBridgeDevicePath ( + IN UINT32 HID, + IN UINT32 UID +); #endif diff --git a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c b/U= efiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c index 512c3127cc..a0d7cdc306 100644 --- a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c +++ b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c @@ -2,7 +2,7 @@ Library instance of PciHostBridgeLib library class for coreboot. =20 Copyright (C) 2016, Red Hat, Inc. - Copyright (c) 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2021, Intel Corporation. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -19,6 +19,7 @@ #include #include #include +#include =20 #include "PciHostBridge.h" =20 @@ -48,7 +49,6 @@ CB_PCI_ROOT_BRIDGE_DEVICE_PATH mRootBridgeDevicePathTempl= ate =3D { } }; =20 - /** Initialize a PCI_ROOT_BRIDGE structure. =20 @@ -145,6 +145,27 @@ InitRootBridge ( return EFI_SUCCESS; } =20 +/** + Initialize DevicePath for a PCI_ROOT_BRIDGE. + @param[in] HID HID for device path + @param[in] UID UID for device path + + @retval A pointer to the new created device patch. +**/ +EFI_DEVICE_PATH_PROTOCOL * +CreateRootBridgeDevicePath ( + IN UINT32 HID, + IN UINT32 UID +) +{ + CB_PCI_ROOT_BRIDGE_DEVICE_PATH *DevicePath; + DevicePath =3D AllocateCopyPool (sizeof (mRootBridgeDevicePathTemplate), + &mRootBridgeDevicePathTemplate); + ASSERT (DevicePath !=3D NULL); + DevicePath->AcpiDevicePath.HID =3D HID; + DevicePath->AcpiDevicePath.UID =3D UID; + return (EFI_DEVICE_PATH_PROTOCOL *)DevicePath; +} =20 /** Return all the root bridge instances in an array. @@ -161,10 +182,30 @@ PciHostBridgeGetRootBridges ( UINTN *Count ) { + UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridgeInfo; + EFI_HOB_GUID_TYPE *GuidHob; + UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader; + // + // Find Universal Payload PCI Root Bridge Info hob + // + GuidHob =3D GetFirstGuidHob (&gUniversalPayloadPciRootBridgeInfoGuid); + if (GuidHob !=3D NULL) { + GenericHeader =3D (UNIVERSAL_PAYLOAD_GENERIC_HEADER *) GET_GUID_HOB_DA= TA (GuidHob); + if ((sizeof(UNIVERSAL_PAYLOAD_GENERIC_HEADER) <=3D GET_GUID_HOB_DATA_S= IZE (GuidHob)) && (GenericHeader->Length <=3D GET_GUID_HOB_DATA_SIZE (GuidH= ob))) { + if ((GenericHeader->Revision =3D=3D UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDG= ES_REVISION) && (GenericHeader->Length >=3D sizeof (UNIVERSAL_PAYLOAD_PCI_R= OOT_BRIDGES))) { + // + // UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES structure is used when Revis= ion equals to UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES_REVISION + // + PciRootBridgeInfo =3D (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *) GET_G= UID_HOB_DATA (GuidHob); + if (PciRootBridgeInfo->Count <=3D (GET_GUID_HOB_DATA_SIZE (GuidHob= ) - sizeof(UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES)) / sizeof(UNIVERSAL_PAYLOAD_= PCI_ROOT_BRIDGE)) { + return RetrieveRootBridgeInfoFromHob (PciRootBridgeInfo, Count); + } + } + } + } return ScanForRootBridges (Count); } =20 - /** Free the root bridge instances array returned from PciHostBridgeGetRootBridges(). diff --git a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf b= /UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf index 7896df2416..6069dcc0ef 100644 --- a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf +++ b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf @@ -2,7 +2,7 @@ # Library instance of PciHostBridgeLib library class for coreboot. # # Copyright (C) 2016, Red Hat, Inc. -# Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2016 - 2021, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -39,3 +39,9 @@ DevicePathLib MemoryAllocationLib PciLib + +[Guids] + gUniversalPayloadPciRootBridgeInfoGuid + +[Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration diff --git a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSupport.c= b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSupport.c index fffbf04cad..b0268f0506 100644 --- a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSupport.c +++ b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSupport.c @@ -1,7 +1,7 @@ /** @file Scan the entire PCI bus for root bridges to support coreboot UEFI payloa= d. =20 - Copyright (c) 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2021, Intel Corporation. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -582,3 +582,74 @@ ScanForRootBridges ( =20 return RootBridges; } + +/** + Scan for all root bridges from Universal Payload PciRootBridgeInfoHob + + @param[in] PciRootBridgeInfo Pointer of Universal Payload PCI Root B= ridge Info Hob + @param[out] NumberOfRootBridges Number of root bridges detected + + @retval Pointer to the allocated PCI_ROOT_BRIDGE structure array. + +**/ +PCI_ROOT_BRIDGE * +RetrieveRootBridgeInfoFromHob ( + IN UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridgeInfo, + OUT UINTN *NumberOfRootBridges +) +{ + PCI_ROOT_BRIDGE *PciRootBridges; + UINTN Size; + UINT8 Index; + + ASSERT (PciRootBridgeInfo !=3D NULL); + ASSERT (NumberOfRootBridges !=3D NULL); + if (PciRootBridgeInfo =3D=3D NULL) { + return NULL; + } + if (PciRootBridgeInfo->Count =3D=3D 0) { + return NULL; + } + Size =3D PciRootBridgeInfo->Count * sizeof (PCI_ROOT_BRIDGE); + PciRootBridges =3D (PCI_ROOT_BRIDGE *) AllocatePool (Size); + ASSERT (PciRootBridges !=3D NULL); + if (PciRootBridges =3D=3D NULL) { + return NULL; + } + ZeroMem (PciRootBridges, PciRootBridgeInfo->Count * sizeof (PCI_ROOT_BRI= DGE)); + + // + // Create all root bridges with PciRootBridgeInfoHob + // + for (Index =3D 0; Index < PciRootBridgeInfo->Count; Index++) { + PciRootBridges[Index].Segment =3D PciRootBridgeInfo->Roo= tBridge[Index].Segment; + PciRootBridges[Index].Supports =3D PciRootBridgeInfo->Roo= tBridge[Index].Supports; + PciRootBridges[Index].Attributes =3D PciRootBridgeInfo->Roo= tBridge[Index].Attributes; + PciRootBridges[Index].DmaAbove4G =3D PciRootBridgeInfo->Roo= tBridge[Index].DmaAbove4G; + PciRootBridges[Index].NoExtendedConfigSpace =3D PciRootBridgeInfo->Roo= tBridge[Index].NoExtendedConfigSpace; + PciRootBridges[Index].ResourceAssigned =3D PciRootBridgeInfo->Res= ourceAssigned; + PciRootBridges[Index].AllocationAttributes =3D PciRootBridgeInfo->Roo= tBridge[Index].AllocationAttributes; + PciRootBridges[Index].DevicePath =3D CreateRootBridgeDevice= Path(PciRootBridgeInfo->RootBridge[Index].HID, PciRootBridgeInfo->RootBridg= e[Index].UID); + CopyMem(&PciRootBridges[Index].Bus, &PciRootBridgeInfo->RootBr= idge[Index].Bus, sizeof(UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE)= ); + CopyMem(&PciRootBridges[Index].Io, &PciRootBridgeInfo->RootBr= idge[Index].Io, sizeof(UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE)= ); + CopyMem(&PciRootBridges[Index].Mem, &PciRootBridgeInfo->RootBr= idge[Index].Mem, sizeof(UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE)= ); + CopyMem(&PciRootBridges[Index].MemAbove4G, &PciRootBridgeInfo->RootBr= idge[Index].MemAbove4G, sizeof(UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE)= ); + CopyMem(&PciRootBridges[Index].PMem, &PciRootBridgeInfo->RootBr= idge[Index].PMem, sizeof(UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE)= ); + CopyMem(&PciRootBridges[Index].PMemAbove4G, &PciRootBridgeInfo->RootBr= idge[Index].PMemAbove4G, sizeof(UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE)= ); + } + + *NumberOfRootBridges =3D PciRootBridgeInfo->Count; + + // + // Now, this library only supports RootBridge that ResourceAssigned is T= rue + // + if (PciRootBridgeInfo->ResourceAssigned) { + PcdSetBoolS (PcdPciDisableBusEnumeration, TRUE); + } else { + DEBUG ((DEBUG_ERROR, "There is root bridge whose ResourceAssigned is F= ALSE\n")); + PcdSetBoolS (PcdPciDisableBusEnumeration, FALSE); + return NULL; + } + + return PciRootBridges; +} diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayload= Pkg.dsc index 37ad5a0ae7..e9211adf86 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -323,7 +323,6 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl|$(SERIAL_FIFO_CONTRO= L) gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize|$(SERIAL_EXTE= NDED_TX_FIFO_SIZE) =20 - gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|$(UART_DEFAULT_BAUD_RATE) gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits|$(UART_DEFAULT_DATA_BITS) gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity|$(UART_DEFAULT_PARITY) @@ -363,6 +362,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn|100 gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0 gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseSize|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE =20 ##########################################################################= ###### # --=20 2.30.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 (#76295): https://edk2.groups.io/g/devel/message/76295 Mute This Topic: https://groups.io/mt/83435787/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- From nobody Tue May 14 06:47:38 2024 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+76296+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+76296+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1623288837; cv=none; d=zohomail.com; s=zohoarc; b=UKs9M03Uoj0h8KXYWQ41L8zkU4OJVKtnyrbk+NZA+hJ0hPy0tWrbs48uUkz/sHzJH3u5CsMB6Wh3b1CBv+YVS3M+nRkeIWzZ/mPMpW8/3QJoCvgga6X2L7eqe6DlMQG1uprW8Oyj76xf1KHTRQRYhIJDyMexDooSGz/3v4xFOuI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623288837; 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=uZKPJrzlT03VIVGgHfhfoV9YX2tSUNutV1d8CXMslWg=; b=HW2rSc2HqVxLg8jfxJvRcYh+m93EmDJAmsC7788RrnKPe3X1fmNiGPHgtePQO6i8cvJCc+T/tEuFpN3jQ4NL/htkJqlKzsEjcy/AcqT8bPyI+vBRVgNHeCDpJIqxnhcMzwxzZqbVRiA8U479jliESULkib71pbDU5BGOy/p5c/E= 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+76296+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1623288837926781.2725708886298; Wed, 9 Jun 2021 18:33:57 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id UfSuYY1788612xBaEye3nN8p; Wed, 09 Jun 2021 18:33:57 -0700 X-Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web09.4366.1623288831981190282 for ; Wed, 09 Jun 2021 18:33:52 -0700 IronPort-SDR: qdT/BHacMNCLg/nnJDehlMjkk3xwEFyVVSjArFKrC4KTfo/7q+loEjXN0QOKWge21bzYXyi2RL bP/Zd8YeIzQQ== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="266359695" X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="266359695" X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 18:33:51 -0700 IronPort-SDR: O02O2vvcEaa75c36m5C17AoHxt0tNli/OAhzpDYbjfAZyLzsbMv9nYtCD84WuXCCq47CoIrxsV 5VYqIweX8e4g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="402630990" X-Received: from fieedk002.ccr.corp.intel.com ([10.239.158.144]) by orsmga003.jf.intel.com with ESMTP; 09 Jun 2021 18:33:50 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Jian J Wang , Hao A Wu Subject: [edk2-devel] [Patch V4 4/9] MdeModulePkg: Add new structure for the Universal Payload SMBios Table Info Hob Date: Thu, 10 Jun 2021 09:33:13 +0800 Message-Id: <20210610013318.1885-5-zhiguang.liu@intel.com> In-Reply-To: <20210610013318.1885-1-zhiguang.liu@intel.com> References: <20210610013318.1885-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: fxAiZ6n4ikp1QttOQuT8GLyFx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1623288837; bh=5Ocaa+uGETLMsfSqpcbwJzus1N9xxTPr96McJPYJXO4=; h=Cc:Date:From:Reply-To:Subject:To; b=jszUvuBoftQ0oxGYNFqV9EL0YWZlYpZPVE/nA01WyZyYRWIMjUVW8WPqa6NagEY+gc3 BbDBeCzTmnkYSWNZ5e0WX0QV3cAWZQjmgV4/hyA7mDd1C7EHid445lsjauEKW8B6f5SL9 +pRs1jApHrjI8ke4fRT2iA8bOXjhAO3kQkY= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Cc: Michael D Kinney Cc: Liming Gao Cc: Jian J Wang Cc: Hao A Wu Reviewed-by: Hao A Wu Signed-off-by: Zhiguang Liu --- MdeModulePkg/Include/UniversalPayload/SmbiosTable.h | 30 +++++++++++++++++= +++++++++++++ MdeModulePkg/MdeModulePkg.dec | 6 ++++++ 2 files changed, 36 insertions(+) diff --git a/MdeModulePkg/Include/UniversalPayload/SmbiosTable.h b/MdeModul= ePkg/Include/UniversalPayload/SmbiosTable.h new file mode 100644 index 0000000000..64afba6fe1 --- /dev/null +++ b/MdeModulePkg/Include/UniversalPayload/SmbiosTable.h @@ -0,0 +1,30 @@ +/** @file + Define the structure for the Universal Payload SmBios. + +Copyright (c) 2021, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Revision Reference: + - Universal Payload Specification 0.75 (https://universalpayload.githu= b.io/documentation/) +**/ + +#ifndef __UNIVERSAL_PAYLOAD_SMBIOS_TABLE_H_ +#define __UNIVERSAL_PAYLOAD_SMBIOS_TABLE_H_ + +#include +#include + +#pragma pack (1) + +typedef struct { + UNIVERSAL_PAYLOAD_GENERIC_HEADER Header; + EFI_PHYSICAL_ADDRESS SmBiosEntryPoint; +} UNIVERSAL_PAYLOAD_SMBIOS_TABLE; + +#pragma pack() + +#define UNIVERSAL_PAYLOAD_SMBIOS_TABLE_REVISION 1 + +extern GUID gUniversalPayloadSmbios3TableGuid; +extern GUID gUniversalPayloadSmbiosTableGuid; +#endif //__UNIVERSAL_PAYLOAD_SMBIOS_TABLE_H_ diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 5cee4e159a..377e868e7c 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -410,6 +410,12 @@ ## Include/UniversalPayload/PciRootBridges.h gUniversalPayloadPciRootBridgeInfoGuid =3D { 0xec4ebacb, 0x2638, 0x416e,= { 0xbe, 0x80, 0xe5, 0xfa, 0x4b, 0x51, 0x19, 0x01 }} =20 + ## Include/UniversalPayload/SmbiosTable.h + gUniversalPayloadSmbios3TableGuid =3D { 0x92b7896c, 0x3362, 0x46ce, { 0x= 99, 0xb3, 0x4f, 0x5e, 0x3c, 0x34, 0xeb, 0x42 } } + + ## Include/UniversalPayload/SmbiosTable.h + gUniversalPayloadSmbiosTableGuid =3D { 0x590a0d26, 0x06e5, 0x4d20, { 0x8= a, 0x82, 0x59, 0xea, 0x1b, 0x34, 0x98, 0x2d } } + [Ppis] ## Include/Ppi/AtaController.h gPeiAtaControllerPpiGuid =3D { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0,= 0x7a, 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }} --=20 2.30.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 (#76296): https://edk2.groups.io/g/devel/message/76296 Mute This Topic: https://groups.io/mt/83435788/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- From nobody Tue May 14 06:47:38 2024 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+76297+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+76297+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1623288840; cv=none; d=zohomail.com; s=zohoarc; b=GiYj+UYrimmKdYiHJpgjs7e1ufzXH2JNtpEqc9TPJQjF6NvyKBIsiGMDYsnYHd/U8dGB+k6rEe57xFDsEWoB8BZUFrix3gFPLDB16X/2IyyyaI0y5LsKWBzCuYImJTGOCH6xp0KHfE4hN2cWx8hQjX4+Uy3H3MBDcIY6mWlE14E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623288840; 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=W/kVMrZqnBWZTM4tXQXlKMIErn4sjct0lNcQDiU+Zwc=; b=OaAOsBI16bdI1rf5XsOa9gIqmZHFYy06BCINUi+awRFnH4vg/oQjTTnmUqoG0jOmSHLoteNHjOkHL5dnRBKxBLFicw+pOc4RUflRK3b1nOKCywE2V0OcrOwtzKOEiWvE5QeWsK0jDqvC8lQVDDoyJB8PYxOJBRKkgGPVTmcIX8Q= 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+76297+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1623288840265335.2035613756742; Wed, 9 Jun 2021 18:34:00 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id SEAjYY1788612xVgfsvkheOp; Wed, 09 Jun 2021 18:33:59 -0700 X-Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web08.4310.1623288834084367139 for ; Wed, 09 Jun 2021 18:33:54 -0700 IronPort-SDR: lbpPViPgerIK4fqfFUnTpk5B9qTljnC0sPTQA+H5QKnOdoFiImQB4p/1T9detTpLQfu78B7Q/9 UasVJbvYwrNg== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="266359702" X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="266359702" X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 18:33:53 -0700 IronPort-SDR: /k5hPtJMXvb+VAUrELsQ1CKnBV6G32e7qYJ3AtT6aPbAFAcPGS8tzgyQYBG0NjgUl5uFe6WddB S0boyoxTWTpQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="402631001" X-Received: from fieedk002.ccr.corp.intel.com ([10.239.158.144]) by orsmga003.jf.intel.com with ESMTP; 09 Jun 2021 18:33:51 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Dandan Bi , Star Zeng , Zhichao Gao , Patrick Rudolph Subject: [edk2-devel] [Patch V4 5/9] MdeModulePkg/Universal/SmbiosDxe: Scan for existing tables Date: Thu, 10 Jun 2021 09:33:14 +0800 Message-Id: <20210610013318.1885-6-zhiguang.liu@intel.com> In-Reply-To: <20210610013318.1885-1-zhiguang.liu@intel.com> References: <20210610013318.1885-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: gAn1JqGj7lbOG31sDOLLUD4ix1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1623288839; bh=4YwwF2mzdVZLqLbbKgmjIN7rTXqHVSJau4ajEojST2w=; h=Cc:Date:From:Reply-To:Subject:To; b=IHFEQMOU1gNTR55wQueJrzJEqQUdIXMdDNh8Gv6ddE51zyhTyvCQc2QoSTAD0qgl61W DNVBOGuqH0WXdR0ctg20pi9EyiVe1I4awf4zZGJLRZti/Hzc5WOQgVj/aiX1HG9d1Dfhp dBvKPKeriGYRVEtLAHkVzow5lUFhk077k3E= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" V1: The default EfiSmbiosProtocol operates on an empty SMBIOS table. The SMBIOS tables are provided by the bootloader on UefiPayloadPkg. Scan for existing tables in SmbiosDxe and load them if they seem valid. This fixes the settings menu not showing any hardware information, instead only "0 MB RAM" was displayed. Tests showed that the OS can still see the SMBIOS tables. V2: SmbiosDxe will get the SMBIOS from a guid Hob. Also will keep the SmbiosHandle if it is available. Cc: Jian J Wang Cc: Hao A Wu Cc: Dandan Bi Cc: Star Zeng Cc: Zhichao Gao Reviewed-by: Hao A Wu Signed-off-by: Patrick Rudolph Signed-off-by: Zhiguang Liu --- MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c | 293 +++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++++++++++++++++++++++++++++++++++++++++- MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h | 65 +++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++- MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf | 5 ++++- 3 files changed, 360 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c b/MdeModulePkg/Un= iversal/SmbiosDxe/SmbiosDxe.c index 3cdb0b1ed7..400b0fa578 100644 --- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c +++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c @@ -2,7 +2,7 @@ This code produces the Smbios protocol. It also responsible for construc= ting SMBIOS table into system table. =20 -Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -148,6 +148,12 @@ SMBIOS_TABLE_3_0_ENTRY_POINT Smbios30EntryPointStructu= reData =3D { // 0 }; + +IS_SMBIOS_TABLE_VALID_ENTRY mIsSmbiosTableValid[] =3D { + {&gUniversalPayloadSmbios3TableGuid, IsValidSmbios30Table }, + {&gUniversalPayloadSmbiosTableGuid, IsValidSmbios20Table } +}; + /** =20 Get the full size of SMBIOS structure including optional strings that fo= llow the formatted structure. @@ -1408,6 +1414,290 @@ SmbiosTableConstruction ( } } =20 +/** + Validates a SMBIOS 2.0 table entry point. + + @param TableEntry The SmBios table entry to validate. + @param TableAddress On exit, point to the smbios table addres. + @param TableMaximumSize On exit, point to the maximum size of the table. + + @retval TRUE SMBIOS table entry point is valid. + @retval FALSE SMBIOS table entry point is malformed. + +**/ +STATIC +BOOLEAN +IsValidSmbios20Table ( + IN VOID *TableEntry, + OUT VOID **TableAddress, + OUT UINTN *TableMaximumSize + ) +{ + UINT8 Checksum; + SMBIOS_TABLE_ENTRY_POINT *SmbiosTable; + SmbiosTable =3D (SMBIOS_TABLE_ENTRY_POINT *) TableEntry; + + if (CompareMem (SmbiosTable->AnchorString, "_SM_", 4) !=3D 0) { + return FALSE; + } + + if (CompareMem (SmbiosTable->IntermediateAnchorString, "_DMI_", 5) !=3D = 0) { + return FALSE; + } + + // + // The actual value of the EntryPointLength should be 1Fh. + // However, it was incorrectly stated in version 2.1 of smbios specifica= tion. + // Therefore, 0x1F and 0x1E are both accepted. + // + if (SmbiosTable->EntryPointLength !=3D 0x1E && SmbiosTable->EntryPointLe= ngth !=3D sizeof (SMBIOS_TABLE_ENTRY_POINT)) { + return FALSE; + } + + // + // MajorVersion should not be less than 2. + // + if (SmbiosTable->MajorVersion < 2) { + return FALSE; + } + + // + // The whole struct check sum should be zero + // + Checksum =3D CalculateSum8 ( + (UINT8 *) SmbiosTable, + SmbiosTable->EntryPointLength + ); + if (Checksum !=3D 0) { + return FALSE; + } + + // + // The Intermediate Entry Point Structure check sum should be zero. + // + Checksum =3D CalculateSum8 ( + (UINT8 *) SmbiosTable + OFFSET_OF (SMBIOS_TABLE_ENTRY_POINT= , IntermediateAnchorString), + SmbiosTable->EntryPointLength - OFFSET_OF (SMBIOS_TABLE_ENT= RY_POINT, IntermediateAnchorString) + ); + if (Checksum !=3D 0) { + return FALSE; + } + + *TableAddress =3D (VOID *) (UINTN) SmbiosTable->TableAddress; + *TableMaximumSize =3D SmbiosTable->TableLength; + return TRUE; +} + +/** + Validates a SMBIOS 3.0 table entry point. + + @param TableEntry The SmBios table entry to validate. + @param TableAddress On exit, point to the smbios table addres. + @param TableMaximumSize On exit, point to the maximum size of the table. + + @retval TRUE SMBIOS table entry point is valid. + @retval FALSE SMBIOS table entry point is malformed. + +**/ +STATIC +BOOLEAN +IsValidSmbios30Table ( + IN VOID *TableEntry, + OUT VOID **TableAddress, + OUT UINTN *TableMaximumSize + ) +{ + UINT8 Checksum; + SMBIOS_TABLE_3_0_ENTRY_POINT *SmbiosTable; + SmbiosTable =3D (SMBIOS_TABLE_3_0_ENTRY_POINT *) TableEntry; + + if (CompareMem (SmbiosTable->AnchorString, "_SM3_", 5) !=3D 0) { + return FALSE; + } + if (SmbiosTable->EntryPointLength < sizeof (SMBIOS_TABLE_3_0_ENTRY_POINT= )) { + return FALSE; + } + if (SmbiosTable->MajorVersion < 3) { + return FALSE; + } + + // + // The whole struct check sum should be zero + // + Checksum =3D CalculateSum8 ( + (UINT8 *) SmbiosTable, + SmbiosTable->EntryPointLength + ); + if (Checksum !=3D 0) { + return FALSE; + } + + *TableAddress =3D (VOID *) (UINTN) SmbiosTable->TableAddress; + *TableMaximumSize =3D SmbiosTable->TableMaximumSize; + return TRUE; +} + +/** + Parse an existing SMBIOS table and insert it using SmbiosAdd. + + @param ImageHandle The EFI_HANDLE to this driver. + @param Smbios The SMBIOS table to parse. + @param Length The length of the SMBIOS table. + + @retval EFI_SUCCESS SMBIOS table was parsed and installed. + @retval EFI_OUT_OF_RESOURCES Record was not added due to lack of system= resources. + @retval EFI_INVALID_PARAMETER Smbios is not a correct smbios table + +**/ +STATIC +EFI_STATUS +ParseAndAddExistingSmbiosTable ( + IN EFI_HANDLE ImageHandle, + IN SMBIOS_STRUCTURE_POINTER Smbios, + IN UINTN Length + ) +{ + EFI_STATUS Status; + CHAR8 *String; + EFI_SMBIOS_HANDLE SmbiosHandle; + SMBIOS_STRUCTURE_POINTER SmbiosEnd; + + SmbiosEnd.Raw =3D Smbios.Raw + Length; + + if (Smbios.Raw >=3D SmbiosEnd.Raw || Smbios.Raw =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + do { + // + // Make sure not to access memory beyond SmbiosEnd + // + if (Smbios.Raw + sizeof (SMBIOS_STRUCTURE) > SmbiosEnd.Raw || + Smbios.Raw + sizeof (SMBIOS_STRUCTURE) < Smbios.Raw) { + return EFI_INVALID_PARAMETER; + } + // + // Check for end marker + // + if (Smbios.Hdr->Type =3D=3D SMBIOS_TYPE_END_OF_TABLE) { + break; + } + // + // Make sure not to access memory beyond SmbiosEnd + // Each structure shall be terminated by a double-null (0000h). + // + if (Smbios.Raw + Smbios.Hdr->Length + 2 * sizeof (UINT8) > SmbiosEnd.R= aw || + Smbios.Raw + Smbios.Hdr->Length + 2 * sizeof (UINT8) < Smbios.Raw) { + return EFI_INVALID_PARAMETER; + } + // + // Install the table + // + SmbiosHandle =3D Smbios.Hdr->Handle; + Status =3D SmbiosAdd ( + &mPrivateData.Smbios, + ImageHandle, + &SmbiosHandle, + Smbios.Hdr + ); + + ASSERT_EFI_ERROR (Status); + if (EFI_ERROR (Status)) { + return Status; + } + // + // Go to the next SMBIOS structure. Each SMBIOS structure may include = 2 parts: + // 1. Formatted section; 2. Unformatted string section. So, 2 steps ar= e needed + // to skip one SMBIOS structure. + // + + // + // Step 1: Skip over formatted section. + // + String =3D (CHAR8 *) (Smbios.Raw + Smbios.Hdr->Length); + + // + // Step 2: Skip over unformatted string section. + // + do { + // + // Each string is terminated with a NULL(00h) BYTE and the sets of s= trings + // is terminated with an additional NULL(00h) BYTE. + // + for ( ; *String !=3D 0; String++) { + if ((UINTN) String >=3D (UINTN) SmbiosEnd.Raw - sizeof (UINT8)) { + return EFI_INVALID_PARAMETER; + } + } + + if (*(UINT8 *) ++String =3D=3D 0) { + // + // Pointer to the next SMBIOS structure. + // + Smbios.Raw =3D (UINT8 *) ++String; + break; + } + } while (TRUE); + } while (Smbios.Raw < SmbiosEnd.Raw); + + return EFI_SUCCESS; +} + +/** + Retrieve SMBIOS from Hob. + @param ImageHandle Module's image handle + + @retval EFI_SUCCESS Smbios from Hob is installed. + @return EFI_NOT_FOUND Not found Smbios from Hob. + @retval Other No Smbios from Hob is installed. + +**/ +EFI_STATUS +RetrieveSmbiosFromHob ( + IN EFI_HANDLE ImageHandle + ) +{ + EFI_STATUS Status; + UINTN Index; + SMBIOS_STRUCTURE_POINTER Smbios; + EFI_HOB_GUID_TYPE *GuidHob; + UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmBiosTableAdress; + UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader; + VOID *TableAddress; + UINTN TableMaximumSize; + + Status =3D EFI_NOT_FOUND; + + for (Index =3D 0; Index < ARRAY_SIZE (mIsSmbiosTableValid); Index++) { + GuidHob =3D GetFirstGuidHob (mIsSmbiosTableValid[Index].Guid); + if (GuidHob =3D=3D NULL) { + continue; + } + GenericHeader =3D (UNIVERSAL_PAYLOAD_GENERIC_HEADER *) GET_GUID_HOB_DA= TA (GuidHob); + if ((sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) <=3D GET_GUID_HOB_DATA_= SIZE (GuidHob)) && (GenericHeader->Length <=3D GET_GUID_HOB_DATA_SIZE (Guid= Hob))) { + if (GenericHeader->Revision =3D=3D UNIVERSAL_PAYLOAD_SMBIOS_TABLE_RE= VISION) { + // + // UNIVERSAL_PAYLOAD_SMBIOS_TABLE structure is used when Revision = equals to UNIVERSAL_PAYLOAD_SMBIOS_TABLE_REVISION + // + SmBiosTableAdress =3D (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *) GET_GUID_= HOB_DATA (GuidHob); + if (GenericHeader->Length >=3D UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FI= ELD (UNIVERSAL_PAYLOAD_SMBIOS_TABLE, SmBiosEntryPoint)) { + if (mIsSmbiosTableValid[Index].IsValid ((VOID *) (UINTN )SmBiosT= ableAdress->SmBiosEntryPoint, &TableAddress, &TableMaximumSize)) { + Smbios.Raw =3D TableAddress; + Status =3D ParseAndAddExistingSmbiosTable (ImageHandle, Smbios= , TableMaximumSize); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "RetrieveSmbiosFromHob: Failed to parse= preinstalled tables from Guid Hob\n")); + Status =3D EFI_UNSUPPORTED; + } else { + return EFI_SUCCESS; + } + } + } + } + } + } + return Status; +} + /** =20 Driver to produce Smbios protocol and pre-allocate 1 page for the final = SMBIOS table. @@ -1451,5 +1741,6 @@ SmbiosDriverEntryPoint ( &mPrivateData.Smbios ); =20 + RetrieveSmbiosFromHob (ImageHandle); return Status; } diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h b/MdeModulePkg/Un= iversal/SmbiosDxe/SmbiosDxe.h index f97c85ae40..a131bdabec 100644 --- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h +++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h @@ -1,7 +1,7 @@ /** @file This code supports the implementation of the Smbios protocol =20 -Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -24,6 +24,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include +#include =20 #define SMBIOS_INSTANCE_SIGNATURE SIGNATURE_32 ('S', 'B', 'i', 's') typedef struct { @@ -121,4 +123,65 @@ SmbiosTableConstruction ( BOOLEAN Smbios64BitTable ); =20 +/** + Validates a SMBIOS 3.0 table entry point. + + @param TableEntry The SmBios table entry to validate. + @param TableAddress On exit, point to the smbios table addres. + @param TableMaximumSize On exit, point to the maximum size of the table. + + @retval TRUE SMBIOS table entry point is valid. + @retval FALSE SMBIOS table entry point is malformed. + +**/ +STATIC +BOOLEAN +IsValidSmbios30Table ( + IN VOID *TableEntry, + OUT VOID **TableAddress, + OUT UINTN *TableMaximumSize + ); + +/** + Validates a SMBIOS 2.0 table entry point. + + @param TableEntry The SmBios table entry to validate. + @param TableAddress On exit, point to the smbios table addres. + @param TableMaximumSize On exit, point to the maximum size of the table. + + @retval TRUE SMBIOS table entry point is valid. + @retval FALSE SMBIOS table entry point is malformed. + +**/ +STATIC +BOOLEAN +IsValidSmbios20Table ( + IN VOID *TableEntry, + OUT VOID **TableAddress, + OUT UINTN *TableMaximumSize + ); + +/** + Validates a SMBIOS table entry point. + + @param TableEntry The SmBios table entry to validate. + @param TableAddress On exit, point to the smbios table addres. + @param TableMaximumSize On exit, point to the maximum size of the table. + + @retval TRUE SMBIOS table entry point is valid. + @retval FALSE SMBIOS table entry point is malformed. + +**/ +typedef +BOOLEAN +(* IS_SMBIOS_TABLE_VALID) ( + IN VOID *TableEntry, + OUT VOID **TableAddress, + OUT UINTN *TableMaximumSize + ); +typedef struct { + EFI_GUID *Guid; + IS_SMBIOS_TABLE_VALID IsValid; +} IS_SMBIOS_TABLE_VALID_ENTRY; + #endif diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf b/MdeModulePkg/= Universal/SmbiosDxe/SmbiosDxe.inf index f6c036e1dc..c03915a692 100644 --- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf +++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf @@ -1,7 +1,7 @@ ## @file # This driver initializes and installs the SMBIOS protocol, constructs SMB= IOS table into system configuration table. # -# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -41,6 +41,7 @@ UefiDriverEntryPoint DebugLib PcdLib + HobLib =20 [Protocols] gEfiSmbiosProtocolGuid ## PRODUCES @@ -48,6 +49,8 @@ [Guids] gEfiSmbiosTableGuid ## SOMETIMES_PRODUCES = ## SystemTable gEfiSmbios3TableGuid ## SOMETIMES_PRODUCES = ## SystemTable + gUniversalPayloadSmbios3TableGuid ## CONSUMES = ## HOB + gUniversalPayloadSmbiosTableGuid ## SOMETIMES_CONSUMES = ## HOB =20 [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion ## CONSUMES --=20 2.30.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 (#76297): https://edk2.groups.io/g/devel/message/76297 Mute This Topic: https://groups.io/mt/83435789/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- From nobody Tue May 14 06:47:38 2024 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+76298+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+76298+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1623288843; cv=none; d=zohomail.com; s=zohoarc; b=Ab4x5m8eioi+2Bb3NvPsJNKG4/iMr2hSLpNZ7qgW5alHOQ8GYOnLoHxqT+na+JYMc4+U5GlNBl8nNuy3lnaUnqGfghK68auyZ8ZNelPQraSGMZNqWGwyCncACXPXK6gU3mBrOu64A1qcmCRirEOeHSrbteyuk2OkcNIn+TJmZt4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623288843; 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=WdSDbSdmQzSv0mSTSP5Mh4wd0vSLtanz6Wo9lEIgrxA=; b=njkoIklGTRYq3e8/PB+cbL1+T3Fgt1yZSUlQS0J1c7Jo4czLk+c46fQeBuUZJqhyvLsQoaX5dRC71OMaMyZbhrtyfi4mZ/fuhu3O3ISw9RFz/iMHF08UTR8m5XVf8BjT7bEIlHgCOPZ8Iz6t31yD1teYWAa3V/EX/QjsRFcgKuk= 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+76298+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1623288843222225.3652158438324; Wed, 9 Jun 2021 18:34:03 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id zILMYY1788612xP7JGbkt4yE; Wed, 09 Jun 2021 18:34:02 -0700 X-Received: from mga06.intel.com (mga06.intel.com []) by mx.groups.io with SMTP id smtpd.web08.4310.1623288834084367139 for ; Wed, 09 Jun 2021 18:33:57 -0700 IronPort-SDR: kslfV86e9TVahrh16Qhqzj3dgmhVyDdv45UCDyuDS5uQxB93axt2fVmhVjFwH5q18EEImfU0JQ wRyVveqcUu3A== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="266359708" X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208,223";a="266359708" X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 18:33:54 -0700 IronPort-SDR: m57aJtoxp1X/CvTesnpWBPrb2yn3zdOAhafdzl2qzRxUEGerZpZUQeHBF6cp3z4kE193JyBlCz iOXZi1UM9OmQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208,223";a="402631009" X-Received: from fieedk002.ccr.corp.intel.com ([10.239.158.144]) by orsmga003.jf.intel.com with ESMTP; 09 Jun 2021 18:33:53 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Maurice Ma , Guo Dong , Benjamin You Subject: [edk2-devel] [Patch V4 6/9] UefiPayloadPkg: Creat gPldSmbiosTableGuid Hob Date: Thu, 10 Jun 2021 09:33:15 +0800 Message-Id: <20210610013318.1885-7-zhiguang.liu@intel.com> In-Reply-To: <20210610013318.1885-1-zhiguang.liu@intel.com> References: <20210610013318.1885-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: RP5M9C5DsfHmb5u2lLyKKWYBx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1623288842; bh=fZPNJdGCmjqw4UWdfc5Sj7GDKfE8xuNui41jtn235aA=; h=Cc:Date:From:Reply-To:Subject:To; b=Bgk22+WAyQif7tdhGiyr+zjOCN/jcre/x5V2GvmhZLj8r6E/AA+ZjH+3OhQmK6YTDhG ltsjlGZ4TX9CDoK/D6jxc05GcWiQfagXvkjloKmcKyfGxzXCQKIhGhccHdR1FnlkChMZt Mr5sit6Go3berthf5O+aecvrpxBMUAig+SU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From SysTableInfo Hob, get Smbios table address, and creat gPldSmbiosTableG= uid Hob to store it. Remove diretly adding smbios table to ConfigurationTable. Dxe module SmbiosDxe will parse it and install smbios table from it. Cc: Maurice Ma Cc: Guo Dong Cc: Benjamin You Reviewed-by: Guo Dong Signed-off-by: Zhiguang Liu --- UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c | 11 +---------- UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf | 3 +-- UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c | 12 +++++++++++- UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h | 3 ++- UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf | 3 ++- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c b/UefiPayloadPkg/Bl= SupportDxe/BlSupportDxe.c index a746d0581e..56b85b8e6d 100644 --- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c +++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c @@ -2,7 +2,7 @@ This driver will report some MMIO/IO resources to dxe core, extract smbi= os and acpi tables from bootloader. =20 - Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -129,15 +129,6 @@ BlDxeEntryPoint ( ASSERT_EFI_ERROR (Status); } =20 - // - // Install Smbios Table - // - if (SystemTableInfo->SmbiosTableBase !=3D 0 && SystemTableInfo->SmbiosTa= bleSize !=3D 0) { - DEBUG ((DEBUG_ERROR, "Install Smbios Table at 0x%lx, length 0x%x\n", S= ystemTableInfo->SmbiosTableBase, SystemTableInfo->SmbiosTableSize)); - Status =3D gBS->InstallConfigurationTable (&gEfiSmbiosTableGuid, (VOID= *)(UINTN)SystemTableInfo->SmbiosTableBase); - ASSERT_EFI_ERROR (Status); - } - // // Find the frame buffer information and update PCDs // diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf b/UefiPayloadPkg/= BlSupportDxe/BlSupportDxe.inf index cebc811355..30f41f8c39 100644 --- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf +++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf @@ -3,7 +3,7 @@ # # Report some MMIO/IO resources to dxe core, extract smbios and acpi tables # -# Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.
+# Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -43,7 +43,6 @@ =20 [Guids] gEfiAcpiTableGuid - gEfiSmbiosTableGuid gUefiSystemTableInfoGuid gUefiAcpiBoardInfoGuid gEfiGraphicsInfoHobGuid diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPaylo= adPkg/UefiPayloadEntry/UefiPayloadEntry.c index 805f5448d9..80f66a3fd5 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -234,6 +234,7 @@ BuildHobFromBl ( EFI_PEI_GRAPHICS_INFO_HOB *NewGfxInfo; EFI_PEI_GRAPHICS_DEVICE_INFO_HOB GfxDeviceInfo; EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *NewGfxDeviceInfo; + UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmBiosTableHob; =20 // // Parse memory info and build memory HOBs @@ -276,6 +277,15 @@ BuildHobFromBl ( DEBUG ((DEBUG_INFO, "Detected Acpi Table at 0x%lx, length 0x%x\n", Sys= TableInfo.AcpiTableBase, SysTableInfo.AcpiTableSize)); DEBUG ((DEBUG_INFO, "Detected Smbios Table at 0x%lx, length 0x%x\n", S= ysTableInfo.SmbiosTableBase, SysTableInfo.SmbiosTableSize)); } + // + // Creat SmBios table Hob + // + SmBiosTableHob =3D BuildGuidHob (&gUniversalPayloadSmbiosTableGuid, size= of (UNIVERSAL_PAYLOAD_SMBIOS_TABLE)); + ASSERT (SmBiosTableHob !=3D NULL); + SmBiosTableHob->Header.Revision =3D UNIVERSAL_PAYLOAD_SMBIOS_TABLE_REVIS= ION; + SmBiosTableHob->Header.Length =3D sizeof (UNIVERSAL_PAYLOAD_SMBIOS_TABLE= ); + SmBiosTableHob->SmBiosEntryPoint =3D SysTableInfo.SmbiosTableBase; + DEBUG ((DEBUG_INFO, "Create smbios table gUniversalPayloadSmbiosTableGui= d guid hob\n")); =20 // // Create guid hob for acpi board information diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h b/UefiPaylo= adPkg/UefiPayloadEntry/UefiPayloadEntry.h index 2c84d6ed53..e7d0d15118 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h @@ -1,6 +1,6 @@ /** @file * -* Copyright (c) 2020, Intel Corporation. All rights reserved.
+* Copyright (c) 2021, Intel Corporation. All rights reserved.
* * SPDX-License-Identifier: BSD-2-Clause-Patent * @@ -31,6 +31,7 @@ #include #include #include +#include =20 =20 #define LEGACY_8259_MASK_REGISTER_MASTER 0x21 diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf b/UefiPay= loadPkg/UefiPayloadEntry/UefiPayloadEntry.inf index cc59f1903b..fc5b5ce9d4 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf @@ -1,7 +1,7 @@ ## @file # This is the first module for UEFI payload. # -# Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
+# Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
# Copyright (c) 2017, AMD Incorporated. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent @@ -64,6 +64,7 @@ gEfiGraphicsInfoHobGuid gEfiGraphicsDeviceInfoHobGuid gUefiAcpiBoardInfoGuid + gUniversalPayloadSmbiosTableGuid =20 [FeaturePcd.IA32] gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## CONSUMES --=20 2.30.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 (#76298): https://edk2.groups.io/g/devel/message/76298 Mute This Topic: https://groups.io/mt/83435790/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- From nobody Tue May 14 06:47:38 2024 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+76299+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+76299+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1623288844; cv=none; d=zohomail.com; s=zohoarc; b=QG0xZTdtWeVIFnouUJXNZfqOEHlchbORMouwO46766KC5X6re7wRqAqbJC7+YPnDDBlpJkSdLGUH7RO31m5VbjnJKtWnjrq5S13X3mHBB/E8i1Gzkczj8ovxQdK9EF+iYJI1jBxaVyZQBhOuwGlhhcK/AG599uuhiSUxWgPTEn8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623288844; 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=dMvCwOB15I1zC7wsZW8rf/kGwC2D/l80g5jUsBqvrRs=; b=Wl5vEX3jW/fSPwpUVAf2tlNsfx17et2axT7G+HRy6NRQdPuvPwO1j3mJhoqY18z2LXKnZc2YuVw7BXRYOOoZNLjSxFloAXCfP7AepwVkVkSxb5FOYRgyPdgq4TSScx70FZqIYTwXmBpyGXVU1EYa4MdaWJS8KmzZON2DKcHt898= 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+76299+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1623288844008866.6098570247777; Wed, 9 Jun 2021 18:34:04 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id BGW7YY1788612xhsw0p3qfE6; Wed, 09 Jun 2021 18:34:03 -0700 X-Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web11.4376.1623288837500074409 for ; Wed, 09 Jun 2021 18:33:57 -0700 IronPort-SDR: l8yS3dzwlD9/AEfyl9oVEHFUEyjcjiTsgOYhPPcJZWxo5iFiUihe/MTWDVmE03Pfg9OLrOh2ND niyO/IXQT84w== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="266359716" X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="266359716" X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 18:33:56 -0700 IronPort-SDR: TGgC5bLqpFe/QyLOPYuq/zzfRBB3kMVdkCjJL8HBDUTRao0anVyA8GPFsNhHLUFimTIw+yM6X+ LXmsrWr1cM4A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="402631016" X-Received: from fieedk002.ccr.corp.intel.com ([10.239.158.144]) by orsmga003.jf.intel.com with ESMTP; 09 Jun 2021 18:33:54 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Jian J Wang , Hao A Wu Subject: [edk2-devel] [Patch V4 7/9] MdeModulePkg: Add new structure for the Universal Payload ACPI Table Info Hob Date: Thu, 10 Jun 2021 09:33:16 +0800 Message-Id: <20210610013318.1885-8-zhiguang.liu@intel.com> In-Reply-To: <20210610013318.1885-1-zhiguang.liu@intel.com> References: <20210610013318.1885-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: fpGJxnLmn4JOoxZafNiiQJrDx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1623288843; bh=NES1TCHsZBKS4ZAHMMh7mM75A+Elbf/caRV7Wie3QgI=; h=Cc:Date:From:Reply-To:Subject:To; b=i88V92ekH8v5B2gLxppmivncLsC8nrasEkBc9zjPmTw42m88f88zyDq1PeCVOWyugth zRHYCcmcUrqER2EwH4UYYygDAHX3xQml3yg2UCPDY1xWxUuoQTLClT68MM5vJe6RNoLBb 2N5ndXHfVrnp/g/u2lZ3DgmuWDBo1w1Y0Es= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Cc: Michael D Kinney Cc: Liming Gao Cc: Jian J Wang Cc: Hao A Wu Reviewed-by: Hao A Wu Signed-off-by: Zhiguang Liu --- MdeModulePkg/Include/UniversalPayload/AcpiTable.h | 30 +++++++++++++++++++= +++++++++++ MdeModulePkg/MdeModulePkg.dec | 3 +++ 2 files changed, 33 insertions(+) diff --git a/MdeModulePkg/Include/UniversalPayload/AcpiTable.h b/MdeModuleP= kg/Include/UniversalPayload/AcpiTable.h new file mode 100644 index 0000000000..ff60c74d86 --- /dev/null +++ b/MdeModulePkg/Include/UniversalPayload/AcpiTable.h @@ -0,0 +1,30 @@ +/** @file + Define the structure for the Universal Payload APCI table. + +Copyright (c) 2021, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Revision Reference: + - Universal Payload Specification 0.75 (https://universalpayload.githu= b.io/documentation/) +**/ + +#ifndef __UNIVERSAL_PAYLOAD_ACPI_TABLE_H_ +#define __UNIVERSAL_PAYLOAD_ACPI_TABLE_H_ + +#include +#include + +#pragma pack(1) + +typedef struct { + UNIVERSAL_PAYLOAD_GENERIC_HEADER Header; + EFI_PHYSICAL_ADDRESS Rsdp; +} UNIVERSAL_PAYLOAD_ACPI_TABLE; + +#pragma pack() + +#define UNIVERSAL_PAYLOAD_ACPI_TABLE_REVISION 1 + +extern GUID gUniversalPayloadAcpiTableGuid; + +#endif //__UNIVERSAL_PAYLOAD_ACPI_TABLE_H_ diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 377e868e7c..8c0885955b 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -416,6 +416,9 @@ ## Include/UniversalPayload/SmbiosTable.h gUniversalPayloadSmbiosTableGuid =3D { 0x590a0d26, 0x06e5, 0x4d20, { 0x8= a, 0x82, 0x59, 0xea, 0x1b, 0x34, 0x98, 0x2d } } =20 + ## Include/UniversalPayload/AcpiTable.h + gUniversalPayloadAcpiTableGuid =3D { 0x9f9a9506, 0x5597, 0x4515, { 0xba,= 0xb6, 0x8b, 0xcd, 0xe7, 0x84, 0xba, 0x87 } } + [Ppis] ## Include/Ppi/AtaController.h gPeiAtaControllerPpiGuid =3D { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0,= 0x7a, 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }} --=20 2.30.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 (#76299): https://edk2.groups.io/g/devel/message/76299 Mute This Topic: https://groups.io/mt/83435791/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- From nobody Tue May 14 06:47:38 2024 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+76300+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+76300+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1623288844; cv=none; d=zohomail.com; s=zohoarc; b=cKVQ1Sdf8jSDJGDIf5SEjvPuFC+vDy4tDHzVetQUoQi1OAC9mdcSOZSR3kfCkIywLgswWL+zPKDltQlmx8o0YjQncu5bpCaUMr7WKTcNXhP7KtzBvFPjBHN0kM1DzMC3EucxKfXsuqMrvVlzvbFmn5qTNytEPq42qaPvQNGU8Q0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623288844; 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=syBvmWzPCpI8auUnCiX//OGdFrQS2AFE6iRnJvAEqQs=; b=npg1XMPZlnrJ2Sd3RswKV/ZPLc67r/4mXRd1bNlq/zL7hgDpv5rORJYJ0q/1hhywNqWb3wTYYaTMmfpsYlM4ei/N2FE0O98P68FphMpm9jfhymONHUuzVGp5+71dhXCHntYQhgas3aCc1EAk97+ugObSG/p0RGgl2WCNcv9nME0= 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+76300+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1623288844758321.8320426035126; Wed, 9 Jun 2021 18:34:04 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 0YWnYY1788612xERFbC92nJl; Wed, 09 Jun 2021 18:34:04 -0700 X-Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web10.4380.1623288838470038504 for ; Wed, 09 Jun 2021 18:33:58 -0700 IronPort-SDR: 7l8/X9No53Y3wYqPIYAUObBdM1+JeIlPa5PSKwxOxGxhLy2GT15PTzQBdGLXYOQJ34+eWq/OXu GZ7Yn5f15/pg== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="266359721" X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="266359721" X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 18:33:58 -0700 IronPort-SDR: +AO3mzDyLUPFjyAOaVW5X6IYFLWXBfK3v2jQ08zkOF3216yMNwqoBwLY1vaKvLQUkAqIVEGN/f kdPs5yhQuqgQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="402631035" X-Received: from fieedk002.ccr.corp.intel.com ([10.239.158.144]) by orsmga003.jf.intel.com with ESMTP; 09 Jun 2021 18:33:56 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Dandan Bi , Liming Gao , Ray Ni Subject: [edk2-devel] [Patch V4 8/9] MdeModulePkg/ACPI: Install ACPI table from HOB. Date: Thu, 10 Jun 2021 09:33:17 +0800 Message-Id: <20210610013318.1885-9-zhiguang.liu@intel.com> In-Reply-To: <20210610013318.1885-1-zhiguang.liu@intel.com> References: <20210610013318.1885-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: hFHMjitsp7BanNaZ2rpt0T0nx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1623288844; bh=16ML3R+/A+IIKTHtIsDTo8Q5K+aOAtfoq6BpeagRyD0=; h=Cc:Date:From:Reply-To:Subject:To; b=oTm45N9DyvJtgnI4+DrnDVl7N86JCtNCC2u6WPts12D8bAXZn20VfF8OSA65QPO/gO9 a1lTezTL4PdY6rurkqiIRLRWokm7T9wI4L8j8Lxpff921vTcAhC8E1grUdh+7JJD1Lbxd ah4qoWd2YCN6OAS7YtPbBx3pG7u4u9eTZnI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" V1: If HOB contains APCI table information, entry point of AcpiTableDxe.inf should parse the APCI table from HOB, and install these tables. We assume the whole ACPI table (starting with EFI_ACPI_2_0_ROOT_SYSTEM_DESC= RIPTION_POINTER) is contained by a single gEfiAcpiTableGuid HOB. V2: If error happens when installing ACPI table, stop installing and removing a= ll the tables that are already added. Cc: Jian J Wang Cc: Hao A Wu Cc: Dandan Bi Cc: Liming Gao Cc: Ray Ni Reviewed-by: Hao A Wu Signed-off-by: Zhiguang Liu --- MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c | 92 +++++++= ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------= ---------- MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h | 38 +++++++= ++++++++++++++++++++++++++++++- MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf | 8 +++++--- MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 171 +++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++------- 4 files changed, 271 insertions(+), 38 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c b/MdeModule= Pkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c index 14ced68e64..d98573d613 100644 --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c @@ -1,7 +1,7 @@ /** @file ACPI Sdt Protocol Driver =20 - Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -191,8 +191,7 @@ SdtNotifyAcpiList ( /** Returns a requested ACPI table. =20 - The GetAcpiTable() function returns a pointer to a buffer containing the= ACPI table associated - with the Index that was input. The following structures are not consider= ed elements in the list of + The following structures are not considered elements in the list of ACPI tables: - Root System Description Pointer (RSD_PTR) - Root System Description Table (RSDT) @@ -201,42 +200,32 @@ SdtNotifyAcpiList ( member. For tables installed via the EFI_ACPI_TABLE_PROTOCOL.InstallAcpi= Table() interface, the function returns the value of EFI_ACPI_STD_PROTOCOL.AcpiVersion. =20 - @param[in] Index The zero-based index of the table to retrieve. - @param[out] Table Pointer for returning the table buffer. - @param[out] Version On return, updated with the ACPI versions to w= hich this table belongs. Type - EFI_ACPI_TABLE_VERSION is defined in "Related = Definitions" in the - EFI_ACPI_SDT_PROTOCOL. - @param[out] TableKey On return, points to the table key for the spe= cified ACPI system definition table. - This is identical to the table key used in the= EFI_ACPI_TABLE_PROTOCOL. - The TableKey can be passed to EFI_ACPI_TABLE_P= ROTOCOL.UninstallAcpiTable() - to uninstall the table. - @retval EFI_SUCCESS The function completed successfully. - @retval EFI_NOT_FOUND The requested index is too large and a table w= as not found. + @param[in] AcpiTableInstance ACPI table Instance. + @param[in] Index The zero-based index of the table to re= trieve. + @param[out] Table Pointer for returning the table buffer. + @param[out] Version On return, updated with the ACPI versio= ns to which this table belongs. Type + EFI_ACPI_TABLE_VERSION is defined in "R= elated Definitions" in the + EFI_ACPI_SDT_PROTOCOL. + @param[out] TableKey On return, points to the table key for = the specified ACPI system definition table. + This is identical to the table key used= in the EFI_ACPI_TABLE_PROTOCOL. + The TableKey can be passed to EFI_ACPI_= TABLE_PROTOCOL.UninstallAcpiTable() + to uninstall the table. + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_NOT_FOUND The requested index is too large and a = table was not found. **/ EFI_STATUS -EFIAPI -GetAcpiTable2 ( +SdtGetAcpiTable ( + IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance, IN UINTN Index, OUT EFI_ACPI_SDT_HEADER **Table, OUT EFI_ACPI_TABLE_VERSION *Version, OUT UINTN *TableKey ) { - EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance; UINTN TableIndex; LIST_ENTRY *CurrentLink; LIST_ENTRY *StartLink; EFI_ACPI_TABLE_LIST *CurrentTable; - - ASSERT (Table !=3D NULL); - ASSERT (Version !=3D NULL); - ASSERT (TableKey !=3D NULL); - - // - // Get the instance of the ACPI Table - // - AcpiTableInstance =3D SdtGetAcpiTableInstance (); - // // Find the table // @@ -270,6 +259,55 @@ GetAcpiTable2 ( return EFI_SUCCESS; } =20 +/** + Returns a requested ACPI table. + + The GetAcpiTable() function returns a pointer to a buffer containing the= ACPI table associated + with the Index that was input. The following structures are not consider= ed elements in the list of + ACPI tables: + - Root System Description Pointer (RSD_PTR) + - Root System Description Table (RSDT) + - Extended System Description Table (XSDT) + Version is updated with a bit map containing all the versions of ACPI of= which the table is a + member. For tables installed via the EFI_ACPI_TABLE_PROTOCOL.InstallAcpi= Table() interface, + the function returns the value of EFI_ACPI_STD_PROTOCOL.AcpiVersion. + + @param[in] Index The zero-based index of the table to retrieve. + @param[out] Table Pointer for returning the table buffer. + @param[out] Version On return, updated with the ACPI versions to w= hich this table belongs. Type + EFI_ACPI_TABLE_VERSION is defined in "Related = Definitions" in the + EFI_ACPI_SDT_PROTOCOL. + @param[out] TableKey On return, points to the table key for the spe= cified ACPI system definition table. + This is identical to the table key used in the= EFI_ACPI_TABLE_PROTOCOL. + The TableKey can be passed to EFI_ACPI_TABLE_P= ROTOCOL.UninstallAcpiTable() + to uninstall the table. + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_NOT_FOUND The requested index is too large and a table w= as not found. +**/ +EFI_STATUS +EFIAPI +GetAcpiTable2 ( + IN UINTN Index, + OUT EFI_ACPI_SDT_HEADER **Table, + OUT EFI_ACPI_TABLE_VERSION *Version, + OUT UINTN *TableKey + ) +{ + EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance; + + ASSERT (Table !=3D NULL); + ASSERT (Version !=3D NULL); + ASSERT (TableKey !=3D NULL); + + // + // Get the instance of the ACPI Table + // + AcpiTableInstance =3D SdtGetAcpiTableInstance (); + + return SdtGetAcpiTable (AcpiTableInstance, Index, Table, Version, TableK= ey); +} + + /** Register a callback when an ACPI table is installed. =20 diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h b/MdeModu= lePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h index 9d7cf7ccfc..0af2d11a1a 100644 --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h @@ -1,7 +1,7 @@ /** @file ACPI Table Protocol Driver =20 - Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -24,6 +24,8 @@ #include #include #include +#include +#include =20 // // Statements that include other files @@ -228,6 +230,40 @@ SdtAcpiTableAcpiSdtConstructor ( IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance ); =20 +/** + Returns a requested ACPI table. + + The following structures are not considered elements in the list of + ACPI tables: + - Root System Description Pointer (RSD_PTR) + - Root System Description Table (RSDT) + - Extended System Description Table (XSDT) + Version is updated with a bit map containing all the versions of ACPI of= which the table is a + member. For tables installed via the EFI_ACPI_TABLE_PROTOCOL.InstallAcpi= Table() interface, + the function returns the value of EFI_ACPI_STD_PROTOCOL.AcpiVersion. + + @param[in] AcpiTableInstance ACPI table Instance. + @param[in] Index The zero-based index of the table to re= trieve. + @param[out] Table Pointer for returning the table buffer. + @param[out] Version On return, updated with the ACPI versio= ns to which this table belongs. Type + EFI_ACPI_TABLE_VERSION is defined in "R= elated Definitions" in the + EFI_ACPI_SDT_PROTOCOL. + @param[out] TableKey On return, points to the table key for = the specified ACPI system definition table. + This is identical to the table key used= in the EFI_ACPI_TABLE_PROTOCOL. + The TableKey can be passed to EFI_ACPI_= TABLE_PROTOCOL.UninstallAcpiTable() + to uninstall the table. + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_NOT_FOUND The requested index is too large and a = table was not found. +**/ +EFI_STATUS +SdtGetAcpiTable ( + IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance, + IN UINTN Index, + OUT EFI_ACPI_SDT_HEADER **Table, + OUT EFI_ACPI_TABLE_VERSION *Version, + OUT UINTN *TableKey + ); + // // export PrivateData symbol, because we need that in AcpiSdtProtol implem= entation // diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf b/Md= eModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf index d341df439e..86dea43e27 100644 --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf @@ -4,7 +4,7 @@ # This driver initializes ACPI tables (Rsdp, Rsdt and Xsdt) and produces = UEFI/PI # services to install/uninstall/manage ACPI tables. # -# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
# Copyright (c) 2016, Linaro Ltd. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -51,10 +51,12 @@ DebugLib BaseLib PcdLib + HobLib =20 [Guids] - gEfiAcpi10TableGuid ## PRODUCES ## SystemTable - gEfiAcpiTableGuid ## PRODUCES ## SystemTable + gEfiAcpi10TableGuid ## PRODUCES ## S= ystemTable + gEfiAcpiTableGuid ## PRODUCES ## S= ystemTable + gUniversalPayloadAcpiTableGuid ## SOMETIMES_CONSUMES ## H= OB =20 [FeaturePcd] gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol ## CONSUMES diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c b= /MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c index 5a2afdff27..34d4a1cec0 100644 --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c @@ -1,7 +1,7 @@ /** @file ACPI Table Protocol Implementation =20 - Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
Copyright (c) 2016, Linaro Ltd. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -30,6 +30,7 @@ STATIC EFI_ALLOCATE_TYPE mAcpiTableAllocType; @param Table Table to add. @param Checksum Does the table require checksumming. @param Version The version of the list to add the tab= le to. + @param IsFromHob True, if add Apci Table from Hob List. @param Handle Pointer for returning the handle. =20 @return EFI_SUCCESS The function completed successfully. @@ -44,6 +45,7 @@ AddTableToList ( IN VOID *Table, IN BOOLEAN Checksum, IN EFI_ACPI_TABLE_VERSION Version, + IN BOOLEAN IsFromHob, OUT UINTN *Handle ); =20 @@ -238,6 +240,7 @@ InstallAcpiTable ( AcpiTableBufferConst, TRUE, Version, + FALSE, TableKey ); if (!EFI_ERROR (Status)) { @@ -472,6 +475,7 @@ FreeTableMemory ( @param Table Table to add. @param Checksum Does the table require checksumming. @param Version The version of the list to add the tab= le to. + @param IsFromHob True, if add Apci Table from Hob List. @param Handle Pointer for returning the handle. =20 @return EFI_SUCCESS The function completed successfully. @@ -487,6 +491,7 @@ AddTableToList ( IN VOID *Table, IN BOOLEAN Checksum, IN EFI_ACPI_TABLE_VERSION Version, + IN BOOLEAN IsFromHob, OUT UINTN *Handle ) { @@ -553,12 +558,17 @@ AddTableToList ( // SMM communication ACPI table. // ASSERT ((EFI_PAGE_SIZE % 64) =3D=3D 0); - Status =3D gBS->AllocatePages ( - AllocateMaxAddress, - EfiACPIMemoryNVS, - EFI_SIZE_TO_PAGES (CurrentTableList->TableSize), - &AllocPhysAddress - ); + if (IsFromHob){ + AllocPhysAddress =3D (UINTN)Table; + Status =3D EFI_SUCCESS; + } else { + Status =3D gBS->AllocatePages ( + AllocateMaxAddress, + EfiACPIMemoryNVS, + EFI_SIZE_TO_PAGES (CurrentTableList->TableSize), + &AllocPhysAddress + ); + } } else if (mAcpiTableAllocType =3D=3D AllocateAnyPages) { // // If there is no allocation limit, there is also no need to use page @@ -1689,6 +1699,151 @@ ChecksumCommonTables ( return EFI_SUCCESS; } =20 +/** + This function will find gUniversalPayloadAcpiTableGuid Guid Hob, and ins= tall Acpi table from it. + + @param AcpiTableInstance Protocol instance private data. + + @return EFI_SUCCESS The function completed successfully. + @return EFI_NOT_FOUND The function doesn't find the gEfiAcpiTableGu= id Guid Hob. + @return EFI_ABORTED The function could not complete successfully. + +**/ +EFI_STATUS +InstallAcpiTableFromHob ( + EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance + ) +{ + EFI_HOB_GUID_TYPE *GuidHob; + EFI_ACPI_TABLE_VERSION Version; + EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp; + EFI_ACPI_DESCRIPTION_HEADER *Rsdt; + EFI_ACPI_DESCRIPTION_HEADER *ChildTable; + UINT64 ChildTableAddress; + UINTN Count; + UINTN Index; + UINTN TableKey; + EFI_STATUS Status; + UINTN EntrySize; + UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTableAdress; + VOID *TableToInstall; + EFI_ACPI_SDT_HEADER *Table; + UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader; + + TableKey =3D 0; + Version =3D PcdGet32 (PcdAcpiExposedTableVersions); + Status =3D EFI_SUCCESS; + // + // HOB only contains the ACPI table in 2.0+ format. + // + GuidHob =3D GetFirstGuidHob (&gUniversalPayloadAcpiTableGuid); + 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_ACPI_TABLE_REVISION= ) { + // + // UNIVERSAL_PAYLOAD_ACPI_TABLE structure is used when Revision equals= to UNIVERSAL_PAYLOAD_ACPI_TABLE_REVISION + // + AcpiTableAdress =3D (UNIVERSAL_PAYLOAD_ACPI_TABLE *) GET_GUID_HOB_DATA= (GuidHob); + if (AcpiTableAdress->Header.Length < UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_= FIELD (UNIVERSAL_PAYLOAD_ACPI_TABLE, Rsdp)) { + // + // Retrun if can't find the ACPI Info Hob with enough length + // + return EFI_NOT_FOUND; + } + Rsdp =3D (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *) (UINTN) (Acp= iTableAdress->Rsdp); + + // + // An ACPI-compatible OS must use the XSDT if present. + // It shouldn't happen that XsdtAddress points beyond 4G range in 32-b= it environment. + // + ASSERT ((UINTN) Rsdp->XsdtAddress =3D=3D Rsdp->XsdtAddress); + + EntrySize =3D sizeof (UINT64); + Rsdt =3D (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress; + if (Rsdt =3D=3D NULL) { + // + // XsdtAddress is zero, then we use Rsdt which has 32 bit entry + // + Rsdt =3D (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress; + EntrySize =3D sizeof (UINT32); + } + + if (Rsdt->Length <=3D sizeof (EFI_ACPI_DESCRIPTION_HEADER)) { + return EFI_ABORTED; + } + + Count =3D (Rsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / Entr= ySize; + + for (Index =3D 0; Index < Count; Index++){ + ChildTableAddress =3D 0; + CopyMem (&ChildTableAddress, (UINT8 *) (Rsdt + 1) + EntrySize * Inde= x, EntrySize); + // + // If the address is of UINT64 while this module runs at 32 bits, + // make sure the upper bits are all-zeros. + // + ASSERT (ChildTableAddress =3D=3D (UINTN) ChildTableAddress); + if (ChildTableAddress !=3D (UINTN) ChildTableAddress) { + Status =3D EFI_ABORTED; + break; + } + + ChildTable =3D (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) ChildTableAdd= ress; + Status =3D AddTableToList (AcpiTableInstance, ChildTable, TRUE, Vers= ion, TRUE, &TableKey); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "InstallAcpiTableFromHob: Fail to add ACPI ta= ble at 0x%p\n", ChildTable)); + ASSERT_EFI_ERROR (Status); + break; + } + if (ChildTable->Signature =3D=3D EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION= _TABLE_SIGNATURE){ + // + // Add the FACS and DSDT tables if it is not NULL. + // + if (((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *) ChildTable)->Fi= rmwareCtrl !=3D 0) { + TableToInstall =3D (VOID *) (UINTN) ((EFI_ACPI_3_0_FIXED_ACPI_DE= SCRIPTION_TABLE *) ChildTable)->FirmwareCtrl; + Status =3D AddTableToList (AcpiTableInstance, TableToInstall, TR= UE, Version, TRUE, &TableKey); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "InstallAcpiTableFromHob: Fail to add ACP= I table FACS\n")); + ASSERT_EFI_ERROR (Status); + break; + } + } + + if (((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *) ChildTable)->Ds= dt !=3D 0) { + TableToInstall =3D (VOID *) (UINTN) ((EFI_ACPI_3_0_FIXED_ACPI_DE= SCRIPTION_TABLE *) ChildTable)->Dsdt; + Status =3D AddTableToList (AcpiTableInstance, TableToInstall, TR= UE, Version, TRUE, &TableKey); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "InstallAcpiTableFromHob: Fail to add ACP= I table DSDT\n")); + ASSERT_EFI_ERROR (Status); + break; + } + } + } + } + } else { + return EFI_NOT_FOUND; + } + + if (EFI_ERROR (Status)) { + // + // Error happens when trying to add ACPI table to the list. + // Remove all of them from list because at this time, no other tables = except from HOB are in the list + // + while (SdtGetAcpiTable (AcpiTableInstance, 0, &Table, &Version, &Table= Key) =3D=3D EFI_SUCCESS) { + RemoveTableFromList (AcpiTableInstance, Version, TableKey); + } + } else { + Status =3D PublishTables (AcpiTableInstance, Version); + } + + ASSERT_EFI_ERROR (Status); + return Status; +} =20 /** Constructor for the ACPI table protocol. Initializes instance @@ -1918,6 +2073,8 @@ AcpiTableAcpiTableConstructor ( =20 ChecksumCommonTables (AcpiTableInstance); =20 + InstallAcpiTableFromHob (AcpiTableInstance); + // // Completed successfully // --=20 2.30.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 (#76300): https://edk2.groups.io/g/devel/message/76300 Mute This Topic: https://groups.io/mt/83435792/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- From nobody Tue May 14 06:47:38 2024 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+76301+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+76301+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1623288845; cv=none; d=zohomail.com; s=zohoarc; b=M2UKPUKRSYZwcWHmdjh8O4zqiTLLgE5XUqZiXre6XW1pkbvi52Gk6DYDX/v+vu8VTxI+iNAYQ7MrBm6JC6RAfdmwEdyXK3aDWMoZbzdat+QcylQvSN57tpcaffBeC9NGG6cQH5FglakJy/2F9DK+W88mUDnbtd47jfSSaDmv8Ec= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623288845; 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=PGqUQHIMJi5X6dxUtU5zmP6e4k+xr2X7m77uXwe05Ns=; b=JEQqjzVpTWcHhdKkt9zCLVcMty7SPXZRsqMMNleUbxz281qVi5bafoipsvFl8quBdyWNGmOArDObg4ufg0c9GlATRK6tPHVeHs0A286zZfM4BwYBfKItvKizHW5JOrjWrySG7cUSM/3S4WfXDXYOAerV4cBUwupsL3aqdszNsSI= 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+76301+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1623288845932762.6863967040786; Wed, 9 Jun 2021 18:34:05 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id X0XCYY1788612xirf9WMQ0mq; Wed, 09 Jun 2021 18:34:05 -0700 X-Received: from mga06.intel.com (mga06.intel.com []) by mx.groups.io with SMTP id smtpd.web10.4380.1623288838470038504 for ; Wed, 09 Jun 2021 18:34:00 -0700 IronPort-SDR: Eutmij+BCGcBQ6KeBdxAeFfeHHINH7IhfJFvK8NCHhdnKU9isSMuvc43YB7rgvZgbdZW2zNGI4 yA6iTIhIvizg== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="266359730" X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208,223";a="266359730" X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 18:33:59 -0700 IronPort-SDR: +wPfH/f6WXf4ATfWGo1I9weMpHQMVMWLe/dubfuAOaXg3H7ta28RCAqk3Wp/xPOUwX4QIxvAbr cq1ua/cwbmnw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208,223";a="402631047" X-Received: from fieedk002.ccr.corp.intel.com ([10.239.158.144]) by orsmga003.jf.intel.com with ESMTP; 09 Jun 2021 18:33:58 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Maurice Ma , Guo Dong , Benjamin You , Ray Ni Subject: [edk2-devel] [Patch V4 9/9] UefiPayloadPkg: Creat gPldAcpiTableGuid Hob Date: Thu, 10 Jun 2021 09:33:18 +0800 Message-Id: <20210610013318.1885-10-zhiguang.liu@intel.com> In-Reply-To: <20210610013318.1885-1-zhiguang.liu@intel.com> References: <20210610013318.1885-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: gNj8nRmARIyUOrEAoSHeuBcax1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1623288845; bh=f9qDKr9UkBZVTLGqW799yUwP9NoCP4rBTWC8OHS3G/I=; h=Cc:Date:From:Reply-To:Subject:To; b=jt4XNolkf8483949mm+wff8/M3+R1sJFS/CmwkYhP/teC4t7YIJ9KbpTTp8t2KDMmOH MGVWucP408dXDdgLBnVgt6/eOBBusv8J37G+alfkKun77ROL6mG5WJdXfzmR5mq/zuRY3 RAHrUxmKv2Td2Et8e7IwgnO3RAGVwobnkjU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From SysTableInfo Hob, get ACPI table address, and creat gPldAcpiTableGuid = Hob to store it. Remove diretly adding ACPI table to ConfigurationTable. Dxe ACPI driver will parse it and install ACPI table from Guid Hob. Cc: Maurice Ma Cc: Guo Dong Cc: Benjamin You Cc: Ray Ni Signed-off-by: Zhiguang Liu Reviewed-by: Guo Dong --- UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c | 17 ----------------- UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h | 5 +---- UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf | 1 - UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c | 11 +++++++++++ UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h | 2 +- UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf | 1 + UefiPayloadPkg/UefiPayloadPkg.fdf | 4 ++++ 7 files changed, 18 insertions(+), 23 deletions(-) diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c b/UefiPayloadPkg/Bl= SupportDxe/BlSupportDxe.c index 56b85b8e6d..ffd3427fb3 100644 --- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c +++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c @@ -99,7 +99,6 @@ BlDxeEntryPoint ( { EFI_STATUS Status; EFI_HOB_GUID_TYPE *GuidHob; - SYSTEM_TABLE_INFO *SystemTableInfo; EFI_PEI_GRAPHICS_INFO_HOB *GfxInfo; ACPI_BOARD_INFO *AcpiBoardInfo; =20 @@ -113,22 +112,6 @@ BlDxeEntryPoint ( Status =3D ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0= xFED00000, SIZE_1KB, 0, ImageHandle); // HPET ASSERT_EFI_ERROR (Status); =20 - // - // Find the system table information guid hob - // - GuidHob =3D GetFirstGuidHob (&gUefiSystemTableInfoGuid); - ASSERT (GuidHob !=3D NULL); - SystemTableInfo =3D (SYSTEM_TABLE_INFO *)GET_GUID_HOB_DATA (GuidHob); - - // - // Install Acpi Table - // - if (SystemTableInfo->AcpiTableBase !=3D 0 && SystemTableInfo->AcpiTableS= ize !=3D 0) { - DEBUG ((DEBUG_ERROR, "Install Acpi Table at 0x%lx, length 0x%x\n", Sys= temTableInfo->AcpiTableBase, SystemTableInfo->AcpiTableSize)); - Status =3D gBS->InstallConfigurationTable (&gEfiAcpiTableGuid, (VOID *= )(UINTN)SystemTableInfo->AcpiTableBase); - ASSERT_EFI_ERROR (Status); - } - // // Find the frame buffer information and update PCDs // diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h b/UefiPayloadPkg/Bl= SupportDxe/BlSupportDxe.h index 512105fafd..3332a30eae 100644 --- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h +++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h @@ -1,7 +1,7 @@ /** @file The header file of bootloader support DXE. =20 -Copyright (c) 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -19,12 +19,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include =20 -#include #include #include #include #include =20 -#include - #endif diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf b/UefiPayloadPkg/= BlSupportDxe/BlSupportDxe.inf index 30f41f8c39..1ccb250991 100644 --- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf +++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf @@ -42,7 +42,6 @@ HobLib =20 [Guids] - gEfiAcpiTableGuid gUefiSystemTableInfoGuid gUefiAcpiBoardInfoGuid gEfiGraphicsInfoHobGuid diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPaylo= adPkg/UefiPayloadEntry/UefiPayloadEntry.c index 80f66a3fd5..f44e0ea7f0 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c @@ -235,6 +235,7 @@ BuildHobFromBl ( EFI_PEI_GRAPHICS_DEVICE_INFO_HOB GfxDeviceInfo; EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *NewGfxDeviceInfo; UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmBiosTableHob; + UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTableHob; =20 // // Parse memory info and build memory HOBs @@ -287,6 +288,16 @@ BuildHobFromBl ( SmBiosTableHob->SmBiosEntryPoint =3D SysTableInfo.SmbiosTableBase; DEBUG ((DEBUG_INFO, "Create smbios table gUniversalPayloadSmbiosTableGui= d guid hob\n")); =20 + //=20 + // Creat ACPI table Hob + // + AcpiTableHob =3D BuildGuidHob (&gUniversalPayloadAcpiTableGuid, sizeof (= UNIVERSAL_PAYLOAD_ACPI_TABLE)); + ASSERT (AcpiTableHob !=3D NULL); + AcpiTableHob->Header.Revision =3D UNIVERSAL_PAYLOAD_ACPI_TABLE_REVISION; + AcpiTableHob->Header.Length =3D sizeof (UNIVERSAL_PAYLOAD_ACPI_TABLE); + AcpiTableHob->Rsdp =3D SysTableInfo.AcpiTableBase; + DEBUG ((DEBUG_INFO, "Create smbios table gUniversalPayloadAcpiTableGuid = guid hob\n")); + // // Create guid hob for acpi board information // diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h b/UefiPaylo= adPkg/UefiPayloadEntry/UefiPayloadEntry.h index e7d0d15118..a4c9da128e 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h @@ -32,7 +32,7 @@ #include #include #include - +#include =20 #define LEGACY_8259_MASK_REGISTER_MASTER 0x21 #define LEGACY_8259_MASK_REGISTER_SLAVE 0xA1 diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf b/UefiPay= loadPkg/UefiPayloadEntry/UefiPayloadEntry.inf index fc5b5ce9d4..8d42925fcd 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf @@ -65,6 +65,7 @@ gEfiGraphicsDeviceInfoHobGuid gUefiAcpiBoardInfoGuid gUniversalPayloadSmbiosTableGuid + gUniversalPayloadAcpiTableGuid =20 [FeaturePcd.IA32] gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## CONSUMES diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf b/UefiPayloadPkg/UefiPayload= Pkg.fdf index 8fc509024b..ed7fbcaddb 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.fdf +++ b/UefiPayloadPkg/UefiPayloadPkg.fdf @@ -175,6 +175,10 @@ INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf INF MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf =20 +# +# ACPI Support +# +INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf =20 # # Shell --=20 2.30.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 (#76301): https://edk2.groups.io/g/devel/message/76301 Mute This Topic: https://groups.io/mt/83435793/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-