StandaloneMmPkg: Add LockBox Dependency Library

The LockBox Dependency Library is designed for standalone MM
environments where gBS are not accessible to indicates that LockBox API
is readyfor 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
that the LockBox API is ready for use, and this functionality is
implemented in the constructor of this library.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Hongbin1 Zhang <hongbin1.zhang@intel.com>
Cc: Wei6 Xu <wei6.xu@intel.com>
Cc: Dun Tan <dun.tan@intel.com>

Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>

Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
This commit is contained in:
xieyuanh 2024-04-15 13:23:17 +08:00 committed by mergify[bot]
parent 1fc55a3933
commit 3ada6c0db6
2 changed files with 84 additions and 0 deletions

View File

@ -0,0 +1,50 @@
/** @file
LockBox Dependency DXE Library.
By installing the LockBox protocol with the gEfiLockBoxProtocolGuid,
it signals that the LockBox API is fully operational and ready for use.
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;
}

View File

@ -0,0 +1,34 @@
## @file
# LockBox Dependency DXE Library.
#
# By installing the LockBox protocol with the gEfiLockBoxProtocolGuid,
# it signals that the LockBox API is fully operational and ready for use.
#
# 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
MdeModulePkg/MdeModulePkg.dec
[Protocols]
gEfiLockBoxProtocolGuid
[LibraryClasses]
BaseLib
UefiBootServicesTableLib