From nobody Tue Feb 10 05:44:16 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+76512+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+76512+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1623748379; cv=none; d=zohomail.com; s=zohoarc; b=BinDdaVKFxjEvfI3vgUcw81ylRDJSEil3Zf2U03G9NpMkwc5vsuKDRObytJbCCehO9Y3rEqG37N3LD0S/yuCcYW4++7yiCdJKRirM2YJlz/792Pd9XfYU3G3HCwWc/jMdUNZ9a+rz0amcW+W7H1x4xCAG2GvGT8UV+7EIIV79Fc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623748379; 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=3r1xj9EvQd+m9sSTbR3f34EjlCTW/bKcbeTfDvDxKBQ=; b=BuHodE3TB9MXFYJ78Nic7dNVcAhwhFbHpz+nefOw8RsGe3JaedrSSZfic7HClLXSd0m8XrYh1C/1MtdtP1jOEEYSJXJkcD3TxZj1R98ieHzUCpDv38D7jiEssqaXu/0NAmEPWfLMDJJQNHgw1xo3kn88nZfnqEVFSgSAnwNhbBg= 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+76512+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1623748379046440.1621192864874; Tue, 15 Jun 2021 02:12:59 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id zOmSYY1788612x5204SJ3QMo; Tue, 15 Jun 2021 02:12:58 -0700 X-Received: from mga12.intel.com (mga12.intel.com []) by mx.groups.io with SMTP id smtpd.web11.6831.1623748371467770763 for ; Tue, 15 Jun 2021 02:12:53 -0700 IronPort-SDR: 8792uOYISETiDkZlBG069XFQoLg5N/tWNNaSKk4nKSrKnWQ3gYrAAeLdSE5pJsDAvEzL35rhUH FOvnsvDbbocA== X-IronPort-AV: E=McAfee;i="6200,9189,10015"; a="185647649" X-IronPort-AV: E=Sophos;i="5.83,275,1616482800"; d="scan'208";a="185647649" X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2021 02:12:35 -0700 IronPort-SDR: /C+5FA7eF7xVLVNRgxtoUiqq+2DWyn/V+XCAo5GPmWLBBf7A6J697R6BCqW8v/JQ5la7FF5hqr AqgLmIFzLEew== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,275,1616482800"; d="scan'208";a="487713226" X-Received: from fieedk002.ccr.corp.intel.com ([10.239.158.144]) by fmsmga002.fm.intel.com with ESMTP; 15 Jun 2021 02:12:33 -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 V5 8/9] MdeModulePkg/ACPI: Install ACPI table from HOB. Date: Tue, 15 Jun 2021 17:12:10 +0800 Message-Id: <20210615091211.801-9-zhiguang.liu@intel.com> In-Reply-To: <20210615091211.801-1-zhiguang.liu@intel.com> References: <20210615091211.801-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: jJ5alSd6SnFDXW874ySEzY78x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1623748378; bh=1LvKAY8A2IEAIJQN/3TwNA1W4+pM8Lr+fJ0ebU8SGEE=; h=Cc:Date:From:Reply-To:Subject:To; b=KZ9N7nCzdmjg5AbnV9ywxtqfuOv38zIa5vWK3R66mlm6NbCR3B0DSbywkJl1uY0HTOG 1HrpnB7LbjzcbjsczehbcDcihwoUO6HZOAGppUj1sqlS+7MFsMuGTSzimtG/6DtFlBLMJ NeEhDMUiOY7TLOeVLPeJu/kM3aMp5YZ1tPI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" 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_DESCRIPTION_POINTER) is contained by a single gEfiAcpiTableGuid HOB. If error happens when installing ACPI table, stop installing and removing all 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 (#76512): https://edk2.groups.io/g/devel/message/76512 Mute This Topic: https://groups.io/mt/83551801/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-