diff --git a/DynamicTablesPkg/DynamicTablesPkg.ci.yaml b/DynamicTablesPkg/DynamicTablesPkg.ci.yaml index 56069e286f..2c0dcefefb 100644 --- a/DynamicTablesPkg/DynamicTablesPkg.ci.yaml +++ b/DynamicTablesPkg/DynamicTablesPkg.ci.yaml @@ -118,6 +118,7 @@ "lless", "MPIDR", "NAMESPACEID", + "NUVIA", "PASID", "PERIPHBASE", "phandle", @@ -128,6 +129,7 @@ "sapic", "ssdtcmn", "ssdtserialporttemplate", + "SMCCC", "SMMUV", "ssdtpcieosctemplate", "SSDTPC", diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec b/DynamicTablesPkg/DynamicTablesPkg.dec index d0aa4bcf76..4ed8e834ca 100644 --- a/DynamicTablesPkg/DynamicTablesPkg.dec +++ b/DynamicTablesPkg/DynamicTablesPkg.dec @@ -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 diff --git a/DynamicTablesPkg/DynamicTablesPkg.dsc b/DynamicTablesPkg/DynamicTablesPkg.dsc index 1c34609bf3..e4fcc45f44 100644 --- a/DynamicTablesPkg/DynamicTablesPkg.dsc +++ b/DynamicTablesPkg/DynamicTablesPkg.dsc @@ -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 diff --git a/DynamicTablesPkg/Include/Library/SmbiosSmcLib.h b/DynamicTablesPkg/Include/Library/SmbiosSmcLib.h new file mode 100644 index 0000000000..f3aef3b88f --- /dev/null +++ b/DynamicTablesPkg/Include/Library/SmbiosSmcLib.h @@ -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_ diff --git a/DynamicTablesPkg/Library/Smbios/Arm/SmbiosSmcLib/SmbiosSmcLib.c b/DynamicTablesPkg/Library/Smbios/Arm/SmbiosSmcLib/SmbiosSmcLib.c new file mode 100644 index 0000000000..1e163c86b2 --- /dev/null +++ b/DynamicTablesPkg/Library/Smbios/Arm/SmbiosSmcLib/SmbiosSmcLib.c @@ -0,0 +1,114 @@ +/** @file + SMBIOS SMC helper functions. + + Copyright (c) 2021, NUVIA Inc. All rights reserved.
+ Copyright (c) 2021 - 2022, Ampere Computing LLC. All rights reserved.
+ Copyright (c) 2025, ARM Ltd. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include + +/** 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; +} diff --git a/DynamicTablesPkg/Library/Smbios/Arm/SmbiosSmcLib/SmbiosSmcLib.inf b/DynamicTablesPkg/Library/Smbios/Arm/SmbiosSmcLib/SmbiosSmcLib.inf new file mode 100644 index 0000000000..ea43c0784a --- /dev/null +++ b/DynamicTablesPkg/Library/Smbios/Arm/SmbiosSmcLib/SmbiosSmcLib.inf @@ -0,0 +1,26 @@ +#/** @file +# +# Copyright (c) 2025, ARM Ltd. All rights reserved.
+# +# 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 +