MdeModulePkg DxeCore: Return memory type from internal free pool/pages
The following patch for MemoryAttributesTable will need the memory type. And CoreUpdateProfile() can also use the memory type for check. Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Feng Tian <feng.tian@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>
This commit is contained in:
@ -1269,33 +1269,6 @@ CoreAllocatePages (
|
|||||||
IN OUT EFI_PHYSICAL_ADDRESS *Memory
|
IN OUT EFI_PHYSICAL_ADDRESS *Memory
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
Allocates pages from the memory map.
|
|
||||||
|
|
||||||
@param Type The type of allocation to perform
|
|
||||||
@param MemoryType The type of memory to turn the allocated pages
|
|
||||||
into
|
|
||||||
@param NumberOfPages The number of pages to allocate
|
|
||||||
@param Memory A pointer to receive the base allocated memory
|
|
||||||
address
|
|
||||||
|
|
||||||
@return Status. On success, Memory is filled in with the base address allocated
|
|
||||||
@retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in
|
|
||||||
spec.
|
|
||||||
@retval EFI_NOT_FOUND Could not allocate pages match the requirement.
|
|
||||||
@retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
|
|
||||||
@retval EFI_SUCCESS Pages successfully allocated.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
CoreInternalAllocatePages (
|
|
||||||
IN EFI_ALLOCATE_TYPE Type,
|
|
||||||
IN EFI_MEMORY_TYPE MemoryType,
|
|
||||||
IN UINTN NumberOfPages,
|
|
||||||
IN OUT EFI_PHYSICAL_ADDRESS *Memory
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Frees previous allocated pages.
|
Frees previous allocated pages.
|
||||||
|
|
||||||
@ -1314,24 +1287,6 @@ CoreFreePages (
|
|||||||
IN UINTN NumberOfPages
|
IN UINTN NumberOfPages
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
Frees previous allocated pages.
|
|
||||||
|
|
||||||
@param Memory Base address of memory being freed
|
|
||||||
@param NumberOfPages The number of pages to free
|
|
||||||
|
|
||||||
@retval EFI_NOT_FOUND Could not find the entry that covers the range
|
|
||||||
@retval EFI_INVALID_PARAMETER Address not aligned
|
|
||||||
@return EFI_SUCCESS -Pages successfully freed.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
CoreInternalFreePages (
|
|
||||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
|
||||||
IN UINTN NumberOfPages
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This function returns a copy of the current memory map. The map is an array of
|
This function returns a copy of the current memory map. The map is an array of
|
||||||
memory descriptors, each of which describes a contiguous block of memory.
|
memory descriptors, each of which describes a contiguous block of memory.
|
||||||
@ -1435,6 +1390,7 @@ CoreFreePool (
|
|||||||
Frees pool.
|
Frees pool.
|
||||||
|
|
||||||
@param Buffer The allocated pool entry to free
|
@param Buffer The allocated pool entry to free
|
||||||
|
@param PoolType Pointer to pool type
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER Buffer is not a valid value.
|
@retval EFI_INVALID_PARAMETER Buffer is not a valid value.
|
||||||
@retval EFI_SUCCESS Pool successfully freed.
|
@retval EFI_SUCCESS Pool successfully freed.
|
||||||
@ -1443,7 +1399,8 @@ CoreFreePool (
|
|||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
CoreInternalFreePool (
|
CoreInternalFreePool (
|
||||||
IN VOID *Buffer
|
IN VOID *Buffer,
|
||||||
|
OUT EFI_MEMORY_TYPE *PoolType OPTIONAL
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,6 +112,7 @@ CoreAllocatePoolI (
|
|||||||
Caller must have the memory lock held
|
Caller must have the memory lock held
|
||||||
|
|
||||||
@param Buffer The allocated pool entry to free
|
@param Buffer The allocated pool entry to free
|
||||||
|
@param PoolType Pointer to pool type
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER Buffer not valid
|
@retval EFI_INVALID_PARAMETER Buffer not valid
|
||||||
@retval EFI_SUCCESS Buffer successfully freed.
|
@retval EFI_SUCCESS Buffer successfully freed.
|
||||||
@ -119,7 +120,8 @@ CoreAllocatePoolI (
|
|||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
CoreFreePoolI (
|
CoreFreePoolI (
|
||||||
IN VOID *Buffer
|
IN VOID *Buffer,
|
||||||
|
OUT EFI_MEMORY_TYPE *PoolType OPTIONAL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Support routines for UEFI memory profile.
|
Support routines for UEFI memory profile.
|
||||||
|
|
||||||
Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -730,7 +730,7 @@ UnregisterMemoryProfileImage (
|
|||||||
//
|
//
|
||||||
// Use CoreInternalFreePool() that will not update profile for this FreePool action.
|
// Use CoreInternalFreePool() that will not update profile for this FreePool action.
|
||||||
//
|
//
|
||||||
CoreInternalFreePool (DriverInfoData);
|
CoreInternalFreePool (DriverInfoData, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -1083,7 +1083,7 @@ CoreUpdateProfileFree (
|
|||||||
//
|
//
|
||||||
// Use CoreInternalFreePool() that will not update profile for this FreePool action.
|
// Use CoreInternalFreePool() that will not update profile for this FreePool action.
|
||||||
//
|
//
|
||||||
CoreInternalFreePool (AllocInfoData);
|
CoreInternalFreePool (AllocInfoData, NULL);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1345,6 +1345,7 @@ CoreAllocatePages (
|
|||||||
|
|
||||||
@param Memory Base address of memory being freed
|
@param Memory Base address of memory being freed
|
||||||
@param NumberOfPages The number of pages to free
|
@param NumberOfPages The number of pages to free
|
||||||
|
@param MemoryType Pointer to memory type
|
||||||
|
|
||||||
@retval EFI_NOT_FOUND Could not find the entry that covers the range
|
@retval EFI_NOT_FOUND Could not find the entry that covers the range
|
||||||
@retval EFI_INVALID_PARAMETER Address not aligned
|
@retval EFI_INVALID_PARAMETER Address not aligned
|
||||||
@ -1355,7 +1356,8 @@ EFI_STATUS
|
|||||||
EFIAPI
|
EFIAPI
|
||||||
CoreInternalFreePages (
|
CoreInternalFreePages (
|
||||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||||
IN UINTN NumberOfPages
|
IN UINTN NumberOfPages,
|
||||||
|
OUT EFI_MEMORY_TYPE *MemoryType OPTIONAL
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
@ -1403,6 +1405,10 @@ CoreInternalFreePages (
|
|||||||
NumberOfPages += EFI_SIZE_TO_PAGES (Alignment) - 1;
|
NumberOfPages += EFI_SIZE_TO_PAGES (Alignment) - 1;
|
||||||
NumberOfPages &= ~(EFI_SIZE_TO_PAGES (Alignment) - 1);
|
NumberOfPages &= ~(EFI_SIZE_TO_PAGES (Alignment) - 1);
|
||||||
|
|
||||||
|
if (MemoryType != NULL) {
|
||||||
|
*MemoryType = Entry->Type;
|
||||||
|
}
|
||||||
|
|
||||||
Status = CoreConvertPages (Memory, NumberOfPages, EfiConventionalMemory);
|
Status = CoreConvertPages (Memory, NumberOfPages, EfiConventionalMemory);
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
@ -1433,8 +1439,9 @@ CoreFreePages (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
EFI_MEMORY_TYPE MemoryType;
|
||||||
|
|
||||||
Status = CoreInternalFreePages (Memory, NumberOfPages);
|
Status = CoreInternalFreePages (Memory, NumberOfPages, &MemoryType);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
CoreUpdateProfile ((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0), MemoryProfileActionFreePages, (EFI_MEMORY_TYPE) 0, EFI_PAGES_TO_SIZE (NumberOfPages), (VOID *) (UINTN) Memory);
|
CoreUpdateProfile ((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0), MemoryProfileActionFreePages, (EFI_MEMORY_TYPE) 0, EFI_PAGES_TO_SIZE (NumberOfPages), (VOID *) (UINTN) Memory);
|
||||||
}
|
}
|
||||||
|
@ -459,6 +459,7 @@ Done:
|
|||||||
Frees pool.
|
Frees pool.
|
||||||
|
|
||||||
@param Buffer The allocated pool entry to free
|
@param Buffer The allocated pool entry to free
|
||||||
|
@param PoolType Pointer to pool type
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER Buffer is not a valid value.
|
@retval EFI_INVALID_PARAMETER Buffer is not a valid value.
|
||||||
@retval EFI_SUCCESS Pool successfully freed.
|
@retval EFI_SUCCESS Pool successfully freed.
|
||||||
@ -467,7 +468,8 @@ Done:
|
|||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
CoreInternalFreePool (
|
CoreInternalFreePool (
|
||||||
IN VOID *Buffer
|
IN VOID *Buffer,
|
||||||
|
OUT EFI_MEMORY_TYPE *PoolType OPTIONAL
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
@ -477,7 +479,7 @@ CoreInternalFreePool (
|
|||||||
}
|
}
|
||||||
|
|
||||||
CoreAcquireMemoryLock ();
|
CoreAcquireMemoryLock ();
|
||||||
Status = CoreFreePoolI (Buffer);
|
Status = CoreFreePoolI (Buffer, PoolType);
|
||||||
CoreReleaseMemoryLock ();
|
CoreReleaseMemoryLock ();
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
@ -498,8 +500,9 @@ CoreFreePool (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
EFI_MEMORY_TYPE PoolType;
|
||||||
|
|
||||||
Status = CoreInternalFreePool (Buffer);
|
Status = CoreInternalFreePool (Buffer, &PoolType);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
CoreUpdateProfile ((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0), MemoryProfileActionFreePool, (EFI_MEMORY_TYPE) 0, 0, Buffer);
|
CoreUpdateProfile ((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0), MemoryProfileActionFreePool, (EFI_MEMORY_TYPE) 0, 0, Buffer);
|
||||||
}
|
}
|
||||||
@ -511,6 +514,7 @@ CoreFreePool (
|
|||||||
Caller must have the memory lock held
|
Caller must have the memory lock held
|
||||||
|
|
||||||
@param Buffer The allocated pool entry to free
|
@param Buffer The allocated pool entry to free
|
||||||
|
@param PoolType Pointer to pool type
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER Buffer not valid
|
@retval EFI_INVALID_PARAMETER Buffer not valid
|
||||||
@retval EFI_SUCCESS Buffer successfully freed.
|
@retval EFI_SUCCESS Buffer successfully freed.
|
||||||
@ -518,7 +522,8 @@ CoreFreePool (
|
|||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
CoreFreePoolI (
|
CoreFreePoolI (
|
||||||
IN VOID *Buffer
|
IN VOID *Buffer,
|
||||||
|
OUT EFI_MEMORY_TYPE *PoolType OPTIONAL
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
POOL *Pool;
|
POOL *Pool;
|
||||||
@ -583,6 +588,10 @@ CoreFreePoolI (
|
|||||||
Granularity = DEFAULT_PAGE_ALLOCATION;
|
Granularity = DEFAULT_PAGE_ALLOCATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (PoolType != NULL) {
|
||||||
|
*PoolType = Head->Type;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Determine the pool list
|
// Determine the pool list
|
||||||
//
|
//
|
||||||
@ -667,7 +676,7 @@ CoreFreePoolI (
|
|||||||
//
|
//
|
||||||
if (((UINT32) Pool->MemoryType >= MEMORY_TYPE_OEM_RESERVED_MIN) && Pool->Used == 0) {
|
if (((UINT32) Pool->MemoryType >= MEMORY_TYPE_OEM_RESERVED_MIN) && Pool->Used == 0) {
|
||||||
RemoveEntryList (&Pool->Link);
|
RemoveEntryList (&Pool->Link);
|
||||||
CoreFreePoolI (Pool);
|
CoreFreePoolI (Pool, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
Reference in New Issue
Block a user