EdkCompatibilityPkg: Add UEFI memory and SMRAM profile support.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16336 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -4,7 +4,7 @@
|
|||||||
# Intel's Framework Boot Script Save Protocol is replaced by S3 Save State Protocol in PI.
|
# Intel's Framework Boot Script Save Protocol is replaced by S3 Save State Protocol in PI.
|
||||||
# This module produces Framework Boot Script Save protocol by consuming PI S3 Save State protocol
|
# This module produces Framework Boot Script Save protocol by consuming PI S3 Save State protocol
|
||||||
#
|
#
|
||||||
# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
|
# Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||||
#
|
#
|
||||||
# This program and the accompanying materials
|
# This program and the accompanying materials
|
||||||
# are licensed and made available under the terms and conditions of the BSD License
|
# are licensed and made available under the terms and conditions of the BSD License
|
||||||
@ -62,13 +62,20 @@
|
|||||||
PcdLib
|
PcdLib
|
||||||
DxeServicesLib
|
DxeServicesLib
|
||||||
CacheMaintenanceLib
|
CacheMaintenanceLib
|
||||||
|
BaseMemoryLib
|
||||||
|
DevicePathLib
|
||||||
|
UefiLib
|
||||||
|
|
||||||
[Protocols]
|
[Protocols]
|
||||||
gEfiBootScriptSaveProtocolGuid ## PRODUCES
|
gEfiBootScriptSaveProtocolGuid ## PRODUCES
|
||||||
gEfiS3SaveStateProtocolGuid ## CONSUMES
|
gEfiS3SaveStateProtocolGuid ## CONSUMES
|
||||||
|
|
||||||
|
[Guids]
|
||||||
|
gEdkiiMemoryProfileGuid
|
||||||
|
|
||||||
[Pcd]
|
[Pcd]
|
||||||
gEfiEdkCompatibilityPkgTokenSpaceGuid.BootScriptThunkDataPtr
|
gEfiEdkCompatibilityPkgTokenSpaceGuid.BootScriptThunkDataPtr
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfilePropertyMask
|
||||||
|
|
||||||
[Depex]
|
[Depex]
|
||||||
gEfiS3SaveStateProtocolGuid
|
gEfiS3SaveStateProtocolGuid
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
Implementation for S3 Boot Script Save thunk driver.
|
Implementation for S3 Boot Script Save thunk driver.
|
||||||
This thunk driver consumes PI S3SaveState protocol to produce framework S3BootScriptSave Protocol
|
This thunk driver consumes PI S3SaveState protocol to produce framework S3BootScriptSave Protocol
|
||||||
|
|
||||||
Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -791,6 +791,47 @@ BootScriptCloseTable (
|
|||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Register image to memory profile.
|
||||||
|
|
||||||
|
@param FileName File name of the image.
|
||||||
|
@param ImageBase Image base address.
|
||||||
|
@param ImageSize Image size.
|
||||||
|
@param FileType File type of the image.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
RegisterMemoryProfileImage (
|
||||||
|
IN EFI_GUID *FileName,
|
||||||
|
IN PHYSICAL_ADDRESS ImageBase,
|
||||||
|
IN UINT64 ImageSize,
|
||||||
|
IN EFI_FV_FILETYPE FileType
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EDKII_MEMORY_PROFILE_PROTOCOL *ProfileProtocol;
|
||||||
|
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FilePath;
|
||||||
|
UINT8 TempBuffer[sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH) + sizeof (EFI_DEVICE_PATH_PROTOCOL)];
|
||||||
|
|
||||||
|
if ((PcdGet8 (PcdMemoryProfilePropertyMask) & BIT0) != 0) {
|
||||||
|
|
||||||
|
FilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)TempBuffer;
|
||||||
|
Status = gBS->LocateProtocol (&gEdkiiMemoryProfileGuid, NULL, (VOID **) &ProfileProtocol);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
EfiInitializeFwVolDevicepathNode (FilePath, FileName);
|
||||||
|
SetDevicePathEndNode (FilePath + 1);
|
||||||
|
|
||||||
|
Status = ProfileProtocol->RegisterImage (
|
||||||
|
ProfileProtocol,
|
||||||
|
(EFI_DEVICE_PATH_PROTOCOL *) FilePath,
|
||||||
|
ImageBase,
|
||||||
|
ImageSize,
|
||||||
|
FileType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This routine is entry point of ScriptSave driver.
|
This routine is entry point of ScriptSave driver.
|
||||||
|
|
||||||
@ -893,6 +934,14 @@ InitializeScriptSaveOnS3SaveState (
|
|||||||
// Flush the instruction cache so the image data is written before we execute it
|
// Flush the instruction cache so the image data is written before we execute it
|
||||||
//
|
//
|
||||||
InvalidateInstructionCacheRange ((VOID *)(UINTN)ImageContext.ImageAddress, (UINTN)ImageContext.ImageSize);
|
InvalidateInstructionCacheRange ((VOID *)(UINTN)ImageContext.ImageAddress, (UINTN)ImageContext.ImageSize);
|
||||||
|
|
||||||
|
RegisterMemoryProfileImage (
|
||||||
|
&gEfiCallerIdGuid,
|
||||||
|
ImageContext.ImageAddress,
|
||||||
|
ImageContext.ImageSize,
|
||||||
|
EFI_FV_FILETYPE_DRIVER
|
||||||
|
);
|
||||||
|
|
||||||
Status = ((EFI_IMAGE_ENTRY_POINT)(UINTN)(ImageContext.EntryPoint)) (NewImageHandle, SystemTable);
|
Status = ((EFI_IMAGE_ENTRY_POINT)(UINTN)(ImageContext.EntryPoint)) (NewImageHandle, SystemTable);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Header file for S3 Boot Script Saver thunk driver.
|
Header file for S3 Boot Script Saver thunk driver.
|
||||||
|
|
||||||
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -28,8 +28,12 @@
|
|||||||
#include <Library/MemoryAllocationLib.h>
|
#include <Library/MemoryAllocationLib.h>
|
||||||
#include <Library/DxeServicesLib.h>
|
#include <Library/DxeServicesLib.h>
|
||||||
#include <Library/CacheMaintenanceLib.h>
|
#include <Library/CacheMaintenanceLib.h>
|
||||||
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
#include <Library/DevicePathLib.h>
|
||||||
|
#include <Library/UefiLib.h>
|
||||||
|
|
||||||
#include <Guid/BootScriptThunkData.h>
|
#include <Guid/BootScriptThunkData.h>
|
||||||
|
#include <Guid/MemoryProfile.h>
|
||||||
|
|
||||||
#include <IndustryStandard/SmBus.h>
|
#include <IndustryStandard/SmBus.h>
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include <Library/MemoryAllocationLib.h>
|
#include <Library/MemoryAllocationLib.h>
|
||||||
#include <Library/SynchronizationLib.h>
|
#include <Library/SynchronizationLib.h>
|
||||||
#include <Library/CpuLib.h>
|
#include <Library/CpuLib.h>
|
||||||
|
#include <Library/PcdLib.h>
|
||||||
#include <Guid/SmmBaseThunkCommunication.h>
|
#include <Guid/SmmBaseThunkCommunication.h>
|
||||||
#include <Protocol/SmmBaseHelperReady.h>
|
#include <Protocol/SmmBaseHelperReady.h>
|
||||||
#include <Protocol/SmmCpu.h>
|
#include <Protocol/SmmCpu.h>
|
||||||
@ -44,6 +45,42 @@
|
|||||||
#include <Protocol/SmmReadyToLock.h>
|
#include <Protocol/SmmReadyToLock.h>
|
||||||
#include <Protocol/SmmAccess2.h>
|
#include <Protocol/SmmAccess2.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Register SMM image to SMRAM profile.
|
||||||
|
|
||||||
|
@param[in] FilePath File path of the image.
|
||||||
|
@param[in] ImageBuffer Image base address.
|
||||||
|
@param[in] NumberOfPage Number of page.
|
||||||
|
|
||||||
|
@retval TRUE Register success.
|
||||||
|
@retval FALSE Register fail.
|
||||||
|
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
RegisterSmramProfileImage (
|
||||||
|
IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
|
||||||
|
IN PHYSICAL_ADDRESS ImageBuffer,
|
||||||
|
IN UINTN NumberOfPage
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Unregister SMM image from SMRAM profile.
|
||||||
|
|
||||||
|
@param[in] FilePath File path of the image.
|
||||||
|
@param[in] ImageBuffer Image base address.
|
||||||
|
@param[in] NumberOfPage Number of page.
|
||||||
|
|
||||||
|
@retval TRUE Unregister success.
|
||||||
|
@retval FALSE Unregister fail.
|
||||||
|
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
UnregisterSmramProfileImage (
|
||||||
|
IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
|
||||||
|
IN PHYSICAL_ADDRESS ImageBuffer,
|
||||||
|
IN UINTN NumberOfPage
|
||||||
|
);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Structure for tracking paired information of registered Framework SMI handler
|
/// Structure for tracking paired information of registered Framework SMI handler
|
||||||
/// and correpsonding dispatch handle for SMI handler thunk.
|
/// and correpsonding dispatch handle for SMI handler thunk.
|
||||||
@ -694,11 +731,13 @@ LoadImage (
|
|||||||
mFrameworkSmst->NumberOfCpus = mNumberOfProcessors;
|
mFrameworkSmst->NumberOfCpus = mNumberOfProcessors;
|
||||||
mFrameworkSmst->CurrentlyExecutingCpu = gSmst->CurrentlyExecutingCpu;
|
mFrameworkSmst->CurrentlyExecutingCpu = gSmst->CurrentlyExecutingCpu;
|
||||||
|
|
||||||
|
RegisterSmramProfileImage (FilePath, DstBuffer, PageCount);
|
||||||
Status = gBS->StartImage (*ImageHandle, NULL, NULL);
|
Status = gBS->StartImage (*ImageHandle, NULL, NULL);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
mLoadPe32Image->UnLoadPeImage (mLoadPe32Image, *ImageHandle);
|
mLoadPe32Image->UnLoadPeImage (mLoadPe32Image, *ImageHandle);
|
||||||
*ImageHandle = NULL;
|
*ImageHandle = NULL;
|
||||||
FreePages ((VOID *)(UINTN)DstBuffer, PageCount);
|
FreePages ((VOID *)(UINTN)DstBuffer, PageCount);
|
||||||
|
UnregisterSmramProfileImage (FilePath, DstBuffer, PageCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
## @file
|
## @file
|
||||||
# Component description file for SMM Base Helper SMM driver.
|
# Component description file for SMM Base Helper SMM driver.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
|
# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||||
#
|
#
|
||||||
# This program and the accompanying materials
|
# This program and the accompanying materials
|
||||||
# are licensed and made available under the terms and conditions of the BSD License
|
# are licensed and made available under the terms and conditions of the BSD License
|
||||||
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
[Sources]
|
[Sources]
|
||||||
SmmBaseHelper.c
|
SmmBaseHelper.c
|
||||||
|
SmramProfileRecord.c
|
||||||
|
|
||||||
[Sources.Ia32]
|
[Sources.Ia32]
|
||||||
PageFaultHandler.c
|
PageFaultHandler.c
|
||||||
@ -58,9 +59,11 @@
|
|||||||
MemoryAllocationLib
|
MemoryAllocationLib
|
||||||
SynchronizationLib
|
SynchronizationLib
|
||||||
CpuLib
|
CpuLib
|
||||||
|
PcdLib
|
||||||
|
|
||||||
[Guids]
|
[Guids]
|
||||||
gEfiSmmBaseThunkCommunicationGuid
|
gEfiSmmBaseThunkCommunicationGuid
|
||||||
|
gEdkiiMemoryProfileGuid
|
||||||
|
|
||||||
[Protocols]
|
[Protocols]
|
||||||
gEfiSmmBaseHelperReadyProtocolGuid # PROTOCOL ALWAYS_PRODUCED
|
gEfiSmmBaseHelperReadyProtocolGuid # PROTOCOL ALWAYS_PRODUCED
|
||||||
@ -73,6 +76,10 @@
|
|||||||
gEfiLoadPeImageProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
gEfiLoadPeImageProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||||
gEfiSmmReadyToLockProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
gEfiSmmReadyToLockProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||||
gEfiSmmAccess2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
gEfiSmmAccess2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||||
|
gEfiSmmCommunicationProtocolGuid
|
||||||
|
|
||||||
|
[Pcd]
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfilePropertyMask
|
||||||
|
|
||||||
[Depex]
|
[Depex]
|
||||||
gEfiSmmCpuProtocolGuid AND
|
gEfiSmmCpuProtocolGuid AND
|
||||||
|
@ -0,0 +1,171 @@
|
|||||||
|
/** @file
|
||||||
|
|
||||||
|
Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
|
||||||
|
This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php.
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <PiSmm.h>
|
||||||
|
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/MemoryAllocationLib.h>
|
||||||
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
|
#include <Library/SmmServicesTableLib.h>
|
||||||
|
#include <Library/DevicePathLib.h>
|
||||||
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Protocol/SmmCommunication.h>
|
||||||
|
|
||||||
|
#include <Guid/MemoryProfile.h>
|
||||||
|
|
||||||
|
EFI_SMM_COMMUNICATION_PROTOCOL *mSmmCommunication = NULL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the GUID file name from the file path.
|
||||||
|
|
||||||
|
@param FilePath File path.
|
||||||
|
|
||||||
|
@return The GUID file name from the file path.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_GUID *
|
||||||
|
GetFileNameFromFilePath (
|
||||||
|
IN EFI_DEVICE_PATH_PROTOCOL *FilePath
|
||||||
|
)
|
||||||
|
{
|
||||||
|
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *ThisFilePath;
|
||||||
|
|
||||||
|
ThisFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) FilePath;
|
||||||
|
while (!IsDevicePathEnd (ThisFilePath)) {
|
||||||
|
if ((DevicePathType (ThisFilePath) == MEDIA_DEVICE_PATH) && (DevicePathSubType (ThisFilePath) == MEDIA_PIWG_FW_FILE_DP)) {
|
||||||
|
return &ThisFilePath->FvFileName;
|
||||||
|
}
|
||||||
|
ThisFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) NextDevicePathNode (ThisFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Register SMM image to SMRAM profile.
|
||||||
|
|
||||||
|
@param[in] FilePath File path of the image.
|
||||||
|
@param[in] ImageBuffer Image base address.
|
||||||
|
@param[in] NumberOfPage Number of page.
|
||||||
|
|
||||||
|
@retval TRUE Register success.
|
||||||
|
@retval FALSE Register fail.
|
||||||
|
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
RegisterSmramProfileImage (
|
||||||
|
IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
|
||||||
|
IN PHYSICAL_ADDRESS ImageBuffer,
|
||||||
|
IN UINTN NumberOfPage
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_GUID *FileName;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
UINTN CommSize;
|
||||||
|
UINT8 CommBuffer[sizeof (EFI_GUID) + sizeof (UINTN) + sizeof (SMRAM_PROFILE_PARAMETER_REGISTER_IMAGE)];
|
||||||
|
EFI_SMM_COMMUNICATE_HEADER *CommHeader;
|
||||||
|
SMRAM_PROFILE_PARAMETER_REGISTER_IMAGE *CommRegisterImage;
|
||||||
|
|
||||||
|
if ((PcdGet8 (PcdMemoryProfilePropertyMask) & BIT1) == 0) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
FileName = GetFileNameFromFilePath (FilePath);
|
||||||
|
|
||||||
|
if (mSmmCommunication == NULL) {
|
||||||
|
Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &mSmmCommunication);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
CommHeader = (EFI_SMM_COMMUNICATE_HEADER *) &CommBuffer[0];
|
||||||
|
CopyMem (&CommHeader->HeaderGuid, &gEdkiiMemoryProfileGuid, sizeof (gEdkiiMemoryProfileGuid));
|
||||||
|
CommHeader->MessageLength = sizeof (SMRAM_PROFILE_PARAMETER_REGISTER_IMAGE);
|
||||||
|
|
||||||
|
CommRegisterImage = (SMRAM_PROFILE_PARAMETER_REGISTER_IMAGE *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
|
||||||
|
CommRegisterImage->Header.Command = SMRAM_PROFILE_COMMAND_REGISTER_IMAGE;
|
||||||
|
CommRegisterImage->Header.DataLength = sizeof (*CommRegisterImage);
|
||||||
|
CommRegisterImage->Header.ReturnStatus = (UINT64)-1;
|
||||||
|
CopyMem (&CommRegisterImage->FileName, FileName, sizeof(EFI_GUID));
|
||||||
|
CommRegisterImage->ImageBuffer = ImageBuffer;
|
||||||
|
CommRegisterImage->NumberOfPage = NumberOfPage;
|
||||||
|
|
||||||
|
CommSize = sizeof (EFI_GUID) + sizeof (UINTN) + CommHeader->MessageLength;
|
||||||
|
Status = mSmmCommunication->Communicate (mSmmCommunication, CommBuffer, &CommSize);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
if (CommRegisterImage->Header.ReturnStatus != 0) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Unregister SMM image from SMRAM profile.
|
||||||
|
|
||||||
|
@param[in] FilePath File path of the image.
|
||||||
|
@param[in] ImageBuffer Image base address.
|
||||||
|
@param[in] NumberOfPage Number of page.
|
||||||
|
|
||||||
|
@retval TRUE Unregister success.
|
||||||
|
@retval FALSE Unregister fail.
|
||||||
|
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
UnregisterSmramProfileImage (
|
||||||
|
IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
|
||||||
|
IN PHYSICAL_ADDRESS ImageBuffer,
|
||||||
|
IN UINTN NumberOfPage
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_GUID *FileName;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
UINTN CommSize;
|
||||||
|
UINT8 CommBuffer[sizeof (EFI_GUID) + sizeof (UINTN) + sizeof (SMRAM_PROFILE_PARAMETER_UNREGISTER_IMAGE)];
|
||||||
|
EFI_SMM_COMMUNICATE_HEADER *CommHeader;
|
||||||
|
SMRAM_PROFILE_PARAMETER_UNREGISTER_IMAGE *CommUnregisterImage;
|
||||||
|
|
||||||
|
if ((PcdGet8 (PcdMemoryProfilePropertyMask) & BIT1) == 0) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
FileName = GetFileNameFromFilePath (FilePath);
|
||||||
|
|
||||||
|
if (mSmmCommunication == NULL) {
|
||||||
|
Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &mSmmCommunication);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
|
||||||
|
CopyMem (&CommHeader->HeaderGuid, &gEdkiiMemoryProfileGuid, sizeof(gEdkiiMemoryProfileGuid));
|
||||||
|
CommHeader->MessageLength = sizeof(SMRAM_PROFILE_PARAMETER_UNREGISTER_IMAGE);
|
||||||
|
|
||||||
|
CommUnregisterImage = (SMRAM_PROFILE_PARAMETER_UNREGISTER_IMAGE *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
|
||||||
|
CommUnregisterImage->Header.Command = SMRAM_PROFILE_COMMAND_UNREGISTER_IMAGE;
|
||||||
|
CommUnregisterImage->Header.DataLength = sizeof (*CommUnregisterImage);
|
||||||
|
CommUnregisterImage->Header.ReturnStatus = (UINT64)-1;
|
||||||
|
CopyMem (&CommUnregisterImage->FileName, FileName, sizeof(EFI_GUID));
|
||||||
|
CommUnregisterImage->ImageBuffer = ImageBuffer;
|
||||||
|
CommUnregisterImage->NumberOfPage = NumberOfPage;
|
||||||
|
|
||||||
|
CommSize = sizeof (EFI_GUID) + sizeof (UINTN) + CommHeader->MessageLength;
|
||||||
|
Status = mSmmCommunication->Communicate (mSmmCommunication, CommBuffer, &CommSize);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
if (CommUnregisterImage->Header.ReturnStatus != 0) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
Reference in New Issue
Block a user