TianoCore EDK2 master
Loading...
Searching...
No Matches
SmramProfileRecord.c File Reference
#include "PiSmmCore.h"

Go to the source code of this file.

Data Structures

struct  MEMORY_PROFILE_CONTEXT_DATA
 
struct  MEMORY_PROFILE_DRIVER_INFO_DATA
 
struct  MEMORY_PROFILE_ALLOC_INFO_DATA
 
struct  ACTION_STRING
 
struct  PROFILE_MEMORY_TYPE_STRING
 

Macros

#define IS_SMRAM_PROFILE_ENABLED   ((PcdGet8 (PcdMemoryProfilePropertyMask) & BIT1) != 0)
 
#define IS_UEFI_MEMORY_PROFILE_ENABLED   ((PcdGet8 (PcdMemoryProfilePropertyMask) & BIT0) != 0)
 
#define GET_OCCUPIED_SIZE(ActualSize, Alignment)    ((ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1)))
 
#define SMRAM_INFO_DUMP_PAGE_THRESHOLD   4
 

Functions

VOID DumpSmramInfo (VOID)
 
EFI_STATUS EFIAPI SmramProfileProtocolGetData (IN EDKII_SMM_MEMORY_PROFILE_PROTOCOL *This, IN OUT UINT64 *ProfileSize, OUT VOID *ProfileBuffer)
 
EFI_STATUS EFIAPI SmramProfileProtocolRegisterImage (IN EDKII_SMM_MEMORY_PROFILE_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *FilePath, IN PHYSICAL_ADDRESS ImageBase, IN UINT64 ImageSize, IN EFI_FV_FILETYPE FileType)
 
EFI_STATUS EFIAPI SmramProfileProtocolUnregisterImage (IN EDKII_SMM_MEMORY_PROFILE_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *FilePath, IN PHYSICAL_ADDRESS ImageBase, IN UINT64 ImageSize)
 
EFI_STATUS EFIAPI SmramProfileProtocolGetRecordingState (IN EDKII_SMM_MEMORY_PROFILE_PROTOCOL *This, OUT BOOLEAN *RecordingState)
 
EFI_STATUS EFIAPI SmramProfileProtocolSetRecordingState (IN EDKII_SMM_MEMORY_PROFILE_PROTOCOL *This, IN BOOLEAN RecordingState)
 
EFI_STATUS EFIAPI SmramProfileProtocolRecord (IN EDKII_SMM_MEMORY_PROFILE_PROTOCOL *This, IN PHYSICAL_ADDRESS CallerAddress, IN MEMORY_PROFILE_ACTION Action, IN EFI_MEMORY_TYPE MemoryType, IN VOID *Buffer, IN UINTN Size, IN CHAR8 *ActionString OPTIONAL)
 
MEMORY_PROFILE_CONTEXT_DATAGetSmramProfileContext (VOID)
 
UINT16 InternalPeCoffGetSubsystem (IN VOID *Pe32Data)
 
RETURN_STATUS InternalPeCoffGetEntryPoint (IN VOID *Pe32Data, OUT VOID **EntryPoint)
 
MEMORY_PROFILE_DRIVER_INFO_DATABuildDriverInfo (IN MEMORY_PROFILE_CONTEXT_DATA *ContextData, IN EFI_GUID *FileName, IN PHYSICAL_ADDRESS ImageBase, IN UINT64 ImageSize, IN PHYSICAL_ADDRESS EntryPoint, IN UINT16 ImageSubsystem, IN EFI_FV_FILETYPE FileType)
 
VOID RegisterImageToDxe (IN EFI_GUID *FileName, IN PHYSICAL_ADDRESS ImageBase, IN UINT64 ImageSize, IN EFI_FV_FILETYPE FileType)
 
VOID UnregisterImageFromDxe (IN EFI_GUID *FileName, IN PHYSICAL_ADDRESS ImageBase, IN UINT64 ImageSize)
 
BOOLEAN NeedRecordThisDriver (IN EFI_DEVICE_PATH_PROTOCOL *DriverFilePath)
 
BOOLEAN RegisterSmmCore (IN MEMORY_PROFILE_CONTEXT_DATA *ContextData)
 
VOID SmramProfileInit (VOID)
 
VOID SmramProfileInstallProtocol (VOID)
 
EFI_GUIDGetFileNameFromFilePath (IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
 
EFI_STATUS RegisterSmramProfileImage (IN EFI_SMM_DRIVER_ENTRY *DriverEntry, IN BOOLEAN RegisterToDxe)
 
MEMORY_PROFILE_DRIVER_INFO_DATAGetMemoryProfileDriverInfoByFileNameAndAddress (IN MEMORY_PROFILE_CONTEXT_DATA *ContextData, IN EFI_GUID *FileName, IN PHYSICAL_ADDRESS Address)
 
MEMORY_PROFILE_DRIVER_INFO_DATAGetMemoryProfileDriverInfoFromAddress (IN MEMORY_PROFILE_CONTEXT_DATA *ContextData, IN PHYSICAL_ADDRESS Address)
 
EFI_STATUS UnregisterSmramProfileImage (IN EFI_SMM_DRIVER_ENTRY *DriverEntry, IN BOOLEAN UnregisterFromDxe)
 
BOOLEAN SmmCoreNeedRecordProfile (IN EFI_MEMORY_TYPE MemoryType)
 
EFI_MEMORY_TYPE GetProfileMemoryIndex (IN EFI_MEMORY_TYPE MemoryType)
 
VOID SmramProfileUpdateFreePages (IN MEMORY_PROFILE_CONTEXT_DATA *ContextData)
 
EFI_STATUS SmmCoreUpdateProfileAllocate (IN PHYSICAL_ADDRESS CallerAddress, IN MEMORY_PROFILE_ACTION Action, IN EFI_MEMORY_TYPE MemoryType, IN UINTN Size, IN VOID *Buffer, IN CHAR8 *ActionString OPTIONAL)
 
MEMORY_PROFILE_ALLOC_INFO_DATAGetMemoryProfileAllocInfoFromAddress (IN MEMORY_PROFILE_DRIVER_INFO_DATA *DriverInfoData, IN MEMORY_PROFILE_ACTION BasicAction, IN UINTN Size, IN VOID *Buffer)
 
EFI_STATUS SmmCoreUpdateProfileFree (IN PHYSICAL_ADDRESS CallerAddress, IN MEMORY_PROFILE_ACTION Action, IN UINTN Size, IN VOID *Buffer)
 
EFI_STATUS EFIAPI SmmCoreUpdateProfile (IN PHYSICAL_ADDRESS CallerAddress, IN MEMORY_PROFILE_ACTION Action, IN EFI_MEMORY_TYPE MemoryType, IN UINTN Size, IN VOID *Buffer, IN CHAR8 *ActionString OPTIONAL)
 
VOID SmramProfileReadyToLock (VOID)
 
UINTN SmramProfileGetDataSize (VOID)
 
VOID SmramProfileCopyData (OUT VOID *ProfileBuffer, IN OUT UINT64 *ProfileSize, IN OUT UINT64 *ProfileOffset)
 
VOID SmramProfileHandlerGetInfo (IN SMRAM_PROFILE_PARAMETER_GET_PROFILE_INFO *SmramProfileParameterGetInfo)
 
VOID SmramProfileHandlerGetData (IN SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA *SmramProfileParameterGetData)
 
VOID SmramProfileHandlerGetDataByOffset (IN SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA_BY_OFFSET *SmramProfileParameterGetDataByOffset)
 
EFI_STATUS EFIAPI SmramProfileHandler (IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
 
VOID RegisterSmramProfileHandler (VOID)
 
VOID DumpSmramRange (VOID)
 
VOID DumpFreePagesList (VOID)
 
VOID DumpFreePoolList (VOID)
 
CHAR8 * ProfileMemoryTypeToStr (IN EFI_MEMORY_TYPE MemoryType)
 
CHAR8 * ProfileActionToStr (IN MEMORY_PROFILE_ACTION Action)
 
VOID DumpSmramProfile (VOID)
 

Variables

GLOBAL_REMOVE_IF_UNREFERENCED MEMORY_PROFILE_FREE_MEMORY mSmramFreeMemory
 
GLOBAL_REMOVE_IF_UNREFERENCED LIST_ENTRY mImageQueue = INITIALIZE_LIST_HEAD_VARIABLE (mImageQueue)
 
GLOBAL_REMOVE_IF_UNREFERENCED MEMORY_PROFILE_CONTEXT_DATA mSmramProfileContext
 
GLOBAL_REMOVE_IF_UNREFERENCED MEMORY_PROFILE_CONTEXT_DATAmSmramProfileContextPtr = NULL
 
GLOBAL_REMOVE_IF_UNREFERENCED BOOLEAN mSmramReadyToLock
 
GLOBAL_REMOVE_IF_UNREFERENCED BOOLEAN mSmramProfileGettingStatus = FALSE
 
GLOBAL_REMOVE_IF_UNREFERENCED BOOLEAN mSmramProfileRecordingEnable = MEMORY_PROFILE_RECORDING_DISABLE
 
GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_PROTOCOLmSmramProfileDriverPath
 
GLOBAL_REMOVE_IF_UNREFERENCED UINTN mSmramProfileDriverPathSize
 
GLOBAL_REMOVE_IF_UNREFERENCED EDKII_SMM_MEMORY_PROFILE_PROTOCOL mSmmProfileProtocol
 
GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 * mSmmActionString []
 
GLOBAL_REMOVE_IF_UNREFERENCED ACTION_STRING mExtActionString []
 
GLOBAL_REMOVE_IF_UNREFERENCED PROFILE_MEMORY_TYPE_STRING mMemoryTypeString []
 

Detailed Description

Support routines for SMRAM profile.

Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file SmramProfileRecord.c.

Macro Definition Documentation

◆ GET_OCCUPIED_SIZE

#define GET_OCCUPIED_SIZE (   ActualSize,
  Alignment 
)     ((ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1)))

Definition at line 14 of file SmramProfileRecord.c.

◆ IS_SMRAM_PROFILE_ENABLED

#define IS_SMRAM_PROFILE_ENABLED   ((PcdGet8 (PcdMemoryProfilePropertyMask) & BIT1) != 0)

Definition at line 11 of file SmramProfileRecord.c.

◆ IS_UEFI_MEMORY_PROFILE_ENABLED

#define IS_UEFI_MEMORY_PROFILE_ENABLED   ((PcdGet8 (PcdMemoryProfilePropertyMask) & BIT0) != 0)

Definition at line 12 of file SmramProfileRecord.c.

◆ SMRAM_INFO_DUMP_PAGE_THRESHOLD

#define SMRAM_INFO_DUMP_PAGE_THRESHOLD   4

Definition at line 41 of file SmramProfileRecord.c.

Function Documentation

◆ BuildDriverInfo()

MEMORY_PROFILE_DRIVER_INFO_DATA * BuildDriverInfo ( IN MEMORY_PROFILE_CONTEXT_DATA ContextData,
IN EFI_GUID FileName,
IN PHYSICAL_ADDRESS  ImageBase,
IN UINT64  ImageSize,
IN PHYSICAL_ADDRESS  EntryPoint,
IN UINT16  ImageSubsystem,
IN EFI_FV_FILETYPE  FileType 
)

Build driver info.

Parameters
ContextDataMemory profile context.
FileNameFile name of the image.
ImageBaseImage base address.
ImageSizeImage size.
EntryPointEntry point of the image.
ImageSubsystemImage subsystem of the image.
FileTypeFile type of the image.
Returns
Pointer to memory profile driver info.

Definition at line 371 of file SmramProfileRecord.c.

◆ DumpFreePagesList()

VOID DumpFreePagesList ( VOID  )

Dump SMRAM free page list.

Definition at line 2481 of file SmramProfileRecord.c.

◆ DumpFreePoolList()

VOID DumpFreePoolList ( VOID  )

Dump SMRAM free pool list.

Definition at line 2524 of file SmramProfileRecord.c.

◆ DumpSmramInfo()

VOID DumpSmramInfo ( VOID  )

Dump SMRAM information.

Definition at line 2797 of file SmramProfileRecord.c.

◆ DumpSmramProfile()

VOID DumpSmramProfile ( VOID  )

Dump SMRAM profile.

Definition at line 2678 of file SmramProfileRecord.c.

◆ DumpSmramRange()

VOID DumpSmramRange ( VOID  )

Dump SMRAM range.

Definition at line 2442 of file SmramProfileRecord.c.

◆ GetFileNameFromFilePath()

EFI_GUID * GetFileNameFromFilePath ( IN EFI_DEVICE_PATH_PROTOCOL FilePath)

Get the GUID file name from the file path.

Parameters
FilePathFile path.
Returns
The GUID file name from the file path.

Definition at line 720 of file SmramProfileRecord.c.

◆ GetMemoryProfileAllocInfoFromAddress()

MEMORY_PROFILE_ALLOC_INFO_DATA * GetMemoryProfileAllocInfoFromAddress ( IN MEMORY_PROFILE_DRIVER_INFO_DATA DriverInfoData,
IN MEMORY_PROFILE_ACTION  BasicAction,
IN UINTN  Size,
IN VOID *  Buffer 
)

Get memory profile alloc info from memory profile

Parameters
DriverInfoDataDriver info
BasicActionThis Free basic action
SizeBuffer size
BufferBuffer address
Returns
Pointer to memory profile alloc info.

Definition at line 1225 of file SmramProfileRecord.c.

◆ GetMemoryProfileDriverInfoByFileNameAndAddress()

MEMORY_PROFILE_DRIVER_INFO_DATA * GetMemoryProfileDriverInfoByFileNameAndAddress ( IN MEMORY_PROFILE_CONTEXT_DATA ContextData,
IN EFI_GUID FileName,
IN PHYSICAL_ADDRESS  Address 
)

Search image from memory profile.

Parameters
ContextDataMemory profile context.
FileNameImage file name.
AddressImage Address.
Returns
Pointer to memory profile driver info.

Definition at line 819 of file SmramProfileRecord.c.

◆ GetMemoryProfileDriverInfoFromAddress()

MEMORY_PROFILE_DRIVER_INFO_DATA * GetMemoryProfileDriverInfoFromAddress ( IN MEMORY_PROFILE_CONTEXT_DATA ContextData,
IN PHYSICAL_ADDRESS  Address 
)

Search image from memory profile. It will return image, if (Address >= ImageBuffer) AND (Address < ImageBuffer + ImageSize)

Parameters
ContextDataMemory profile context.
AddressImage or Function address.
Returns
Pointer to memory profile driver info.

Definition at line 865 of file SmramProfileRecord.c.

◆ GetProfileMemoryIndex()

EFI_MEMORY_TYPE GetProfileMemoryIndex ( IN EFI_MEMORY_TYPE  MemoryType)

Convert EFI memory type to profile memory index. The rule is: If BIOS memory type (0 ~ EfiMaxMemoryType - 1), ProfileMemoryIndex = MemoryType. As SMRAM profile is only to record EfiRuntimeServicesCode and EfiRuntimeServicesData, so return input memory type directly.

Parameters
MemoryTypeMemory type.
Returns
EFI memory type as profile memory index.

Definition at line 1037 of file SmramProfileRecord.c.

◆ GetSmramProfileContext()

MEMORY_PROFILE_CONTEXT_DATA * GetSmramProfileContext ( VOID  )

Return SMRAM profile context.

Returns
SMRAM profile context.

Definition at line 245 of file SmramProfileRecord.c.

◆ InternalPeCoffGetEntryPoint()

RETURN_STATUS InternalPeCoffGetEntryPoint ( IN VOID *  Pe32Data,
OUT VOID **  EntryPoint 
)

Retrieves and returns a pointer to the entry point to a PE/COFF image that has been loaded into system memory with the PE/COFF Loader Library functions.

Retrieves the entry point to the PE/COFF image specified by Pe32Data and returns this entry point in EntryPoint. If the entry point could not be retrieved from the PE/COFF image, then return RETURN_INVALID_PARAMETER. Otherwise return RETURN_SUCCESS. If Pe32Data is NULL, then ASSERT(). If EntryPoint is NULL, then ASSERT().

Parameters
Pe32DataThe pointer to the PE/COFF image that is loaded in system memory.
EntryPointThe pointer to entry point to the PE/COFF image to return.
Return values
RETURN_SUCCESSEntryPoint was returned.
RETURN_INVALID_PARAMETERThe entry point could not be found in the PE/COFF image.

Definition at line 317 of file SmramProfileRecord.c.

◆ InternalPeCoffGetSubsystem()

UINT16 InternalPeCoffGetSubsystem ( IN VOID *  Pe32Data)

Retrieves and returns the Subsystem of a PE/COFF image that has been loaded into system memory. If Pe32Data is NULL, then ASSERT().

Parameters
Pe32DataThe pointer to the PE/COFF image that is loaded in system memory.
Returns
The Subsystem of the PE/COFF image.

Definition at line 262 of file SmramProfileRecord.c.

◆ NeedRecordThisDriver()

BOOLEAN NeedRecordThisDriver ( IN EFI_DEVICE_PATH_PROTOCOL DriverFilePath)

Return if record for this driver is needed..

Parameters
DriverFilePathDriver file path.
Return values
TRUERecord for this driver is needed.
FALSERecord for this driver is not needed.

Definition at line 548 of file SmramProfileRecord.c.

◆ ProfileActionToStr()

CHAR8 * ProfileActionToStr ( IN MEMORY_PROFILE_ACTION  Action)

Action to string.

Parameters
[in]ActionProfile action.
Returns
Pointer to string.

Definition at line 2649 of file SmramProfileRecord.c.

◆ ProfileMemoryTypeToStr()

CHAR8 * ProfileMemoryTypeToStr ( IN EFI_MEMORY_TYPE  MemoryType)

Memory type to string.

Parameters
[in]MemoryTypeMemory type.
Returns
Pointer to string.

Definition at line 2625 of file SmramProfileRecord.c.

◆ RegisterImageToDxe()

VOID RegisterImageToDxe ( IN EFI_GUID FileName,
IN PHYSICAL_ADDRESS  ImageBase,
IN UINT64  ImageSize,
IN EFI_FV_FILETYPE  FileType 
)

Register image to DXE.

Parameters
FileNameFile name of the image.
ImageBaseImage base address.
ImageSizeImage size.
FileTypeFile type of the image.

Definition at line 471 of file SmramProfileRecord.c.

◆ RegisterSmmCore()

BOOLEAN RegisterSmmCore ( IN MEMORY_PROFILE_CONTEXT_DATA ContextData)

Register SMM Core to SMRAM profile.

Parameters
ContextDataSMRAM profile context.
Return values
TRUERegister success.
FALSERegister fail.

Definition at line 608 of file SmramProfileRecord.c.

◆ RegisterSmramProfileHandler()

VOID RegisterSmramProfileHandler ( VOID  )

Register SMRAM profile handler.

Definition at line 2416 of file SmramProfileRecord.c.

◆ RegisterSmramProfileImage()

EFI_STATUS RegisterSmramProfileImage ( IN EFI_SMM_DRIVER_ENTRY DriverEntry,
IN BOOLEAN  RegisterToDxe 
)

Register SMM image to SMRAM profile.

Parameters
DriverEntrySMM image info.
RegisterToDxeRegister image to DXE.
Returns
EFI_SUCCESS Register successfully.
EFI_UNSUPPORTED Memory profile is unsupported, or memory profile for the image is not required.
EFI_OUT_OF_RESOURCES No enough resource for this register.

Definition at line 756 of file SmramProfileRecord.c.

◆ SmmCoreNeedRecordProfile()

BOOLEAN SmmCoreNeedRecordProfile ( IN EFI_MEMORY_TYPE  MemoryType)

Return if this memory type needs to be recorded into memory profile. Only need to record EfiRuntimeServicesCode and EfiRuntimeServicesData for SMRAM profile.

Parameters
MemoryTypeMemory type.
Return values
TRUEThis memory type need to be recorded.
FALSEThis memory type need not to be recorded.

Definition at line 1004 of file SmramProfileRecord.c.

◆ SmmCoreUpdateProfile()

EFI_STATUS EFIAPI SmmCoreUpdateProfile ( IN PHYSICAL_ADDRESS  CallerAddress,
IN MEMORY_PROFILE_ACTION  Action,
IN EFI_MEMORY_TYPE  MemoryType,
IN UINTN  Size,
IN VOID *  Buffer,
IN CHAR8 *ActionString  OPTIONAL 
)

Update SMRAM profile information.

Parameters
CallerAddressAddress of caller who call Allocate or Free.
ActionThis Allocate or Free action.
MemoryTypeMemory type. EfiMaxMemoryType means the MemoryType is unknown.
SizeBuffer size.
BufferBuffer address.
ActionStringString for memory profile action. Only needed for user defined allocate action.
Returns
EFI_SUCCESS Memory profile is updated.
EFI_UNSUPPORTED Memory profile is unsupported, or memory profile for the image is not required, or memory profile for the memory type is not required.
EFI_ACCESS_DENIED It is during memory profile data getting.
EFI_ABORTED Memory profile recording is not enabled.
EFI_OUT_OF_RESOURCES No enough resource to update memory profile for allocate action.
EFI_NOT_FOUND No matched allocate info found for free action.

Definition at line 1476 of file SmramProfileRecord.c.

◆ SmmCoreUpdateProfileAllocate()

EFI_STATUS SmmCoreUpdateProfileAllocate ( IN PHYSICAL_ADDRESS  CallerAddress,
IN MEMORY_PROFILE_ACTION  Action,
IN EFI_MEMORY_TYPE  MemoryType,
IN UINTN  Size,
IN VOID *  Buffer,
IN CHAR8 *ActionString  OPTIONAL 
)

Update SMRAM profile Allocate information.

Parameters
CallerAddressAddress of caller who call Allocate.
ActionThis Allocate action.
MemoryTypeMemory type.
SizeBuffer size.
BufferBuffer address.
ActionStringString for memory profile action.
Returns
EFI_SUCCESS Memory profile is updated.
EFI_UNSUPPORTED Memory profile is unsupported, or memory profile for the image is not required.
EFI_OUT_OF_RESOURCES No enough resource to update memory profile for allocate action.

Definition at line 1094 of file SmramProfileRecord.c.

◆ SmmCoreUpdateProfileFree()

EFI_STATUS SmmCoreUpdateProfileFree ( IN PHYSICAL_ADDRESS  CallerAddress,
IN MEMORY_PROFILE_ACTION  Action,
IN UINTN  Size,
IN VOID *  Buffer 
)

Update SMRAM profile Free information.

Parameters
CallerAddressAddress of caller who call Free.
ActionThis Free action.
SizeBuffer size.
BufferBuffer address.
Returns
EFI_SUCCESS Memory profile is updated.
EFI_UNSUPPORTED Memory profile is unsupported.
EFI_NOT_FOUND No matched allocate info found for free action.

Definition at line 1292 of file SmramProfileRecord.c.

◆ SmramProfileCopyData()

VOID SmramProfileCopyData ( OUT VOID *  ProfileBuffer,
IN OUT UINT64 *  ProfileSize,
IN OUT UINT64 *  ProfileOffset 
)

Copy SMRAM profile data.

Parameters
ProfileBufferThe buffer to hold SMRAM profile data.
ProfileSizeOn input, profile buffer size. On output, actual profile data size copied.
ProfileOffsetOn input, profile buffer offset to copy. On output, next time profile buffer offset to copy.

Definition at line 1667 of file SmramProfileRecord.c.

◆ SmramProfileGetDataSize()

UINTN SmramProfileGetDataSize ( VOID  )

Get SMRAM profile data size.

Returns
SMRAM profile data size.

Definition at line 1571 of file SmramProfileRecord.c.

◆ SmramProfileHandler()

EFI_STATUS EFIAPI SmramProfileHandler ( IN EFI_HANDLE  DispatchHandle,
IN CONST VOID *Context  OPTIONAL,
IN OUT VOID *CommBuffer  OPTIONAL,
IN OUT UINTN *CommBufferSize  OPTIONAL 
)

Dispatch function for a Software SMI handler.

Caution: This function may receive untrusted input. Communicate buffer and buffer size are external input, so this function will do basic validation.

Parameters
DispatchHandleThe unique handle assigned to this handler by SmiHandlerRegister().
ContextPoints to an optional handler context which was specified when the handler was registered.
CommBufferA pointer to a collection of data in memory that will be conveyed from a non-SMM environment into an SMM environment.
CommBufferSizeThe size of the CommBuffer.
Return values
EFI_SUCCESSCommand is handled successfully.

Definition at line 2301 of file SmramProfileRecord.c.

◆ SmramProfileHandlerGetData()

VOID SmramProfileHandlerGetData ( IN SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA SmramProfileParameterGetData)

SMRAM profile handler to get profile data.

Parameters
SmramProfileParameterGetDataThe parameter of SMM profile get data.

Definition at line 2194 of file SmramProfileRecord.c.

◆ SmramProfileHandlerGetDataByOffset()

VOID SmramProfileHandlerGetDataByOffset ( IN SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA_BY_OFFSET SmramProfileParameterGetDataByOffset)

SMRAM profile handler to get profile data by offset.

Parameters
SmramProfileParameterGetDataByOffsetThe parameter of SMM profile get data by offset.

Definition at line 2248 of file SmramProfileRecord.c.

◆ SmramProfileHandlerGetInfo()

VOID SmramProfileHandlerGetInfo ( IN SMRAM_PROFILE_PARAMETER_GET_PROFILE_INFO SmramProfileParameterGetInfo)

SMRAM profile handler to get profile info.

Parameters
SmramProfileParameterGetInfoThe parameter of SMM profile get size.

Definition at line 2166 of file SmramProfileRecord.c.

◆ SmramProfileInit()

VOID SmramProfileInit ( VOID  )

Initialize SMRAM profile.

Definition at line 647 of file SmramProfileRecord.c.

◆ SmramProfileInstallProtocol()

VOID SmramProfileInstallProtocol ( VOID  )

Install SMRAM profile protocol.

Definition at line 690 of file SmramProfileRecord.c.

◆ SmramProfileProtocolGetData()

EFI_STATUS EFIAPI SmramProfileProtocolGetData ( IN EDKII_SMM_MEMORY_PROFILE_PROTOCOL This,
IN OUT UINT64 *  ProfileSize,
OUT VOID *  ProfileBuffer 
)

Get memory profile data.

Parameters
[in]ThisThe EDKII_SMM_MEMORY_PROFILE_PROTOCOL instance.
[in,out]ProfileSizeOn entry, points to the size in bytes of the ProfileBuffer. On return, points to the size of the data returned in ProfileBuffer.
[out]ProfileBufferProfile buffer.
Returns
EFI_SUCCESS Get the memory profile data successfully.
EFI_UNSUPPORTED Memory profile is unsupported.
EFI_BUFFER_TO_SMALL The ProfileSize is too small for the resulting data. ProfileSize is updated with the size required.

Definition at line 1937 of file SmramProfileRecord.c.

◆ SmramProfileProtocolGetRecordingState()

EFI_STATUS EFIAPI SmramProfileProtocolGetRecordingState ( IN EDKII_SMM_MEMORY_PROFILE_PROTOCOL This,
OUT BOOLEAN *  RecordingState 
)

Get memory profile recording state.

Parameters
[in]ThisThe EDKII_SMM_MEMORY_PROFILE_PROTOCOL instance.
[out]RecordingStateRecording state.
Returns
EFI_SUCCESS Memory profile recording state is returned.
EFI_UNSUPPORTED Memory profile is unsupported.
EFI_INVALID_PARAMETER RecordingState is NULL.

Definition at line 2073 of file SmramProfileRecord.c.

◆ SmramProfileProtocolRecord()

EFI_STATUS EFIAPI SmramProfileProtocolRecord ( IN EDKII_SMM_MEMORY_PROFILE_PROTOCOL This,
IN PHYSICAL_ADDRESS  CallerAddress,
IN MEMORY_PROFILE_ACTION  Action,
IN EFI_MEMORY_TYPE  MemoryType,
IN VOID *  Buffer,
IN UINTN  Size,
IN CHAR8 *ActionString  OPTIONAL 
)

Record memory profile of multilevel caller.

Parameters
[in]ThisThe EDKII_SMM_MEMORY_PROFILE_PROTOCOL instance.
[in]CallerAddressAddress of caller.
[in]ActionMemory profile action.
[in]MemoryTypeMemory type. EfiMaxMemoryType means the MemoryType is unknown.
[in]BufferBuffer address.
[in]SizeBuffer size.
[in]ActionStringString for memory profile action. Only needed for user defined allocate action.
Returns
EFI_SUCCESS Memory profile is updated.
EFI_UNSUPPORTED Memory profile is unsupported, or memory profile for the image is not required, or memory profile for the memory type is not required.
EFI_ACCESS_DENIED It is during memory profile data getting.
EFI_ABORTED Memory profile recording is not enabled.
EFI_OUT_OF_RESOURCES No enough resource to update memory profile for allocate action.
EFI_NOT_FOUND No matched allocate info found for free action.

Definition at line 2146 of file SmramProfileRecord.c.

◆ SmramProfileProtocolRegisterImage()

EFI_STATUS EFIAPI SmramProfileProtocolRegisterImage ( IN EDKII_SMM_MEMORY_PROFILE_PROTOCOL This,
IN EFI_DEVICE_PATH_PROTOCOL FilePath,
IN PHYSICAL_ADDRESS  ImageBase,
IN UINT64  ImageSize,
IN EFI_FV_FILETYPE  FileType 
)

Register image to memory profile.

Parameters
[in]ThisThe EDKII_SMM_MEMORY_PROFILE_PROTOCOL instance.
[in]FilePathFile path of the image.
[in]ImageBaseImage base address.
[in]ImageSizeImage size.
[in]FileTypeFile type of the image.
Returns
EFI_SUCCESS Register successfully.
EFI_UNSUPPORTED Memory profile is unsupported, or memory profile for the image is not required.
EFI_OUT_OF_RESOURCE No enough resource for this register.

Register image to memory profile.

Parameters
[in]ThisThe EDKII_SMM_MEMORY_PROFILE_PROTOCOL instance.
[in]FilePathFile path of the image.
[in]ImageBaseImage base address.
[in]ImageSizeImage size.
[in]FileTypeFile type of the image.
Returns
EFI_SUCCESS Register successfully.
EFI_UNSUPPORTED Memory profile is unsupported, or memory profile for the image is not required.
EFI_OUT_OF_RESOURCES No enough resource for this register.

Definition at line 1989 of file SmramProfileRecord.c.

◆ SmramProfileProtocolSetRecordingState()

EFI_STATUS EFIAPI SmramProfileProtocolSetRecordingState ( IN EDKII_SMM_MEMORY_PROFILE_PROTOCOL This,
IN BOOLEAN  RecordingState 
)

Set memory profile recording state.

Parameters
[in]ThisThe EDKII_SMM_MEMORY_PROFILE_PROTOCOL instance.
[in]RecordingStateRecording state.
Returns
EFI_SUCCESS Set memory profile recording state successfully.
EFI_UNSUPPORTED Memory profile is unsupported.

Definition at line 2105 of file SmramProfileRecord.c.

◆ SmramProfileProtocolUnregisterImage()

EFI_STATUS EFIAPI SmramProfileProtocolUnregisterImage ( IN EDKII_SMM_MEMORY_PROFILE_PROTOCOL This,
IN EFI_DEVICE_PATH_PROTOCOL FilePath,
IN PHYSICAL_ADDRESS  ImageBase,
IN UINT64  ImageSize 
)

Unregister image from memory profile.

Parameters
[in]ThisThe EDKII_SMM_MEMORY_PROFILE_PROTOCOL instance.
[in]FilePathFile path of the image.
[in]ImageBaseImage base address.
[in]ImageSizeImage size.
Returns
EFI_SUCCESS Unregister successfully.
EFI_UNSUPPORTED Memory profile is unsupported, or memory profile for the image is not required.
EFI_NOT_FOUND The image is not found.

Definition at line 2033 of file SmramProfileRecord.c.

◆ SmramProfileReadyToLock()

VOID SmramProfileReadyToLock ( VOID  )

SMRAM profile ready to lock callback function.

Definition at line 1550 of file SmramProfileRecord.c.

◆ SmramProfileUpdateFreePages()

VOID SmramProfileUpdateFreePages ( IN MEMORY_PROFILE_CONTEXT_DATA ContextData)

Update SMRAM profile FreeMemoryPages information

Parameters
ContextDataMemory profile context.

Definition at line 1051 of file SmramProfileRecord.c.

◆ UnregisterImageFromDxe()

VOID UnregisterImageFromDxe ( IN EFI_GUID FileName,
IN PHYSICAL_ADDRESS  ImageBase,
IN UINT64  ImageSize 
)

Unregister image from DXE.

Parameters
FileNameFile name of the image.
ImageBaseImage base address.
ImageSizeImage size.

Definition at line 510 of file SmramProfileRecord.c.

◆ UnregisterSmramProfileImage()

EFI_STATUS UnregisterSmramProfileImage ( IN EFI_SMM_DRIVER_ENTRY DriverEntry,
IN BOOLEAN  UnregisterFromDxe 
)

Unregister image from SMRAM profile.

Parameters
DriverEntrySMM image info.
UnregisterFromDxeUnregister image from DXE.
Returns
EFI_SUCCESS Unregister successfully.
EFI_UNSUPPORTED Memory profile is unsupported, or memory profile for the image is not required.
EFI_NOT_FOUND The image is not found.

Definition at line 911 of file SmramProfileRecord.c.

Variable Documentation

◆ mExtActionString

Initial value:
= {
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_PAGES, "Lib:AllocatePages" },
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_PAGES, "Lib:AllocateRuntimePages" },
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_PAGES, "Lib:AllocateReservedPages" },
{ MEMORY_PROFILE_ACTION_LIB_FREE_PAGES, "Lib:FreePages" },
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_PAGES, "Lib:AllocateAlignedPages" },
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_RUNTIME_PAGES, "Lib:AllocateAlignedRuntimePages" },
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_RESERVED_PAGES, "Lib:AllocateAlignedReservedPages" },
{ MEMORY_PROFILE_ACTION_LIB_FREE_ALIGNED_PAGES, "Lib:FreeAlignedPages" },
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_POOL, "Lib:AllocatePool" },
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_POOL, "Lib:AllocateRuntimePool" },
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_POOL, "Lib:AllocateReservedPool" },
{ MEMORY_PROFILE_ACTION_LIB_FREE_POOL, "Lib:FreePool" },
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ZERO_POOL, "Lib:AllocateZeroPool" },
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_ZERO_POOL, "Lib:AllocateRuntimeZeroPool" },
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_ZERO_POOL, "Lib:AllocateReservedZeroPool" },
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_COPY_POOL, "Lib:AllocateCopyPool" },
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_COPY_POOL, "Lib:AllocateRuntimeCopyPool" },
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_COPY_POOL, "Lib:AllocateReservedCopyPool" },
{ MEMORY_PROFILE_ACTION_LIB_REALLOCATE_POOL, "Lib:ReallocatePool" },
{ MEMORY_PROFILE_ACTION_LIB_REALLOCATE_RUNTIME_POOL, "Lib:ReallocateRuntimePool" },
{ MEMORY_PROFILE_ACTION_LIB_REALLOCATE_RESERVED_POOL, "Lib:ReallocateReservedPool" },
}

Definition at line 2582 of file SmramProfileRecord.c.

◆ mImageQueue

Definition at line 53 of file SmramProfileRecord.c.

◆ mMemoryTypeString

Initial value:
= {
{ EfiRuntimeServicesCode, "EfiRuntimeServicesCode" },
{ EfiRuntimeServicesData, "EfiRuntimeServicesData" }
}
@ EfiRuntimeServicesCode
@ EfiRuntimeServicesData

Definition at line 2611 of file SmramProfileRecord.c.

◆ mSmmActionString

GLOBAL_REMOVE_IF_UNREFERENCED CHAR8* mSmmActionString[]
Initial value:
= {
"SmmUnknown",
"gSmst->SmmAllocatePages",
"gSmst->SmmFreePages",
"gSmst->SmmAllocatePool",
"gSmst->SmmFreePool",
}

Definition at line 2569 of file SmramProfileRecord.c.

◆ mSmmProfileProtocol

Initial value:
= {
}
EFI_STATUS EFIAPI SmramProfileProtocolGetData(IN EDKII_SMM_MEMORY_PROFILE_PROTOCOL *This, IN OUT UINT64 *ProfileSize, OUT VOID *ProfileBuffer)
EFI_STATUS EFIAPI SmramProfileProtocolRecord(IN EDKII_SMM_MEMORY_PROFILE_PROTOCOL *This, IN PHYSICAL_ADDRESS CallerAddress, IN MEMORY_PROFILE_ACTION Action, IN EFI_MEMORY_TYPE MemoryType, IN VOID *Buffer, IN UINTN Size, IN CHAR8 *ActionString OPTIONAL)
EFI_STATUS EFIAPI SmramProfileProtocolUnregisterImage(IN EDKII_SMM_MEMORY_PROFILE_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *FilePath, IN PHYSICAL_ADDRESS ImageBase, IN UINT64 ImageSize)
EFI_STATUS EFIAPI SmramProfileProtocolRegisterImage(IN EDKII_SMM_MEMORY_PROFILE_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *FilePath, IN PHYSICAL_ADDRESS ImageBase, IN UINT64 ImageSize, IN EFI_FV_FILETYPE FileType)
EFI_STATUS EFIAPI SmramProfileProtocolGetRecordingState(IN EDKII_SMM_MEMORY_PROFILE_PROTOCOL *This, OUT BOOLEAN *RecordingState)
EFI_STATUS EFIAPI SmramProfileProtocolSetRecordingState(IN EDKII_SMM_MEMORY_PROFILE_PROTOCOL *This, IN BOOLEAN RecordingState)

Definition at line 229 of file SmramProfileRecord.c.

◆ mSmramFreeMemory

Initial value:
= {
{
MEMORY_PROFILE_FREE_MEMORY_SIGNATURE,
MEMORY_PROFILE_FREE_MEMORY_REVISION
},
0,
0
}

Definition at line 43 of file SmramProfileRecord.c.

◆ mSmramProfileContext

Initial value:
= {
MEMORY_PROFILE_CONTEXT_SIGNATURE,
{
{
MEMORY_PROFILE_CONTEXT_SIGNATURE,
MEMORY_PROFILE_CONTEXT_REVISION
},
0,
0,
{ 0 },
{ 0 },
0,
0,
0
},
&mImageQueue,
}

Definition at line 54 of file SmramProfileRecord.c.

◆ mSmramProfileContextPtr

Definition at line 72 of file SmramProfileRecord.c.

◆ mSmramProfileDriverPath

Definition at line 77 of file SmramProfileRecord.c.

◆ mSmramProfileDriverPathSize

GLOBAL_REMOVE_IF_UNREFERENCED UINTN mSmramProfileDriverPathSize

Definition at line 78 of file SmramProfileRecord.c.

◆ mSmramProfileGettingStatus

GLOBAL_REMOVE_IF_UNREFERENCED BOOLEAN mSmramProfileGettingStatus = FALSE

Definition at line 75 of file SmramProfileRecord.c.

◆ mSmramProfileRecordingEnable

GLOBAL_REMOVE_IF_UNREFERENCED BOOLEAN mSmramProfileRecordingEnable = MEMORY_PROFILE_RECORDING_DISABLE

Definition at line 76 of file SmramProfileRecord.c.

◆ mSmramReadyToLock

GLOBAL_REMOVE_IF_UNREFERENCED BOOLEAN mSmramReadyToLock

Definition at line 74 of file SmramProfileRecord.c.