TianoCore EDK2 master
Loading...
Searching...
No Matches
MemoryProfileInfo.c File Reference

Go to the source code of this file.

Data Structures

struct  ACTION_STRING
 
struct  MEMORY_PROFILE_ALLOC_SUMMARY_INFO
 
struct  MEMORY_PROFILE_ALLOC_SUMMARY_INFO_DATA
 
struct  MEMORY_PROFILE_DRIVER_SUMMARY_INFO_DATA
 
struct  MEMORY_PROFILE_CONTEXT_SUMMARY_DATA
 

Macros

#define PROFILE_NAME_STRING_LENGTH   64
 
#define MEMORY_PROFILE_ALLOC_SUMMARY_INFO_SIGNATURE   SIGNATURE_32 ('M','P','A','S')
 
#define MEMORY_PROFILE_ALLOC_SUMMARY_INFO_REVISION   0x0001
 

Functions

VOID GetShortPdbFileName (IN CHAR8 *PdbFileName, OUT CHAR8 *AsciiBuffer)
 
CHAR8 * GetDriverNameString (IN MEMORY_PROFILE_DRIVER_INFO *DriverInfo)
 
CHAR8 * ProfileMemoryTypeToStr (IN EFI_MEMORY_TYPE MemoryType)
 
CHAR8 * ProfileActionToStr (IN MEMORY_PROFILE_ACTION Action, IN CHAR8 *UserDefinedActionString, IN BOOLEAN IsForSmm)
 
MEMORY_PROFILE_ALLOC_INFODumpMemoryProfileAllocInfo (IN MEMORY_PROFILE_DRIVER_INFO *DriverInfo, IN UINTN AllocIndex, IN MEMORY_PROFILE_ALLOC_INFO *AllocInfo, IN BOOLEAN IsForSmm)
 
MEMORY_PROFILE_DRIVER_INFODumpMemoryProfileDriverInfo (IN UINTN DriverIndex, IN MEMORY_PROFILE_DRIVER_INFO *DriverInfo, IN BOOLEAN IsForSmm)
 
VOID * DumpMemoryProfileContext (IN MEMORY_PROFILE_CONTEXT *Context, IN BOOLEAN IsForSmm)
 
MEMORY_PROFILE_DESCRIPTORDumpMemoryProfileDescriptor (IN UINTN DescriptorIndex, IN MEMORY_PROFILE_DESCRIPTOR *Descriptor)
 
VOID * DumpMemoryProfileFreeMemory (IN MEMORY_PROFILE_FREE_MEMORY *FreeMemory)
 
VOID * DumpMemoryProfileMemoryRange (IN MEMORY_PROFILE_MEMORY_RANGE *MemoryRange)
 
VOID * ScanMemoryProfileBySignature (IN PHYSICAL_ADDRESS ProfileBuffer, IN UINT64 ProfileSize, IN UINT32 Signature)
 
VOID DumpMemoryProfile (IN PHYSICAL_ADDRESS ProfileBuffer, IN UINT64 ProfileSize, IN BOOLEAN IsForSmm)
 
MEMORY_PROFILE_ALLOC_SUMMARY_INFO_DATAGetAllocSummaryInfoByCallerAddress (IN PHYSICAL_ADDRESS CallerAddress, IN MEMORY_PROFILE_DRIVER_SUMMARY_INFO_DATA *DriverSummaryInfoData)
 
MEMORY_PROFILE_ALLOC_INFOCreateAllocSummaryInfo (IN OUT MEMORY_PROFILE_DRIVER_SUMMARY_INFO_DATA *DriverSummaryInfoData, IN MEMORY_PROFILE_ALLOC_INFO *AllocInfo)
 
MEMORY_PROFILE_DRIVER_INFOCreateDriverSummaryInfo (IN OUT MEMORY_PROFILE_CONTEXT_SUMMARY_DATA *ContextSummaryData, IN MEMORY_PROFILE_DRIVER_INFO *DriverInfo)
 
MEMORY_PROFILE_CONTEXT_SUMMARY_DATACreateContextSummaryData (IN PHYSICAL_ADDRESS ProfileBuffer, IN UINT64 ProfileSize)
 
VOID DumpContextSummaryData (IN MEMORY_PROFILE_CONTEXT_SUMMARY_DATA *ContextSummaryData, IN BOOLEAN IsForSmm)
 
VOID DestroyContextSummaryData (IN OUT MEMORY_PROFILE_CONTEXT_SUMMARY_DATA *ContextSummaryData)
 
EFI_STATUS GetUefiMemoryProfileData (VOID)
 
EFI_STATUS GetSmramProfileData (VOID)
 
EFI_STATUS EFIAPI UefiMain (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

CHAR8 * mActionString []
 
CHAR8 * mSmmActionString []
 
ACTION_STRING mExtActionString []
 
CHAR8 mUserDefinedActionString [] = { "UserDefined-0x80000000" }
 
CHAR8 * mMemoryTypeString []
 
CHAR8 * mSubsystemString []
 
CHAR8 * mFileTypeString []
 
CHAR8 mNameString [PROFILE_NAME_STRING_LENGTH+1]
 
LIST_ENTRY mImageSummaryQueue = INITIALIZE_LIST_HEAD_VARIABLE (mImageSummaryQueue)
 
MEMORY_PROFILE_CONTEXT_SUMMARY_DATA mMemoryProfileContextSummary
 

Detailed Description

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

Definition in file MemoryProfileInfo.c.

Macro Definition Documentation

◆ MEMORY_PROFILE_ALLOC_SUMMARY_INFO_REVISION

#define MEMORY_PROFILE_ALLOC_SUMMARY_INFO_REVISION   0x0001

Definition at line 137 of file MemoryProfileInfo.c.

◆ MEMORY_PROFILE_ALLOC_SUMMARY_INFO_SIGNATURE

#define MEMORY_PROFILE_ALLOC_SUMMARY_INFO_SIGNATURE   SIGNATURE_32 ('M','P','A','S')

Definition at line 136 of file MemoryProfileInfo.c.

◆ PROFILE_NAME_STRING_LENGTH

#define PROFILE_NAME_STRING_LENGTH   64

Definition at line 130 of file MemoryProfileInfo.c.

Function Documentation

◆ CreateAllocSummaryInfo()

MEMORY_PROFILE_ALLOC_INFO * CreateAllocSummaryInfo ( IN OUT MEMORY_PROFILE_DRIVER_SUMMARY_INFO_DATA DriverSummaryInfoData,
IN MEMORY_PROFILE_ALLOC_INFO AllocInfo 
)

Create Allocate summary information structure and link to Driver summary information data structure.

Parameters
[in,out]DriverSummaryInfoDataDriver summary information data structure.
[in]AllocInfoPointer to memory profile alloc info.
Returns
Pointer to next memory profile alloc info.

Definition at line 770 of file MemoryProfileInfo.c.

◆ CreateContextSummaryData()

MEMORY_PROFILE_CONTEXT_SUMMARY_DATA * CreateContextSummaryData ( IN PHYSICAL_ADDRESS  ProfileBuffer,
IN UINT64  ProfileSize 
)

Create Context summary information structure.

Parameters
[in]ProfileBufferMemory profile base address.
[in]ProfileSizeMemory profile size.
Returns
Context summary information structure.

Definition at line 870 of file MemoryProfileInfo.c.

◆ CreateDriverSummaryInfo()

MEMORY_PROFILE_DRIVER_INFO * CreateDriverSummaryInfo ( IN OUT MEMORY_PROFILE_CONTEXT_SUMMARY_DATA ContextSummaryData,
IN MEMORY_PROFILE_DRIVER_INFO DriverInfo 
)

Create Driver summary information structure and link to Context summary information data structure.

Parameters
[in,out]ContextSummaryDataContext summary information data structure.
[in]DriverInfoPointer to memory profile driver info.
Returns
Pointer to next memory profile driver info.

Definition at line 825 of file MemoryProfileInfo.c.

◆ DestroyContextSummaryData()

VOID DestroyContextSummaryData ( IN OUT MEMORY_PROFILE_CONTEXT_SUMMARY_DATA ContextSummaryData)

Destroy Context summary information.

Parameters
[in,out]ContextSummaryDataContext summary information data.

Definition at line 991 of file MemoryProfileInfo.c.

◆ DumpContextSummaryData()

VOID DumpContextSummaryData ( IN MEMORY_PROFILE_CONTEXT_SUMMARY_DATA ContextSummaryData,
IN BOOLEAN  IsForSmm 
)

Dump Context summary information.

Parameters
[in]ContextSummaryDataContext summary information data.
[in]IsForSmmTRUE - SMRAM profile. FALSE - UEFI memory profile.

Definition at line 908 of file MemoryProfileInfo.c.

◆ DumpMemoryProfile()

VOID DumpMemoryProfile ( IN PHYSICAL_ADDRESS  ProfileBuffer,
IN UINT64  ProfileSize,
IN BOOLEAN  IsForSmm 
)

Dump memory profile information.

Parameters
[in]ProfileBufferMemory profile base address.
[in]ProfileSizeMemory profile size.
[in]IsForSmmTRUE - SMRAM profile. FALSE - UEFI memory profile.

Definition at line 692 of file MemoryProfileInfo.c.

◆ DumpMemoryProfileAllocInfo()

MEMORY_PROFILE_ALLOC_INFO * DumpMemoryProfileAllocInfo ( IN MEMORY_PROFILE_DRIVER_INFO DriverInfo,
IN UINTN  AllocIndex,
IN MEMORY_PROFILE_ALLOC_INFO AllocInfo,
IN BOOLEAN  IsForSmm 
)

Dump memory profile allocate information.

Parameters
[in]DriverInfoPointer to memory profile driver info.
[in]AllocIndexMemory profile alloc info index.
[in]AllocInfoPointer to memory profile alloc info.
[in]IsForSmmTRUE - SMRAM profile. FALSE - UEFI memory profile.
Returns
Pointer to next memory profile alloc info.

Definition at line 384 of file MemoryProfileInfo.c.

◆ DumpMemoryProfileContext()

VOID * DumpMemoryProfileContext ( IN MEMORY_PROFILE_CONTEXT Context,
IN BOOLEAN  IsForSmm 
)

Dump memory profile context information.

Parameters
[in]ContextPointer to memory profile context.
[in]IsForSmmTRUE - SMRAM profile. FALSE - UEFI memory profile.
Returns
Pointer to the end of memory profile context buffer.

Definition at line 494 of file MemoryProfileInfo.c.

◆ DumpMemoryProfileDescriptor()

MEMORY_PROFILE_DESCRIPTOR * DumpMemoryProfileDescriptor ( IN UINTN  DescriptorIndex,
IN MEMORY_PROFILE_DESCRIPTOR Descriptor 
)

Dump memory profile descriptor information.

Parameters
[in]DescriptorIndexMemory profile descriptor index.
[in]DescriptorPointer to memory profile descriptor.
Returns
Pointer to next memory profile descriptor.

Definition at line 547 of file MemoryProfileInfo.c.

◆ DumpMemoryProfileDriverInfo()

MEMORY_PROFILE_DRIVER_INFO * DumpMemoryProfileDriverInfo ( IN UINTN  DriverIndex,
IN MEMORY_PROFILE_DRIVER_INFO DriverInfo,
IN BOOLEAN  IsForSmm 
)

Dump memory profile driver information.

Parameters
[in]DriverIndexMemory profile driver info index.
[in]DriverInfoPointer to memory profile driver info.
[in]IsForSmmTRUE - SMRAM profile. FALSE - UEFI memory profile.
Returns
Pointer to next memory profile driver info.

Definition at line 429 of file MemoryProfileInfo.c.

◆ DumpMemoryProfileFreeMemory()

VOID * DumpMemoryProfileFreeMemory ( IN MEMORY_PROFILE_FREE_MEMORY FreeMemory)

Dump memory profile free memory information.

Parameters
[in]FreeMemoryPointer to memory profile free memory.
Returns
Pointer to the end of memory profile free memory buffer.

Definition at line 575 of file MemoryProfileInfo.c.

◆ DumpMemoryProfileMemoryRange()

VOID * DumpMemoryProfileMemoryRange ( IN MEMORY_PROFILE_MEMORY_RANGE MemoryRange)

Dump memory profile memory range information.

Parameters
[in]MemoryRangePointer to memory profile memory range.
Returns
Pointer to the end of memory profile memory range buffer.

Definition at line 613 of file MemoryProfileInfo.c.

◆ GetAllocSummaryInfoByCallerAddress()

MEMORY_PROFILE_ALLOC_SUMMARY_INFO_DATA * GetAllocSummaryInfoByCallerAddress ( IN PHYSICAL_ADDRESS  CallerAddress,
IN MEMORY_PROFILE_DRIVER_SUMMARY_INFO_DATA DriverSummaryInfoData 
)

Get Allocate summary information structure by caller address.

Parameters
[in]CallerAddressCaller address.
[in]DriverSummaryInfoDataDriver summary information data structure.
Returns
Allocate summary information structure by caller address.

Definition at line 728 of file MemoryProfileInfo.c.

◆ GetDriverNameString()

CHAR8 * GetDriverNameString ( IN MEMORY_PROFILE_DRIVER_INFO DriverInfo)

Get a human readable name for an image. The following methods will be tried orderly:

  1. Image PDB
  2. FFS UI section
  3. Image GUID
Parameters
[in]DriverInfoPointer to memory profile driver info.
Returns
The resulting Ascii name string is stored in the mNameString global array.

Definition at line 237 of file MemoryProfileInfo.c.

◆ GetShortPdbFileName()

VOID GetShortPdbFileName ( IN CHAR8 *  PdbFileName,
OUT CHAR8 *  AsciiBuffer 
)

Get the file name portion of the Pdb File Name.

The portion of the Pdb File Name between the last backslash and either a following period or the end of the string is copied into AsciiBuffer. The name is truncated, if necessary, to ensure that AsciiBuffer is not overrun.

Parameters
[in]PdbFileNamePdb file name.
[out]AsciiBufferThe resultant Ascii File Name.

Definition at line 183 of file MemoryProfileInfo.c.

◆ GetSmramProfileData()

EFI_STATUS GetSmramProfileData ( VOID  )

Get and dump SMRAM profile data.

Returns
EFI_SUCCESS Get the SMRAM profile data successfully.
other Fail to get the SMRAM profile data.

Definition at line 1144 of file MemoryProfileInfo.c.

◆ GetUefiMemoryProfileData()

EFI_STATUS GetUefiMemoryProfileData ( VOID  )

Get and dump UEFI memory profile data.

Returns
EFI_SUCCESS Get the memory profile data successfully.
other Fail to get the memory profile data.

Definition at line 1051 of file MemoryProfileInfo.c.

◆ ProfileActionToStr()

CHAR8 * ProfileActionToStr ( IN MEMORY_PROFILE_ACTION  Action,
IN CHAR8 *  UserDefinedActionString,
IN BOOLEAN  IsForSmm 
)

Action to string.

Parameters
[in]ActionProfile action.
[in]UserDefinedActionStringPointer to user defined action string.
[in]IsForSmmTRUE - SMRAM profile. FALSE - UEFI memory profile.
Returns
Pointer to string.

Definition at line 331 of file MemoryProfileInfo.c.

◆ ProfileMemoryTypeToStr()

CHAR8 * ProfileMemoryTypeToStr ( IN EFI_MEMORY_TYPE  MemoryType)

Memory type to string.

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

Definition at line 296 of file MemoryProfileInfo.c.

◆ ScanMemoryProfileBySignature()

VOID * ScanMemoryProfileBySignature ( IN PHYSICAL_ADDRESS  ProfileBuffer,
IN UINT64  ProfileSize,
IN UINT32  Signature 
)

Scan memory profile by Signature.

Parameters
[in]ProfileBufferMemory profile base address.
[in]ProfileSizeMemory profile size.
[in]SignatureSignature.
Returns
Pointer to the structure with the signature.

Definition at line 652 of file MemoryProfileInfo.c.

◆ UefiMain()

EFI_STATUS EFIAPI UefiMain ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

The user Entry Point for Application. The user code starts with this function as the real entry point for the image goes into a library that calls this function.

Parameters
[in]ImageHandleThe firmware allocated handle for the EFI image.
[in]SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSThe entry point is executed successfully.
otherSome error occurs when executing this entry point.

Definition at line 1395 of file MemoryProfileInfo.c.

Variable Documentation

◆ mActionString

CHAR8* mActionString[]
Initial value:
= {
"Unknown",
"gBS->AllocatePages",
"gBS->FreePages",
"gBS->AllocatePool",
"gBS->FreePool",
}

Definition at line 27 of file MemoryProfileInfo.c.

◆ mExtActionString

ACTION_STRING 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 48 of file MemoryProfileInfo.c.

◆ mFileTypeString

CHAR8* mFileTypeString[]
Initial value:
= {
"Unknown",
"RAW",
"FREEFORM",
"SECURITY_CORE",
"PEI_CORE",
"DXE_CORE",
"PEIM",
"DRIVER",
"COMBINED_PEIM_DRIVER",
"APPLICATION",
"SMM",
"FIRMWARE_VOLUME_IMAGE",
"COMBINED_SMM_DXE",
"SMM_CORE",
}

Definition at line 113 of file MemoryProfileInfo.c.

◆ mImageSummaryQueue

LIST_ENTRY mImageSummaryQueue = INITIALIZE_LIST_HEAD_VARIABLE (mImageSummaryQueue)

Definition at line 167 of file MemoryProfileInfo.c.

◆ mMemoryProfileContextSummary

MEMORY_PROFILE_CONTEXT_SUMMARY_DATA mMemoryProfileContextSummary

Definition at line 168 of file MemoryProfileInfo.c.

◆ mMemoryTypeString

CHAR8* mMemoryTypeString[]
Initial value:
= {
"EfiReservedMemoryType",
"EfiLoaderCode",
"EfiLoaderData",
"EfiBootServicesCode",
"EfiBootServicesData",
"EfiRuntimeServicesCode",
"EfiRuntimeServicesData",
"EfiConventionalMemory",
"EfiUnusableMemory",
"EfiACPIReclaimMemory",
"EfiACPIMemoryNVS",
"EfiMemoryMappedIO",
"EfiMemoryMappedIOPortSpace",
"EfiPalCode",
"EfiPersistentMemory",
"EfiOSReserved",
"EfiOemReserved",
}

Definition at line 74 of file MemoryProfileInfo.c.

◆ mNameString

CHAR8 mNameString[PROFILE_NAME_STRING_LENGTH+1]

Definition at line 131 of file MemoryProfileInfo.c.

◆ mSmmActionString

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

Definition at line 35 of file MemoryProfileInfo.c.

◆ mSubsystemString

CHAR8* mSubsystemString[]
Initial value:
= {
"Unknown",
"NATIVE",
"WINDOWS_GUI",
"WINDOWS_CUI",
"Unknown",
"Unknown",
"Unknown",
"POSIX_CUI",
"Unknown",
"WINDOWS_CE_GUI",
"EFI_APPLICATION",
"EFI_BOOT_SERVICE_DRIVER",
"EFI_RUNTIME_DRIVER",
"EFI_ROM",
"XBOX",
"Unknown",
}

Definition at line 94 of file MemoryProfileInfo.c.

◆ mUserDefinedActionString

CHAR8 mUserDefinedActionString[] = { "UserDefined-0x80000000" }

Definition at line 72 of file MemoryProfileInfo.c.