DynamicTablesPkg: Add SmbiosSmcLib

Implement a support library for SMBIOS-related SMC calls. Currently this
implements a function to return the SoC ID.

Signed-off-by: Sarah Walker <Sarah.Walker2@arm.com>
This commit is contained in:
Sarah Walker
2025-07-18 15:23:07 +01:00
committed by mergify[bot]
parent 3e62dbf504
commit 34e3bd44ff
6 changed files with 170 additions and 0 deletions
@@ -118,6 +118,7 @@
"lless",
"MPIDR",
"NAMESPACEID",
"NUVIA",
"PASID",
"PERIPHBASE",
"phandle",
@@ -128,6 +129,7 @@
"sapic",
"ssdtcmn",
"ssdtserialporttemplate",
"SMCCC",
"SMMUV",
"ssdtpcieosctemplate",
"SSDTPC",
+3
View File
@@ -55,6 +55,9 @@
## @libraryclass Defines a set of methods for generating Tpm2 Device Table method.
Tpm2DeviceTableLib|Include/Library/Tpm2DeviceTableLib.h
## @libraryclass Defines a set of SMBIOS related SMC helper methods.
SmcbiosSmbLib|Include/Library/SmbiosSmcLib.h
[LibraryClasses.AARCH64]
## @libraryclass Defines a set of APIs to populate CmObj using SCMI.
DynamicTablesScmiInfoLib|Include/Library/DynamicTablesScmiInfoLib.h
+1
View File
@@ -55,6 +55,7 @@
[Components.AARCH64]
DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
DynamicTablesPkg/Library/Smbios/Arm/SmbiosSmcLib/SmbiosSmcLib.inf
[Components.AARCH64]
DynamicTablesPkg/Library/DynamicTablesScmiInfoLib/DynamicTablesScmiInfoLib.inf
@@ -0,0 +1,24 @@
/** @file
*
* Copyright (c) 2025, ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*
**/
#ifndef SMBIOS_SMC_LIB_H_
#define SMBIOS_SMC_LIB_H_
/** Returns the SOC ID, formatted for the SMBIOS Type 4 Processor ID field.
@param Processor ID.
@return 0 on success
@return EFI_UNSUPPORTED if SMCCC_ARCH_SOC_ID is not implemented
**/
UINT64
SmbiosSmcGetSocId (
UINT64 *ProcessorId
);
#endif // SMBIOS_SMC_LIB_H_
@@ -0,0 +1,114 @@
/** @file
SMBIOS SMC helper functions.
Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
Copyright (c) 2021 - 2022, Ampere Computing LLC. All rights reserved.<BR>
Copyright (c) 2025, ARM Ltd. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <Uefi.h>
#include <IndustryStandard/ArmStdSmc.h>
#include <Library/ArmSmcLib.h>
#include <Library/SmbiosSmcLib.h>
/** Checks if the ARM64 SoC ID SMC call is supported
@return Whether the ARM64 SoC ID call is supported.
**/
STATIC
BOOLEAN
HasSmcArm64SocId (
VOID
)
{
INT32 SmcCallStatus;
BOOLEAN Arm64SocIdSupported;
UINTN SmcParam;
Arm64SocIdSupported = FALSE;
SmcCallStatus = ArmCallSmc0 (SMCCC_VERSION, NULL, NULL, NULL);
if ((SmcCallStatus < 0) || ((SmcCallStatus >> 16) >= 1)) {
SmcParam = SMCCC_ARCH_SOC_ID;
SmcCallStatus = ArmCallSmc1 (SMCCC_ARCH_FEATURES, &SmcParam, NULL, NULL);
if (SmcCallStatus >= 0) {
Arm64SocIdSupported = TRUE;
}
}
return Arm64SocIdSupported;
}
/** Fetches the JEP106 code and SoC Revision.
@param Jep106Code JEP 106 code.
@param SocRevision SoC revision.
@retval EFI_SUCCESS Succeeded.
@retval EFI_UNSUPPORTED Failed.
**/
STATIC
EFI_STATUS
SmbiosGetSmcArm64SocId (
OUT UINT32 *Jep106Code,
OUT UINT32 *SocRevision
)
{
INT32 SmcCallStatus;
EFI_STATUS Status;
UINTN SmcParam;
Status = EFI_SUCCESS;
SmcParam = 0;
SmcCallStatus = ArmCallSmc1 (SMCCC_ARCH_SOC_ID, &SmcParam, NULL, NULL);
if (SmcCallStatus >= 0) {
*Jep106Code = (UINT32)SmcCallStatus;
} else {
Status = EFI_UNSUPPORTED;
}
SmcParam = 1;
SmcCallStatus = ArmCallSmc1 (SMCCC_ARCH_SOC_ID, &SmcParam, NULL, NULL);
if (SmcCallStatus >= 0) {
*SocRevision = (UINT32)SmcCallStatus;
} else {
Status = EFI_UNSUPPORTED;
}
return Status;
}
/** Returns the SOC ID, formatted for the SMBIOS Type 4 Processor ID field.
@param Processor ID.
@return 0 on success
@return EFI_UNSUPPORTED if SMCCC_ARCH_SOC_ID is not implemented
**/
UINT64
SmbiosSmcGetSocId (
UINT64 *ProcessorId
)
{
EFI_STATUS Status;
UINT32 Jep106Code;
UINT32 SocRevision;
if (HasSmcArm64SocId ()) {
Status = SmbiosGetSmcArm64SocId (&Jep106Code, &SocRevision);
if (!EFI_ERROR (Status)) {
*ProcessorId = ((UINT64)SocRevision << 32) | Jep106Code;
}
} else {
Status = EFI_UNSUPPORTED;
}
return Status;
}
@@ -0,0 +1,26 @@
#/** @file
#
# Copyright (c) 2025, ARM Ltd. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
#**/
[Defines]
INF_VERSION = 1.30
BASE_NAME = SmbiosSmcLib
FILE_GUID = 201d7312-46c8-42f4-a1cf-38897ddfe916
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = SmbiosSmcLib
[Sources]
SmbiosSmcLib.c
[Packages]
DynamicTablesPkg/DynamicTablesPkg.dec
MdePkg/MdePkg.dec
[LibraryClasses]
ArmSmcLib