The LockBox Dependency DXE Driver is designed for use with standalone mm where gBS are not accessible to indicates that LockBox API is ready for use.
For DXE drivers use lockbox APIs via a communication mechanism triggering an SMI, it's must to have the corresponding SMI handler pre-installed for interrupt management. To ensure orderly operations and proper notification, besides specified the guid in the [Depex] section of the .inf file. The installation of smi handler, along with the LockBox protocol marked by gEfiLockBoxProtocolGuid, must be informed to the DXE driver. This protocol installation signifies to the DXE driver that the LockBox API is ready for use. Cc: Liming Gao <gaolim...@byosoft.com.cn> Cc: Jiaxin Wu <jiaxin...@intel.com> Cc: Ray Ni <ray...@intel.com> Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Sami Mujawar <sami.muja...@arm.com> Reviewed-by: Jiaxin Wu <jiaxin...@intel.com> Signed-off-by: Yuanhao Xie <yuanhao....@intel.com> --- StandaloneMmPkg/Library/SmmLockBoxMmDependency/SmmLockBoxMmDependency.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ StandaloneMmPkg/Library/SmmLockBoxMmDependency/SmmLockBoxMmDependency.inf | 37 +++++++++++++++++++++++++++++++++++++ StandaloneMmPkg/StandaloneMmPkg.dsc | 3 ++- 3 files changed, 91 insertions(+), 1 deletion(-) diff --git a/StandaloneMmPkg/Library/SmmLockBoxMmDependency/SmmLockBoxMmDependency.c b/StandaloneMmPkg/Library/SmmLockBoxMmDependency/SmmLockBoxMmDependency.c new file mode 100644 index 0000000000..b91659055b --- /dev/null +++ b/StandaloneMmPkg/Library/SmmLockBoxMmDependency/SmmLockBoxMmDependency.c @@ -0,0 +1,52 @@ +/** @file + LockBox Dependency DXE Driver. + + By installing the LockBox protocol with the gEfiLockBoxProtocolGuid, + it signals that the LockBox API is fully operational and ready for use. + Drivers that intend to utilize the LockBox functionality at their entry + point should declare this dependency explicitly. + + Copyright (c) 2024, Intel Corporation. All rights reserved.<BR> + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include <Uefi.h> +#include <Library/UefiBootServicesTableLib.h> +#include <Library/DebugLib.h> +#include <Protocol/LockBox.h> + +/** + The constructor function of SmmLockBoxMmDependency. + + It attempts to install the gEfiLockBoxProtocolGuid protocol into the system's DXE database + with NULL as notify. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the Management mode System Table. + + @retval EFI_SUCCESS The protocol was successfully installed into the DXE database. + @retval Others An error occurred while installing the protocol. +**/ +EFI_STATUS +EFIAPI +SmmLockBoxMmDependencyConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + // + // Install NULL to DXE data base as notify + // + Status = gBS->InstallProtocolInterface ( + &ImageHandle, + &gEfiLockBoxProtocolGuid, + EFI_NATIVE_INTERFACE, + NULL + ); + ASSERT_EFI_ERROR (Status); + return Status; +} diff --git a/StandaloneMmPkg/Library/SmmLockBoxMmDependency/SmmLockBoxMmDependency.inf b/StandaloneMmPkg/Library/SmmLockBoxMmDependency/SmmLockBoxMmDependency.inf new file mode 100644 index 0000000000..e377d398ca --- /dev/null +++ b/StandaloneMmPkg/Library/SmmLockBoxMmDependency/SmmLockBoxMmDependency.inf @@ -0,0 +1,37 @@ +## @file +# LockBox Dependency DXE Driver. +# +# By installing the LockBox protocol with the gEfiLockBoxProtocolGuid, +# it signals that the LockBox API is fully operational and ready for use. +# Drivers that intend to utilize the LockBox functionality at their entry +# point should declare this dependency explicitly. +# +# Copyright (c) 2024, Intel Corporation. All rights reserved.<BR> +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x00010006 + BASE_NAME = SmmLockBoxMmDependency + FILE_GUID = c45ce910-7f8b-4f49-88e2-2c26c5743ee2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = NULL + CONSTRUCTOR = SmmLockBoxMmDependencyConstructor + +[Sources] + SmmLockBoxMmDependency.c + +[Packages] + MdePkg/MdePkg.dec + StandaloneMmPkg/StandaloneMmPkg.dec + MdeModulePkg/MdeModulePkg.dec + +[Protocols] + gEfiLockBoxProtocolGuid + +[LibraryClasses] + BaseLib + UefiBootServicesTableLib diff --git a/StandaloneMmPkg/StandaloneMmPkg.dsc b/StandaloneMmPkg/StandaloneMmPkg.dsc index 8012f93b7d..8a4f9a20ec 100644 --- a/StandaloneMmPkg/StandaloneMmPkg.dsc +++ b/StandaloneMmPkg/StandaloneMmPkg.dsc @@ -1,7 +1,7 @@ ## @file # Standalone MM Platform. # -# Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2015 - 2024, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.<BR> # Copyright (C) Microsoft Corporation<BR> # @@ -117,6 +117,7 @@ StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf StandaloneMmPkg/Library/VariableMmDependency/VariableMmDependency.inf + StandaloneMmPkg/Library/SmmLockBoxMmDependency/SmmLockBoxMmDependency.inf [Components.AARCH64, Components.ARM] StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf -- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#119687): https://edk2.groups.io/g/devel/message/119687 Mute This Topic: https://groups.io/mt/106848512/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-