From 0806fb60d4502c05f378cdbf4cdeca9be5ff502a Mon Sep 17 00:00:00 2001 From: Dun Tan Date: Tue, 11 Jun 2024 12:16:42 +0800 Subject: [PATCH] StandaloneMmPkg: Create null instance for MmPlatformHobProducerLib Create null instance MmPlatformHobProducerLibNull.inf for MmPlatformHobProducerLib. Signed-off-by: Dun Tan --- .../MmPlatformHobProducerLibNull.c | 66 +++++++++++++++++++ .../MmPlatformHobProducerLibNull.inf | 28 ++++++++ StandaloneMmPkg/StandaloneMmPkg.dsc | 2 + 3 files changed, 96 insertions(+) create mode 100644 StandaloneMmPkg/Library/MmPlatformHobProducerLibNull/MmPlatformHobProducerLibNull.c create mode 100644 StandaloneMmPkg/Library/MmPlatformHobProducerLibNull/MmPlatformHobProducerLibNull.inf diff --git a/StandaloneMmPkg/Library/MmPlatformHobProducerLibNull/MmPlatformHobProducerLibNull.c b/StandaloneMmPkg/Library/MmPlatformHobProducerLibNull/MmPlatformHobProducerLibNull.c new file mode 100644 index 0000000000..814ea1c4a0 --- /dev/null +++ b/StandaloneMmPkg/Library/MmPlatformHobProducerLibNull/MmPlatformHobProducerLibNull.c @@ -0,0 +1,66 @@ +/** @file + Null instance of MM Platform HOB Producer Library Class. + + CreateMmPlatformHob() function is called by StandaloneMm IPL to create all + Platform specific HOBs that required by Standalone MM environment. + + Copyright (c) 2024, Intel Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include + +/** + Create the platform specific HOBs needed by the Standalone MM environment. + + The following HOBs are created by StandaloneMm IPL common logic. + Hence they should NOT be created by this function: + * Single EFI_HOB_TYPE_FV to describe the Firmware Volume where MM Core resides. + * Single GUIDed (gEfiSmmSmramMemoryGuid) HOB to describe the MM regions. + * Single EFI_HOB_MEMORY_ALLOCATION_MODULE to describe the MM region used by MM Core. + * Multiple EFI_HOB_RESOURCE_DESCRIPTOR to describe the non-MM regions and their access permissions. + Note: All accessible non-MM regions should be described by EFI_HOB_RESOURCE_DESCRIPTOR HOBs. + * Single GUIDed (gMmCommBufferHobGuid) HOB to identify MM Communication buffer in non-MM region. + * Multiple GUIDed (gSmmBaseHobGuid) HOB to describe the SMM base address of each processor. + * Multiple GUIDed (gMpInformation2HobGuid) HOB to describe the MP information. + * Single GUIDed (gMmCpuSyncConfigHobGuid) HOB to describe how BSP synchronizes with APs in x86 SMM. + * Single GUIDed (gMmAcpiS3EnableHobGuid) HOB to describe the ACPI S3 enable status. + * Single GUIDed (gEfiAcpiVariableGuid) HOB to identify the S3 data root region in x86. + * Single GUIDed (gMmProfileDataHobGuid) HOB to describe the MM profile data region. + + @param[in] Buffer The free buffer to be used for HOB creation. + @param[in, out] BufferSize The buffer size. + On return, the expected/used size. + + @retval RETURN_INVALID_PARAMETER BufferSize is NULL. + @retval RETURN_INVALID_PARAMETER Buffer is NULL and BufferSize is not 0. + @retval RETURN_BUFFER_TOO_SMALL The buffer is too small for HOB creation. + BufferSize is updated to indicate the expected buffer size. + When the input BufferSize is bigger than the expected buffer size, + the BufferSize value will be changed to the used buffer size. + @retval RETURN_SUCCESS The HOB list is created successfully. + +**/ +EFI_STATUS +EFIAPI +CreateMmPlatformHob ( + IN VOID *Buffer, + IN OUT UINTN *BufferSize + ) +{ + if (BufferSize == NULL) { + return RETURN_INVALID_PARAMETER; + } + + if ((*BufferSize != 0) && (Buffer == NULL)) { + return RETURN_INVALID_PARAMETER; + } + + *BufferSize = 0; + + return EFI_SUCCESS; +} diff --git a/StandaloneMmPkg/Library/MmPlatformHobProducerLibNull/MmPlatformHobProducerLibNull.inf b/StandaloneMmPkg/Library/MmPlatformHobProducerLibNull/MmPlatformHobProducerLibNull.inf new file mode 100644 index 0000000000..64e1ac185f --- /dev/null +++ b/StandaloneMmPkg/Library/MmPlatformHobProducerLibNull/MmPlatformHobProducerLibNull.inf @@ -0,0 +1,28 @@ +## @file +# Null instance of MM Platform HOB Producer Library Class. +# +# Copyright (c) 2024, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# +## + +[Defines] + INF_VERSION = 0x00010017 + BASE_NAME = MmPlatformHobProducerLibNull + FILE_GUID = DE6B5E7C-6636-4646-90F8-776408157750 + MODULE_TYPE = PEIM + VERSION_STRING = 1.0 + LIBRARY_CLASS = MmPlatformHobProducerLib + +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + MmPlatformHobProducerLibNull.c + +[Packages] + MdePkg/MdePkg.dec + StandaloneMmPkg/StandaloneMmPkg.dec diff --git a/StandaloneMmPkg/StandaloneMmPkg.dsc b/StandaloneMmPkg/StandaloneMmPkg.dsc index 39aea898bb..fc2c12447d 100644 --- a/StandaloneMmPkg/StandaloneMmPkg.dsc +++ b/StandaloneMmPkg/StandaloneMmPkg.dsc @@ -60,6 +60,7 @@ StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf VariableMmDependency|StandaloneMmPkg/Library/VariableMmDependency/VariableMmDependency.inf HobPrintLib|MdeModulePkg/Library/HobPrintLib/HobPrintLib.inf + MmPlatformHobProducerLib|StandaloneMmPkg/Library/MmPlatformHobProducerLibNull/MmPlatformHobProducerLibNull.inf [LibraryClasses.AARCH64, LibraryClasses.ARM] ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf @@ -119,6 +120,7 @@ StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf StandaloneMmPkg/Library/VariableMmDependency/VariableMmDependency.inf StandaloneMmPkg/Library/SmmLockBoxMmDependency/SmmLockBoxMmDependency.inf + StandaloneMmPkg/Library/MmPlatformHobProducerLibNull/MmPlatformHobProducerLibNull.inf [Components.AARCH64, Components.ARM] StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf