/** @file\r
UEFI Memory pool management functions.\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
@param Buffer The address to return a pointer to the allocated\r
pool\r
\r
- @retval EFI_INVALID_PARAMETER PoolType not valid or Buffer is NULL. \r
- PoolType was EfiPersistentMemory.\r
+ @retval EFI_INVALID_PARAMETER Buffer is NULL.\r
+ PoolType is in the range EfiMaxMemoryType..0x6FFFFFFF.\r
+ PoolType is EfiPersistentMemory.\r
@retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.\r
@retval EFI_SUCCESS Pool successfully allocated.\r
\r
@param Buffer The address to return a pointer to the allocated\r
pool\r
\r
- @retval EFI_INVALID_PARAMETER PoolType not valid or Buffer is NULL. \r
+ @retval EFI_INVALID_PARAMETER Buffer is NULL.\r
+ PoolType is in the range EfiMaxMemoryType..0x6FFFFFFF.\r
+ PoolType is EfiPersistentMemory.\r
@retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.\r
@retval EFI_SUCCESS Pool successfully allocated.\r
\r
Status = CoreInternalAllocatePool (PoolType, Size, Buffer);\r
if (!EFI_ERROR (Status)) {\r
CoreUpdateProfile ((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0), MemoryProfileActionAllocatePool, PoolType, Size, *Buffer);\r
+ InstallMemoryAttributesTableOnMemoryAllocation (PoolType);\r
}\r
return Status;\r
}\r
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
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
}\r
\r
CoreAcquireMemoryLock ();\r
- Status = CoreFreePoolI (Buffer);\r
+ Status = CoreFreePoolI (Buffer, PoolType);\r
CoreReleaseMemoryLock ();\r
return Status;\r
}\r
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
+ InstallMemoryAttributesTableOnMemoryAllocation (PoolType);\r
}\r
return Status;\r
}\r
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
**/\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
Granularity = DEFAULT_PAGE_ALLOCATION;\r
}\r
\r
+ if (PoolType != NULL) {\r
+ *PoolType = Head->Type;\r
+ }\r
+\r
//\r
// Determine the pool list\r
//\r
}\r
\r
//\r
- // If this is an OS specific memory type, then check to see if the last\r
+ // If this is an OS/OEM specific memory type, then check to see if the last\r
// portion of that memory type has been freed. If it has, then free the\r
// list entry for that memory type\r
//\r
- if ((INT32)Pool->MemoryType < 0 && Pool->Used == 0) {\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