From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.10308.1633704413042657108 for ; Fri, 08 Oct 2021 07:46:53 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: pierre.gondois@arm.com) 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 B211012FC; Fri, 8 Oct 2021 07:46:40 -0700 (PDT) Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2AB9E3F66F; Fri, 8 Oct 2021 07:46:38 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [PATCH v3 03/21] DynamicTablesPkg: Add AddSsdtAcpiHeader() Date: Fri, 8 Oct 2021 15:46:14 +0100 Message-Id: <20211008144632.31894-4-Pierre.Gondois@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-1-Pierre.Gondois@arm.com> From: Pierre Gondois To fetch the Oem information from the ConfigurationManagerProtocol and the AcpiTableInfo, and populate the SSDT ACPI header when creating a RootNode via the AmlLib, create AddSsdtAcpiHeader(). Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../Include/Library/TableHelperLib.h | 35 ++++++++ .../Common/TableHelperLib/TableHelper.c | 87 +++++++++++++++++++ 2 files changed, 122 insertions(+) diff --git a/DynamicTablesPkg/Include/Library/TableHelperLib.h b/DynamicTablesPkg/Include/Library/TableHelperLib.h index 6d362ff99a27..76f9e8c25fea 100644 --- a/DynamicTablesPkg/Include/Library/TableHelperLib.h +++ b/DynamicTablesPkg/Include/Library/TableHelperLib.h @@ -12,6 +12,8 @@ #ifndef TABLE_HELPER_LIB_H_ #define TABLE_HELPER_LIB_H_ +#include + /** The GetCgfMgrInfo function gets the CM_STD_OBJ_CONFIGURATION_MANAGER_INFO object from the Configuration Manager. @@ -62,6 +64,39 @@ AddAcpiHeader ( IN CONST UINT32 Length ); +/** Build a RootNode containing SSDT ACPI header information using the AmlLib. + + The function utilizes the ACPI table Generator and the Configuration + Manager protocol to obtain any information required for constructing the + header. It then creates a RootNode. The SSDT ACPI header is part of the + RootNode. + + This is essentially a wrapper around AmlCodeGenDefinitionBlock () + from the AmlLib. + + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + protocol interface. + @param [in] Generator Pointer to the ACPI table Generator. + @param [in] AcpiTableInfo Pointer to the ACPI table info structure. + @param [out] RootNode If success, contains the created RootNode. + The SSDT ACPI header is part of the RootNode. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The required object information is not found. + @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration + Manager is less than the Object size for the + requested object. +**/ +EFI_STATUS +EFIAPI +AddSsdtAcpiHeader ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, + IN CONST ACPI_TABLE_GENERATOR * CONST Generator, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo, + OUT AML_ROOT_NODE_HANDLE * RootNode + ); + /** Function prototype for testing if two arbitrary objects are equal. diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c index f98da7ffdd67..d92c82eac99e 100644 --- a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c @@ -185,6 +185,93 @@ error_handler: return Status; } +/** Build a RootNode containing SSDT ACPI header information using the AmlLib. + + The function utilizes the ACPI table Generator and the Configuration + Manager protocol to obtain any information required for constructing the + header. It then creates a RootNode. The SSDT ACPI header is part of the + RootNode. + + This is essentially a wrapper around AmlCodeGenDefinitionBlock () + from the AmlLib. + + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + protocol interface. + @param [in] Generator Pointer to the ACPI table Generator. + @param [in] AcpiTableInfo Pointer to the ACPI table info structure. + @param [out] RootNode If success, contains the created RootNode. + The SSDT ACPI header is part of the RootNode. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The required object information is not found. + @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration + Manager is less than the Object size for the + requested object. +**/ +EFI_STATUS +EFIAPI +AddSsdtAcpiHeader ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, + IN CONST ACPI_TABLE_GENERATOR * CONST Generator, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo, + OUT AML_ROOT_NODE_HANDLE * RootNode + ) +{ + EFI_STATUS Status; + UINT64 OemTableId; + UINT32 OemRevision; + CM_STD_OBJ_CONFIGURATION_MANAGER_INFO * CfgMfrInfo; + + ASSERT (CfgMgrProtocol != NULL); + ASSERT (Generator != NULL); + ASSERT (AcpiTableInfo != NULL); + + if ((CfgMgrProtocol == NULL) || + (Generator == NULL) || + (AcpiTableInfo == NULL)) { + return EFI_INVALID_PARAMETER; + } + + Status = GetCgfMgrInfo (CfgMgrProtocol, &CfgMfrInfo); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to get Configuration Manager info. Status = %r\n", + Status + )); + return Status; + } + + if (AcpiTableInfo->OemTableId != 0) { + OemTableId = AcpiTableInfo->OemTableId; + } else { + OemTableId = SIGNATURE_32 ( + CfgMfrInfo->OemId[0], + CfgMfrInfo->OemId[1], + CfgMfrInfo->OemId[2], + CfgMfrInfo->OemId[3] + ) | + ((UINT64)Generator->AcpiTableSignature << 32); + } + + if (AcpiTableInfo->OemRevision != 0) { + OemRevision = AcpiTableInfo->OemRevision; + } else { + OemRevision = CfgMfrInfo->Revision; + } + + Status = AmlCodeGenDefinitionBlock ( + "SSDT", + (CONST CHAR8*)&CfgMfrInfo->OemId, + (CONST CHAR8*)&OemTableId, + OemRevision, + RootNode + ); + ASSERT_EFI_ERROR (Status); + return Status; +} + /** Test and report if a duplicate entry exists in the given array of comparable elements. -- 2.17.1