ArmPkg: Add Arm SMCCC SoC ID library

Add ArmSmcccSocIdLib to provide a shared interface for checking support
for the SMCCC Architecture SoC ID service and retrieving the JEP106
identification code and SoC revision.

Move the existing SMCCC SoC ID handling out of ProcessorSubClassDxe and
update the driver to use the new library. Continue to use the MIDR value
for the SMBIOS Processor ID when the SMCCC SoC ID service is unavailable.

This allows other SMBIOS implementations to reuse the SMCCC handling
without duplicating it or depending on the legacy ProcessorSubClassDxe
driver.

Signed-off-by: Varshit Pandya <Varshit.Pandya@arm.com>
This commit is contained in:
VarshitPandya 2026-07-22 15:51:46 +01:00 committed by mergify[bot]
parent 71c401f2e9
commit 5c6e9d475f
8 changed files with 195 additions and 82 deletions

View file

@ -2,7 +2,7 @@
# ARM processor package.
#
# Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>
# Copyright (c) 2011 - 2023, ARM Limited. All rights reserved.
# Copyright (c) 2011 - 2026, ARM Limited. All rights reserved.
# Copyright (c) 2021, Ampere Computing LLC. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
@ -51,6 +51,11 @@
#
ArmMonitorLib|Include/Library/ArmMonitorLib.h
## @libraryclass Provides access to the Arm SMCCC Architecture SoC ID
# interface.
#
ArmSmcccSocIdLib|Include/Library/ArmSmcccSocIdLib.h
## @libraryclass Provides an interface to query miscellaneous OEM
# information.
#

View file

@ -2,7 +2,7 @@
# ARM processor package.
#
# Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>
# Copyright (c) 2011 - 2021, Arm Limited. All rights reserved.<BR>
# Copyright (c) 2011 - 2026, Arm Limited. All rights reserved.<BR>
# Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
# Copyright (c) Microsoft Corporation.<BR>
# Copyright (c) 2021, Ampere Computing LLC. All rights reserved.
@ -37,6 +37,7 @@
!include MdePkg/MdeLibs.dsc.inc
[LibraryClasses.common]
ArmSmcccSocIdLib|ArmPkg/Library/ArmSmcccSocIdLib/ArmSmcccSocIdLib.inf
BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
@ -111,6 +112,7 @@
[Components.common]
ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
ArmPkg/Library/ArmPsciResetSystemLib/ArmPsciResetSystemLib.inf
ArmPkg/Library/ArmSmcccSocIdLib/ArmSmcccSocIdLib.inf
ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf
ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf
ArmPkg/Library/SemiHostingDebugLib/SemiHostingDebugLib.inf

View file

@ -0,0 +1,39 @@
/** @file
Arm SMCCC SoC ID library.
Copyright (c) 2026, Arm Limited. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#pragma once
/**
Check whether the SMCCC Architecture SoC ID interface is supported.
@retval TRUE The SMCCC Architecture SoC ID interface is supported.
@retval FALSE The SMCCC Architecture SoC ID interface is not supported.
**/
BOOLEAN
ArmSmcccSocIdIsSupported (
VOID
);
/**
Get the JEP106 identification code and SoC revision using the SMCCC
Architecture SoC ID interface.
@param[out] Jep106Code Pointer to the JEP106 identification code.
@param[out] SocRevision Pointer to the SoC revision.
@retval EFI_SUCCESS The SoC identification information was
returned successfully.
@retval EFI_INVALID_PARAMETER A required output parameter is NULL.
@retval EFI_UNSUPPORTED The SMCCC Architecture SoC ID interface is
unsupported or an SoC ID call failed.
**/
EFI_STATUS
ArmSmcccGetSocId (
OUT UINT32 *Jep106Code,
OUT UINT32 *SocRevision
);

View file

@ -0,0 +1,110 @@
/** @file
Arm SMCCC SoC ID library.
Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
Copyright (c) 2021 - 2022, Ampere Computing LLC. All rights reserved.<BR>
Copyright (c) 2026, Arm Limited. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <Uefi.h>
#include <IndustryStandard/ArmStdSmc.h>
#include <Library/ArmSmcLib.h>
#include <Library/ArmSmcccSocIdLib.h>
/**
Check whether the SMCCC Architecture SoC ID interface is supported.
@retval TRUE The SMCCC Architecture SoC ID interface is supported.
@retval FALSE The SMCCC Architecture SoC ID interface is not supported.
**/
BOOLEAN
ArmSmcccSocIdIsSupported (
VOID
)
{
INT32 SmcCallStatus;
UINTN SmcParameter;
SmcCallStatus = ArmCallSmc0 (SMCCC_VERSION, NULL, NULL, NULL);
if ((SmcCallStatus >= 0) && ((SmcCallStatus >> 16) < 1)) {
return FALSE;
}
SmcParameter = SMCCC_ARCH_SOC_ID;
SmcCallStatus = ArmCallSmc1 (
SMCCC_ARCH_FEATURES,
&SmcParameter,
NULL,
NULL
);
return (SmcCallStatus >= 0);
}
/**
Get the JEP106 identification code and SoC revision using the SMCCC
Architecture SoC ID interface.
@param[out] Jep106Code Pointer to the JEP106 identification code.
@param[out] SocRevision Pointer to the SoC revision.
@retval EFI_SUCCESS The SoC identification information was
returned successfully.
@retval EFI_INVALID_PARAMETER A required output parameter is NULL.
@retval EFI_UNSUPPORTED The SMCCC Architecture SoC ID interface is
unsupported or an SoC ID call failed.
**/
EFI_STATUS
ArmSmcccGetSocId (
OUT UINT32 *Jep106Code,
OUT UINT32 *SocRevision
)
{
INT32 SmcCallStatus;
UINTN SmcParameter;
UINT32 LocalJep106Code;
UINT32 LocalSocRevision;
if ((Jep106Code == NULL) || (SocRevision == NULL)) {
return EFI_INVALID_PARAMETER;
}
if (!ArmSmcccSocIdIsSupported ()) {
return EFI_UNSUPPORTED;
}
SmcParameter = 0;
SmcCallStatus = ArmCallSmc1 (
SMCCC_ARCH_SOC_ID,
&SmcParameter,
NULL,
NULL
);
if (SmcCallStatus < 0) {
return EFI_UNSUPPORTED;
}
LocalJep106Code = (UINT32)SmcCallStatus;
SmcParameter = 1;
SmcCallStatus = ArmCallSmc1 (
SMCCC_ARCH_SOC_ID,
&SmcParameter,
NULL,
NULL
);
if (SmcCallStatus < 0) {
return EFI_UNSUPPORTED;
}
LocalSocRevision = (UINT32)SmcCallStatus;
*Jep106Code = LocalJep106Code;
*SocRevision = LocalSocRevision;
return EFI_SUCCESS;
}

View file

@ -0,0 +1,25 @@
## @file
# Arm SMCCC SoC ID library.
#
# Copyright (c) 2026, Arm Limited. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
[Defines]
INF_VERSION = 1.30
BASE_NAME = ArmSmcccSocIdLib
FILE_GUID = 06525cc6-5a4d-4465-be65-186e2e587b1d
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = ArmSmcccSocIdLib
[Sources]
ArmSmcccSocIdLib.c
[Packages]
ArmPkg/ArmPkg.dec
MdePkg/MdePkg.dec
[LibraryClasses]
ArmSmcLib

View file

@ -12,10 +12,8 @@
#include <Uefi.h>
#include <Protocol/Smbios.h>
#include <IndustryStandard/ArmCache.h>
#include <IndustryStandard/ArmStdSmc.h>
#include <IndustryStandard/SmBios.h>
#include <Library/ArmLib.h>
#include <Library/ArmSmcLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>

View file

@ -4,6 +4,7 @@
# Copyright (c) 2021, NUVIA Inc. All rights reserved.
# Copyright (c) 2015, Hisilicon Limited. All rights reserved.
# Copyright (c) 2015, Linaro Limited. All rights reserved.
# Copyright (c) 2026, Arm Limited. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@ -34,7 +35,7 @@
[LibraryClasses]
ArmLib
ArmSmcLib
ArmSmcccSocIdLib
BaseLib
BaseMemoryLib
DebugLib

View file

@ -3,6 +3,7 @@
Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
Copyright (c) 2021 - 2022, Ampere Computing LLC. All rights reserved.<BR>
Copyright (c) 2026, Arm Limited. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@ -10,10 +11,9 @@
#include <Uefi.h>
#include <IndustryStandard/ArmCache.h>
#include <IndustryStandard/ArmStdSmc.h>
#include <IndustryStandard/SmBios.h>
#include <Library/ArmLib.h>
#include <Library/ArmSmcLib.h>
#include <Library/ArmSmcccSocIdLib.h>
#include <Library/BaseMemoryLib.h>
#include "SmbiosProcessor.h"
@ -79,75 +79,6 @@ SmbiosProcessorHasSeparateCaches (
return SeparateCaches;
}
/** Checks if ther ARM64 SoC ID SMC call is supported
@return Whether the ARM64 SoC ID call is supported.
**/
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.
**/
EFI_STATUS
SmbiosGetSmcArm64SocId (
OUT INT32 *Jep106Code,
OUT INT32 *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 = SmcCallStatus;
} else {
Status = EFI_UNSUPPORTED;
}
SmcParam = 1;
SmcCallStatus = ArmCallSmc1 (SMCCC_ARCH_SOC_ID, &SmcParam, NULL, NULL);
if (SmcCallStatus >= 0) {
*SocRevision = SmcCallStatus;
} else {
Status = EFI_UNSUPPORTED;
}
return Status;
}
/** Returns a value for the Processor ID field that conforms to SMBIOS
requirements.
@ -158,12 +89,13 @@ SmbiosGetProcessorId (
VOID
)
{
INT32 Jep106Code;
INT32 SocRevision;
UINT64 ProcessorId;
EFI_STATUS Status;
UINT32 Jep106Code;
UINT32 SocRevision;
UINT64 ProcessorId;
if (HasSmcArm64SocId ()) {
SmbiosGetSmcArm64SocId (&Jep106Code, &SocRevision);
Status = ArmSmcccGetSocId (&Jep106Code, &SocRevision);
if (!EFI_ERROR (Status)) {
ProcessorId = ((UINT64)SocRevision << 32) | Jep106Code;
} else {
ProcessorId = ArmReadMidr ();
@ -236,7 +168,8 @@ SmbiosGetProcessorCharacteristics (
ZeroMem (&Characteristics, sizeof (Characteristics));
Characteristics.ProcessorArm64SocId = HasSmcArm64SocId ();
Characteristics.ProcessorArm64SocId =
ArmSmcccSocIdIsSupported ();
return Characteristics;
}