From: Star Zeng Date: Mon, 18 May 2015 01:30:04 +0000 (+0000) Subject: MdeModulePkg: Update memory profile for OEM reserved memory type. X-Git-Tag: edk2-stable201903~9794 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=db9b00f1d58516fec77df359e99ee60ed3da0278 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 --- 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]); diff --git a/MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c b/MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c index 1ae991b702..2c6713f5e9 100644 --- a/MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c +++ b/MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c @@ -13,6 +13,7 @@ **/ #include "DxeMain.h" +#include "Imem.h" #define IS_UEFI_MEMORY_PROFILE_ENABLED ((PcdGet8 (PcdMemoryProfilePropertyMask) & BIT0) != 0) @@ -737,8 +738,9 @@ UnregisterMemoryProfileImage ( /** Return if this memory type needs to be recorded into memory profile. - If BIOS memory type (0 ~ EfiMaxMemoryType), it checks bit (1 << MemoryType). + If BIOS memory type (0 ~ EfiMaxMemoryType - 1), it checks bit (1 << MemoryType). If OS memory type (0x80000000 ~ 0xFFFFFFFF), it checks bit63 - 0x8000000000000000. + If OEM memory type (0x70000000 ~ 0x7FFFFFFF), it checks bit62 - 0x4000000000000000. @param MemoryType Memory type. @@ -753,8 +755,10 @@ CoreNeedRecordProfile ( { UINT64 TestBit; - if ((UINT32) MemoryType >= 0x80000000) { + if ((UINT32) MemoryType >= MEMORY_TYPE_OS_RESERVED_MIN) { TestBit = BIT63; + } else if ((UINT32) MemoryType >= MEMORY_TYPE_OEM_RESERVED_MIN) { + TestBit = BIT62; } else { TestBit = LShiftU64 (1, MemoryType); } @@ -768,8 +772,9 @@ CoreNeedRecordProfile ( /** Convert EFI memory type to profile memory index. The rule is: - If BIOS memory type (0 ~ EfiMaxMemoryType), ProfileMemoryIndex = MemoryType. + If BIOS memory type (0 ~ EfiMaxMemoryType - 1), ProfileMemoryIndex = MemoryType. If OS memory type (0x80000000 ~ 0xFFFFFFFF), ProfileMemoryIndex = EfiMaxMemoryType. + If OEM memory type (0x70000000 ~ 0x7FFFFFFF), ProfileMemoryIndex = EfiMaxMemoryType + 1. @param MemoryType Memory type. @@ -781,8 +786,10 @@ GetProfileMemoryIndex ( IN EFI_MEMORY_TYPE MemoryType ) { - if ((UINT32) MemoryType >= 0x80000000) { + if ((UINT32) MemoryType >= MEMORY_TYPE_OS_RESERVED_MIN) { return EfiMaxMemoryType; + } else if ((UINT32) MemoryType >= MEMORY_TYPE_OEM_RESERVED_MIN) { + return EfiMaxMemoryType + 1; } else { return MemoryType; } diff --git a/MdeModulePkg/Include/Guid/MemoryProfile.h b/MdeModulePkg/Include/Guid/MemoryProfile.h index 3c1e5e79ca..a2f03256c3 100644 --- a/MdeModulePkg/Include/Guid/MemoryProfile.h +++ b/MdeModulePkg/Include/Guid/MemoryProfile.h @@ -1,7 +1,7 @@ /** @file Memory profile data structure. - Copyright (c) 2014, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.
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 @@ -16,8 +16,9 @@ #define _MEMORY_PROFILE_H_ // -// For BIOS MemoryType (0 ~ EfiMaxMemoryType), it is recorded in UsageByType[MemoryType]. (Each valid entry has one entry) +// For BIOS MemoryType (0 ~ EfiMaxMemoryType - 1), it is recorded in UsageByType[MemoryType]. (Each valid entry has one entry) // For OS MemoryType (0x80000000 ~ 0xFFFFFFFF), it is recorded in UsageByType[EfiMaxMemoryType]. (All types are combined into one entry) +// For OEM MemoryType (0x70000000 ~ 0x7FFFFFFF), it is recorded in UsageByType[EfiMaxMemoryType + 1]. (All types are combined into one entry) // typedef struct { @@ -27,21 +28,21 @@ typedef struct { } MEMORY_PROFILE_COMMON_HEADER; #define MEMORY_PROFILE_CONTEXT_SIGNATURE SIGNATURE_32 ('M','P','C','T') -#define MEMORY_PROFILE_CONTEXT_REVISION 0x0001 +#define MEMORY_PROFILE_CONTEXT_REVISION 0x0002 typedef struct { MEMORY_PROFILE_COMMON_HEADER Header; UINT64 CurrentTotalUsage; UINT64 PeakTotalUsage; - UINT64 CurrentTotalUsageByType[EfiMaxMemoryType + 1]; - UINT64 PeakTotalUsageByType[EfiMaxMemoryType + 1]; + UINT64 CurrentTotalUsageByType[EfiMaxMemoryType + 2]; + UINT64 PeakTotalUsageByType[EfiMaxMemoryType + 2]; UINT64 TotalImageSize; UINT32 ImageCount; UINT32 SequenceCount; } MEMORY_PROFILE_CONTEXT; #define MEMORY_PROFILE_DRIVER_INFO_SIGNATURE SIGNATURE_32 ('M','P','D','I') -#define MEMORY_PROFILE_DRIVER_INFO_REVISION 0x0001 +#define MEMORY_PROFILE_DRIVER_INFO_REVISION 0x0002 typedef struct { MEMORY_PROFILE_COMMON_HEADER Header; @@ -55,8 +56,8 @@ typedef struct { UINT32 AllocRecordCount; UINT64 CurrentUsage; UINT64 PeakUsage; - UINT64 CurrentUsageByType[EfiMaxMemoryType + 1]; - UINT64 PeakUsageByType[EfiMaxMemoryType + 1]; + UINT64 CurrentUsageByType[EfiMaxMemoryType + 2]; + UINT64 PeakUsageByType[EfiMaxMemoryType + 2]; } MEMORY_PROFILE_DRIVER_INFO; typedef enum { diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index bb953ed5b3..93ae120f54 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -902,6 +902,7 @@ # EfiMemoryMappedIOPortSpace 0x1000
# EfiPalCode 0x2000
# EfiPersistentMemory 0x4000
+ # OEM Reserved 0x4000000000000000
# OS Reserved 0x8000000000000000
# # e.g. Reserved+ACPINvs+ACPIReclaim+RuntimeCode+RuntimeData are needed, 0x661 should be used.
diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni index 7d767b06a6..238474def7 100644 Binary files a/MdeModulePkg/MdeModulePkg.uni and b/MdeModulePkg/MdeModulePkg.uni differ