]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg DxeCoreMemoryAllocationLib: Extend to support MemoryProfileLib
authorStar Zeng <star.zeng@intel.com>
Thu, 23 Jun 2016 14:33:55 +0000 (22:33 +0800)
committerStar Zeng <star.zeng@intel.com>
Fri, 1 Jul 2016 01:39:58 +0000 (09:39 +0800)
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf
MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.uni
MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationProfileLib.inf [new file with mode: 0644]
MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationProfileLib.uni [new file with mode: 0644]
MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryProfileLib.c [new file with mode: 0644]
MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryProfileLibNull.c [new file with mode: 0644]
MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryProfileServices.h [new file with mode: 0644]
MdeModulePkg/Library/DxeCoreMemoryAllocationLib/MemoryAllocationLib.c
MdeModulePkg/MdeModulePkg.dsc

index 0747f6e697599e2fa1dd0342b7361410c862b041..caba8cd4a42984f26b0a121893ac99336a22a275 100644 (file)
@@ -1,10 +1,10 @@
 ## @file\r
 # Memory Allocation Library instance dedicated to DXE Core.\r
 # The implementation borrows the DxeCore Memory Allocation services as the primitive\r
-# for memory allocation instead of using UEFI boot servces in an indirect way.\r
-# It is assumed that this library instance must be linked with DxeCore in this package. \r
+# for memory allocation instead of using UEFI boot services in an indirect way.\r
+# It is assumed that this library instance must be linked with DxeCore in this package.\r
 #\r
-# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -24,7 +24,7 @@
   MODULE_TYPE                    = DXE_CORE\r
   VERSION_STRING                 = 1.0\r
   LIBRARY_CLASS                  = MemoryAllocationLib|DXE_CORE\r
-  \r
+\r
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
 [Sources]\r
   MemoryAllocationLib.c\r
   DxeCoreMemoryAllocationServices.h\r
+  DxeCoreMemoryProfileLibNull.c\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
-\r
+  MdeModulePkg/MdeModulePkg.dec\r
 \r
 [LibraryClasses]\r
   DebugLib\r
   BaseMemoryLib\r
-\r
-\r
index 85f8c7ec27ca47ac9e1ab1ec3342b52166f41f8d..aa67c8baf1829c6cc20ff0fe32df8840b8da0674 100644 (file)
@@ -2,10 +2,10 @@
 // Memory Allocation Library instance dedicated to DXE Core.\r
 //\r
 // The implementation borrows the DxeCore Memory Allocation services as the primitive\r
-// for memory allocation instead of using UEFI boot servces in an indirect way.\r
+// for memory allocation instead of using UEFI boot services in an indirect way.\r
 // It is assumed that this library instance must be linked with DxeCore in this package.\r
 //\r
-// Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>\r
+// Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR>\r
 //\r
 // This program and the accompanying materials\r
 // are licensed and made available under the terms and conditions of the BSD License\r
diff --git a/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationProfileLib.inf b/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationProfileLib.inf
new file mode 100644 (file)
index 0000000..a2b5f8c
--- /dev/null
@@ -0,0 +1,48 @@
+## @file\r
+# Memory Allocation/Profile Library instance dedicated to DXE Core.\r
+# The implementation borrows the DxeCore Memory Allocation/profile services as the primitive\r
+# for memory allocation/profile instead of using UEFI boot services or memory profile protocol in an indirect way.\r
+# It is assumed that this library instance must be linked with DxeCore in this package.\r
+#\r
+# Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR>\r
+#\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
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = DxeCoreMemoryAllocationProfileLib\r
+  MODULE_UNI_FILE                = DxeCoreMemoryAllocationProfileLib.uni\r
+  FILE_GUID                      = 7ADD7147-74E8-4583-BE34-B6BC45353BB5\r
+  MODULE_TYPE                    = DXE_CORE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = MemoryAllocationLib|DXE_CORE\r
+  LIBRARY_CLASS                  = MemoryProfileLib|DXE_CORE\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  MemoryAllocationLib.c\r
+  DxeCoreMemoryAllocationServices.h\r
+  DxeCoreMemoryProfileLib.c\r
+  DxeCoreMemoryProfileServices.h\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+\r
+[LibraryClasses]\r
+  DebugLib\r
+  BaseMemoryLib\r
+\r
diff --git a/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationProfileLib.uni b/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationProfileLib.uni
new file mode 100644 (file)
index 0000000..82cdca6
--- /dev/null
@@ -0,0 +1,23 @@
+// /** @file\r
+// Memory Allocation/Profile Library instance dedicated to DXE Core.\r
+//\r
+// The implementation borrows the DxeCore Memory Allocation/Profile services as the primitive\r
+// for memory allocation/profile instead of using UEFI boot services or memory profile protocol in an indirect way.\r
+// It is assumed that this library instance must be linked with DxeCore in this package.\r
+//\r
+// Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR>\r
+//\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
+// http://opensource.org/licenses/bsd-license.php\r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+//\r
+// **/\r
+\r
+\r
+#string STR_MODULE_ABSTRACT             #language en-US "Memory Allocation/Profile Library instance dedicated to DXE Core"\r
+\r
+#string STR_MODULE_DESCRIPTION          #language en-US "The implementation borrows the DxeCore Memory Allocation/Profile services as the primitive for memory allocation/profile instead of using UEFI boot services or memory profile protocol in an indirect way. It is assumed that this library instance must be linked with DxeCore in this package."\r
+\r
diff --git a/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryProfileLib.c b/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryProfileLib.c
new file mode 100644 (file)
index 0000000..8f28b98
--- /dev/null
@@ -0,0 +1,57 @@
+/** @file\r
+  Support routines for memory profile for DxeCore.\r
+\r
+  Copyright (c) 2016, 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
+  http://opensource.org/licenses/bsd-license.php.                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Guid/MemoryProfile.h>\r
+\r
+#include "DxeCoreMemoryProfileServices.h"\r
+\r
+/**\r
+  Record memory profile of multilevel caller.\r
+\r
+  @param[in] CallerAddress      Address of caller.\r
+  @param[in] Action             Memory profile action.\r
+  @param[in] MemoryType         Memory type.\r
+                                EfiMaxMemoryType means the MemoryType is unknown.\r
+  @param[in] Buffer             Buffer address.\r
+  @param[in] Size               Buffer size.\r
+  @param[in] ActionString       String for memory profile action.\r
+                                Only needed for user defined allocate action.\r
+\r
+  @return EFI_SUCCESS           Memory profile is updated.\r
+  @return EFI_UNSUPPORTED       Memory profile is unsupported,\r
+                                or memory profile for the image is not required,\r
+                                or memory profile for the memory type is not required.\r
+  @return EFI_ACCESS_DENIED     It is during memory profile data getting.\r
+  @return EFI_ABORTED           Memory profile recording is not enabled.\r
+  @return EFI_OUT_OF_RESOURCES  No enough resource to update memory profile for allocate action.\r
+  @return EFI_NOT_FOUND         No matched allocate info found for free action.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MemoryProfileLibRecord (\r
+  IN PHYSICAL_ADDRESS           CallerAddress,\r
+  IN MEMORY_PROFILE_ACTION      Action,\r
+  IN EFI_MEMORY_TYPE            MemoryType,\r
+  IN VOID                       *Buffer,\r
+  IN UINTN                      Size,\r
+  IN CHAR8                      *ActionString OPTIONAL\r
+  )\r
+{\r
+  return CoreUpdateProfile (CallerAddress, Action, MemoryType, Size, Buffer, ActionString);\r
+}\r
+\r
diff --git a/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryProfileLibNull.c b/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryProfileLibNull.c
new file mode 100644 (file)
index 0000000..9ae0db8
--- /dev/null
@@ -0,0 +1,55 @@
+/** @file\r
+  Null routines for memory profile for DxeCore.\r
+\r
+  Copyright (c) 2016, 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
+  http://opensource.org/licenses/bsd-license.php.                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Guid/MemoryProfile.h>\r
+\r
+/**\r
+  Record memory profile of multilevel caller.\r
+\r
+  @param[in] CallerAddress      Address of caller.\r
+  @param[in] Action             Memory profile action.\r
+  @param[in] MemoryType         Memory type.\r
+                                EfiMaxMemoryType means the MemoryType is unknown.\r
+  @param[in] Buffer             Buffer address.\r
+  @param[in] Size               Buffer size.\r
+  @param[in] ActionString       String for memory profile action.\r
+                                Only needed for user defined allocate action.\r
+\r
+  @return EFI_SUCCESS           Memory profile is updated.\r
+  @return EFI_UNSUPPORTED       Memory profile is unsupported,\r
+                                or memory profile for the image is not required,\r
+                                or memory profile for the memory type is not required.\r
+  @return EFI_ACCESS_DENIED     It is during memory profile data getting.\r
+  @return EFI_ABORTED           Memory profile recording is not enabled.\r
+  @return EFI_OUT_OF_RESOURCES  No enough resource to update memory profile for allocate action.\r
+  @return EFI_NOT_FOUND         No matched allocate info found for free action.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MemoryProfileLibRecord (\r
+  IN PHYSICAL_ADDRESS           CallerAddress,\r
+  IN MEMORY_PROFILE_ACTION      Action,\r
+  IN EFI_MEMORY_TYPE            MemoryType,\r
+  IN VOID                       *Buffer,\r
+  IN UINTN                      Size,\r
+  IN CHAR8                      *ActionString OPTIONAL\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
diff --git a/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryProfileServices.h b/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryProfileServices.h
new file mode 100644 (file)
index 0000000..619d7ad
--- /dev/null
@@ -0,0 +1,54 @@
+/** @file\r
+  Contains function prototypes for Memory Profile Services in DxeCore.\r
+\r
+  This header file borrows the DxeCore Memory Profile services as the primitive\r
+  for memory profile.\r
+\r
+  Copyright (c) 2016, 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
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#ifndef _DXE_CORE_MEMORY_PROFILE_SERVICES_H_\r
+#define _DXE_CORE_MEMORY_PROFILE_SERVICES_H_\r
+\r
+/**\r
+  Update memory profile information.\r
+\r
+  @param CallerAddress  Address of caller who call Allocate or Free.\r
+  @param Action         This Allocate or Free action.\r
+  @param MemoryType     Memory type.\r
+                        EfiMaxMemoryType means the MemoryType is unknown.\r
+  @param Size           Buffer size.\r
+  @param Buffer         Buffer address.\r
+  @param ActionString   String for memory profile action.\r
+                        Only needed for user defined allocate action.\r
+\r
+  @return EFI_SUCCESS           Memory profile is updated.\r
+  @return EFI_UNSUPPORTED       Memory profile is unsupported,\r
+                                or memory profile for the image is not required,\r
+                                or memory profile for the memory type is not required.\r
+  @return EFI_ACCESS_DENIED     It is during memory profile data getting.\r
+  @return EFI_ABORTED           Memory profile recording is not enabled.\r
+  @return EFI_OUT_OF_RESOURCES  No enough resource to update memory profile for allocate action.\r
+  @return EFI_NOT_FOUND         No matched allocate info found for free action.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CoreUpdateProfile (\r
+  IN PHYSICAL_ADDRESS       CallerAddress,\r
+  IN MEMORY_PROFILE_ACTION  Action,\r
+  IN EFI_MEMORY_TYPE        MemoryType,\r
+  IN UINTN                  Size,       // Valid for AllocatePages/FreePages/AllocatePool\r
+  IN VOID                   *Buffer,\r
+  IN CHAR8                  *ActionString OPTIONAL\r
+  );\r
+\r
+#endif\r
index d7d9ff311e16aa4955374e38fe5f486584cec0e8..89c19e7c83dcb6ad0922dac813f15ff454169ea5 100644 (file)
@@ -1,8 +1,9 @@
 /** @file\r
   Support routines for memory allocation routines based \r
-  on boot services for Dxe phase drivers.\r
+  on DxeCore Memory Allocation services for DxeCore,\r
+  with memory profile support.\r
 \r
-  Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2016, 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
@@ -22,6 +23,8 @@
 #include <Library/DebugLib.h>\r
 #include "DxeCoreMemoryAllocationServices.h"\r
 \r
+#include <Library/MemoryProfileLib.h>\r
+\r
 /**\r
   Allocates one or more 4KB pages of a certain memory type.\r
 \r
@@ -74,7 +77,20 @@ AllocatePages (
   IN UINTN  Pages\r
   )\r
 {\r
-  return InternalAllocatePages (EfiBootServicesData, Pages);\r
+  VOID  *Buffer;\r
+\r
+  Buffer = InternalAllocatePages (EfiBootServicesData, Pages);\r
+  if (Buffer != NULL) {\r
+    MemoryProfileLibRecord (\r
+      (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+      MEMORY_PROFILE_ACTION_LIB_ALLOCATE_PAGES,\r
+      EfiBootServicesData,\r
+      Buffer,\r
+      EFI_PAGES_TO_SIZE (Pages),\r
+      NULL\r
+      );\r
+  }\r
+  return Buffer;\r
 }\r
 \r
 /**\r
@@ -96,7 +112,20 @@ AllocateRuntimePages (
   IN UINTN  Pages\r
   )\r
 {\r
-  return InternalAllocatePages (EfiRuntimeServicesData, Pages);\r
+  VOID  *Buffer;\r
+\r
+  Buffer = InternalAllocatePages (EfiRuntimeServicesData, Pages);\r
+  if (Buffer != NULL) {\r
+    MemoryProfileLibRecord (\r
+      (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+      MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_PAGES,\r
+      EfiRuntimeServicesData,\r
+      Buffer,\r
+      EFI_PAGES_TO_SIZE (Pages),\r
+      NULL\r
+      );\r
+  }\r
+  return Buffer;\r
 }\r
 \r
 /**\r
@@ -118,7 +147,20 @@ AllocateReservedPages (
   IN UINTN  Pages\r
   )\r
 {\r
-  return InternalAllocatePages (EfiReservedMemoryType, Pages);\r
+  VOID  *Buffer;\r
+\r
+  Buffer = InternalAllocatePages (EfiReservedMemoryType, Pages);\r
+  if (Buffer != NULL) {\r
+    MemoryProfileLibRecord (\r
+      (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+      MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_PAGES,\r
+      EfiReservedMemoryType,\r
+      Buffer,\r
+      EFI_PAGES_TO_SIZE (Pages),\r
+      NULL\r
+      );\r
+  }\r
+  return Buffer;\r
 }\r
 \r
 /**\r
@@ -263,7 +305,20 @@ AllocateAlignedPages (
   IN UINTN  Alignment\r
   )\r
 {\r
-  return InternalAllocateAlignedPages (EfiBootServicesData, Pages, Alignment);\r
+  VOID  *Buffer;\r
+\r
+  Buffer = InternalAllocateAlignedPages (EfiBootServicesData, Pages, Alignment);\r
+  if (Buffer != NULL) {\r
+    MemoryProfileLibRecord (\r
+      (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+      MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_PAGES,\r
+      EfiBootServicesData,\r
+      Buffer,\r
+      EFI_PAGES_TO_SIZE (Pages),\r
+      NULL\r
+      );\r
+  }\r
+  return Buffer;\r
 }\r
 \r
 /**\r
@@ -291,7 +346,20 @@ AllocateAlignedRuntimePages (
   IN UINTN  Alignment\r
   )\r
 {\r
-  return InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment);\r
+  VOID  *Buffer;\r
+\r
+  Buffer = InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment);\r
+  if (Buffer != NULL) {\r
+    MemoryProfileLibRecord (\r
+      (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+      MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_RUNTIME_PAGES,\r
+      EfiRuntimeServicesData,\r
+      Buffer,\r
+      EFI_PAGES_TO_SIZE (Pages),\r
+      NULL\r
+      );\r
+  }\r
+  return Buffer;\r
 }\r
 \r
 /**\r
@@ -319,7 +387,20 @@ AllocateAlignedReservedPages (
   IN UINTN  Alignment\r
   )\r
 {\r
-  return InternalAllocateAlignedPages (EfiReservedMemoryType, Pages, Alignment);\r
+  VOID  *Buffer;\r
+\r
+  Buffer = InternalAllocateAlignedPages (EfiReservedMemoryType, Pages, Alignment);\r
+  if (Buffer != NULL) {\r
+    MemoryProfileLibRecord (\r
+      (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+      MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_RESERVED_PAGES,\r
+      EfiReservedMemoryType,\r
+      Buffer,\r
+      EFI_PAGES_TO_SIZE (Pages),\r
+      NULL\r
+      );\r
+  }\r
+  return Buffer;\r
 }\r
 \r
 /**\r
@@ -402,7 +483,20 @@ AllocatePool (
   IN UINTN  AllocationSize\r
   )\r
 {\r
-  return InternalAllocatePool (EfiBootServicesData, AllocationSize);\r
+  VOID  *Buffer;\r
+\r
+  Buffer = InternalAllocatePool (EfiBootServicesData, AllocationSize);\r
+  if (Buffer != NULL) {\r
+    MemoryProfileLibRecord (\r
+      (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+      MEMORY_PROFILE_ACTION_LIB_ALLOCATE_POOL,\r
+      EfiBootServicesData,\r
+      Buffer,\r
+      AllocationSize,\r
+      NULL\r
+      );\r
+  }\r
+  return Buffer;\r
 }\r
 \r
 /**\r
@@ -423,7 +517,20 @@ AllocateRuntimePool (
   IN UINTN  AllocationSize\r
   )\r
 {\r
-  return InternalAllocatePool (EfiRuntimeServicesData, AllocationSize);\r
+  VOID  *Buffer;\r
+\r
+  Buffer = InternalAllocatePool (EfiRuntimeServicesData, AllocationSize);\r
+  if (Buffer != NULL) {\r
+    MemoryProfileLibRecord (\r
+      (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+      MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_POOL,\r
+      EfiRuntimeServicesData,\r
+      Buffer,\r
+      AllocationSize,\r
+      NULL\r
+      );\r
+  }\r
+  return Buffer;\r
 }\r
 \r
 /**\r
@@ -444,7 +551,20 @@ AllocateReservedPool (
   IN UINTN  AllocationSize\r
   )\r
 {\r
-  return InternalAllocatePool (EfiReservedMemoryType, AllocationSize);\r
+  VOID  *Buffer;\r
+\r
+  Buffer = InternalAllocatePool (EfiReservedMemoryType, AllocationSize);\r
+  if (Buffer != NULL) {\r
+    MemoryProfileLibRecord (\r
+      (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+      MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_POOL,\r
+      EfiReservedMemoryType,\r
+      Buffer,\r
+      AllocationSize,\r
+      NULL\r
+      );\r
+  }\r
+  return Buffer;\r
 }\r
 \r
 /**\r
@@ -495,7 +615,20 @@ AllocateZeroPool (
   IN UINTN  AllocationSize\r
   )\r
 {\r
-  return InternalAllocateZeroPool (EfiBootServicesData, AllocationSize);\r
+  VOID  *Buffer;\r
+\r
+  Buffer = InternalAllocateZeroPool (EfiBootServicesData, AllocationSize);\r
+  if (Buffer != NULL) {\r
+    MemoryProfileLibRecord (\r
+      (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+      MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ZERO_POOL,\r
+      EfiBootServicesData,\r
+      Buffer,\r
+      AllocationSize,\r
+      NULL\r
+      );\r
+  }\r
+  return Buffer;\r
 }\r
 \r
 /**\r
@@ -517,7 +650,20 @@ AllocateRuntimeZeroPool (
   IN UINTN  AllocationSize\r
   )\r
 {\r
-  return InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize);\r
+  VOID  *Buffer;\r
+\r
+  Buffer = InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize);\r
+  if (Buffer != NULL) {\r
+    MemoryProfileLibRecord (\r
+      (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+      MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_ZERO_POOL,\r
+      EfiRuntimeServicesData,\r
+      Buffer,\r
+      AllocationSize,\r
+      NULL\r
+      );\r
+  }\r
+  return Buffer;\r
 }\r
 \r
 /**\r
@@ -539,7 +685,20 @@ AllocateReservedZeroPool (
   IN UINTN  AllocationSize\r
   )\r
 {\r
-  return InternalAllocateZeroPool (EfiReservedMemoryType, AllocationSize);\r
+  VOID  *Buffer;\r
+\r
+  Buffer = InternalAllocateZeroPool (EfiReservedMemoryType, AllocationSize);\r
+  if (Buffer != NULL) {\r
+    MemoryProfileLibRecord (\r
+      (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+      MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_ZERO_POOL,\r
+      EfiReservedMemoryType,\r
+      Buffer,\r
+      AllocationSize,\r
+      NULL\r
+      );\r
+  }\r
+  return Buffer;\r
 }\r
 \r
 /**\r
@@ -602,7 +761,20 @@ AllocateCopyPool (
   IN CONST VOID  *Buffer\r
   )\r
 {\r
-  return InternalAllocateCopyPool (EfiBootServicesData, AllocationSize, Buffer);\r
+  VOID  *NewBuffer;\r
+\r
+  NewBuffer = InternalAllocateCopyPool (EfiBootServicesData, AllocationSize, Buffer);\r
+  if (NewBuffer != NULL) {\r
+    MemoryProfileLibRecord (\r
+      (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+      MEMORY_PROFILE_ACTION_LIB_ALLOCATE_COPY_POOL,\r
+      EfiBootServicesData,\r
+      NewBuffer,\r
+      AllocationSize,\r
+      NULL\r
+      );\r
+  }\r
+  return NewBuffer;\r
 }\r
 \r
 /**\r
@@ -629,7 +801,20 @@ AllocateRuntimeCopyPool (
   IN CONST VOID  *Buffer\r
   )\r
 {\r
-  return InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer);\r
+  VOID  *NewBuffer;\r
+\r
+  NewBuffer = InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer);\r
+  if (NewBuffer != NULL) {\r
+    MemoryProfileLibRecord (\r
+      (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+      MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_COPY_POOL,\r
+      EfiRuntimeServicesData,\r
+      NewBuffer,\r
+      AllocationSize,\r
+      NULL\r
+      );\r
+  }\r
+  return NewBuffer;\r
 }\r
 \r
 /**\r
@@ -656,7 +841,20 @@ AllocateReservedCopyPool (
   IN CONST VOID  *Buffer\r
   )\r
 {\r
-  return InternalAllocateCopyPool (EfiReservedMemoryType, AllocationSize, Buffer);\r
+  VOID  *NewBuffer;\r
+\r
+  NewBuffer = InternalAllocateCopyPool (EfiReservedMemoryType, AllocationSize, Buffer);\r
+  if (NewBuffer != NULL) {\r
+    MemoryProfileLibRecord (\r
+      (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+      MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_COPY_POOL,\r
+      EfiRuntimeServicesData,\r
+      NewBuffer,\r
+      AllocationSize,\r
+      NULL\r
+      );\r
+  }\r
+  return NewBuffer;\r
 }\r
 \r
 /**\r
@@ -728,7 +926,20 @@ ReallocatePool (
   IN VOID   *OldBuffer  OPTIONAL\r
   )\r
 {\r
-  return InternalReallocatePool (EfiBootServicesData, OldSize, NewSize, OldBuffer);\r
+  VOID  *Buffer;\r
+\r
+  Buffer = InternalReallocatePool (EfiBootServicesData, OldSize, NewSize, OldBuffer);\r
+  if (Buffer != NULL) {\r
+    MemoryProfileLibRecord (\r
+      (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+      MEMORY_PROFILE_ACTION_LIB_REALLOCATE_POOL,\r
+      EfiBootServicesData,\r
+      Buffer,\r
+      NewSize,\r
+      NULL\r
+      );\r
+  }\r
+  return Buffer;\r
 }\r
 \r
 /**\r
@@ -760,7 +971,20 @@ ReallocateRuntimePool (
   IN VOID   *OldBuffer  OPTIONAL\r
   )\r
 {\r
-  return InternalReallocatePool (EfiRuntimeServicesData, OldSize, NewSize, OldBuffer);\r
+  VOID  *Buffer;\r
+\r
+  Buffer = InternalReallocatePool (EfiRuntimeServicesData, OldSize, NewSize, OldBuffer);\r
+  if (Buffer != NULL) {\r
+    MemoryProfileLibRecord (\r
+      (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+      MEMORY_PROFILE_ACTION_LIB_REALLOCATE_RUNTIME_POOL,\r
+      EfiRuntimeServicesData,\r
+      Buffer,\r
+      NewSize,\r
+      NULL\r
+      );\r
+  }\r
+  return Buffer;\r
 }\r
 \r
 /**\r
@@ -792,7 +1016,20 @@ ReallocateReservedPool (
   IN VOID   *OldBuffer  OPTIONAL\r
   )\r
 {\r
-  return InternalReallocatePool (EfiReservedMemoryType, OldSize, NewSize, OldBuffer);\r
+  VOID  *Buffer;\r
+\r
+  Buffer = InternalReallocatePool (EfiReservedMemoryType, OldSize, NewSize, OldBuffer);\r
+  if (Buffer != NULL) {\r
+    MemoryProfileLibRecord (\r
+      (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+      MEMORY_PROFILE_ACTION_LIB_REALLOCATE_RESERVED_POOL,\r
+      EfiReservedMemoryType,\r
+      Buffer,\r
+      NewSize,\r
+      NULL\r
+      );\r
+  }\r
+  return Buffer;\r
 }\r
 \r
 /**\r
index ae38a2de7b9d7734b094b60a693972fc63036664..972f96e401ee04fbf43f71ead0c5cb021840f395 100644 (file)
   MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf\r
   MdeModulePkg/Library/UefiMemoryAllocationProfileLib/UefiMemoryAllocationProfileLib.inf\r
   MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf\r
+  MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationProfileLib.inf\r
   MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf\r
   MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32GuidedSectionExtractLib.inf\r
   MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf\r