Cc: Jiewen Yao <jiewen....@intel.com>
Cc: Liming Gao <liming....@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.z...@intel.com>
---
 .../MemoryProfileInfo/MemoryProfileInfo.c          |  39 +++++++++++++++++++--
 MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c    |  15 +++++---
 MdeModulePkg/Include/Guid/MemoryProfile.h          |  17 ++++-----
 MdeModulePkg/MdeModulePkg.dec                      |   1 +
 MdeModulePkg/MdeModulePkg.uni                      | Bin 163654 -> 163916 bytes
 5 files changed, 57 insertions(+), 15 deletions(-)

diff --git a/MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c 
b/MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c
index 96bb9ad..6304b7f 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[] = {
@@ -214,6 +215,38 @@ GetDriverNameString (
 }
 
 /**
+  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.
 
   @param[in] DriverInfo         Pointer to memory profile driver info.
@@ -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 1ae991b..2c6713f 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 3c1e5e7..a2f0325 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.<BR>
+  Copyright (c) 2014 - 2015, 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
@@ -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 ec4e76e..1b65dd1 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -899,6 +899,7 @@
   #  EfiMemoryMappedIOPortSpace     0x1000<BR>
   #  EfiPalCode                     0x2000<BR>
   #  EfiPersistentMemory            0x4000<BR>
+  #  OEM Reserved       0x4000000000000000<BR>
   #  OS Reserved        0x8000000000000000<BR>
   #
   # e.g. Reserved+ACPINvs+ACPIReclaim+RuntimeCode+RuntimeData are needed, 
0x661 should be used.<BR>
diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni
index 
a3ed93e03707624ad190d900dcf0be46b396774f..82b4d8af50edc44db11a333a9714f35e54080508
 100644
GIT binary patch
delta 40
ycmV+@0N4M<{t3*03b0Pk14RH$lfju2lQIh)lQ6&p0W_0`&&h*I&$mj?0sOCFx)J&S

delta 18
acmX@pz;)~&=LWy?%^?@Ihg@L%u^s?j=n5ME

-- 
1.9.5.msysgit.0


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to