TianoCore EDK2 master
|
#include <Library/AcpiLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Protocol/AcpiTable.h>
#include <AcpiTableGenerator.h>
#include <ConfigurationManagerObject.h>
#include <ConfigurationManagerHelper.h>
#include <Library/AcpiHelperLib.h>
#include <Library/TableHelperLib.h>
#include <Library/AmlLib/AmlLib.h>
#include <Protocol/ConfigurationManagerProtocol.h>
#include "SsdtCpuTopologyGenerator.h"
Go to the source code of this file.
Macros | |
#define | SSDT_CPU_TOPOLOGY_GENERATOR_REVISION CREATE_REVISION (1, 0) |
Variables | |
STATIC ACPI_CPU_TOPOLOGY_GENERATOR | SsdtCpuTopologyGenerator |
SSDT Cpu Topology Table Generator.
Copyright (c) 2021 - 2023, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file SsdtCpuTopologyGenerator.c.
#define SSDT_CPU_TOPOLOGY_GENERATOR_REVISION CREATE_REVISION (1, 0) |
This macro defines the SSDT Cpu Topology Table Generator revision.
Definition at line 1343 of file SsdtCpuTopologyGenerator.c.
EFI_STATUS EFIAPI AcpiSsdtCpuTopologyLibConstructor | ( | IN EFI_HANDLE | ImageHandle, |
IN EFI_SYSTEM_TABLE * | SystemTable | ||
) |
Register the Generator with the ACPI Table Factory.
[in] | ImageHandle | The handle to the image. |
[in] | SystemTable | Pointer to the System Table. |
EFI_SUCCESS | The Generator is registered. |
EFI_INVALID_PARAMETER | A parameter is invalid. |
EFI_ALREADY_STARTED | The Generator for the Table ID is already registered. |
Definition at line 1403 of file SsdtCpuTopologyGenerator.c.
EFI_STATUS EFIAPI AcpiSsdtCpuTopologyLibDestructor | ( | IN EFI_HANDLE | ImageHandle, |
IN EFI_SYSTEM_TABLE * | SystemTable | ||
) |
Deregister the Generator from the ACPI Table Factory.
[in] | ImageHandle | The handle to the image. |
[in] | SystemTable | Pointer to the System Table. |
EFI_SUCCESS | The Generator is deregistered. |
EFI_INVALID_PARAMETER | A parameter is invalid. |
EFI_NOT_FOUND | The Generator is not registered. |
Definition at line 1432 of file SsdtCpuTopologyGenerator.c.
STATIC EFI_STATUS EFIAPI BuildSsdtCpuTopologyTable | ( | 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 | ||
) |
Construct the SSDT Cpu Topology ACPI 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.
[in] | This | Pointer to the table generator. |
[in] | AcpiTableInfo | Pointer to the ACPI Table Info. |
[in] | CfgMgrProtocol | Pointer to the Configuration Manager Protocol Interface. |
[out] | Table | Pointer to the constructed ACPI Table. |
EFI_SUCCESS | Table generated successfully. |
EFI_INVALID_PARAMETER | A parameter is invalid. |
EFI_NOT_FOUND | The required object was not found. |
EFI_BAD_BUFFER_SIZE | The size returned by the Configuration Manager is less than the Object size for the requested object. |
Definition at line 1206 of file SsdtCpuTopologyGenerator.c.
STATIC EFI_STATUS EFIAPI CheckProcNode | ( | UINT32 | NodeFlags, |
BOOLEAN | IsLeaf, | ||
CM_OBJECT_TOKEN | NodeToken, | ||
CM_OBJECT_TOKEN | ParentNodeToken, | ||
BOOLEAN | PackageNodeSeen | ||
) |
Check flags and topology of a ProcNode.
[in] | NodeFlags | Flags of the ProcNode to check. |
[in] | IsLeaf | The ProcNode is a leaf. |
[in] | NodeToken | NodeToken of the ProcNode. |
[in] | ParentNodeToken | Parent NodeToken of the ProcNode. |
[in] | PackageNodeSeen | A parent of the ProcNode has the physical package flag set. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
Definition at line 919 of file SsdtCpuTopologyGenerator.c.
EFI_STATUS EFIAPI CreateAmlCpcNode | ( | IN ACPI_CPU_TOPOLOGY_GENERATOR * | Generator, |
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST | CfgMgrProtocol, | ||
IN CM_OBJECT_TOKEN | CpcToken, | ||
IN AML_OBJECT_NODE_HANDLE * | Node | ||
) |
Create and add an _CPC Node to Cpu Node.
For instance, transform an AML node from: Device (C002) { Name (_UID, 2) Name (_HID, "ACPI0007") }
To: Device (C002) { Name (_UID, 2) Name (_HID, "ACPI0007") Name(_CPC, Package() { NumEntries, // Integer Revision, // Integer HighestPerformance, // Integer or Buffer (Resource Descriptor) NominalPerformance, // Integer or Buffer (Resource Descriptor) LowestNonlinearPerformance, // Integer or Buffer (Resource Descriptor) LowestPerformance, // Integer or Buffer (Resource Descriptor) GuaranteedPerformanceRegister, // Buffer (Resource Descriptor) DesiredPerformanceRegister , // Buffer (Resource Descriptor) MinimumPerformanceRegister , // Buffer (Resource Descriptor) MaximumPerformanceRegister , // Buffer (Resource Descriptor) PerformanceReductionToleranceRegister, // Buffer (Resource Descriptor) TimeWindowRegister, // Buffer (Resource Descriptor) CounterWraparoundTime, // Integer or Buffer (Resource Descriptor) ReferencePerformanceCounterRegister, // Buffer (Resource Descriptor) DeliveredPerformanceCounterRegister, // Buffer (Resource Descriptor) PerformanceLimitedRegister, // Buffer (Resource Descriptor) CPPCEnableRegister // Buffer (Resource Descriptor) AutonomousSelectionEnable, // Integer or Buffer (Resource Descriptor) AutonomousActivityWindowRegister, // Buffer (Resource Descriptor) EnergyPerformancePreferenceRegister, // Buffer (Resource Descriptor) ReferencePerformance // Integer or Buffer (Resource Descriptor) LowestFrequency, // Integer or Buffer (Resource Descriptor) NominalFrequency // Integer or Buffer (Resource Descriptor) }) }
[in] | Generator | The SSDT Cpu Topology generator. |
[in] | CfgMgrProtocol | Pointer to the Configuration Manager Protocol Interface. |
[in] | CpcToken | CPC token of the INTC info describing the Cpu. |
[in] | Node | CPU Node to which the _CPC node is attached. |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 372 of file SsdtCpuTopologyGenerator.c.
EFI_STATUS EFIAPI CreateAmlCpu | ( | IN ACPI_CPU_TOPOLOGY_GENERATOR * | Generator, |
IN AML_NODE_HANDLE | ParentNode, | ||
IN UINT32 | AcpiProcessorUid, | ||
IN UINT32 | CpuName, | ||
OUT AML_OBJECT_NODE_HANDLE *CpuNodePtr | OPTIONAL | ||
) |
Create a Cpu in the AML namespace.
This generates the following ASL code: Device (C002) { Name (_UID, 2) Name (_HID, "ACPI0007") }
[in] | Generator | The SSDT Cpu Topology generator. |
[in] | ParentNode | Parent node to attach the Cpu node to. |
[in] | AcpiProcessorUid | ACPI processor UID of the CPU. |
[in] | CpuName | Value used to generate the node name. |
[out] | CpuNodePtr | If not NULL, return the created Cpu node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 639 of file SsdtCpuTopologyGenerator.c.
STATIC EFI_STATUS EFIAPI CreateAmlCpuFromProcHierarchy | ( | IN ACPI_CPU_TOPOLOGY_GENERATOR * | Generator, |
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST | CfgMgrProtocol, | ||
IN AML_NODE_HANDLE | ParentNode, | ||
IN UINT32 | CpuName, | ||
IN CM_ARCH_COMMON_PROC_HIERARCHY_INFO * | ProcHierarchyNodeInfo | ||
) |
Create a Cpu in the AML namespace from a CM_ARCH_COMMON_PROC_HIERARCHY_INFO CM object.
[in] | Generator | The SSDT Cpu Topology generator. |
[in] | CfgMgrProtocol | Pointer to the Configuration Manager Protocol Interface. |
[in] | ParentNode | Parent node to attach the Cpu node to. |
[in] | CpuName | Value used to generate the node name. |
[in] | ProcHierarchyNodeInfo | CM_ARCH_COMMON_PROC_HIERARCHY_INFO describing the Cpu. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 714 of file SsdtCpuTopologyGenerator.c.
STATIC EFI_STATUS EFIAPI CreateAmlCpuTopologyTree | ( | IN ACPI_CPU_TOPOLOGY_GENERATOR * | Generator, |
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST | CfgMgrProtocol, | ||
IN CM_OBJECT_TOKEN | NodeToken, | ||
IN AML_NODE_HANDLE | ParentNode, | ||
IN OUT UINT32 * | ProcContainerIndex, | ||
IN BOOLEAN | PackageNodeSeen | ||
) |
Create an AML representation of the Cpu topology.
A processor container is by extension any non-leave device in the cpu topology.
[in] | Generator | The SSDT Cpu Topology generator. |
[in] | CfgMgrProtocol | Pointer to the Configuration Manager Protocol Interface. |
[in] | NodeToken | Token of the CM_ARCH_COMMON_PROC_HIERARCHY_INFO currently handled. |
[in] | ParentNode | Parent node to attach the created node to. |
[in,out] | ProcContainerIndex | Pointer to the current processor container index to be used as UID. |
[in] | PackageNodeSeen | A parent of the ProcNode has the physical package flag set. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 979 of file SsdtCpuTopologyGenerator.c.
STATIC EFI_STATUS EFIAPI CreateAmlLpiMethod | ( | IN ACPI_CPU_TOPOLOGY_GENERATOR * | Generator, |
IN CM_ARCH_COMMON_PROC_HIERARCHY_INFO * | ProcHierarchyNodeInfo, | ||
IN AML_OBJECT_NODE_HANDLE * | Node | ||
) |
Create and add an _LPI method to Cpu/Cluster Node.
For instance, transform an AML node from: Device (C002) { Name (_UID, 2) Name (_HID, "ACPI0007") }
To: Device (C002) { Name (_UID, 2) Name (_HID, "ACPI0007") Method (_LPI, 0, NotSerialized) { Return (_SB.L003) } }
[in] | Generator | The SSDT Cpu Topology generator. |
[in] | ProcHierarchyNodeInfo | CM_ARCH_COMMON_PROC_HIERARCHY_INFO describing the Cpu. |
[in] | Node | Node to which the _LPI method is attached. Can represent a Cpu or a Cluster. |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 436 of file SsdtCpuTopologyGenerator.c.
STATIC EFI_STATUS EFIAPI CreateAmlProcessorContainer | ( | IN ACPI_CPU_TOPOLOGY_GENERATOR * | Generator, |
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST | CfgMgrProtocol, | ||
IN AML_NODE_HANDLE | ParentNode, | ||
IN CM_ARCH_COMMON_PROC_HIERARCHY_INFO * | ProcHierarchyNodeInfo, | ||
IN UINT16 | ProcContainerName, | ||
IN UINT32 | ProcContainerUid, | ||
OUT AML_OBJECT_NODE_HANDLE * | ProcContainerNodePtr | ||
) |
Create a Processor Container in the AML namespace.
Any CM_ARCH_COMMON_PROC_HIERARCHY_INFO object with the following flags is assumed to be a processor container:
This generates the following ASL code: Device (C002) { Name (_UID, 2) Name (_HID, "ACPI0010") }
[in] | Generator | The SSDT Cpu Topology generator. |
[in] | CfgMgrProtocol | Pointer to the Configuration Manager Protocol Interface. |
[in] | ParentNode | Parent node to attach the processor container node to. |
[in] | ProcHierarchyNodeInfo | CM_ARCH_COMMON_PROC_HIERARCHY_INFO object used to create the node. |
[in] | ProcContainerName | Name of the processor container. |
[in] | ProcContainerUid | Uid of the processor container. |
[out] | ProcContainerNodePtr | If success, contains the created processor container node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 830 of file SsdtCpuTopologyGenerator.c.
STATIC EFI_STATUS EFIAPI CreateAmlPsdNode | ( | IN ACPI_CPU_TOPOLOGY_GENERATOR * | Generator, |
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST | CfgMgrProtocol, | ||
IN CM_OBJECT_TOKEN | PsdToken, | ||
IN AML_OBJECT_NODE_HANDLE * | Node | ||
) |
Create and add an _PSD Node to Cpu Node.
For instance, transform an AML node from: Device (C002) { Name (_UID, 2) Name (_HID, "ACPI0007") }
To: Device (C002) { Name (_UID, 2) Name (_HID, "ACPI0007") Name (_PSD, Package() { NumEntries, // Integer Revision, // Integer Domain, // Integer CoordType, // Integer NumProcessors, // Integer }) }
[in] | Generator | The SSDT Cpu Topology generator. |
[in] | CfgMgrProtocol | Pointer to the Configuration Manager Protocol Interface. |
[in] | PsdToken | Token to identify the Psd information. |
[in] | Node | CPU Node to which the _CPC node is attached. |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 286 of file SsdtCpuTopologyGenerator.c.
STATIC EFI_STATUS EFIAPI CreateTopologyFromProcHierarchy | ( | IN ACPI_CPU_TOPOLOGY_GENERATOR * | Generator, |
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST | CfgMgrProtocol, | ||
IN AML_OBJECT_NODE_HANDLE | ScopeNode | ||
) |
Create the processor hierarchy AML tree from CM_ARCH_COMMON_PROC_HIERARCHY_INFO CM objects.
[in] | Generator | The SSDT Cpu Topology generator. |
[in] | CfgMgrProtocol | Pointer to the Configuration Manager Protocol Interface. |
[in] | ScopeNode | Scope node handle ('_SB' scope). |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 1134 of file SsdtCpuTopologyGenerator.c.
STATIC EFI_STATUS EFIAPI FreeSsdtCpuTopologyTableResources | ( | 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, | ||
IN OUT EFI_ACPI_DESCRIPTION_HEADER **CONST | Table | ||
) |
Free any resources allocated for constructing the SSDT Cpu Topology ACPI table.
[in] | This | Pointer to the table generator. |
[in] | AcpiTableInfo | Pointer to the ACPI Table Info. |
[in] | CfgMgrProtocol | Pointer to the Configuration Manager Protocol Interface. |
[in,out] | Table | Pointer to the ACPI Table. |
EFI_SUCCESS | The resources were freed successfully. |
EFI_INVALID_PARAMETER | The table pointer is NULL or invalid. |
Definition at line 1317 of file SsdtCpuTopologyGenerator.c.
STATIC EFI_STATUS EFIAPI GenerateLpiStates | ( | IN ACPI_CPU_TOPOLOGY_GENERATOR * | Generator, |
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST | CfgMgrProtocol, | ||
IN AML_OBJECT_NODE_HANDLE | ScopeNode | ||
) |
Generate all the Lpi states under the '_SB' scope.
This function generates the following ASL code: Scope (_SB) { Name (L000, Package() { 0, // Version 0, // Level Index X, // Count Package() { [An Lpi state] }, Package() { [Another Lpi state] }, } // Name L000
Name (L001, Package() { ... } // Name L001
... } // Scope /_SB
The Lpi states are fetched from the Configuration Manager. The names of the Lpi states are generated from the TokenTable.
[in] | Generator | The SSDT Cpu Topology generator. |
[in] | CfgMgrProtocol | Pointer to the Configuration Manager Protocol Interface. |
[in] | ScopeNode | Scope node handle ('_SB' scope). |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 523 of file SsdtCpuTopologyGenerator.c.
GET_OBJECT_LIST | ( | EObjNameSpaceArchCommon | , |
EArchCommonObjCmRef | , | ||
CM_ARCH_COMMON_OBJ_REF | |||
) |
This macro expands to a function that retrieves the cross-CM-object- reference information from the Configuration Manager.
GET_OBJECT_LIST | ( | EObjNameSpaceArchCommon | , |
EArchCommonObjCpcInfo | , | ||
CM_ARCH_COMMON_CPC_INFO | |||
) |
This macro expands to a function that retrieves the CPC information from the Configuration Manager.
GET_OBJECT_LIST | ( | EObjNameSpaceArchCommon | , |
EArchCommonObjLpiInfo | , | ||
CM_ARCH_COMMON_LPI_INFO | |||
) |
This macro expands to a function that retrieves the Lpi information from the Configuration Manager.
GET_OBJECT_LIST | ( | EObjNameSpaceArchCommon | , |
EArchCommonObjProcHierarchyInfo | , | ||
CM_ARCH_COMMON_PROC_HIERARCHY_INFO | |||
) |
SSDT Cpu Topology Table Generator.
Requirements: The following Configuration Manager Object(s) are required by this Generator:
GET_OBJECT_LIST | ( | EObjNameSpaceArchCommon | , |
EArchCommonObjPsdInfo | , | ||
CM_ARCH_COMMON_PSD_INFO | |||
) |
This macro expands to a function that retrieves the PSD information from the Configuration Manager.
STATIC UINT32 EFIAPI TokenTableAdd | ( | IN ACPI_CPU_TOPOLOGY_GENERATOR * | Generator, |
IN CM_OBJECT_TOKEN | Token | ||
) |
Add a new entry to the TokenTable and return its index.
If an entry with Token is already available in the table, return its index without adding a new entry.
[in] | Generator | The SSDT Cpu Topology generator. |
[in] | Token | New Token entry to add. |
The | index of the token entry in the TokenTable. |
Definition at line 173 of file SsdtCpuTopologyGenerator.c.
STATIC VOID EFIAPI TokenTableFree | ( | IN ACPI_CPU_TOPOLOGY_GENERATOR * | Generator | ) |
Free the TokenTable.
[in] | Generator | The SSDT Cpu Topology generator. |
Definition at line 148 of file SsdtCpuTopologyGenerator.c.
STATIC EFI_STATUS EFIAPI TokenTableInitialize | ( | IN ACPI_CPU_TOPOLOGY_GENERATOR * | Generator, |
IN UINT32 | Count | ||
) |
Initialize the TokenTable.
One entry should be allocated for each CM_ARCH_COMMON_PROC_HIERARCHY_INFO structure of the platform. The TokenTable allows to have a mapping: Index <-> CM_OBJECT_TOKEN (to CM_ARCH_COMMON_LPI_INFO structures).
There will always be less sets of Lpi states (CM_ARCH_COMMON_OBJ_REF) than the number of cpus/clusters (CM_ARCH_COMMON_PROC_HIERARCHY_INFO).
[in] | Generator | The SSDT Cpu Topology generator. |
[in] | Count | Number of entries to allocate in the TokenTable. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 115 of file SsdtCpuTopologyGenerator.c.
EFI_STATUS EFIAPI WriteAslName | ( | IN CHAR8 | LeadChar, |
IN UINT32 | Value, | ||
IN OUT CHAR8 * | AslName | ||
) |
Write a string 'Xxxx\0' in AslName (5 bytes long), with 'X' being the leading char of the name, and with 'xxx' being Value in hexadecimal.
As 'xxx' in hexadecimal represents a number on 12 bits, we have Value < (1 << 12).
[in] | LeadChar | Leading char of the name. |
[in] | Value | Hex value of the name. Must be lower than (2 << 12). |
[in,out] | AslName | Pointer to write the 'Xxxx' string to. Must be at least 5 bytes long. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
Definition at line 222 of file SsdtCpuTopologyGenerator.c.
STATIC ACPI_CPU_TOPOLOGY_GENERATOR SsdtCpuTopologyGenerator |
The interface for the SSDT Cpu Topology Table Generator.
Definition at line 1348 of file SsdtCpuTopologyGenerator.c.