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 Feb 5, 2025
1 parent 03e1a77 commit 1c3b4ce
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 1 deletion.
11 changes: 11 additions & 0 deletions 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 @@ -801,6 +802,16 @@ 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 @@ -268,6 +268,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 @@ -25,6 +25,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 @@ -79,6 +92,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
);

/**
This macro expands to a function that retrieves the cross-CM-object-
reference information from the Configuration Manager.
Expand Down Expand Up @@ -483,6 +505,7 @@ CreateTopologyFromIntC (
CM_ARCH_COMMON_PCT_INFO *PctInfo;
CM_ARCH_COMMON_PPC_INFO *PpcInfo;
CM_ARCH_COMMON_PSS_INFO *PssInfo;
CM_ARCH_COMMON_STA_INFO *StaInfo;
CM_X64_LOCAL_APIC_X2APIC_INFO *LocalApicX2ApicInfo;
EFI_STATUS Status;
TOKEN_TABLE CstTokenTable;
Expand Down Expand Up @@ -745,6 +768,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_handler:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,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 @@ -788,6 +794,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 @@ -965,7 +972,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 1c3b4ce

Please sign in to comment.