From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 97C66AC14DB for ; Mon, 4 Mar 2024 15:44:12 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=koG2nkr+bXQugvKjdz8mNoDHdUq3D7GNdOHhK6Nkp8w=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Received-SPF:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1709567051; v=1; b=QKQtX4MdSZYg8RqXHPfJBxkUioJpjrVHh37wURigAETzKJ/ka25Rh3bICXiB+ZbxYTq4BgAY Xmgz/GA+yW9f89HHqdQ/Dg5xAv2zRrnc64cDlYpC/9vcbYleXNYorBwG8P7z4oh6ZydDgkW3Nlm +wbungKOq3B7D7SqJNQGt+vE= X-Received: by 127.0.0.2 with SMTP id y02mYY7687511xyX2UjYgLv4; Mon, 04 Mar 2024 07:44:11 -0800 X-Received: from NAM04-DM6-obe.outbound.protection.outlook.com (NAM04-DM6-obe.outbound.protection.outlook.com [40.107.102.59]) by mx.groups.io with SMTP id smtpd.web11.102092.1709567050621854003 for ; Mon, 04 Mar 2024 07:44:10 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QOFOIHXJTv4xofu8+Ow+5j2/TPhevb5yVrebJ77qdKsI1fFXBFFHKVSMvypnoNh90BS6kOaOvojK4MieA+YirJYsoAFEj/xhb8CwAYPyiQFlcpKTCGSyPqz4s5HheptdJyx4Z3t263cio83Sck81BZJoMBwYRmTLnZ89pJR3jzZGvbuMqINJ5opALJG7LeYNqCwwWp+d8YbujNT9/u1JgAXoR9TJWN/dZ0zpf7fUyjjknhh0WNiF2IOyxJgI/zUnx37wzcociGzC4xnP6fJxwbaA93UfspthBsJXa22komDkyftTddQwiKu58VyH4WHOHmjMjpH6+JcbQMcLISc+Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kYgENrqc0303SRywhFoQ6IgpnZYsDOoDo8tLIwh/NSQ=; b=nSv2CTHhx1wJM/G2NigDPjVN8tcIReR0SdGie0YJfd3E1SN4h3nkp8Crf9ptzhhGcCzAG+yY2W+vw8UAmg8BmA8wHz11mFJoqjK3AWjODLJiURXbTlE0aPpPLDUWbSimTKsqadw6s0Qc9Lu0jQwX8Xo7pnoAtEs4BncXeIRBgkVDZXXyYbXvw0YzXcyxTwU3aMLmN2fth+LXst1m0/Pwouhs3QgbmKcJekvF1wi8Q62uET4+VWczCAfH+7SnO95egnx3FLvkmVw0FlSbUKY1pU5iGEZV9EIod5rlLvdwq4iVmrXwuofx7KjyWSAbFHyUFxdK86T7Ca0Px+WseGGWyA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) X-Received: from CY5PR15CA0108.namprd15.prod.outlook.com (2603:10b6:930:7::24) by DM6PR12MB4370.namprd12.prod.outlook.com (2603:10b6:5:2aa::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38; Mon, 4 Mar 2024 15:44:07 +0000 X-Received: from CY4PEPF0000EE32.namprd05.prod.outlook.com (2603:10b6:930:7:cafe::68) by CY5PR15CA0108.outlook.office365.com (2603:10b6:930:7::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39 via Frontend Transport; Mon, 4 Mar 2024 15:44:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C X-Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE32.mail.protection.outlook.com (10.167.242.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7362.11 via Frontend Transport; Mon, 4 Mar 2024 15:44:07 +0000 X-Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 4 Mar 2024 09:44:03 -0600 X-Received: from BLR-LAB-SFW01.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Mon, 4 Mar 2024 09:44:02 -0600 From: "Abdul Lateef Attar via groups.io" To: CC: Abdul Lateef Attar , Sami Mujawar , Pierre Gondois Subject: [edk2-devel] [PATCH v2 1/4] DynamicTablesPkg: Adds ACPI FADT Table generator Date: Mon, 4 Mar 2024 21:13:53 +0530 Message-ID: In-Reply-To: References: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: abdattar@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE32:EE_|DM6PR12MB4370:EE_ X-MS-Office365-Filtering-Correlation-Id: 18cc7b37-79cb-4ccb-a73b-08dc3c61eda9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: f7sFww1YugV+n7cEZ9EvE1JowvS1RBSst7vHU9PdPY/mzTNwe2CfMF0pKsO++ISEiDf0FdQPvs8ZbuGIzrBuo/fCE6jTSwHNfyXoTeP1q/cAUmRexBZYVs4hC0I/8hXKV98ATt1DJIB+/rg2CtadoncejaCtDHXMvxGdAmchjsyzDx39Ev8libVFubFE73IBFTA5eojD6r382fe1x3WwetJnO+vCB5wXW2ZfnVNxlTULspqmglhI62TGHOsBi9xO0G4frEBNmNkU/zV4esKmxt8aBaHIMlsvhRhyNe+M0seApNSptMfZ4+09vWiSFTAMQD3WnLj7XArLQc8z3wxpohP5m0mbyUj4J+cMPljw/tqfOmgrZUfyMFe0taqieLDDddyF7mDHQl09OGzHQ2Wc7epdM1yHgxhOZ0O2z5PHx8/4WYBt/JfsYbUHh55HYD64Wo9jg27IzO/XRohEqEhbu4d882VvYfezrkFT5fNMFSJuOupXaB7YQi5DjiMmZlzWS4NPIzNHXQbloxvVnieQZ9ZW0qTl5pI6mwJewRXb3k2zw6+XQj8dbVfIxh+zs5vobBvkNWB2hSeNFN7rsb+uafpTIbMGfAUbBLVhJOO4rinQ2PRE/XgL8t2f7d9psbwgjzeBQ+R+9Bl0rQXDLMGL7kBr+zn7Tlq65anPh4OY+rUxjbNW6JsCaDG7O85dBcpYc8wms0I1Uz7bZ9cPP3OkfJceWbQmtka56Fye+7qSuteRdjPWWNCvw8gijB7JgC6y X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2024 15:44:07.5643 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 18cc7b37-79cb-4ccb-a73b-08dc3c61eda9 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE32.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4370 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 Reply-To: devel@edk2.groups.io,AbdulLateef.Attar@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: V8HUoeyXe0yWUFHLECiig1fJx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=QKQtX4Md; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io From: Abdul Lateef Attar Adds generic ACPI FADT table generator library. Register/Deregister FADT table. Adds Arch namespace ids. Update the FADT table during boot as per specification. Cc: Sami Mujawar Cc: Pierre Gondois Signed-off-by: Abdul Lateef Attar --- DynamicTablesPkg/DynamicTables.dsc.inc | 10 +- DynamicTablesPkg/DynamicTablesPkg.ci.yaml | 4 +- .../Include/ArchNameSpaceObjects.h | 217 +++++ .../Include/ConfigurationManagerObject.h | 6 + .../Library/Acpi/AcpiFadtLib/AcpiFadtLib.inf | 36 + .../Library/Acpi/AcpiFadtLib/Arm/FadtUpdate.c | 39 + .../Library/Acpi/AcpiFadtLib/FadtGenerator.c | 747 ++++++++++++++++++ .../Library/Acpi/AcpiFadtLib/FadtUpdate.h | 26 + .../Library/Acpi/AcpiFadtLib/X64/FadtUpdate.c | 32 + 9 files changed, 1115 insertions(+), 2 deletions(-) create mode 100644 DynamicTablesPkg/Include/ArchNameSpaceObjects.h create mode 100644 DynamicTablesPkg/Library/Acpi/AcpiFadtLib/AcpiFadtLib.i= nf create mode 100644 DynamicTablesPkg/Library/Acpi/AcpiFadtLib/Arm/FadtUpdat= e.c create mode 100644 DynamicTablesPkg/Library/Acpi/AcpiFadtLib/FadtGenerator= .c create mode 100644 DynamicTablesPkg/Library/Acpi/AcpiFadtLib/FadtUpdate.h create mode 100644 DynamicTablesPkg/Library/Acpi/AcpiFadtLib/X64/FadtUpdat= e.c diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc b/DynamicTablesPkg/Dyna= micTables.dsc.inc index 19ca62d6a8..92f3a138e4 100644 --- a/DynamicTablesPkg/DynamicTables.dsc.inc +++ b/DynamicTablesPkg/DynamicTables.dsc.inc @@ -30,11 +30,19 @@ # DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.i= nf =20 + # + # Generators + # + DynamicTablesPkg/Library/Acpi/AcpiFadtLib/AcpiFadtLib.inf + [Components.IA32, Components.X64] # # Dynamic Table Factory Dxe # - DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.i= nf + DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.i= nf { + + NULL|DynamicTablesPkg/Library/Acpi/AcpiFadtLib/AcpiFadtLib.inf + } =20 [Components.ARM, Components.AARCH64] # diff --git a/DynamicTablesPkg/DynamicTablesPkg.ci.yaml b/DynamicTablesPkg/D= ynamicTablesPkg.ci.yaml index 42829f393e..1ad5540e24 100644 --- a/DynamicTablesPkg/DynamicTablesPkg.ci.yaml +++ b/DynamicTablesPkg/DynamicTablesPkg.ci.yaml @@ -128,7 +128,9 @@ "TABLEEX", "TNSID", "Vatos", - "WBINVD" + "WBINVD", + "NAMESPACEID", + "aswell" ], # words to extend to the dictionary for this packa= ge "IgnoreStandardPaths": [], # Standard Plugin defined paths that # should be ignore diff --git a/DynamicTablesPkg/Include/ArchNameSpaceObjects.h b/DynamicTable= sPkg/Include/ArchNameSpaceObjects.h new file mode 100644 index 0000000000..b421c4cd29 --- /dev/null +++ b/DynamicTablesPkg/Include/ArchNameSpaceObjects.h @@ -0,0 +1,217 @@ +/** @file + ARCH Name space object definations. + + Defines namespace objects which are common across platform. + Platform can implements these optional namespace depends on + their requirements. + + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Glossary: + - Cm or CM - Configuration Manager + - Obj or OBJ - Object + - Std or STD - Standard +**/ + +#ifndef ARCH_NAMESPACE_OBJECTS_H_ +#define ARCH_NAMESPACE_OBJECTS_H_ + +#include +#include + +/** The E_ARCH_OBJECT_ID enum describes the Object IDs + in the ARCH Namespace +*/ +typedef enum ArchObjectID { + EArchObjReserved, ///< 0 - Reserved + EArchObjFadtPreferredPmProfile, ///< 1 - Preferred Power Management Pro= file Info + EArchObjFadtSciInterrupt, ///< 2 - SCI Interrupt information + EArchObjFadtSciCmdInfo, ///< 3 - SCI CMD information + EArchObjFadtPmBlockInfo, ///< 4 - Power management block info + EArchObjFadtGpeBlockInfo, ///< 5 - GPE block info + EArchObjFadtXpmBlockInfo, ///< 6 - 64-bit Power Management block = info + EArchObjFadtXgpeBlockInfo, ///< 7 - 64-bit GPE block info + EArchObjFadtSleepBlockInfo, ///< 8 - SLEEP block info + EArchObjFadtResetBlockInfo, ///< 9 - Reset block info + EArchObjFadtFlags, ///< 10 - FADT flags + EArchObjFadtArmBootArch, ///< 11 - ARM boot arch information + EArchObjFadtHypervisorVendorId, ///< 12 - Hypervisor vendor identity inf= ormation + EArchObjFadtMiscInfo, ///< 13 - Legacy fields; RTC, latency, f= lush stride, etc + EArchObjMax +} E_ARCH_OBJECT_ID; + +/** A structure that describes the + Power Management Profile Information for the Platform. + + ID: EArchObjFadtPreferredPmProfile +*/ +typedef struct CmArchPreferredPmProfile { + /** This is the Preferred_PM_Profile field of the FADT Table + described in the ACPI Specification + */ + UINT8 PreferredPmProfile; +} CM_ARCH_FADT_PREFERRED_PM_PROFILE; + +/** A structure that describes the + SCI interrupt Information for the Platform. + + ID: EArchObjFadtSciInterrupt +*/ +typedef struct CmArchSciInterrupt { + /** This is the Preferred_PM_Profile field of the FADT Table + described in the ACPI Specification + */ + UINT16 SciInterrupt; +} CM_ARCH_FADT_SCI_INTERRUPT; + +/** A structure that describes the + SCI CMD Information for the Platform. + + ID: EArchObjFadtSciCmdInfo +*/ +typedef struct CmArchSciCmdInfo { + /** This is the System control interrupt command information of the FADT= Table + described in the ACPI Specification + */ + UINT32 SciCmd; + UINT8 AcpiEnable; + UINT8 AcpiDisable; + UINT8 S4BiosReq; + UINT8 PstateCnt; + UINT8 CstCnt; +} CM_ARCH_FADT_SCI_CMD_INFO; + +/** A structure that describes the + power management block information. + + ID: EArchObjFadtPmBlockInfo +*/ +typedef struct CmArchPmBlockInfo { + /** This is the System control interrupt command information of the FADT= Table + described in the ACPI Specification + */ + UINT32 Pm1aEvtBlk; + UINT32 Pm1bEvtBlk; + UINT32 Pm1aCntBlk; + UINT32 Pm1bCntBlk; + UINT32 Pm2CntBlk; + UINT32 PmTmrBlk; + UINT8 Pm1EvtLen; + UINT8 Pm1CntLen; + UINT8 Pm2CntLen; + UINT8 PmTmrLen; +} CM_ARCH_FADT_PM_BLOCK_INFO; + +/** A structure that describes the + GPE block information. + + ID: EArchObjFadtGpeBlockInfo +*/ +typedef struct CmArchGpeBlockInfo { + /** This is the GPE Block information of the FADT Table + described in the ACPI Specification + */ + UINT32 Gpe0Blk; + UINT32 Gpe1Blk; + UINT8 Gpe0BlkLen; + UINT8 Gpe1BlkLen; + UINT8 Gpe1Base; +} CM_ARCH_FADT_GPE_BLOCK_INFO; + +/** A structure that describes the + FADT flags Information for the Platform. + + ID: EArchObjFadtFlags +*/ +typedef struct CmArchFadtFlags { + UINT32 Flags; +} CM_ARCH_FADT_FLAGS; + +/** A structure that describes the + ARM Boot Architecture flags. + + ID: EArchObjFadtArmBootArch +*/ +typedef struct CmArchArmBootArch { + UINT16 ArmBootArch; +} CM_ARCH_FADT_ARM_BOOT_ARCH; + +/** A structure that describes the + Hypervisor vendor identity information. + + ID: EArchObjFadtHypervisorVendorId +*/ +typedef struct CmArchHypervisorVendorId { + UINT64 HypervisorVendorIdentity; +} CM_ARCH_FADT_HYPERVISOR_VENDOR_ID; + +/** A structure that describes the + 64bit power management block information. + + ID: EArchObjFadtXpmBlockInfo +*/ +typedef struct CmArchXpmBlockInfo { + /** This is the System control interrupt command information of the FADT= Table + described in the ACPI Specification + */ + EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPm1aEvtBlk; + EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPm1bEvtBlk; + EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPm1aCntBlk; + EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPm1bCntBlk; + EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPm2CntBlk; + EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPmTmrBlk; +} CM_ARCH_FADT_X_PM_BLOCK_INFO; + +/** A structure that describes the + 64-bit GPE block information. + + ID: EArchObjFadtXgpeBlockInfo +*/ +typedef struct CmArchXgpeBlockInfo { + /** This is the GPE Block information of the FADT Table + described in the ACPI Specification + */ + EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XGpe0Blk; + EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XGpe1Blk; +} CM_ARCH_FADT_X_GPE_BLOCK_INFO; + +/** A structure that describes the + sleep control block information. + + ID: EArchObjFadtSleepBlockInfo +*/ +typedef struct CmArchSleepBlockInfo { + EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE SleepControlReg; + EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE SleepStatusReg; +} CM_ARCH_FADT_SLEEP_BLOCK_INFO; + +/** A structure that describes the + Reset control block information. + + ID: EArchObjFadtResetBlockInfo +*/ +typedef struct CmArchResetBlockInfo { + EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE ResetReg; + UINT8 ResetValue; +} CM_ARCH_FADT_RESET_BLOCK_INFO; + +/** A structure that describes the + miscellaneous FADT fields information. + + ID: EArchObjFadtMiscInfo +*/ +typedef struct CmArchFadtMiscInfo { + UINT16 PLvl2Lat; + UINT16 PLvl3Lat; + UINT16 FlushSize; + UINT16 FlushStride; + UINT8 DutyOffset; + UINT8 DutyWidth; + UINT8 DayAlrm; + UINT8 MonAlrm; + UINT8 Century; +} CM_ARCH_FADT_MISC_INFO; + +#endif diff --git a/DynamicTablesPkg/Include/ConfigurationManagerObject.h b/Dynami= cTablesPkg/Include/ConfigurationManagerObject.h index 74ad25d5d9..f2cfadf3d4 100644 --- a/DynamicTablesPkg/Include/ConfigurationManagerObject.h +++ b/DynamicTablesPkg/Include/ConfigurationManagerObject.h @@ -1,6 +1,7 @@ /** @file =20 Copyright (c) 2017 - 2022, ARM Limited. All rights reserved. + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -14,6 +15,7 @@ =20 #include #include +#include =20 #pragma pack(1) =20 @@ -107,6 +109,7 @@ typedef UINT32 CM_OBJECT_ID; typedef enum ObjectNameSpaceID { EObjNameSpaceStandard, ///< Standard Objects Namespace EObjNameSpaceArm, ///< ARM Objects Namespace + EObjNameSpaceArch, ///< Arch Objects Namespace EObjNameSpaceOem =3D 0x8, ///< OEM Objects Namespace EObjNameSpaceMax } EOBJECT_NAMESPACE_ID; @@ -172,6 +175,9 @@ typedef struct CmObjDescriptor { #define CREATE_CM_STD_OBJECT_ID(ObjectId) \ (CREATE_CM_OBJECT_ID (EObjNameSpaceStandard, ObjectId)) =20 +#define CREATE_CM_ARCH_OBJECT_ID(ObjectId) \ + (CREATE_CM_OBJECT_ID (EObjNameSpaceArch, ObjectId)) + /** This macro returns a Configuration Manager Object ID in the ARM Object Namespace. =20 diff --git a/DynamicTablesPkg/Library/Acpi/AcpiFadtLib/AcpiFadtLib.inf b/Dy= namicTablesPkg/Library/Acpi/AcpiFadtLib/AcpiFadtLib.inf new file mode 100644 index 0000000000..6a6656daff --- /dev/null +++ b/DynamicTablesPkg/Library/Acpi/AcpiFadtLib/AcpiFadtLib.inf @@ -0,0 +1,36 @@ +## @file +# FADT Table Generator +# +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 1.27 + BASE_NAME =3D AcpiFadtLib + FILE_GUID =3D 2EBCA674-3849-4D02-A456-3E0495297FCC + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D DXE_DRIVER + LIBRARY_CLASS =3D NULL|DXE_DRIVER + CONSTRUCTOR =3D AcpiFadtLibConstructor + DESTRUCTOR =3D AcpiFadtLibDestructor + +[Sources] + FadtGenerator.c + FadtUpdate.h + +[Sources.IA32, Sources.X64] + X64/FadtUpdate.c + +[Sources.ARM, Sources.AARCH64] + Arm/FadtUpdate.c + +[Packages] + DynamicTablesPkg/DynamicTablesPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + BaseLib + DebugLib diff --git a/DynamicTablesPkg/Library/Acpi/AcpiFadtLib/Arm/FadtUpdate.c b/D= ynamicTablesPkg/Library/Acpi/AcpiFadtLib/Arm/FadtUpdate.c new file mode 100644 index 0000000000..d632d243fa --- /dev/null +++ b/DynamicTablesPkg/Library/Acpi/AcpiFadtLib/Arm/FadtUpdate.c @@ -0,0 +1,39 @@ +/** @file + FADT Update header file + Defines architecture specific function headers. + + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include "../FadtUpdate.h" +#include + +/** Gets Architecture specific bitmask for EObjNameSpaceArch namespace. + + @param [out] EArchObjFadtMask Pointer to the Mask bit variable. + +**/ +VOID +EFIAPI +GetPlatformNameSpaceMask ( + OUT UINT64 *EArchObjFadtMask + ) +{ + if (EArchObjFadtMask =3D=3D NULL) { + return; + } + + *EArchObjFadtMask =3D ((*EArchObjFadtMask) | + (1 << EArchObjFadtSciInterrupt) | + (1 << EArchObjFadtSciCmdInfo) | + (1 << EArchObjFadtPmBlockInfo) | + (1 << EArchObjFadtGpeBlockInfo) | + (1 << EArchObjFadtXpmBlockInfo) | + (1 << EArchObjFadtXgpeBlockInfo) | + (1 << EArchObjFadtSleepBlockInfo) | + (1 << EArchObjFadtResetBlockInfo) | + (1 << EArchObjFadtMiscInfo) + ); +} diff --git a/DynamicTablesPkg/Library/Acpi/AcpiFadtLib/FadtGenerator.c b/Dy= namicTablesPkg/Library/Acpi/AcpiFadtLib/FadtGenerator.c new file mode 100644 index 0000000000..cec00e00b0 --- /dev/null +++ b/DynamicTablesPkg/Library/Acpi/AcpiFadtLib/FadtGenerator.c @@ -0,0 +1,747 @@ +/** @file + FADT Table Generator + + Copyright (c) 2017 - 2023, Arm Limited. All rights reserved. + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - ACPI 6.5 Specification, Aug 29, 2022 + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FadtUpdate.h" + +/** Empty GAS defintion +*/ +#define NULL_GAS { EFI_ACPI_6_5_SYSTEM_MEMORY, 0, 0, EFI_ACPI_6_5_UNDEFI= NED, 0L } + +/** The Creator ID for the ACPI tables generated using + the standard ACPI table generators. +*/ +#define TABLE_GENERATOR_CREATOR_ID_GENERIC SIGNATURE_32('D', 'Y', 'N', 'T= ') + +/** This macro defines the FADT Table Generator revision. +*/ +#define FADT_GENERATOR_REVISION CREATE_REVISION (1, 0) + +/** This macro expands to a function that retrieves the Power + Management Profile Information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceArch, + EArchObjFadtPreferredPmProfile, + CM_ARCH_FADT_PREFERRED_PM_PROFILE + ); + +/** This macro expands to a function that retrieves the + SCI interrupt information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceArch, + EArchObjFadtSciInterrupt, + CM_ARCH_FADT_SCI_INTERRUPT + ); + +/** This macro expands to a function that retrieves the + SCI command information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceArch, + EArchObjFadtSciCmdInfo, + CM_ARCH_FADT_SCI_CMD_INFO + ); + +/** This macro expands to a function that retrieves the + legacy power management information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceArch, + EArchObjFadtPmBlockInfo, + CM_ARCH_FADT_PM_BLOCK_INFO + ); + +/** This macro expands to a function that retrieves the + legacy GPE block information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceArch, + EArchObjFadtGpeBlockInfo, + CM_ARCH_FADT_GPE_BLOCK_INFO + ); + +/** This macro expands to a function that retrieves the + FADT flags information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceArch, + EArchObjFadtFlags, + CM_ARCH_FADT_FLAGS + ) + +/** This macro expands to a function that retrieves the + ARM boot arch information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceArch, + EArchObjFadtArmBootArch, + CM_ARCH_FADT_ARM_BOOT_ARCH + ) + +/** This macro expands to a function that retrieves the + hypervisor vendor identity information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceArch, + EArchObjFadtHypervisorVendorId, + CM_ARCH_FADT_HYPERVISOR_VENDOR_ID + ) + +/** This macro expands to a function that retrieves the + legacy level2 latency, level 3 latency, RTC information from the Confi= guration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceArch, + EArchObjFadtMiscInfo, + CM_ARCH_FADT_MISC_INFO + ) + +/** This macro expands to a function that retrieves the + 64-bit power management information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceArch, + EArchObjFadtXpmBlockInfo, + CM_ARCH_FADT_X_PM_BLOCK_INFO + ); + +/** This macro expands to a function that retrieves the + 64-bit GPE block information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceArch, + EArchObjFadtXgpeBlockInfo, + CM_ARCH_FADT_X_GPE_BLOCK_INFO + ); + +/** This macro expands to a function that retrieves the + sleep block information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceArch, + EArchObjFadtSleepBlockInfo, + CM_ARCH_FADT_SLEEP_BLOCK_INFO + ); + +/** This macro expands to a function that retrieves the + reset block information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceArch, + EArchObjFadtResetBlockInfo, + CM_ARCH_FADT_RESET_BLOCK_INFO + ); + +/** The AcpiFadt is a template EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE + structure used for generating the FADT Table. +*/ +STATIC +EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE mAcpiFadt =3D { + ACPI_HEADER ( + EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, + EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE, + EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_REVISION + ), + // UINT32 FirmwareCtrl + 0, + // UINT32 Dsdt + 0, + // UINT8 Reserved0 + EFI_ACPI_RESERVED_BYTE, + // UINT8 PreferredPmProfile + EFI_ACPI_6_5_PM_PROFILE_UNSPECIFIED, + // UINT16 SciInt + 0, + // UINT32 SmiCmd + 0, + // UINT8 AcpiEnable + 0, + // UINT8 AcpiDisable + 0, + // UINT8 S4BiosReq + 0, + // UINT8 PstateCnt + 0, + // UINT32 Pm1aEvtBlk + 0, + // UINT32 Pm1bEvtBlk + 0, + // UINT32 Pm1aCntBlk + 0, + // UINT32 Pm1bCntBlk + 0, + // UINT32 Pm2CntBlk + 0, + // UINT32 PmTmrBlk + 0, + // UINT32 Gpe0Blk + 0, + // UINT32 Gpe1Blk + 0, + // UINT8 Pm1EvtLen + 0, + // UINT8 Pm1CntLen + 0, + // UINT8 Pm2CntLen + 0, + // UINT8 PmTmrLen + 0, + // UINT8 Gpe0BlkLen + 0, + // UINT8 Gpe1BlkLen + 0, + // UINT8 Gpe1Base + 0, + // UINT8 CstCnt + 0, + // UINT16 PLvl2Lat + 0, + // UINT16 PLvl3Lat + 0, + // UINT16 FlushSize + 0, + // UINT16 FlushStride + 0, + // UINT8 DutyOffset + 0, + // UINT8 DutyWidth + 0, + // UINT8 DayAlrm + 0, + // UINT8 MonAlrm + 0, + // UINT8 Century + 0, + // UINT16 IaPcBootArch + 0, + // UINT8 Reserved1 + 0, + // UINT32 Flags + 0, + // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE ResetReg + NULL_GAS, + // UINT8 ResetValue + 0, + // UINT16 ArmBootArch + 0, + // UINT8 MinorRevision + EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_MINOR_REVISION, + // UINT64 XFirmwareCtrl + 0, + // UINT64 XDsdt + 0, + // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPm1aEvtBlk + NULL_GAS, + // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPm1bEvtBlk + NULL_GAS, + // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPm1aCntBlk + NULL_GAS, + // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPm1bCntBlk + NULL_GAS, + // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPm2CntBlk + NULL_GAS, + // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPmTmrBlk + NULL_GAS, + // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XGpe0Blk + NULL_GAS, + // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XGpe1Blk + NULL_GAS, + // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE SleepControlReg + NULL_GAS, + // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE SleepStatusReg + NULL_GAS, + // UINT64 HypervisorVendorIdentity + EFI_ACPI_RESERVED_QWORD +}; + +/** Construct the FADT table. + + This function invokes the Configuration Manager protocol interface + to get the required hardware information for generating the ACPI + table. + + If this function allocates any resources then they must be freed + in the FreeXXXXTableResources function. + + @param [in] This Pointer to the table generator. + @param [in] AcpiTableInfo Pointer to the ACPI Table Info. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [out] Table Pointer to the constructed ACPI Table. + + @retval EFI_SUCCESS Table generated successfully. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The required object was not found. + @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration + Manager is less than the Object size for t= he + requested object. +**/ +STATIC +EFI_STATUS +BuildFadtTable ( + IN CONST ACPI_TABLE_GENERATOR *CONST This, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, + OUT EFI_ACPI_DESCRIPTION_HEADER **CONST Table + ) +{ + EFI_STATUS Status; + CM_ARCH_FADT_PREFERRED_PM_PROFILE *PmProfile; + CM_ARCH_FADT_SCI_INTERRUPT *SciInterrupt; + CM_ARCH_FADT_SCI_CMD_INFO *SciCmdinfo; + CM_ARCH_FADT_PM_BLOCK_INFO *PmBlockInfo; + CM_ARCH_FADT_GPE_BLOCK_INFO *GpeBlockInfo; + CM_ARCH_FADT_X_PM_BLOCK_INFO *XpmBlockInfo; + CM_ARCH_FADT_X_GPE_BLOCK_INFO *XgpeBlockInfo; + CM_ARCH_FADT_SLEEP_BLOCK_INFO *SleepBlockInfo; + CM_ARCH_FADT_RESET_BLOCK_INFO *ResetBlockInfo; + CM_ARCH_FADT_FLAGS *FadtFlags; + CM_ARCH_FADT_ARM_BOOT_ARCH *ArmBootArch; + CM_ARCH_FADT_HYPERVISOR_VENDOR_ID *HypervisorVendorId; + CM_ARCH_FADT_MISC_INFO *FadtMiscInfo; + UINT64 EArchObjFadtMask; + + ASSERT (This !=3D NULL); + ASSERT (AcpiTableInfo !=3D NULL); + ASSERT (CfgMgrProtocol !=3D NULL); + ASSERT (Table !=3D NULL); + ASSERT (AcpiTableInfo->TableGeneratorId =3D=3D This->GeneratorID); + ASSERT (AcpiTableInfo->AcpiTableSignature =3D=3D This->AcpiTableSignatur= e); + + if ((AcpiTableInfo->AcpiTableRevision < This->MinAcpiTableRevision) || + (AcpiTableInfo->AcpiTableRevision > This->AcpiTableRevision)) + { + DEBUG (( + DEBUG_ERROR, + "ERROR: FADT: Requested table revision =3D %d, is not supported." + "Supported table revision: Minimum =3D %d, Maximum =3D %d\n", + AcpiTableInfo->AcpiTableRevision, + This->MinAcpiTableRevision, + This->AcpiTableRevision + )); + return EFI_INVALID_PARAMETER; + } + + *Table =3D NULL; + + Status =3D AddAcpiHeader ( + CfgMgrProtocol, + This, + (EFI_ACPI_DESCRIPTION_HEADER *)&mAcpiFadt, + AcpiTableInfo, + sizeof (EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE) + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: FADT: Failed to add ACPI header. Status =3D %r\n", + Status + )); + return Status; + } + + EArchObjFadtMask =3D 0; + DEBUG ((DEBUG_ERROR, "before 0x%x\n", EArchObjFadtMask)); + GetPlatformNameSpaceMask (&EArchObjFadtMask); + DEBUG ((DEBUG_ERROR, "after 0x%x\n", EArchObjFadtMask)); + + if (!(EArchObjFadtMask & (1 << EArchObjFadtPreferredPmProfile))) { + // Get the Power Management Profile from the Platform Configuration Ma= nager + Status =3D GetEArchObjFadtPreferredPmProfile ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &PmProfile, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: FADT: Failed to get Power Management Profile information."= \ + " Status =3D %r\n", + Status + )); + } else { + mAcpiFadt.PreferredPmProfile =3D PmProfile->PreferredPmProfile; + } + } + + if (!(EArchObjFadtMask & (1 << EArchObjFadtSciInterrupt))) { + // Get the SCI interrupt from the Platform Configuration Manager + Status =3D GetEArchObjFadtSciInterrupt ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &SciInterrupt, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: FADT: Failed to get SCI Interrupt information." \ + " Status =3D %r\n", + Status + )); + } else { + mAcpiFadt.SciInt =3D SciInterrupt->SciInterrupt; + } + } + + if (!(EArchObjFadtMask & (1 << EArchObjFadtSciCmdInfo))) { + // Get the SCI CMD information from the Platform Configuration Manager + Status =3D GetEArchObjFadtSciCmdInfo ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &SciCmdinfo, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: FADT: Failed to get SCI CMD information." \ + " Status =3D %r\n", + Status + )); + } else { + mAcpiFadt.SmiCmd =3D SciCmdinfo->SciCmd; + mAcpiFadt.AcpiEnable =3D SciCmdinfo->AcpiEnable; + mAcpiFadt.AcpiDisable =3D SciCmdinfo->AcpiDisable; + mAcpiFadt.S4BiosReq =3D SciCmdinfo->S4BiosReq; + mAcpiFadt.PstateCnt =3D SciCmdinfo->PstateCnt; + mAcpiFadt.CstCnt =3D SciCmdinfo->CstCnt; + } + } + + if (!(EArchObjFadtMask & (1 << EArchObjFadtPmBlockInfo))) { + // Get the SCI PM Block information from the Platform Configuration Ma= nager + Status =3D GetEArchObjFadtPmBlockInfo ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &PmBlockInfo, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: FADT: Failed to get PM Block information." \ + " Status =3D %r\n", + Status + )); + } else { + mAcpiFadt.Pm1aEvtBlk =3D PmBlockInfo->Pm1aEvtBlk; + mAcpiFadt.Pm1bEvtBlk =3D PmBlockInfo->Pm1bEvtBlk; + mAcpiFadt.Pm1aCntBlk =3D PmBlockInfo->Pm1aCntBlk; + mAcpiFadt.Pm1bCntBlk =3D PmBlockInfo->Pm1bCntBlk; + mAcpiFadt.Pm2CntBlk =3D PmBlockInfo->Pm2CntBlk; + mAcpiFadt.PmTmrBlk =3D PmBlockInfo->PmTmrBlk; + mAcpiFadt.Pm1EvtLen =3D PmBlockInfo->Pm1EvtLen; + mAcpiFadt.Pm1CntLen =3D PmBlockInfo->Pm1CntLen; + mAcpiFadt.Pm2CntLen =3D PmBlockInfo->Pm2CntLen; + mAcpiFadt.PmTmrLen =3D PmBlockInfo->PmTmrLen; + } + } + + if (!(EArchObjFadtMask & (1 << EArchObjFadtGpeBlockInfo))) { + // Get the SCI PM Block information from the Platform Configuration Ma= nager + Status =3D GetEArchObjFadtGpeBlockInfo ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &GpeBlockInfo, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: FADT: Failed to get PM Block information." \ + " Status =3D %r\n", + Status + )); + } else { + mAcpiFadt.Gpe0Blk =3D GpeBlockInfo->Gpe0Blk; + mAcpiFadt.Gpe1Blk =3D GpeBlockInfo->Gpe1Blk; + mAcpiFadt.Gpe0BlkLen =3D GpeBlockInfo->Gpe0BlkLen; + mAcpiFadt.Gpe1BlkLen =3D GpeBlockInfo->Gpe1BlkLen; + mAcpiFadt.Gpe1Base =3D GpeBlockInfo->Gpe1Base; + } + } + + if (!(EArchObjFadtMask & (1 << EArchObjFadtFlags))) { + // Get the Power Management Profile from the Platform Configuration Ma= nager + Status =3D GetEArchObjFadtFlags ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &FadtFlags, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: FADT: Failed to get FADT flags information." \ + " Status =3D %r\n", + Status + )); + } else { + mAcpiFadt.Flags =3D FadtFlags->Flags; + } + } + + if (!(EArchObjFadtMask & (1 << EArchObjFadtArmBootArch))) { + // Get the Arm boot arch information from the Platform Configuration M= anager + Status =3D GetEArchObjFadtArmBootArch ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &ArmBootArch, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: FADT: Failed to get ARM boot arch flags information." \ + " Status =3D %r\n", + Status + )); + } else { + mAcpiFadt.ArmBootArch =3D ArmBootArch->ArmBootArch; + } + } + + if (!(EArchObjFadtMask & (1 << EArchObjFadtArmBootArch))) { + // Get the Hypervisor Vendor Identity information from the Platform Co= nfiguration Manager + Status =3D GetEArchObjFadtHypervisorVendorId ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &HypervisorVendorId, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: FADT: Failed to get Hypervisor Vendor Identity flags infor= mation." \ + " Status =3D %r\n", + Status + )); + } else { + mAcpiFadt.HypervisorVendorIdentity =3D HypervisorVendorId->Hyperviso= rVendorIdentity; + } + } + + if (!(EArchObjFadtMask & (1 << EArchObjFadtXpmBlockInfo))) { + // Get the 64-bit PM Block information from the Platform Configuration= Manager + Status =3D GetEArchObjFadtXpmBlockInfo ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &XpmBlockInfo, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: FADT: Failed to get 64-bit PM Block information." \ + " Status =3D %r\n", + Status + )); + } else { + CopyMem (&mAcpiFadt.XPm1aCntBlk, &XpmBlockInfo->XPm1aCntBlk, sizeof = (EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE)); + CopyMem (&mAcpiFadt.XPm1bEvtBlk, &XpmBlockInfo->XPm1bEvtBlk, sizeof = (EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE)); + CopyMem (&mAcpiFadt.XPm1aCntBlk, &XpmBlockInfo->XPm1aCntBlk, sizeof = (EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE)); + CopyMem (&mAcpiFadt.XPm1bCntBlk, &XpmBlockInfo->XPm1bCntBlk, sizeof = (EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE)); + CopyMem (&mAcpiFadt.XPm2CntBlk, &XpmBlockInfo->XPm2CntBlk, sizeof (E= FI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE)); + CopyMem (&mAcpiFadt.XPmTmrBlk, &XpmBlockInfo->XPmTmrBlk, sizeof (EFI= _ACPI_6_5_GENERIC_ADDRESS_STRUCTURE)); + } + } + + if (!(EArchObjFadtMask & (1 << EArchObjFadtMiscInfo))) { + // Get the various platform information from the Platform Configuratio= n manager + Status =3D GetEArchObjFadtMiscInfo ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &FadtMiscInfo, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: FADT: Failed to get various platform information." \ + " Status =3D %r\n", + Status + )); + } else { + mAcpiFadt.PLvl2Lat =3D FadtMiscInfo->PLvl2Lat; + mAcpiFadt.PLvl3Lat =3D FadtMiscInfo->PLvl3Lat; + mAcpiFadt.FlushSize =3D FadtMiscInfo->FlushSize; + mAcpiFadt.FlushStride =3D FadtMiscInfo->FlushStride; + mAcpiFadt.DutyOffset =3D FadtMiscInfo->DutyOffset; + mAcpiFadt.DutyWidth =3D FadtMiscInfo->DutyWidth; + mAcpiFadt.DayAlrm =3D FadtMiscInfo->DayAlrm; + mAcpiFadt.MonAlrm =3D FadtMiscInfo->MonAlrm; + mAcpiFadt.Century =3D FadtMiscInfo->Century; + } + } + + if (!(EArchObjFadtMask & (1 << EArchObjFadtXgpeBlockInfo))) { + // Get the 64-bit GPE Block information from the Platform Configuratio= n Manager + Status =3D GetEArchObjFadtXgpeBlockInfo ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &XgpeBlockInfo, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: FADT: Failed to get 64-bit GPE Block information." \ + " Status =3D %r\n", + Status + )); + } else { + CopyMem (&mAcpiFadt.XGpe0Blk, &XgpeBlockInfo->XGpe0Blk, sizeof (EFI_= ACPI_6_5_GENERIC_ADDRESS_STRUCTURE)); + CopyMem (&mAcpiFadt.XGpe1Blk, &XgpeBlockInfo->XGpe1Blk, sizeof (EFI_= ACPI_6_5_GENERIC_ADDRESS_STRUCTURE)); + } + } + + if (!(EArchObjFadtMask & (1 << EArchObjFadtSleepBlockInfo))) { + // Get the sleep Block information from the Platform Configuration Man= ager + Status =3D GetEArchObjFadtSleepBlockInfo ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &SleepBlockInfo, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: FADT: Failed to get Sleep Block information." \ + " Status =3D %r\n", + Status + )); + } else { + CopyMem (&mAcpiFadt.SleepControlReg, &SleepBlockInfo->SleepControlRe= g, sizeof (EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE)); + CopyMem (&mAcpiFadt.SleepStatusReg, &SleepBlockInfo->SleepStatusReg,= sizeof (EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE)); + } + } + + if (!(EArchObjFadtMask & (1 << EArchObjFadtResetBlockInfo))) { + // Get the sleep Block information from the Platform Configuration Man= ager + Status =3D GetEArchObjFadtResetBlockInfo ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &ResetBlockInfo, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: FADT: Failed to get Reset Block information." \ + " Status =3D %r\n", + Status + )); + } else { + CopyMem (&mAcpiFadt.ResetReg, &ResetBlockInfo->ResetReg, sizeof (EFI= _ACPI_6_5_GENERIC_ADDRESS_STRUCTURE)); + mAcpiFadt.ResetValue =3D ResetBlockInfo->ResetValue; + } + } + + Status =3D EFI_SUCCESS; + + *Table =3D (EFI_ACPI_DESCRIPTION_HEADER *)&mAcpiFadt; + + return Status; +} + +/** The interface for the FADT Table Generator. +*/ +STATIC +CONST +ACPI_TABLE_GENERATOR mFadtGenerator =3D { + // Generator ID + CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdFadt), + // Generator Description + L"ACPI.STD.FADT.GENERATOR", + // ACPI Table Signature + EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, + // ACPI Table Revision supported by this Generator + EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_REVISION, + // Minimum supported ACPI Table Revision + EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_REVISION, + // Creator ID + TABLE_GENERATOR_CREATOR_ID_GENERIC, + // Creator Revision + FADT_GENERATOR_REVISION, + // Build Table function + BuildFadtTable, + // No additional resources are allocated by the generator. + // Hence the Free Resource function is not required. + NULL, + // Extended build function not needed + NULL, + // Extended build function not implemented by the generator. + // Hence extended free resource function is not required. + NULL +}; + +/** Register the Generator with the ACPI Table Factory. + + @param [in] ImageHandle The handle to the image. + @param [in] SystemTable Pointer to the System Table. + + @retval EFI_SUCCESS The Generator is registered. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_ALREADY_STARTED The Generator for the Table ID + is already registered. +**/ +EFI_STATUS +EFIAPI +AcpiFadtLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status =3D RegisterAcpiTableGenerator (&mFadtGenerator); + DEBUG ((DEBUG_INFO, "FADT: Register Generator. Status =3D %r\n", Status)= ); + ASSERT_EFI_ERROR (Status); + return Status; +} + +/** Deregister the Generator from the ACPI Table Factory. + + @param [in] ImageHandle The handle to the image. + @param [in] SystemTable Pointer to the System Table. + + @retval EFI_SUCCESS The Generator is deregistered. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The Generator is not registered. +**/ +EFI_STATUS +EFIAPI +AcpiFadtLibDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status =3D DeregisterAcpiTableGenerator (&mFadtGenerator); + DEBUG ((DEBUG_INFO, "FADT: Deregister Generator. Status =3D %r\n", Statu= s)); + ASSERT_EFI_ERROR (Status); + return Status; +} diff --git a/DynamicTablesPkg/Library/Acpi/AcpiFadtLib/FadtUpdate.h b/Dynam= icTablesPkg/Library/Acpi/AcpiFadtLib/FadtUpdate.h new file mode 100644 index 0000000000..c70da3131f --- /dev/null +++ b/DynamicTablesPkg/Library/Acpi/AcpiFadtLib/FadtUpdate.h @@ -0,0 +1,26 @@ +/** @file + FADT Update header file + Defines architecture specific function headers. + + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef FADT_UPDATE_H_ +#define FADT_UPDATE_H_ + +/** Gets Architecture specific bitmask for EObjNameSpaceArch namespace. + + @param [out] EArchObjFadtMask Pointer to the Mask bit variable. + + @retval None +**/ +VOID +EFIAPI +GetPlatformNameSpaceMask ( + OUT UINT64 *EArchObjFadtMask + ); + +#endif // FADT_UPDATE_H_ diff --git a/DynamicTablesPkg/Library/Acpi/AcpiFadtLib/X64/FadtUpdate.c b/D= ynamicTablesPkg/Library/Acpi/AcpiFadtLib/X64/FadtUpdate.c new file mode 100644 index 0000000000..eebb282c18 --- /dev/null +++ b/DynamicTablesPkg/Library/Acpi/AcpiFadtLib/X64/FadtUpdate.c @@ -0,0 +1,32 @@ +/** @file + FADT Update header file + Defines architecture specific function headers. + + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include "../FadtUpdate.h" +#include + +/** Gets Architecture specific bitmask for EObjNameSpaceArch namespace. + + @param [out] EArchObjFadtMask Pointer to the Mask bit variable. + +**/ +VOID +EFIAPI +GetPlatformNameSpaceMask ( + OUT UINT64 *EArchObjFadtMask + ) +{ + if (EArchObjFadtMask =3D=3D NULL) { + return; + } + + *EArchObjFadtMask =3D ((*EArchObjFadtMask) | + (1 << EArchObjFadtArmBootArch) | + (1 << EArchObjFadtHypervisorVendorId) + ); +} --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116325): https://edk2.groups.io/g/devel/message/116325 Mute This Topic: https://groups.io/mt/104724515/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-