From 5c6fea49ee582fa1fbb66396acc7609f38446865 Mon Sep 17 00:00:00 2001 From: Jiaxin Wu Date: Thu, 20 Mar 2025 16:43:24 +0800 Subject: [PATCH] StandaloneMmPkg: Produce gMmStatusCodeUseSerialHobGuid HOB Produce gMmStatusCodeUseSerialHobGuid as MM Foundation HOB to describe the status code use serial port or not. Signed-off-by: Jiaxin Wu --- .../StandaloneMmIplPei/MmFoundationHob.c | 45 +++++++++++++++++++ .../StandaloneMmIplPei/StandaloneMmIplPei.inf | 2 + .../Library/MmPlatformHobProducerLib.h | 1 + .../MmPlatformHobProducerLibNull.c | 1 + 4 files changed, 49 insertions(+) diff --git a/StandaloneMmPkg/Drivers/StandaloneMmIplPei/MmFoundationHob.c b/StandaloneMmPkg/Drivers/StandaloneMmIplPei/MmFoundationHob.c index 2f02920582..96e041639f 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmIplPei/MmFoundationHob.c +++ b/StandaloneMmPkg/Drivers/StandaloneMmIplPei/MmFoundationHob.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -207,6 +208,43 @@ MmIplBuildMmCpuSyncConfigHob ( *HobBufferSize = HobLength; } +/** + Builds MM Status Code Use Serial HOB. + + This function builds MM Status Code Use Serial HOB. + It can only be invoked during PEI phase; + If new HOB buffer is NULL, then ASSERT(). + + @param[in] Hob The pointer of new HOB buffer. + @param[in, out] HobBufferSize The available size of the HOB buffer when as input. + The used size of when as output. + +**/ +VOID +MmIplBuildMmStatusCodeUseSerialHob ( + IN UINT8 *Hob, + IN OUT UINTN *HobBufferSize + ) +{ + EFI_HOB_GUID_TYPE *GuidHob; + MM_STATUS_CODE_USE_SERIAL *MmStatusCodeUseSerial; + UINT16 HobLength; + + HobLength = ALIGN_VALUE (sizeof (EFI_HOB_GUID_TYPE) + sizeof (MM_STATUS_CODE_USE_SERIAL), 8); + if (*HobBufferSize >= HobLength) { + ASSERT (Hob != NULL); + MmIplCreateHob (Hob, EFI_HOB_TYPE_GUID_EXTENSION, HobLength); + + GuidHob = (EFI_HOB_GUID_TYPE *)Hob; + CopyGuid (&GuidHob->Name, &gMmStatusCodeUseSerialHobGuid); + + MmStatusCodeUseSerial = (MM_STATUS_CODE_USE_SERIAL *)(GuidHob + 1); + MmStatusCodeUseSerial->StatusCodeUseSerial = PcdGetBool (PcdStatusCodeUseSerial); + } + + *HobBufferSize = HobLength; +} + /** Copies a data buffer to a newly-built HOB for GUID HOB @@ -957,6 +995,13 @@ CreateMmFoundationHobList ( MmIplBuildMmCpuSyncConfigHob (FoundationHobList + UsedSize, &HobLength); UsedSize += HobLength; + // + // Build MM Status Code Use Serial HOB + // + HobLength = GetRemainingHobSize (*FoundationHobSize, UsedSize); + MmIplBuildMmStatusCodeUseSerialHob (FoundationHobList + UsedSize, &HobLength); + UsedSize += HobLength; + // // Build CPU SMM base HOB in MM HOB list // diff --git a/StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.inf b/StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.inf index f07f26ee41..0341a98d37 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.inf +++ b/StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.inf @@ -56,6 +56,7 @@ gMmCpuSyncConfigHobGuid gMmProfileDataHobGuid gMmUnblockRegionHobGuid + gMmStatusCodeUseSerialHobGuid [Ppis] gEfiPeiMmControlPpiGuid @@ -69,6 +70,7 @@ [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdMmCommBufferPages gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial ## CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode ## CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmApSyncTimeout ## CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmApSyncTimeout2 ## CONSUMES diff --git a/StandaloneMmPkg/Include/Library/MmPlatformHobProducerLib.h b/StandaloneMmPkg/Include/Library/MmPlatformHobProducerLib.h index 2f302bb5b1..ec01152e3b 100644 --- a/StandaloneMmPkg/Include/Library/MmPlatformHobProducerLib.h +++ b/StandaloneMmPkg/Include/Library/MmPlatformHobProducerLib.h @@ -30,6 +30,7 @@ * 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. + * Single GUIDed (gMmStatusCodeUseSerialHobGuid) HOB to describe the status code use serial port. @param[in] Buffer The free buffer to be used for HOB creation. @param[in, out] BufferSize The buffer size. diff --git a/StandaloneMmPkg/Library/MmPlatformHobProducerLibNull/MmPlatformHobProducerLibNull.c b/StandaloneMmPkg/Library/MmPlatformHobProducerLibNull/MmPlatformHobProducerLibNull.c index 814ea1c4a0..79f55d52a0 100644 --- a/StandaloneMmPkg/Library/MmPlatformHobProducerLibNull/MmPlatformHobProducerLibNull.c +++ b/StandaloneMmPkg/Library/MmPlatformHobProducerLibNull/MmPlatformHobProducerLibNull.c @@ -31,6 +31,7 @@ * 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. + * Single GUIDed (gMmStatusCodeUseSerialHobGuid) HOB to describe the status code use serial port. @param[in] Buffer The free buffer to be used for HOB creation. @param[in, out] BufferSize The buffer size.