]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Mem/Pool.c
MdeModulePkg DxeCore: Return memory type from internal free pool/pages
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Mem / Pool.c
index 528c8e8ce9a52326d0db5e1d6dd718e158b13475..5496a09cfa72ab9d004efe8e2c665231e7846f8f 100644 (file)
@@ -459,6 +459,7 @@ Done:
   Frees pool.\r
 \r
   @param  Buffer                 The allocated pool entry to free\r
+  @param  PoolType               Pointer to pool type\r
 \r
   @retval EFI_INVALID_PARAMETER  Buffer is not a valid value.\r
   @retval EFI_SUCCESS            Pool successfully freed.\r
@@ -467,7 +468,8 @@ Done:
 EFI_STATUS\r
 EFIAPI\r
 CoreInternalFreePool (\r
-  IN VOID        *Buffer\r
+  IN VOID               *Buffer,\r
+  OUT EFI_MEMORY_TYPE   *PoolType OPTIONAL\r
   )\r
 {\r
   EFI_STATUS Status;\r
@@ -477,7 +479,7 @@ CoreInternalFreePool (
   }\r
 \r
   CoreAcquireMemoryLock ();\r
-  Status = CoreFreePoolI (Buffer);\r
+  Status = CoreFreePoolI (Buffer, PoolType);\r
   CoreReleaseMemoryLock ();\r
   return Status;\r
 }\r
@@ -497,9 +499,10 @@ CoreFreePool (
   IN VOID  *Buffer\r
   )\r
 {\r
-  EFI_STATUS  Status;\r
+  EFI_STATUS        Status;\r
+  EFI_MEMORY_TYPE   PoolType;\r
 \r
-  Status = CoreInternalFreePool (Buffer);\r
+  Status = CoreInternalFreePool (Buffer, &PoolType);\r
   if (!EFI_ERROR (Status)) {\r
     CoreUpdateProfile ((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0), MemoryProfileActionFreePool, (EFI_MEMORY_TYPE) 0, 0, Buffer);\r
   }\r
@@ -511,6 +514,7 @@ CoreFreePool (
   Caller must have the memory lock held\r
 \r
   @param  Buffer                 The allocated pool entry to free\r
+  @param  PoolType               Pointer to pool type\r
 \r
   @retval EFI_INVALID_PARAMETER  Buffer not valid\r
   @retval EFI_SUCCESS            Buffer successfully freed.\r
@@ -518,7 +522,8 @@ CoreFreePool (
 **/\r
 EFI_STATUS\r
 CoreFreePoolI (\r
-  IN VOID       *Buffer\r
+  IN VOID               *Buffer,\r
+  OUT EFI_MEMORY_TYPE   *PoolType OPTIONAL\r
   )\r
 {\r
   POOL        *Pool;\r
@@ -583,6 +588,10 @@ CoreFreePoolI (
     Granularity = DEFAULT_PAGE_ALLOCATION;\r
   }\r
 \r
+  if (PoolType != NULL) {\r
+    *PoolType = Head->Type;\r
+  }\r
+\r
   //\r
   // Determine the pool list\r
   //\r
@@ -667,7 +676,7 @@ CoreFreePoolI (
   //\r
   if (((UINT32) Pool->MemoryType >= MEMORY_TYPE_OEM_RESERVED_MIN) && Pool->Used == 0) {\r
     RemoveEntryList (&Pool->Link);\r
-    CoreFreePoolI (Pool);\r
+    CoreFreePoolI (Pool, NULL);\r
   }\r
 \r
   return EFI_SUCCESS;\r