From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web10.3237.1634333142518073531 for ; Fri, 15 Oct 2021 14:25:45 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: isaac.w.oram@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10138"; a="288852219" X-IronPort-AV: E=Sophos;i="5.85,376,1624345200"; d="scan'208";a="288852219" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2021 14:25:44 -0700 X-IronPort-AV: E=Sophos;i="5.85,376,1624345200"; d="scan'208";a="492709777" Received: from iworam-desk.amr.corp.intel.com ([10.7.150.79]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2021 14:25:43 -0700 From: "Oram, Isaac W" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone , Liming Gao , Eric Dong Subject: [edk2-devel][edk2-platforms][PATCH V1 01/11] MinPlatformPkg/ReportFvLib: Add ReportMmFv to API Date: Fri, 15 Oct 2021 14:25:24 -0700 Message-Id: <56e26f25e6f8df6c5d4bf6a4a6f0361dc915fad1.1634331939.git.isaac.w.oram@intel.com> X-Mailer: git-send-email 2.27.0.windows.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add ReportMmFv (); API for enabling boards to publish additional regions for MM driver use. This results in different instances of the library for PEI and MM. Added MinPlatformPkg library instances to the CorePeiLib.dsc and CoreDxeLib.dsc as the default library instances. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Liming Gao Cc: Eric Dong Signed-off-by: Isaac Oram --- Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc | 2 + Platform/Intel/MinPlatformPkg/Include/Dsc/CorePeiLib.dsc | 1 + Platform/Intel/MinPlatformPkg/Include/Library/ReportFvLib.h | 18 ++- Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc | 9 +- Platform/Intel/MinPlatformPkg/PlatformInit/Library/ReportFvLib/ReportFvLibMm.c | 53 +++++++ Platform/Intel/MinPlatformPkg/PlatformInit/Library/ReportFvLib/ReportFvLibMm.inf | 33 +++++ Platform/Intel/MinPlatformPkg/PlatformInit/Library/ReportFvLib/ReportFvLibPei.c | 146 ++++++++++++++++++++ Platform/Intel/MinPlatformPkg/PlatformInit/Library/ReportFvLib/ReportFvLibPei.inf | 50 +++++++ 8 files changed, 307 insertions(+), 5 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc b/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc index 209ccdaf54..0127ca7641 100644 --- a/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc +++ b/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc @@ -96,6 +96,8 @@ BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf VariableReadLib|MinPlatformPkg/Library/SmmVariableReadLib/TraditionalMmVariableReadLib.inf VariableWriteLib|MinPlatformPkg/Library/SmmVariableWriteLib/TraditionalMmVariableWriteLib.inf + ReportFvLib|MinPlatformPkg/PlatformInit/Library/ReportFvLib/ReportFvLibMm.inf + [LibraryClasses.common.SMM_CORE] PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf diff --git a/Platform/Intel/MinPlatformPkg/Include/Dsc/CorePeiLib.dsc b/Platform/Intel/MinPlatformPkg/Include/Dsc/CorePeiLib.dsc index c12189bd9a..da4d0d6a1a 100644 --- a/Platform/Intel/MinPlatformPkg/Include/Dsc/CorePeiLib.dsc +++ b/Platform/Intel/MinPlatformPkg/Include/Dsc/CorePeiLib.dsc @@ -73,3 +73,4 @@ PerformanceLib|MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf !endif VariableReadLib|MinPlatformPkg/Library/PeiVariableReadLib/PeiVariableReadLib.inf + ReportFvLib|MinPlatformPkg/PlatformInit/Library/ReportFvLib/ReportFvLibPei.inf diff --git a/Platform/Intel/MinPlatformPkg/Include/Library/ReportFvLib.h b/Platform/Intel/MinPlatformPkg/Include/Library/ReportFvLib.h index 5c40bd0e6e..ba76728add 100644 --- a/Platform/Intel/MinPlatformPkg/Include/Library/ReportFvLib.h +++ b/Platform/Intel/MinPlatformPkg/Include/Library/ReportFvLib.h @@ -4,7 +4,7 @@ This library installs pre-memory and post-memory firmware volumes. -Copyright (c) 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -15,6 +15,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include +// +// This is used by board code to produce a table of FV to publish for MM use. +// The end of the table is indicated by base and size both equal to zero. +// +typedef struct { + UINT32 FvBase; + UINT32 FvSize; +} FV_INFO; + VOID ReportPreMemFv ( VOID @@ -25,4 +34,9 @@ ReportPostMemFv ( VOID ); -#endif \ No newline at end of file +VOID +ReportMmFv ( + FV_INFO **FvInfoTable + ); + +#endif diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc index a09f8db3ab..1dfca06a10 100644 --- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc +++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc @@ -107,8 +107,10 @@ TestPointCheckLib|MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.inf TestPointLib|MinPlatformPkg/Test/Library/TestPointLib/DxeTestPointLib.inf +[LibraryClasses.common.DXE_SMM_DRIVER, LibraryClasses.common.MM_STANDALONE] + SpiFlashCommonLib|MinPlatformPkg/Flash/Library/SpiFlashCommonLibNull/SpiFlashCommonLibNull.inf + [LibraryClasses.common.DXE_SMM_DRIVER] - SpiFlashCommonLib|MinPlatformPkg/Flash/Library/SpiFlashCommonLibNull/SpiFlashCommonLibNull.inf TestPointCheckLib|MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.inf TestPointLib|MinPlatformPkg/Test/Library/TestPointLib/SmmTestPointLib.inf @@ -117,7 +119,6 @@ MemoryAllocationLib|StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - SpiFlashCommonLib|MinPlatformPkg/Flash/Library/SpiFlashCommonLibNull/SpiFlashCommonLibNull.inf StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf VariableReadLib|MinPlatformPkg/Library/SmmVariableReadLib/StandaloneMmVariableReadLib.inf VariableWriteLib|MinPlatformPkg/Library/SmmVariableWriteLib/StandaloneMmVariableWriteLib.inf @@ -189,7 +190,9 @@ MinPlatformPkg/PlatformInit/Library/BoardInitLibNull/BoardInitLibNull.inf MinPlatformPkg/PlatformInit/Library/MultiBoardInitSupportLib/PeiMultiBoardInitSupportLib.inf MinPlatformPkg/PlatformInit/Library/MultiBoardInitSupportLib/DxeMultiBoardInitSupportLib.inf - MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.inf + MinPlatformPkg/PlatformInit/Library/ReportFvLib/ReportFvLibPei.inf + MinPlatformPkg/PlatformInit/Library/ReportFvLib/ReportFvLibMm.inf + MinPlatformPkg/PlatformInit/Library/ReportCpuHobLib/ReportCpuHobLib.inf MinPlatformPkg/PlatformInit/SiliconPolicyPei/SiliconPolicyPeiPreMem.inf MinPlatformPkg/PlatformInit/SiliconPolicyPei/SiliconPolicyPeiPostMem.inf diff --git a/Platform/Intel/MinPlatformPkg/PlatformInit/Library/ReportFvLib/ReportFvLibMm.c b/Platform/Intel/MinPlatformPkg/PlatformInit/Library/ReportFvLib/ReportFvLibMm.c new file mode 100644 index 0000000000..a6339d130d --- /dev/null +++ b/Platform/Intel/MinPlatformPkg/PlatformInit/Library/ReportFvLib/ReportFvLibMm.c @@ -0,0 +1,53 @@ +/** @file + Source code file for Report Firmware Volume (FV) library management mode functionality + + ReportPreMemFv (); is not supported by this libary instance + ReportPostMemFv (); is not supported by this libary instance + + Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include + +// +// This platform driver knows there are multiple FVs on FD. +// Variable region and MicroCode region are required. +// +FV_INFO mBoardFvInfoTable[] = { + {0, 0}, // {PcdGet32 (PcdFlashNvStorageVariableBase), PcdGet32 (PcdFlashNvStorageVariableSize)}, + {0, 0}, // {PcdGet32 (PcdFlashFvMicrocodeBase), PcdGet32 (PcdFlashFvMicrocodeSize)}, + {0, 0} +}; + +/* + Return the firmware volumes that are needed for MM functionality. + NV storage and microcode FV are required. + + @param FvInfoTable Pointer to table of FV to be published + + @return VOID +*/ +VOID +ReportMmFv ( + FV_INFO **FvInfoTable + ) +{ + mBoardFvInfoTable[0].FvBase = PcdGet32 (PcdFlashNvStorageVariableBase); + mBoardFvInfoTable[0].FvSize = PcdGet32 (PcdFlashNvStorageVariableSize); + mBoardFvInfoTable[1].FvBase = PcdGet32 (PcdFlashFvMicrocodeBase); + mBoardFvInfoTable[1].FvSize = PcdGet32 (PcdFlashFvMicrocodeSize); + + DEBUG ((DEBUG_INFO, "MM FvInfo Table:\nNvStorageVariableBase 0x%X\nMicrocodeBase 0x%X\n", mBoardFvInfoTable[0].FvBase, mBoardFvInfoTable[1].FvBase, mBoardFvInfoTable[2].FvBase)); + ASSERT (mBoardFvInfoTable[0].FvBase != 0); + ASSERT (mBoardFvInfoTable[0].FvSize != 0); + ASSERT (mBoardFvInfoTable[1].FvBase != 0); + ASSERT (mBoardFvInfoTable[1].FvSize != 0); + + *FvInfoTable = &mBoardFvInfoTable[0]; +} diff --git a/Platform/Intel/MinPlatformPkg/PlatformInit/Library/ReportFvLib/ReportFvLibMm.inf b/Platform/Intel/MinPlatformPkg/PlatformInit/Library/ReportFvLib/ReportFvLibMm.inf new file mode 100644 index 0000000000..41268f179e --- /dev/null +++ b/Platform/Intel/MinPlatformPkg/PlatformInit/Library/ReportFvLib/ReportFvLibMm.inf @@ -0,0 +1,33 @@ +### @file +# Component information file for the Report Firmware Volume (FV) library. +# +# Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +### + +[Defines] + INF_VERSION = 0x00010017 + BASE_NAME = ReportFvLibMm + FILE_GUID = 57c12e02-a65f-4994-bd76-bb6e3fd14df4 + VERSION_STRING = 1.0 + MODULE_TYPE = BASE + LIBRARY_CLASS = ReportFvLib | DXE_SMM_DRIVER MM_STANDALONE + +[LibraryClasses] + DebugLib + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + MinPlatformPkg/MinPlatformPkg.dec + +[Sources] + ReportFvLibMm.c + +[Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize ## CONSUMES + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvMicrocodeBase ## CONSUMES + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvMicrocodeSize ## CONSUMES diff --git a/Platform/Intel/MinPlatformPkg/PlatformInit/Library/ReportFvLib/ReportFvLibPei.c b/Platform/Intel/MinPlatformPkg/PlatformInit/Library/ReportFvLib/ReportFvLibPei.c new file mode 100644 index 0000000000..7fb755266d --- /dev/null +++ b/Platform/Intel/MinPlatformPkg/PlatformInit/Library/ReportFvLib/ReportFvLibPei.c @@ -0,0 +1,146 @@ +/** @file + Source code file for Report Firmware Volume (FV) library + + ReportMmFv (); is not supported in this library instance + + @copyright + Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include +#include +#include +#include + +VOID +ReportPreMemFv ( + VOID + ) +{ + /// + /// Note : FSP FVs except FSP-T FV are installed in IntelFsp2WrapperPkg in Dispatch mode. + /// + if (PcdGetBool(PcdFspWrapperBootMode)) { + DEBUG ((DEBUG_INFO, "Install FlashFvFspT - 0x%x, 0x%x\n", PcdGet32 (PcdFlashFvFspTBase), PcdGet32 (PcdFlashFvFspTSize))); + PeiServicesInstallFvInfo2Ppi ( + &(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 (PcdFlashFvFspTBase))->FileSystemGuid), + (VOID *) (UINTN) PcdGet32 (PcdFlashFvFspTBase), + PcdGet32 (PcdFlashFvFspTSize), + NULL, + NULL, + 0 + ); + } + DEBUG ((DEBUG_INFO, "Install FlashFvSecurity - 0x%x, 0x%x\n", PcdGet32 (PcdFlashFvSecurityBase), PcdGet32 (PcdFlashFvSecuritySize))); + PeiServicesInstallFvInfo2Ppi ( + &(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 (PcdFlashFvSecurityBase))->FileSystemGuid), + (VOID *) (UINTN) PcdGet32 (PcdFlashFvSecurityBase), + PcdGet32 (PcdFlashFvSecuritySize), + NULL, + NULL, + 0 + ); + if (PcdGet8 (PcdBootStage) >= 6) { + DEBUG (( + DEBUG_INFO, + "Install FlashFvAdvancedPreMemory - 0x%x, 0x%x\n", + PcdGet32 (PcdFlashFvAdvancedPreMemoryBase), + PcdGet32 (PcdFlashFvAdvancedPreMemorySize) + )); + PeiServicesInstallFvInfo2Ppi ( + &(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 (PcdFlashFvAdvancedPreMemoryBase))->FileSystemGuid), + (VOID *) (UINTN) PcdGet32 (PcdFlashFvAdvancedPreMemoryBase), + PcdGet32 (PcdFlashFvAdvancedPreMemorySize), + NULL, + NULL, + 0 + ); + } +} + +VOID +ReportPostMemFv ( + VOID + ) +{ + EFI_STATUS Status; + EFI_BOOT_MODE BootMode; + + Status = PeiServicesGetBootMode (&BootMode); + ASSERT_EFI_ERROR (Status); + + /// + /// Note : FSP FVs except FSP-T FV are installed in IntelFsp2WrapperPkg in Dispatch mode. + /// + + /// + /// Build HOB for DXE + /// + if (BootMode == BOOT_IN_RECOVERY_MODE) { + /// + /// Prepare the recovery service + /// + } else { + DEBUG ((DEBUG_INFO, "Install FlashFvPostMemory - 0x%x, 0x%x\n", PcdGet32 (PcdFlashFvPostMemoryBase), PcdGet32 (PcdFlashFvPostMemorySize))); + PeiServicesInstallFvInfo2Ppi ( + &(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 (PcdFlashFvPostMemoryBase))->FileSystemGuid), + (VOID *) (UINTN) PcdGet32 (PcdFlashFvPostMemoryBase), + PcdGet32 (PcdFlashFvPostMemorySize), + NULL, + NULL, + 0 + ); + DEBUG ((DEBUG_INFO, "Install FlashFvUefiBoot - 0x%x, 0x%x\n", PcdGet32 (PcdFlashFvUefiBootBase), PcdGet32 (PcdFlashFvUefiBootSize))); + PeiServicesInstallFvInfo2Ppi ( + &(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 (PcdFlashFvUefiBootBase))->FileSystemGuid), + (VOID *) (UINTN) PcdGet32 (PcdFlashFvUefiBootBase), + PcdGet32 (PcdFlashFvUefiBootSize), + NULL, + NULL, + 0 + ); + DEBUG ((DEBUG_INFO, "Install FlashFvOsBoot - 0x%x, 0x%x\n", PcdGet32 (PcdFlashFvOsBootBase), PcdGet32 (PcdFlashFvOsBootSize))); + PeiServicesInstallFvInfo2Ppi ( + &(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 (PcdFlashFvOsBootBase))->FileSystemGuid), + (VOID *) (UINTN) PcdGet32 (PcdFlashFvOsBootBase), + PcdGet32 (PcdFlashFvOsBootSize), + NULL, + NULL, + 0 + ); + if (PcdGet8 (PcdBootStage) >= 6) { + DEBUG ((DEBUG_INFO, "Install FlashFvAdvanced - 0x%x, 0x%x\n", PcdGet32 (PcdFlashFvAdvancedBase), PcdGet32 (PcdFlashFvAdvancedSize))); + PeiServicesInstallFvInfo2Ppi ( + &(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 (PcdFlashFvAdvancedBase))->FileSystemGuid), + (VOID *) (UINTN) PcdGet32 (PcdFlashFvAdvancedBase), + PcdGet32 (PcdFlashFvAdvancedSize), + NULL, + NULL, + 0 + ); + } + } + + // + // Report resource HOB for flash FV + // + BuildResourceDescriptorHob ( + EFI_RESOURCE_MEMORY_MAPPED_IO, + (EFI_RESOURCE_ATTRIBUTE_PRESENT | + EFI_RESOURCE_ATTRIBUTE_INITIALIZED | + EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE), + (UINTN) PcdGet32 (PcdFlashAreaBaseAddress), + (UINTN) PcdGet32 (PcdFlashAreaSize) + ); + BuildMemoryAllocationHob ( + (UINTN) PcdGet32 (PcdFlashAreaBaseAddress), + (UINTN) PcdGet32 (PcdFlashAreaSize), + EfiMemoryMappedIO + ); +} diff --git a/Platform/Intel/MinPlatformPkg/PlatformInit/Library/ReportFvLib/ReportFvLibPei.inf b/Platform/Intel/MinPlatformPkg/PlatformInit/Library/ReportFvLib/ReportFvLibPei.inf new file mode 100644 index 0000000000..fdb61347c4 --- /dev/null +++ b/Platform/Intel/MinPlatformPkg/PlatformInit/Library/ReportFvLib/ReportFvLibPei.inf @@ -0,0 +1,50 @@ +### @file +# Component information file for the Report Firmware Volume (FV) library. +# +# Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +### + +[Defines] + INF_VERSION = 0x00010017 + BASE_NAME = ReportFvLibPei + FILE_GUID = 44328FA5-E4DD-4A15-ABDF-C6584AC363D9 + VERSION_STRING = 1.0 + MODULE_TYPE = PEIM + LIBRARY_CLASS = ReportFvLib | PEIM + +[LibraryClasses] + BaseMemoryLib + DebugLib + HobLib + PeiServicesLib + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + MinPlatformPkg/MinPlatformPkg.dec + +[Sources] + ReportFvLibPei.c + +[Pcd] + gMinPlatformPkgTokenSpaceGuid.PcdBootStage ## CONSUMES + gMinPlatformPkgTokenSpaceGuid.PcdFspWrapperBootMode ## CONSUMES + gMinPlatformPkgTokenSpaceGuid.PcdFlashAreaBaseAddress ## CONSUMES + gMinPlatformPkgTokenSpaceGuid.PcdFlashAreaSize ## CONSUMES + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspTBase ## CONSUMES + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspTSize ## CONSUMES + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPostMemoryBase ## CONSUMES + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPostMemorySize ## CONSUMES + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootBase ## CONSUMES + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootSize ## CONSUMES + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootBase ## CONSUMES + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootSize ## CONSUMES + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityBase ## CONSUMES + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecuritySize ## CONSUMES + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedPreMemoryBase ## CONSUMES + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedPreMemorySize ## CONSUMES + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedBase ## CONSUMES + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedSize ## CONSUMES -- 2.27.0.windows.1