Skip to content

Commit

Permalink
DynamicTablesPkg: Add _STA method to CPU object
Browse files Browse the repository at this point in the history
Implement the _STA method for the CPU object based on
the value provided by the configuration manager.

Signed-off-by: Abdul Lateef Attar <[email protected]>
  • Loading branch information
Abdul Lateef Attar authored and Abdul Lateef Attar committed Dec 9, 2024
1 parent 8a9579f commit 2817556
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 2 deletions.
12 changes: 11 additions & 1 deletion DynamicTablesPkg/Include/ArchCommonNameSpaceObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ typedef enum ArchCommonObjectID {
EArchCommonObjPctInfo, ///< 31 - P-State control (PCT) Info
EArchCommonObjPssInfo, ///< 32 - P-State status (PSS) Info
EArchCommonObjPpcInfo, ///< 33 - P-State control (PPC) Info
EArchCommonObjStaInfo, ///< 34 - _STA (Device Status) Info
EArchCommonObjMax
} EARCH_COMMON_OBJECT_ID;

Expand Down Expand Up @@ -782,11 +783,20 @@ typedef AML_PSS_INFO CM_ARCH_COMMON_PSS_INFO;
ID: EArchCommonObjPpcInfo
*/

typedef struct CmArchCommonObjPpcInfo {
/// The number of performance states supported by the processor.
UINT32 PstateCount;
} CM_ARCH_COMMON_PPC_INFO;

/** A structure that describes the _STA (Device Status) Info.
ID: EArchCommonObjStaInfo
*/
typedef struct CmArchCommonStaInfo {
/// Device Status
UINT32 DeviceStatus;
} CM_ARCH_COMMON_STA_INFO;

#pragma pack()

#endif // ARCH_COMMON_NAMESPACE_OBJECTS_H_
5 changes: 5 additions & 0 deletions DynamicTablesPkg/Include/X64NameSpaceObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ typedef struct CmX64LocalApicX2ApicInfo {
i.e. a token referencing a CM_ARCH_COMMON_CPC_INFO object.
*/
CM_OBJECT_TOKEN CpcToken;

/** Optional field: Reference Token for _STA info of this processor.
i.e. a token referencing a CM_ARCH_COMMON_STA_INFO object.
*/
CM_OBJECT_TOKEN StaToken;
} CM_X64_LOCAL_APIC_X2APIC_INFO;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@

#include "SsdtCpuTopologyGenerator.h"

/** This macro defines the supported ACPI Processor Status bits.
The following bits are supported:
- ACPI_AML_STA_DEVICE_STATUS_PRESET
- ACPI_AML_STA_DEVICE_STATUS_ENABLED
- ACPI_AML_STA_DEVICE_STATUS_UI
- ACPI_AML_STA_DEVICE_STATUS_FUNCTIONING
*/
#define ACPI_AML_STA_PROC_SUPPORTED ( \
ACPI_AML_STA_DEVICE_STATUS_PRESET | \
ACPI_AML_STA_DEVICE_STATUS_ENABLED | \
ACPI_AML_STA_DEVICE_STATUS_UI | \
ACPI_AML_STA_DEVICE_STATUS_FUNCTIONING)

/** This macro expands to a function that retrieves the
Local APIC or X2APIC information from the Configuration Manager.
*/
Expand Down Expand Up @@ -76,6 +89,15 @@ GET_OBJECT_LIST (
CM_ARCH_COMMON_PPC_INFO
);

/** This macro expands to a function that retrieves the
_STA (Device Status) information from the Configuration Manager.
*/
GET_OBJECT_LIST (
EObjNameSpaceArchCommon,
EArchCommonObjStaInfo,
CM_ARCH_COMMON_STA_INFO
);

/**
Create the processor hierarchy AML tree from arch specific CM objects.
Expand Down Expand Up @@ -107,6 +129,7 @@ CreateTopologyFromIntC (
UINT32 CsdNumEntries;
UINT32 PssNumEntries;
UINT32 CstNumEntries;
CM_ARCH_COMMON_STA_INFO *StaInfo;

ASSERT (Generator != NULL);
ASSERT (CfgMgrProtocol != NULL);
Expand Down Expand Up @@ -272,6 +295,35 @@ CreateTopologyFromIntC (
return Status;
}
}

if (LocalApicX2ApicInfo[Index].StaToken != CM_NULL_TOKEN) {
Status = GetEArchCommonObjStaInfo (
CfgMgrProtocol,
LocalApicX2ApicInfo[Index].StaToken,
&StaInfo,
NULL
);
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
return Status;
}

/// check STA bits
if ((StaInfo->DeviceStatus & ~(ACPI_AML_STA_PROC_SUPPORTED)) != 0) {
DEBUG ((
DEBUG_ERROR,
"Unsupported STA bits set for processor %d\n",
LocalApicX2ApicInfo[Index].AcpiProcessorUid
));
return EFI_UNSUPPORTED;
}

Status = AmlCodeGenMethodRetInteger ("_STA", StaInfo->DeviceStatus, 0, FALSE, 0, CpuNode, NULL);
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
return Status;
}
}
}

return Status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,12 @@ STATIC CONST CM_OBJ_PARSER CmArchCommonPpcInfoParser[] = {
{ "PstateCount", 4, "0x%x", NULL }
};

/** A parser for EArchCommonObjStaInfo.
*/
STATIC CONST CM_OBJ_PARSER CmArchCommonStaInfoParser[] = {
{ "DeviceStatus", 4, "0x%x", NULL }
};

/** A parser for Arch Common namespace objects.
*/
STATIC CONST CM_OBJ_PARSER_ARRAY ArchCommonNamespaceObjectParser[] = {
Expand Down Expand Up @@ -774,6 +780,7 @@ STATIC CONST CM_OBJ_PARSER_ARRAY ArchCommonNamespaceObjectParser[] = {
CM_PARSER_ADD_OBJECT (EArchCommonObjPctInfo, CmArchCommonPctInfoParser),
CM_PARSER_ADD_OBJECT (EArchCommonObjPssInfo, CmArchCommonPssInfoParser),
CM_PARSER_ADD_OBJECT (EArchCommonObjPpcInfo, CmArchCommonPpcInfoParser),
CM_PARSER_ADD_OBJECT (EArchCommonObjStaInfo, CmArchCommonStaInfoParser),
CM_PARSER_ADD_OBJECT_RESERVED (EArchCommonObjMax)
};

Expand Down Expand Up @@ -951,7 +958,8 @@ STATIC CONST CM_OBJ_PARSER CmX64ObjLocalApicX2ApicInfoParser[] = {
{ "PssToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
{ "PpcToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
{ "PsdToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
{ "CpcToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL }
{ "CpcToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
{ "StaToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL }
};

/** A parser for CmX64IoApicInfoParser.
Expand Down
1 change: 1 addition & 0 deletions DynamicTablesPkg/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ The CM_OBJECT_ID type is used to identify the Configuration Manager
| 31 | Processor P-State Control Info | |
| 32 | Processor P-State Status Info | |
| 33 | Processor P-State Capability Info | |
| 34 | _STA Device Status Info | |
| `*` | All other values are reserved. | |
#### Object ID's in the X64 Namespace:
Expand Down

0 comments on commit 2817556

Please sign in to comment.