From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 96FC1D800CE for ; Wed, 19 Jun 2024 22:06:56 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=6DIi5pRjT2nesxYvE1w62LuycWxTI669XOYkn03rfVk=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1718834816; v=1; b=jIGS77BXF08e4JFRw3VyM1JHIsNesM0pzM6qAk36m+OG8FHggXxbYieYgC1VllzH/jZzr38y NxG51/mlih+4l8NCcAS4SpZPX+pTxNU/Nz9seajHt5x1MUuHtXlY2fplFJHsMeRlZoehe/7nMwh lL97Y8Y82JpAQeit0pmTYA/odBSK2bGHUlf/vAxMBrjPu2liLrgwqWsKJPSdBpu+uyh3b8Y8ao/ e73pBYDwhWWpwJzLQ1Xzt10txRknZ8ZaA7Kjd+fByKm3YUoqPyBnHnGC6OKzzcRO/uRrzLzT7z8 CcnRL3OahBh0pM+y75XQPKL/VbyYCE9YQsvxVdNsMOiwQ== X-Received: by 127.0.0.2 with SMTP id CrdEYY7687511xypQl9rQ6Mp; Wed, 19 Jun 2024 15:06:55 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.34042.1718834814384929173 for ; Wed, 19 Jun 2024 15:06:54 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BFF761515; Wed, 19 Jun 2024 15:07:18 -0700 (PDT) X-Received: from e126645.home (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 62EC73F64C; Wed, 19 Jun 2024 15:06:51 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Pierre Gondois , AbdulLateef Attar , Girish Mahadevan , Jeff Brasen , Jeshua Smith , Leif Lindholm , Meenakshi Aggarwal , Sami Mujawar , Sunil V L , Yeo Reum Yun Subject: [edk2-devel] [staging/dynamictables-reorg PATCH 03/15] DynamicTablesPkg: AcpiFadtLib: Prepare to support other archs Date: Thu, 20 Jun 2024 00:06:17 +0200 Message-Id: <20240619220629.1994362-4-pierre.gondois@arm.com> In-Reply-To: <20240619220629.1994362-1-pierre.gondois@arm.com> References: <20240619220629.1994362-1-pierre.gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Wed, 19 Jun 2024 15:06:54 -0700 Resent-From: pierre.gondois@arm.com Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: G2o9FAqDRA13L0fuMBikaR9bx7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=jIGS77BX; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none) Allow other architectures to reuse the AcpiFadtLib by extracting the Arm specific part of the table generation. Suggested-by: Sunil V L Signed-off-by: Pierre Gondois --- .../Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf | 7 + .../Common/AcpiFadtLib/Arm/ArmFadtGenerator.c | 126 ++++++++++++++++++ .../AcpiFadtLib/Common/CommonFadtGenerator.c | 46 +++++++ .../Acpi/Common/AcpiFadtLib/FadtGenerator.c | 86 ++---------- .../Acpi/Common/AcpiFadtLib/FadtGenerator.h | 35 +++++ 5 files changed, 224 insertions(+), 76 deletions(-) create mode 100644 DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/Arm/Ar= mFadtGenerator.c create mode 100644 DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/Common= /CommonFadtGenerator.c create mode 100644 DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGe= nerator.h diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.i= nf b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf index c9cd850faac0..be2af0cfd53a 100644 --- a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf +++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf @@ -18,6 +18,13 @@ [Defines] =0D [Sources]=0D FadtGenerator.c=0D + FadtGenerator.h=0D +=0D +[Sources.ARM, Sources.AARCH64]=0D + Arm/ArmFadtGenerator.c=0D +=0D +[Sources.IA32, Sources.X64]=0D + Common/CommonFadtGenerator.c=0D =0D [Packages]=0D MdePkg/MdePkg.dec=0D diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/Arm/ArmFadtGe= nerator.c b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/Arm/ArmFadtGen= erator.c new file mode 100644 index 000000000000..2d2afe98ab1f --- /dev/null +++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/Arm/ArmFadtGenerator= .c @@ -0,0 +1,126 @@ +/** @file=0D + ARM FADT Table Helpers=0D +=0D + Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D + @par Reference(s):=0D + - ACPI 6.5 Specification, Aug 29, 2022=0D +=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +=0D +// Module specific include files.=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include "FadtGenerator.h"=0D +=0D +/** ARM Standard FADT Generator=0D +=0D +Requirements:=0D + The following Configuration Manager Object(s) are required by=0D + this Generator:=0D + - EArmObjBootArchInfo=0D +*/=0D +=0D +/** This macro expands to a function that retrieves the Boot=0D + Architecture Information from the Configuration Manager.=0D +*/=0D +GET_OBJECT_LIST (=0D + EObjNameSpaceArm,=0D + EArmObjBootArchInfo,=0D + CM_ARM_BOOT_ARCH_INFO=0D + );=0D +=0D +/** This macro defines the FADT flag options for ARM Platforms.=0D +*/=0D +#define FADT_FLAGS (EFI_ACPI_6_5_HW_REDUCED_ACPI | \=0D + EFI_ACPI_6_5_LOW_POWER_S0_IDLE_CAPABLE)=0D +=0D +/** Updates the Architecture specific information in the FADT Table.=0D +=0D + @param [in] CfgMgrProtocol Pointer to the Configuration Manager=0D + Protocol Interface.=0D + @param [in, out] Fadt Pointer to the constructed ACPI Table.=0D +=0D + @retval EFI_SUCCESS Success.=0D + @retval EFI_INVALID_PARAMETER A parameter is invalid.=0D + @retval EFI_NOT_FOUND The required object was not found.=0D + @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration=0D + Manager is less than the Object size for t= he=0D + requested object.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +EFIAPI=0D +ArmFadtBootArchInfoUpdate (=0D + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,= =0D + IN OUT EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE *Fadt=0D + )=0D +{=0D + EFI_STATUS Status;=0D + CM_ARM_BOOT_ARCH_INFO *BootArchInfo;=0D +=0D + ASSERT (CfgMgrProtocol !=3D NULL);=0D + ASSERT (Fadt !=3D NULL);=0D +=0D + // Get the Boot Architecture flags from the Platform Configuration Manag= er=0D + Status =3D GetEArmObjBootArchInfo (=0D + CfgMgrProtocol,=0D + CM_NULL_TOKEN,=0D + &BootArchInfo,=0D + NULL=0D + );=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((=0D + DEBUG_ERROR,=0D + "ERROR: FADT: Failed to get Boot Architecture flags. Status =3D %r\n= ",=0D + Status=0D + ));=0D + return Status;=0D + }=0D +=0D + DEBUG ((=0D + DEBUG_INFO,=0D + "FADT BootArchFlag =3D 0x%x\n",=0D + BootArchInfo->BootArchFlags=0D + ));=0D +=0D + Fadt->ArmBootArch =3D BootArchInfo->BootArchFlags;=0D +=0D + return Status;=0D +}=0D +=0D +/** Updates the Architecture specific information in the FADT Table.=0D +=0D + @param [in] CfgMgrProtocol Pointer to the Configuration Manager=0D + Protocol Interface.=0D + @param [in, out] Fadt Pointer to the constructed ACPI Table.=0D +=0D + @retval EFI_SUCCESS Success.=0D + @retval EFI_INVALID_PARAMETER A parameter is invalid.=0D + @retval EFI_NOT_FOUND The required object was not found.=0D + @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration=0D + Manager is less than the Object size for t= he=0D + requested object.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +FadtArchUpdate (=0D + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,= =0D + IN OUT EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE *Fadt=0D + )=0D +{=0D + ASSERT (CfgMgrProtocol !=3D NULL);=0D + ASSERT (Fadt !=3D NULL);=0D +=0D + Fadt->Flags =3D FADT_FLAGS;=0D +=0D + return ArmFadtBootArchInfoUpdate (CfgMgrProtocol, Fadt);=0D +}=0D diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/Common/Common= FadtGenerator.c b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/Common/C= ommonFadtGenerator.c new file mode 100644 index 000000000000..d3e908358b7b --- /dev/null +++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/Common/CommonFadtGen= erator.c @@ -0,0 +1,46 @@ +/** @file=0D + Common FADT Table Helpers=0D +=0D + Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D + @par Reference(s):=0D + - ACPI 6.5 Specification, Aug 29, 2022=0D +=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +=0D +// Module specific include files.=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include "FadtGenerator.h"=0D +=0D +/** Updates the Architecture specific information in the FADT Table.=0D +=0D + @param [in] CfgMgrProtocol Pointer to the Configuration Manager=0D + Protocol Interface.=0D + @param [in, out] Fadt Pointer to the constructed ACPI Table.=0D +=0D + @retval EFI_SUCCESS Success.=0D + @retval EFI_INVALID_PARAMETER A parameter is invalid.=0D + @retval EFI_NOT_FOUND The required object was not found.=0D + @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration=0D + Manager is less than the Object size for t= he=0D + requested object.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +FadtArchUpdate (=0D + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,= =0D + IN OUT EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE *Fadt=0D + )=0D +{=0D + // Nothing to do.=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator= .c b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.c index 470f1acfd11f..c2140ef414d2 100644 --- a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.c @@ -19,22 +19,17 @@ #include =0D #include =0D #include =0D +#include "FadtGenerator.h"=0D =0D -/** ARM standard FADT Generator=0D +/** Standard FADT Generator=0D =0D Requirements:=0D The following Configuration Manager Object(s) are required by=0D this Generator:=0D - EArchCommonObjPowerManagementProfileInfo=0D - - EArmObjBootArchInfo=0D - EArchCommonObjHypervisorVendorIdentity (OPTIONAL)=0D */=0D =0D -/** This macro defines the FADT flag options for ARM Platforms.=0D -*/=0D -#define FADT_FLAGS (EFI_ACPI_6_5_HW_REDUCED_ACPI | \=0D - EFI_ACPI_6_5_LOW_POWER_S0_IDLE_CAPABLE)=0D -=0D /** This macro defines the valid mask for the FADT flag option=0D if HW_REDUCED_ACPI flag in the table is set.=0D =0D @@ -159,13 +154,13 @@ EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE AcpiFadt = =3D { // UINT8 Reserved1=0D 0,=0D // UINT32 Flags=0D - FADT_FLAGS,=0D + 0,=0D // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE ResetReg=0D NULL_GAS,=0D // UINT8 ResetValue=0D 0,=0D // UINT16 ArmBootArch=0D - EFI_ACPI_6_5_ARM_PSCI_COMPLIANT, // {Template}: ARM Boot Architecture F= lags=0D + 0, // {Template}: ARM Boot Architecture Flags=0D // UINT8 MinorRevision=0D EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_MINOR_REVISION, // {Template}= =0D // UINT64 XFirmwareCtrl=0D @@ -207,15 +202,6 @@ GET_OBJECT_LIST ( CM_ARCH_COMMON_POWER_MANAGEMENT_PROFILE_INFO=0D );=0D =0D -/** This macro expands to a function that retrieves the Boot=0D - Architecture Information from the Configuration Manager.=0D -*/=0D -GET_OBJECT_LIST (=0D - EObjNameSpaceArm,=0D - EArmObjBootArchInfo,=0D - CM_ARM_BOOT_ARCH_INFO=0D - );=0D -=0D /** This macro expands to a function that retrieves the Hypervisor=0D Vendor ID from the Configuration Manager.=0D */=0D @@ -287,58 +273,6 @@ error_handler: return Status;=0D }=0D =0D -/** Updates the Boot Architecture information in the FADT Table.=0D -=0D - @param [in] CfgMgrProtocol Pointer to the Configuration Manager=0D - Protocol Interface.=0D -=0D - @retval EFI_SUCCESS Success.=0D - @retval EFI_INVALID_PARAMETER A parameter is invalid.=0D - @retval EFI_NOT_FOUND The required object was not found.=0D - @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration=0D - Manager is less than the Object size for t= he=0D - requested object.=0D -**/=0D -STATIC=0D -EFI_STATUS=0D -EFIAPI=0D -FadtAddBootArchInfo (=0D - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol=0D - )=0D -{=0D - EFI_STATUS Status;=0D - CM_ARM_BOOT_ARCH_INFO *BootArchInfo;=0D -=0D - ASSERT (CfgMgrProtocol !=3D NULL);=0D -=0D - // Get the Boot Architecture flags from the Platform Configuration Manag= er=0D - Status =3D GetEArmObjBootArchInfo (=0D - CfgMgrProtocol,=0D - CM_NULL_TOKEN,=0D - &BootArchInfo,=0D - NULL=0D - );=0D - if (EFI_ERROR (Status)) {=0D - DEBUG ((=0D - DEBUG_ERROR,=0D - "ERROR: FADT: Failed to get Boot Architecture flags. Status =3D %r\n= ",=0D - Status=0D - ));=0D - goto error_handler;=0D - }=0D -=0D - DEBUG ((=0D - DEBUG_INFO,=0D - "FADT BootArchFlag =3D 0x%x\n",=0D - BootArchInfo->BootArchFlags=0D - ));=0D -=0D - AcpiFadt.ArmBootArch =3D BootArchInfo->BootArchFlags;=0D -=0D -error_handler:=0D - return Status;=0D -}=0D -=0D /** Update the Hypervisor Vendor ID in the FADT Table.=0D =0D @param [in] CfgMgrProtocol Pointer to the Configuration Manager=0D @@ -577,12 +511,6 @@ BuildFadtTable ( goto error_handler;=0D }=0D =0D - // Update BootArch Info=0D - Status =3D FadtAddBootArchInfo (CfgMgrProtocol);=0D - if (EFI_ERROR (Status)) {=0D - goto error_handler;=0D - }=0D -=0D // Add the Hypervisor Vendor Id if present=0D // Note if no hypervisor is present the zero bytes=0D // will be placed in this field.=0D @@ -623,6 +551,12 @@ BuildFadtTable ( }=0D }=0D =0D + // Update Arch specific Info=0D + Status =3D FadtArchUpdate (CfgMgrProtocol, &AcpiFadt);=0D + if (EFI_ERROR (Status)) {=0D + goto error_handler;=0D + }=0D +=0D *Table =3D (EFI_ACPI_DESCRIPTION_HEADER *)&AcpiFadt;=0D error_handler:=0D return Status;=0D diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator= .h b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.h new file mode 100644 index 000000000000..08ac59e00684 --- /dev/null +++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.h @@ -0,0 +1,35 @@ +/** @file=0D + FADT Table Generator=0D +=0D + Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D + @par Reference(s):=0D + - ACPI 6.5 Specification, Aug 29, 2022=0D +=0D +**/=0D +=0D +#ifndef FADT_GENERATOR_H_=0D +#define FADT_GENERATOR_H_=0D +=0D +/** Updates the Architecture specific information in the FADT Table.=0D +=0D + @param [in] CfgMgrProtocol Pointer to the Configuration Manager=0D + Protocol Interface.=0D + @param [in, out] Fadt Pointer to the constructed ACPI Table.=0D +=0D + @retval EFI_SUCCESS Success.=0D + @retval EFI_INVALID_PARAMETER A parameter is invalid.=0D + @retval EFI_NOT_FOUND The required object was not found.=0D + @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration=0D + Manager is less than the Object size for t= he=0D + requested object.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +FadtArchUpdate (=0D + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,= =0D + IN OUT EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE *Fadt=0D + );=0D +=0D +#endif // FADT_GENERATOR_H_=0D --=20 2.25.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#119635): https://edk2.groups.io/g/devel/message/119635 Mute This Topic: https://groups.io/mt/106770154/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-