diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc b/DynamicTablesPkg/DynamicTables.dsc.inc index c71abe57a6..a442a29d1e 100644 --- a/DynamicTablesPkg/DynamicTables.dsc.inc +++ b/DynamicTablesPkg/DynamicTables.dsc.inc @@ -29,6 +29,7 @@ Tpm2DeviceTableLib|DynamicTablesPkg/Library/Common/Tpm2DeviceTableLib/Tpm2DeviceTableLib.inf [LibraryClasses.AARCH64] + ArmSmcccSocIdLib|ArmPkg/Library/ArmSmcccSocIdLib/ArmSmcccSocIdLib.inf DynamicTablesScmiInfoLib|DynamicTablesPkg/Library/DynamicTablesScmiInfoLib/DynamicTablesScmiInfoLib.inf [Components.ARM, Components.AARCH64, Components.X64, Components.RISCV64, Components.LOONGARCH64] diff --git a/DynamicTablesPkg/Include/Library/SmbiosSmcLib.h b/DynamicTablesPkg/Include/Library/SmbiosSmcLib.h index 2f49055efa..bfd0bf7b91 100644 --- a/DynamicTablesPkg/Include/Library/SmbiosSmcLib.h +++ b/DynamicTablesPkg/Include/Library/SmbiosSmcLib.h @@ -1,6 +1,6 @@ /** @file * -* Copyright (c) 2025, ARM Limited. All rights reserved. +* Copyright (c) 2025 - 2026, ARM Limited. All rights reserved. * * SPDX-License-Identifier: BSD-2-Clause-Patent * @@ -8,14 +8,17 @@ #pragma once -/** Returns the SOC ID, formatted for the SMBIOS Type 4 Processor ID field. +/** + Return the SoC ID formatted for the SMBIOS Type 4 Processor ID field. - @param Processor ID. + @param[out] ProcessorId Pointer to the SMBIOS Processor ID. - @return 0 on success - @return EFI_UNSUPPORTED if SMCCC_ARCH_SOC_ID is not implemented + @retval EFI_SUCCESS The Processor ID was returned successfully. + @retval EFI_INVALID_PARAMETER ProcessorId is NULL. + @retval EFI_UNSUPPORTED The SMCCC Architecture SoC ID interface is + unsupported or an SoC ID call failed. **/ -UINT64 +EFI_STATUS SmbiosSmcGetSocId ( - UINT64 *ProcessorId + OUT UINT64 *ProcessorId ); diff --git a/DynamicTablesPkg/Library/Smbios/Arm/SmbiosSmcLib/SmbiosSmcLib.c b/DynamicTablesPkg/Library/Smbios/Arm/SmbiosSmcLib/SmbiosSmcLib.c index 1e163c86b2..b838f1c4a0 100644 --- a/DynamicTablesPkg/Library/Smbios/Arm/SmbiosSmcLib/SmbiosSmcLib.c +++ b/DynamicTablesPkg/Library/Smbios/Arm/SmbiosSmcLib/SmbiosSmcLib.c @@ -3,111 +3,42 @@ 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.
+ Copyright (c) 2025 - 2026, ARM Ltd. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include -#include -#include +#include #include -/** Checks if the ARM64 SoC ID SMC call is supported +/** + Return the SoC ID formatted for the SMBIOS Type 4 Processor ID field. - @return Whether the ARM64 SoC ID call is supported. + @param[out] ProcessorId Pointer to the SMBIOS Processor ID. + + @retval EFI_SUCCESS The Processor ID was returned successfully. + @retval EFI_INVALID_PARAMETER ProcessorId is NULL. + @retval EFI_UNSUPPORTED The SMCCC Architecture SoC ID interface is + unsupported or an SoC ID call failed. **/ -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 + OUT 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; + if (ProcessorId == NULL) { + return EFI_INVALID_PARAMETER; + } + + Status = ArmSmcccGetSocId (&Jep106Code, &SocRevision); + if (!EFI_ERROR (Status)) { + *ProcessorId = ((UINT64)SocRevision << 32) | Jep106Code; } return Status; diff --git a/DynamicTablesPkg/Library/Smbios/Arm/SmbiosSmcLib/SmbiosSmcLib.inf b/DynamicTablesPkg/Library/Smbios/Arm/SmbiosSmcLib/SmbiosSmcLib.inf index ea43c0784a..ab95d443a3 100644 --- a/DynamicTablesPkg/Library/Smbios/Arm/SmbiosSmcLib/SmbiosSmcLib.inf +++ b/DynamicTablesPkg/Library/Smbios/Arm/SmbiosSmcLib/SmbiosSmcLib.inf @@ -1,6 +1,6 @@ #/** @file # -# Copyright (c) 2025, ARM Ltd. All rights reserved.
+# Copyright (c) 2025 - 2026, ARM Ltd. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -18,9 +18,10 @@ SmbiosSmcLib.c [Packages] + ArmPkg/ArmPkg.dec DynamicTablesPkg/DynamicTablesPkg.dec MdePkg/MdePkg.dec [LibraryClasses] - ArmSmcLib + ArmSmcccSocIdLib