Skip to content

Commit

Permalink
DynamicTablesPkg: Generate X64 CPU SSDT Topology
Browse files Browse the repository at this point in the history
Creates processor objects based on configuration data.

Cc: Sami Mujawar <[email protected]>
Cc: Pierre Gondois <[email protected]>
Signed-off-by: Abdul Lateef Attar <[email protected]>
  • Loading branch information
Abdul Lateef Attar authored and Abdul Lateef Attar committed Nov 18, 2024
1 parent 43bbbf4 commit 879eeaf
Showing 1 changed file with 92 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,40 @@
@retval EFI_UNSUPPORTED Not supported
**/

#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Protocol/AcpiTable.h>

// Module specific include files.
#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"

/** Define Local APIC Flags Masks
*/
#define LOCAL_APIC_FLAGS_ENABLED 0x1
#define LOCAL_APIC_FLAGS_ONLINE 0x2
#define LOCAL_APIC_FLAGS_MASK ( \
LOCAL_APIC_FLAGS_ENABLED | \
LOCAL_APIC_FLAGS_ONLINE)

/** 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.
Expand All @@ -43,7 +71,70 @@ CreateTopologyFromIntC (
IN AML_OBJECT_NODE_HANDLE ScopeNode
)
{
return EFI_UNSUPPORTED;
EFI_STATUS Status;
CM_X64_LOCAL_APIC_X2APIC_INFO *LocalApicX2ApicInfo;
UINT32 LocalApicX2ApicCount;
UINT32 Index;
UINT8 SmtApicMode;
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;
}

SmtApicMode = LocalApicX2ApicInfo[0].ApicMode;
for (Index = 0; Index < LocalApicX2ApicCount; Index++) {
if ((LocalApicX2ApicInfo[Index].Flags & ~LOCAL_APIC_FLAGS_MASK) != 0) {
DEBUG ((DEBUG_ERROR, "ERROR: Invalid Flags field\n"));
return EFI_UNSUPPORTED;
}

if (LocalApicX2ApicInfo[Index].ApicMode != SmtApicMode) {
DEBUG ((DEBUG_ERROR, "ERROR: All processors should be in the same APIC mode\n"));
return EFI_UNSUPPORTED;
}

if (LocalApicX2ApicInfo[Index].ApicMode == 0) {
if (LocalApicX2ApicInfo[Index].ApicId > 0xFF) {
DEBUG ((DEBUG_ERROR, "ERROR: In APIC mode ApicId should be less than 0xFF\n"));
return EFI_UNSUPPORTED;
}

if (LocalApicX2ApicInfo[Index].AcpiProcessorUid > 0xFF) {
DEBUG ((DEBUG_ERROR, "ERROR: In APIC mode AcpiProcessorUid should be less than 0xFF\n"));
return EFI_UNSUPPORTED;
}
}
}

/// 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 (0);
break;
}
}

return Status;
}

/** Add arch specific information to a CPU node in the asl description.
Expand Down

0 comments on commit 879eeaf

Please sign in to comment.