diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc b/DynamicTablesPkg/DynamicTables.dsc.inc index 9cdc0b2f8a63..d01a84807fd6 100644 --- a/DynamicTablesPkg/DynamicTables.dsc.inc +++ b/DynamicTablesPkg/DynamicTables.dsc.inc @@ -74,8 +74,12 @@ # X64 specific NULL|DynamicTablesPkg/Library/Acpi/X64/AcpiHpetLib/AcpiHpetLib.inf NULL|DynamicTablesPkg/Library/Acpi/X64/AcpiMadtLib/AcpiMadtLib.inf - NULL|DynamicTablesPkg/Library/Acpi/X64/AcpiSsdtHpetLib/AcpiSsdtHpetLib.inf NULL|DynamicTablesPkg/Library/Acpi/X64/AcpiWsmtLib/AcpiWsmtLib.inf + # AML Codegen + # Common + NULL|DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/SsdtCpuTopologyLib.inf + # X64 specific + NULL|DynamicTablesPkg/Library/Acpi/X64/AcpiSsdtHpetLib/AcpiSsdtHpetLib.inf } [Components.ARM, Components.AARCH64] diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/SsdtCpuTopologyLib.inf b/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/SsdtCpuTopologyLib.inf index 93ede691cdf9..da228642e2de 100644 --- a/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/SsdtCpuTopologyLib.inf +++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/SsdtCpuTopologyLib.inf @@ -23,6 +23,9 @@ [Sources.ARM, Sources.AARCH64] Arm/ArmSsdtCpuTopologyGenerator.c +[Sources.IA32, Sources.X64] + X64/X64SsdtCpuTopologyGenerator.c + [Packages.ARM, Packages.AARCH64] ArmPlatformPkg/ArmPlatformPkg.dec diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/X64/X64SsdtCpuTopologyGenerator.c b/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/X64/X64SsdtCpuTopologyGenerator.c new file mode 100644 index 000000000000..f58bb2f94c02 --- /dev/null +++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/X64/X64SsdtCpuTopologyGenerator.c @@ -0,0 +1,144 @@ +/** @file + X64 SSDT Cpu Topology Table Generator Helpers. + + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - ACPI 6.3 Specification - January 2019 - s8.4 Declaring Processors +**/ + +#include +#include + +// Module specific include files. +#include +#include +#include +#include +#include +#include + +#include "SsdtCpuTopologyGenerator.h" + +/** This macro expands to a function that retrieves the + Local APIC or X2APIC information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceX64, + EX64ObjLocalApicX2ApicInfo, + CM_X64_LOCAL_APIC_X2APIC_INFO + ); + +/** + Create the processor hierarchy AML tree from arch specific CM objects. + + @param [in] Generator The SSDT Cpu Topology generator. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [in] ScopeNode Scope node handle ('\_SB' scope). + + @retval EFI_UNSUPPORTED Not supported +**/ +EFI_STATUS +EFIAPI +CreateTopologyFromIntC ( + IN ACPI_CPU_TOPOLOGY_GENERATOR *Generator, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, + IN AML_OBJECT_NODE_HANDLE ScopeNode + ) +{ + EFI_STATUS Status; + CM_X64_LOCAL_APIC_X2APIC_INFO *LocalApicX2ApicInfo; + UINT32 LocalApicX2ApicCount; + UINT32 Index; + AML_OBJECT_NODE_HANDLE CpuNode; + + ASSERT (Generator != NULL); + ASSERT (CfgMgrProtocol != NULL); + ASSERT (ScopeNode != NULL); + + LocalApicX2ApicCount = 0; + Status = GetEX64ObjLocalApicX2ApicInfo ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &LocalApicX2ApicInfo, + &LocalApicX2ApicCount + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + return Status; + } + + /// for each processor object, create an AML node. + for (Index = 0; Index < LocalApicX2ApicCount; Index++) { + Status = CreateAmlCpu ( + Generator, + ScopeNode, + LocalApicX2ApicInfo[Index].AcpiProcessorUid, + Index, + &CpuNode + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + break; + } + } + + return Status; +} + +/** Add arch specific information to a CPU node in the asl description. + + @param [in] Generator The SSDT Cpu Topology generator. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [in] AcpiIdObjectToken AcpiIdObjectToken identifying the CPU to fetch the + other fields from. + @param [in] CpuName Value used to generate the CPU node name. + @param [out] CpuNode CPU Node to which the ET device node is + attached. + + @retval EFI_UNSUPPORTED Not supported +**/ +EFI_STATUS +EFIAPI +AddArchAmlCpuInfo ( + IN ACPI_CPU_TOPOLOGY_GENERATOR *Generator, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, + IN CM_OBJECT_TOKEN AcpiIdObjectToken, + IN UINT32 CpuName, + OUT AML_OBJECT_NODE_HANDLE *CpuNode + ) +{ + return EFI_UNSUPPORTED; +} + +/** Get generic interrupt information from arch specific CM objects. + + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [in] AcpiIdObjectToken AcpiIdObjectToken identifying the CPU to fetch the + other fields from. + @param [out] AcpiProcessorUid AcpiProcessorUid of the CPU identified by + the AcpiIdObjectToken. + @param [out] CpcToken CpcToken of the CPU identified by + the AcpiIdObjectToken. + @param [out] PsdToken PsdToken of the CPU identified by + the AcpiIdObjectToken. + + @retval EFI_UNSUPPORTED Not supported +**/ +EFI_STATUS +EFIAPI +GetIntCInfo ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, + IN CM_OBJECT_TOKEN AcpiIdObjectToken, + OUT UINT32 *AcpiProcessorUid, + OUT CM_OBJECT_TOKEN *CpcToken, + OUT CM_OBJECT_TOKEN *PsdToken + ) +{ + return EFI_UNSUPPORTED; +}