PiSmmCore installs LoadedImage for each SMM driver. However ECP SMM driver is missing. Since SmmBaseHelper loads ECP SMM driver, we let SmmBaseHelper installs LoadedImage protocol for SMM driver. So that the SMM image information is complete.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yao, Jiewen <jiewen....@intel.com> Cc: Zeng, Star <star.z...@intel.com> Cc: Fan, Jeff <jeff....@intel.com> Cc: Gao, Liming <liming....@intel.com> Cc: Kinney, Michael D <michael.d.kin...@intel.com> --- .../Compatibility/SmmBaseHelper/SmmBaseHelper.c | 56 ++++++++++++++++++++-- .../Compatibility/SmmBaseHelper/SmmBaseHelper.inf | 3 ++ 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/EdkCompatibilityPkg/Compatibility/SmmBaseHelper/SmmBaseHelper.c b/EdkCompatibilityPkg/Compatibility/SmmBaseHelper/SmmBaseHelper.c index 1d16449..4393143 100644 --- a/EdkCompatibilityPkg/Compatibility/SmmBaseHelper/SmmBaseHelper.c +++ b/EdkCompatibilityPkg/Compatibility/SmmBaseHelper/SmmBaseHelper.c @@ -43,6 +43,7 @@ #include <Protocol/LoadPe32Image.h> #include <Protocol/SmmReadyToLock.h> #include <Protocol/SmmAccess2.h> +#include <Protocol/LoadedImage.h> /** Register SMM image to SMRAM profile. @@ -682,10 +683,13 @@ LoadImage ( OUT EFI_HANDLE *ImageHandle ) { - EFI_STATUS Status; - UINTN PageCount; - UINTN OrgPageCount; - EFI_PHYSICAL_ADDRESS DstBuffer; + EFI_STATUS Status; + UINTN PageCount; + UINTN OrgPageCount; + EFI_PHYSICAL_ADDRESS DstBuffer; + EFI_HANDLE SmmImageHandle; + EFI_LOADED_IMAGE_PROTOCOL *SmmLoadedImage; + EFI_LOADED_IMAGE_PROTOCOL *ParentLoadedImage; if (FilePath == NULL || ImageHandle == NULL) { return EFI_INVALID_PARAMETER; @@ -730,10 +734,54 @@ LoadImage ( mFrameworkSmst->NumberOfCpus = mNumberOfProcessors; mFrameworkSmst->CurrentlyExecutingCpu = gSmst->CurrentlyExecutingCpu; + Status = gBS->HandleProtocol ( + ParentImageHandle, + &gEfiLoadedImageProtocolGuid, + (VOID **) &ParentLoadedImage + ); + ASSERT_EFI_ERROR (Status); + + // + // Allocate a Loaded Image Protocol in EfiBootServicesData + // + Status = gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_LOADED_IMAGE_PROTOCOL), (VOID **)&SmmLoadedImage); + ASSERT_EFI_ERROR (Status); + + ZeroMem (SmmLoadedImage, sizeof (EFI_LOADED_IMAGE_PROTOCOL)); + // + // Fill in the remaining fields of the Loaded Image Protocol instance. + // Note: ImageBase is an SMRAM address that can not be accessed outside of SMRAM if SMRAM window is closed. + // + SmmLoadedImage->Revision = EFI_LOADED_IMAGE_PROTOCOL_REVISION; + SmmLoadedImage->ParentHandle = ParentImageHandle; + SmmLoadedImage->SystemTable = gST; + SmmLoadedImage->DeviceHandle = ParentLoadedImage->DeviceHandle; + + SmmLoadedImage->ImageBase = (VOID *)(UINTN)DstBuffer; + SmmLoadedImage->ImageSize = EFI_PAGES_TO_SIZE(PageCount); + SmmLoadedImage->ImageCodeType = EfiRuntimeServicesCode; + SmmLoadedImage->ImageDataType = EfiRuntimeServicesData; + + // + // Create a new image handle in the UEFI handle database for the SMM Driver + // + SmmImageHandle = NULL; + Status = gBS->InstallMultipleProtocolInterfaces ( + &SmmImageHandle, + &gEfiLoadedImageProtocolGuid, SmmLoadedImage, + NULL + ); + ASSERT_EFI_ERROR (Status); + RegisterSmramProfileImage (FilePath, DstBuffer, PageCount); Status = gBS->StartImage (*ImageHandle, NULL, NULL); if (EFI_ERROR (Status)) { UnregisterSmramProfileImage (FilePath, DstBuffer, PageCount); + gBS->UninstallProtocolInterface ( + SmmImageHandle, + &gEfiLoadedImageProtocolGuid, + SmmLoadedImage + ); mLoadPe32Image->UnLoadPeImage (mLoadPe32Image, *ImageHandle); *ImageHandle = NULL; FreePages ((VOID *)(UINTN)DstBuffer, PageCount); diff --git a/EdkCompatibilityPkg/Compatibility/SmmBaseHelper/SmmBaseHelper.inf b/EdkCompatibilityPkg/Compatibility/SmmBaseHelper/SmmBaseHelper.inf index 8e967dc..256b4cc 100644 --- a/EdkCompatibilityPkg/Compatibility/SmmBaseHelper/SmmBaseHelper.inf +++ b/EdkCompatibilityPkg/Compatibility/SmmBaseHelper/SmmBaseHelper.inf @@ -77,6 +77,9 @@ gEfiSmmReadyToLockProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiSmmAccess2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiSmmCommunicationProtocolGuid + ## PRODUCES + ## CONSUMES + gEfiLoadedImageProtocolGuid [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfilePropertyMask -- 1.9.5.msysgit.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel