]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Update memory profile for OEM reserved memory type.
authorStar Zeng <star.zeng@intel.com>
Mon, 18 May 2015 01:30:04 +0000 (01:30 +0000)
committerlzeng14 <lzeng14@Edk2>
Mon, 18 May 2015 01:30:04 +0000 (01:30 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17462 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c
MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c
MdeModulePkg/Include/Guid/MemoryProfile.h
MdeModulePkg/MdeModulePkg.dec
MdeModulePkg/MdeModulePkg.uni

index 96bb9add8b50230f3dc16b81dca7ee3e283013e3..6304b7fc6c160edf3a8dcf08fd45511f620c75f7 100644 (file)
@@ -56,6 +56,7 @@ CHAR16 *mMemoryTypeString[] = {
   L"EfiPalCode",\r
   L"EfiPersistentMemory",\r
   L"EfiOSReserved",\r
   L"EfiPalCode",\r
   L"EfiPersistentMemory",\r
   L"EfiOSReserved",\r
+  L"EfiOemReserved",\r
 };\r
 \r
 CHAR16 *mSubsystemString[] = {\r
 };\r
 \r
 CHAR16 *mSubsystemString[] = {\r
@@ -213,6 +214,38 @@ GetDriverNameString (
   UnicodeSPrint (mNameString, sizeof (mNameString), L"%g", &DriverInfo->FileName);\r
 }\r
 \r
   UnicodeSPrint (mNameString, sizeof (mNameString), L"%g", &DriverInfo->FileName);\r
 }\r
 \r
+/**\r
+  Memory type to string.\r
+\r
+  @param[in] MemoryType Memory type.\r
+\r
+  @return Pointer to string.\r
+\r
+**/\r
+CHAR16 *\r
+ProfileMemoryTypeToStr (\r
+  IN EFI_MEMORY_TYPE    MemoryType\r
+  )\r
+{\r
+  UINTN     Index;\r
+\r
+  if ((UINT32) MemoryType >= 0x80000000) {\r
+    //\r
+    // OS reserved memory type.\r
+    //\r
+    Index = EfiMaxMemoryType;\r
+  } else if ((UINT32) MemoryType >= 0x70000000) {\r
+    //\r
+    // OEM reserved memory type.\r
+    //\r
+    Index = EfiMaxMemoryType + 1;\r
+  } else {\r
+    Index = MemoryType;\r
+  }\r
+\r
+  return mMemoryTypeString[Index];\r
+}\r
+\r
 /**\r
   Dump memory profile allocate information.\r
 \r
 /**\r
   Dump memory profile allocate information.\r
 \r
@@ -240,7 +273,7 @@ DumpMemoryProfileAllocInfo (
   Print (L"      CallerAddress - 0x%016lx (Offset: 0x%08x)\n", AllocInfo->CallerAddress, (UINTN) (AllocInfo->CallerAddress - DriverInfo->ImageBase));\r
   Print (L"      SequenceId    - 0x%08x\n", AllocInfo->SequenceId);\r
   Print (L"      Action        - 0x%08x (%s)\n", AllocInfo->Action, mActionString[(AllocInfo->Action < sizeof(mActionString)/sizeof(mActionString[0])) ? AllocInfo->Action : 0]);\r
   Print (L"      CallerAddress - 0x%016lx (Offset: 0x%08x)\n", AllocInfo->CallerAddress, (UINTN) (AllocInfo->CallerAddress - DriverInfo->ImageBase));\r
   Print (L"      SequenceId    - 0x%08x\n", AllocInfo->SequenceId);\r
   Print (L"      Action        - 0x%08x (%s)\n", AllocInfo->Action, mActionString[(AllocInfo->Action < sizeof(mActionString)/sizeof(mActionString[0])) ? AllocInfo->Action : 0]);\r
-  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)]);\r
+  Print (L"      MemoryType    - 0x%08x (%s)\n", AllocInfo->MemoryType, ProfileMemoryTypeToStr (AllocInfo->MemoryType));\r
   Print (L"      Buffer        - 0x%016lx\n", AllocInfo->Buffer);\r
   Print (L"      Size          - 0x%016lx\n", AllocInfo->Size);\r
 \r
   Print (L"      Buffer        - 0x%016lx\n", AllocInfo->Buffer);\r
   Print (L"      Size          - 0x%016lx\n", AllocInfo->Size);\r
 \r
@@ -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]);\r
   Print (L"    CurrentUsage            - 0x%016lx\n", DriverInfo->CurrentUsage);\r
   Print (L"    PeakUsage               - 0x%016lx\n", DriverInfo->PeakUsage);\r
   Print (L"    FileType                - 0x%02x (%s)\n", DriverInfo->FileType, mFileTypeString[(DriverInfo->FileType < sizeof(mFileTypeString)/sizeof(mFileTypeString[0])) ? DriverInfo->FileType : 0]);\r
   Print (L"    CurrentUsage            - 0x%016lx\n", DriverInfo->CurrentUsage);\r
   Print (L"    PeakUsage               - 0x%016lx\n", DriverInfo->PeakUsage);\r
-  for (TypeIndex = 0; TypeIndex <= EfiMaxMemoryType; TypeIndex++) {\r
+  for (TypeIndex = 0; TypeIndex < sizeof (DriverInfo->CurrentUsageByType) / sizeof (DriverInfo->CurrentUsageByType[0]); TypeIndex++) {\r
     if ((DriverInfo->CurrentUsageByType[TypeIndex] != 0) ||\r
         (DriverInfo->PeakUsageByType[TypeIndex] != 0)) {\r
       Print (L"    CurrentUsage[0x%02x]      - 0x%016lx (%s)\n", TypeIndex, DriverInfo->CurrentUsageByType[TypeIndex], mMemoryTypeString[TypeIndex]);\r
     if ((DriverInfo->CurrentUsageByType[TypeIndex] != 0) ||\r
         (DriverInfo->PeakUsageByType[TypeIndex] != 0)) {\r
       Print (L"    CurrentUsage[0x%02x]      - 0x%016lx (%s)\n", TypeIndex, DriverInfo->CurrentUsageByType[TypeIndex], mMemoryTypeString[TypeIndex]);\r
@@ -327,7 +360,7 @@ DumpMemoryProfileContext (
   Print (L"  Revision                      - 0x%04x\n", Context->Header.Revision);  \r
   Print (L"  CurrentTotalUsage             - 0x%016lx\n", Context->CurrentTotalUsage);\r
   Print (L"  PeakTotalUsage                - 0x%016lx\n", Context->PeakTotalUsage);\r
   Print (L"  Revision                      - 0x%04x\n", Context->Header.Revision);  \r
   Print (L"  CurrentTotalUsage             - 0x%016lx\n", Context->CurrentTotalUsage);\r
   Print (L"  PeakTotalUsage                - 0x%016lx\n", Context->PeakTotalUsage);\r
-  for (TypeIndex = 0; TypeIndex <= EfiMaxMemoryType; TypeIndex++) {\r
+  for (TypeIndex = 0; TypeIndex < sizeof (Context->CurrentTotalUsageByType) / sizeof (Context->CurrentTotalUsageByType[0]); TypeIndex++) {\r
     if ((Context->CurrentTotalUsageByType[TypeIndex] != 0) ||\r
         (Context->PeakTotalUsageByType[TypeIndex] != 0)) {\r
       Print (L"  CurrentTotalUsage[0x%02x]       - 0x%016lx (%s)\n", TypeIndex, Context->CurrentTotalUsageByType[TypeIndex], mMemoryTypeString[TypeIndex]);\r
     if ((Context->CurrentTotalUsageByType[TypeIndex] != 0) ||\r
         (Context->PeakTotalUsageByType[TypeIndex] != 0)) {\r
       Print (L"  CurrentTotalUsage[0x%02x]       - 0x%016lx (%s)\n", TypeIndex, Context->CurrentTotalUsageByType[TypeIndex], mMemoryTypeString[TypeIndex]);\r
index 1ae991b7024e62e7906fb48738163a470bc0c9b5..2c6713f5e97bd2c2c2b66766220a4b44e26ebcc1 100644 (file)
@@ -13,6 +13,7 @@
 **/\r
 \r
 #include "DxeMain.h"\r
 **/\r
 \r
 #include "DxeMain.h"\r
+#include "Imem.h"\r
 \r
 #define IS_UEFI_MEMORY_PROFILE_ENABLED ((PcdGet8 (PcdMemoryProfilePropertyMask) & BIT0) != 0)\r
 \r
 \r
 #define IS_UEFI_MEMORY_PROFILE_ENABLED ((PcdGet8 (PcdMemoryProfilePropertyMask) & BIT0) != 0)\r
 \r
@@ -737,8 +738,9 @@ UnregisterMemoryProfileImage (
 \r
 /**\r
   Return if this memory type needs to be recorded into memory profile.\r
 \r
 /**\r
   Return if this memory type needs to be recorded into memory profile.\r
-  If BIOS memory type (0 ~ EfiMaxMemoryType), it checks bit (1 << MemoryType).\r
+  If BIOS memory type (0 ~ EfiMaxMemoryType - 1), it checks bit (1 << MemoryType).\r
   If OS memory type (0x80000000 ~ 0xFFFFFFFF), it checks bit63 - 0x8000000000000000.\r
   If OS memory type (0x80000000 ~ 0xFFFFFFFF), it checks bit63 - 0x8000000000000000.\r
+  If OEM memory type (0x70000000 ~ 0x7FFFFFFF), it checks bit62 - 0x4000000000000000.\r
 \r
   @param MemoryType     Memory type.\r
 \r
 \r
   @param MemoryType     Memory type.\r
 \r
@@ -753,8 +755,10 @@ CoreNeedRecordProfile (
 {\r
   UINT64 TestBit;\r
 \r
 {\r
   UINT64 TestBit;\r
 \r
-  if ((UINT32) MemoryType >= 0x80000000) {\r
+  if ((UINT32) MemoryType >= MEMORY_TYPE_OS_RESERVED_MIN) {\r
     TestBit = BIT63;\r
     TestBit = BIT63;\r
+  } else if ((UINT32) MemoryType >= MEMORY_TYPE_OEM_RESERVED_MIN) {\r
+    TestBit = BIT62;\r
   } else {\r
     TestBit = LShiftU64 (1, MemoryType);\r
   }\r
   } else {\r
     TestBit = LShiftU64 (1, MemoryType);\r
   }\r
@@ -768,8 +772,9 @@ CoreNeedRecordProfile (
 \r
 /**\r
   Convert EFI memory type to profile memory index. The rule is:\r
 \r
 /**\r
   Convert EFI memory type to profile memory index. The rule is:\r
-  If BIOS memory type (0 ~ EfiMaxMemoryType), ProfileMemoryIndex = MemoryType.\r
+  If BIOS memory type (0 ~ EfiMaxMemoryType - 1), ProfileMemoryIndex = MemoryType.\r
   If OS memory type (0x80000000 ~ 0xFFFFFFFF), ProfileMemoryIndex = EfiMaxMemoryType.\r
   If OS memory type (0x80000000 ~ 0xFFFFFFFF), ProfileMemoryIndex = EfiMaxMemoryType.\r
+  If OEM memory type (0x70000000 ~ 0x7FFFFFFF), ProfileMemoryIndex = EfiMaxMemoryType + 1.\r
 \r
   @param MemoryType     Memory type.\r
 \r
 \r
   @param MemoryType     Memory type.\r
 \r
@@ -781,8 +786,10 @@ GetProfileMemoryIndex (
   IN EFI_MEMORY_TYPE    MemoryType\r
   )\r
 {\r
   IN EFI_MEMORY_TYPE    MemoryType\r
   )\r
 {\r
-  if ((UINT32) MemoryType >= 0x80000000) {\r
+  if ((UINT32) MemoryType >= MEMORY_TYPE_OS_RESERVED_MIN) {\r
     return EfiMaxMemoryType;\r
     return EfiMaxMemoryType;\r
+  } else if ((UINT32) MemoryType >= MEMORY_TYPE_OEM_RESERVED_MIN) {\r
+    return EfiMaxMemoryType + 1;\r
   } else {\r
     return MemoryType;\r
   }\r
   } else {\r
     return MemoryType;\r
   }\r
index 3c1e5e79cafd202ffc2d11175b32b168b67d894e..a2f03256c317715e144bc2f414cc3083f728810b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Memory profile data structure.\r
 \r
 /** @file\r
   Memory profile data structure.\r
 \r
-  Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -16,8 +16,9 @@
 #define _MEMORY_PROFILE_H_\r
 \r
 //\r
 #define _MEMORY_PROFILE_H_\r
 \r
 //\r
-// For BIOS MemoryType (0 ~ EfiMaxMemoryType), it is recorded in UsageByType[MemoryType]. (Each valid entry has one entry)\r
+// For BIOS MemoryType (0 ~ EfiMaxMemoryType - 1), it is recorded in UsageByType[MemoryType]. (Each valid entry has one entry)\r
 // For OS MemoryType (0x80000000 ~ 0xFFFFFFFF), it is recorded in UsageByType[EfiMaxMemoryType]. (All types are combined into one entry)\r
 // For OS MemoryType (0x80000000 ~ 0xFFFFFFFF), it is recorded in UsageByType[EfiMaxMemoryType]. (All types are combined into one entry)\r
+// For OEM MemoryType (0x70000000 ~ 0x7FFFFFFF), it is recorded in UsageByType[EfiMaxMemoryType + 1]. (All types are combined into one entry)\r
 //\r
 \r
 typedef struct {\r
 //\r
 \r
 typedef struct {\r
@@ -27,21 +28,21 @@ typedef struct {
 } MEMORY_PROFILE_COMMON_HEADER;\r
 \r
 #define MEMORY_PROFILE_CONTEXT_SIGNATURE SIGNATURE_32 ('M','P','C','T')\r
 } MEMORY_PROFILE_COMMON_HEADER;\r
 \r
 #define MEMORY_PROFILE_CONTEXT_SIGNATURE SIGNATURE_32 ('M','P','C','T')\r
-#define MEMORY_PROFILE_CONTEXT_REVISION 0x0001\r
+#define MEMORY_PROFILE_CONTEXT_REVISION 0x0002\r
 \r
 typedef struct {\r
   MEMORY_PROFILE_COMMON_HEADER  Header;\r
   UINT64                        CurrentTotalUsage;\r
   UINT64                        PeakTotalUsage;\r
 \r
 typedef struct {\r
   MEMORY_PROFILE_COMMON_HEADER  Header;\r
   UINT64                        CurrentTotalUsage;\r
   UINT64                        PeakTotalUsage;\r
-  UINT64                        CurrentTotalUsageByType[EfiMaxMemoryType + 1];\r
-  UINT64                        PeakTotalUsageByType[EfiMaxMemoryType + 1];\r
+  UINT64                        CurrentTotalUsageByType[EfiMaxMemoryType + 2];\r
+  UINT64                        PeakTotalUsageByType[EfiMaxMemoryType + 2];\r
   UINT64                        TotalImageSize;\r
   UINT32                        ImageCount;\r
   UINT32                        SequenceCount;\r
 } MEMORY_PROFILE_CONTEXT;\r
 \r
 #define MEMORY_PROFILE_DRIVER_INFO_SIGNATURE SIGNATURE_32 ('M','P','D','I')\r
   UINT64                        TotalImageSize;\r
   UINT32                        ImageCount;\r
   UINT32                        SequenceCount;\r
 } MEMORY_PROFILE_CONTEXT;\r
 \r
 #define MEMORY_PROFILE_DRIVER_INFO_SIGNATURE SIGNATURE_32 ('M','P','D','I')\r
-#define MEMORY_PROFILE_DRIVER_INFO_REVISION 0x0001\r
+#define MEMORY_PROFILE_DRIVER_INFO_REVISION 0x0002\r
 \r
 typedef struct {\r
   MEMORY_PROFILE_COMMON_HEADER  Header;\r
 \r
 typedef struct {\r
   MEMORY_PROFILE_COMMON_HEADER  Header;\r
@@ -55,8 +56,8 @@ typedef struct {
   UINT32                        AllocRecordCount;\r
   UINT64                        CurrentUsage;\r
   UINT64                        PeakUsage;\r
   UINT32                        AllocRecordCount;\r
   UINT64                        CurrentUsage;\r
   UINT64                        PeakUsage;\r
-  UINT64                        CurrentUsageByType[EfiMaxMemoryType + 1];\r
-  UINT64                        PeakUsageByType[EfiMaxMemoryType + 1];\r
+  UINT64                        CurrentUsageByType[EfiMaxMemoryType + 2];\r
+  UINT64                        PeakUsageByType[EfiMaxMemoryType + 2];\r
 } MEMORY_PROFILE_DRIVER_INFO;\r
 \r
 typedef enum {\r
 } MEMORY_PROFILE_DRIVER_INFO;\r
 \r
 typedef enum {\r
index bb953ed5b3e58ec995adda74ef9589394740d104..93ae120f54824df4b568402a6a63d585f9c63c17 100644 (file)
   #  EfiMemoryMappedIOPortSpace     0x1000<BR>\r
   #  EfiPalCode                     0x2000<BR>\r
   #  EfiPersistentMemory            0x4000<BR>\r
   #  EfiMemoryMappedIOPortSpace     0x1000<BR>\r
   #  EfiPalCode                     0x2000<BR>\r
   #  EfiPersistentMemory            0x4000<BR>\r
+  #  OEM Reserved       0x4000000000000000<BR>\r
   #  OS Reserved        0x8000000000000000<BR>\r
   #\r
   # e.g. Reserved+ACPINvs+ACPIReclaim+RuntimeCode+RuntimeData are needed, 0x661 should be used.<BR>\r
   #  OS Reserved        0x8000000000000000<BR>\r
   #\r
   # e.g. Reserved+ACPINvs+ACPIReclaim+RuntimeCode+RuntimeData are needed, 0x661 should be used.<BR>\r
index 7d767b06a6bd8824b265d27971470e909fdeacf3..238474def78b262d32cd92983f065d97c7050f88 100644 (file)
Binary files a/MdeModulePkg/MdeModulePkg.uni and b/MdeModulePkg/MdeModulePkg.uni differ