From db9b00f1d58516fec77df359e99ee60ed3da0278 Mon Sep 17 00:00:00 2001 From: Star Zeng Date: Mon, 18 May 2015 01:30:04 +0000 Subject: MdeModulePkg: Update memory profile for OEM reserved memory type. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17462 6f19259b-4bc3-4df7-8a09-765794883524 --- .../MemoryProfileInfo/MemoryProfileInfo.c | 39 ++++++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'MdeModulePkg/Application') diff --git a/MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c b/MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c index 96bb9add8b..6304b7fc6c 100644 --- a/MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c +++ b/MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c @@ -56,6 +56,7 @@ CHAR16 *mMemoryTypeString[] = { L"EfiPalCode", L"EfiPersistentMemory", L"EfiOSReserved", + L"EfiOemReserved", }; CHAR16 *mSubsystemString[] = { @@ -213,6 +214,38 @@ GetDriverNameString ( UnicodeSPrint (mNameString, sizeof (mNameString), L"%g", &DriverInfo->FileName); } +/** + Memory type to string. + + @param[in] MemoryType Memory type. + + @return Pointer to string. + +**/ +CHAR16 * +ProfileMemoryTypeToStr ( + IN EFI_MEMORY_TYPE MemoryType + ) +{ + UINTN Index; + + if ((UINT32) MemoryType >= 0x80000000) { + // + // OS reserved memory type. + // + Index = EfiMaxMemoryType; + } else if ((UINT32) MemoryType >= 0x70000000) { + // + // OEM reserved memory type. + // + Index = EfiMaxMemoryType + 1; + } else { + Index = MemoryType; + } + + return mMemoryTypeString[Index]; +} + /** Dump memory profile allocate information. @@ -240,7 +273,7 @@ DumpMemoryProfileAllocInfo ( Print (L" CallerAddress - 0x%016lx (Offset: 0x%08x)\n", AllocInfo->CallerAddress, (UINTN) (AllocInfo->CallerAddress - DriverInfo->ImageBase)); Print (L" SequenceId - 0x%08x\n", AllocInfo->SequenceId); Print (L" Action - 0x%08x (%s)\n", AllocInfo->Action, mActionString[(AllocInfo->Action < sizeof(mActionString)/sizeof(mActionString[0])) ? AllocInfo->Action : 0]); - Print (L" MemoryType - 0x%08x (%s)\n", AllocInfo->MemoryType, mMemoryTypeString[(AllocInfo->MemoryType < sizeof(mMemoryTypeString)/sizeof(mMemoryTypeString[0])) ? AllocInfo->MemoryType : (sizeof(mMemoryTypeString)/sizeof(mMemoryTypeString[0]) - 1)]); + Print (L" MemoryType - 0x%08x (%s)\n", AllocInfo->MemoryType, ProfileMemoryTypeToStr (AllocInfo->MemoryType)); Print (L" Buffer - 0x%016lx\n", AllocInfo->Buffer); Print (L" Size - 0x%016lx\n", AllocInfo->Size); @@ -282,7 +315,7 @@ DumpMemoryProfileDriverInfo ( Print (L" FileType - 0x%02x (%s)\n", DriverInfo->FileType, mFileTypeString[(DriverInfo->FileType < sizeof(mFileTypeString)/sizeof(mFileTypeString[0])) ? DriverInfo->FileType : 0]); Print (L" CurrentUsage - 0x%016lx\n", DriverInfo->CurrentUsage); Print (L" PeakUsage - 0x%016lx\n", DriverInfo->PeakUsage); - for (TypeIndex = 0; TypeIndex <= EfiMaxMemoryType; TypeIndex++) { + for (TypeIndex = 0; TypeIndex < sizeof (DriverInfo->CurrentUsageByType) / sizeof (DriverInfo->CurrentUsageByType[0]); TypeIndex++) { if ((DriverInfo->CurrentUsageByType[TypeIndex] != 0) || (DriverInfo->PeakUsageByType[TypeIndex] != 0)) { Print (L" CurrentUsage[0x%02x] - 0x%016lx (%s)\n", TypeIndex, DriverInfo->CurrentUsageByType[TypeIndex], mMemoryTypeString[TypeIndex]); @@ -327,7 +360,7 @@ DumpMemoryProfileContext ( Print (L" Revision - 0x%04x\n", Context->Header.Revision); Print (L" CurrentTotalUsage - 0x%016lx\n", Context->CurrentTotalUsage); Print (L" PeakTotalUsage - 0x%016lx\n", Context->PeakTotalUsage); - for (TypeIndex = 0; TypeIndex <= EfiMaxMemoryType; TypeIndex++) { + for (TypeIndex = 0; TypeIndex < sizeof (Context->CurrentTotalUsageByType) / sizeof (Context->CurrentTotalUsageByType[0]); TypeIndex++) { if ((Context->CurrentTotalUsageByType[TypeIndex] != 0) || (Context->PeakTotalUsageByType[TypeIndex] != 0)) { Print (L" CurrentTotalUsage[0x%02x] - 0x%016lx (%s)\n", TypeIndex, Context->CurrentTotalUsageByType[TypeIndex], mMemoryTypeString[TypeIndex]); -- cgit v1.2.3