summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Core/Dxe/Mem/Page.c
diff options
context:
space:
mode:
authorStar Zeng <star.zeng@intel.com>2014-11-12 03:27:48 +0000
committerlzeng14 <lzeng14@Edk2>2014-11-12 03:27:48 +0000
commit84edd20bd0756ef5719835498d4283435d6b5e77 (patch)
tree2fceedfc8b217a7475ec26277c070b9c08991dfd /MdeModulePkg/Core/Dxe/Mem/Page.c
parentdad83a8c1207e585b2cb417d0680fe2e9452d262 (diff)
downloadedk2-platforms-84edd20bd0756ef5719835498d4283435d6b5e77.tar.xz
MdeModulePkg DxeCore/PiSmmCore: Add UEFI memory and SMRAM profile support.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16335 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Core/Dxe/Mem/Page.c')
-rw-r--r--MdeModulePkg/Core/Dxe/Mem/Page.c66
1 files changed, 64 insertions, 2 deletions
diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/Page.c
index f5067f663e..18780070c5 100644
--- a/MdeModulePkg/Core/Dxe/Mem/Page.c
+++ b/MdeModulePkg/Core/Dxe/Mem/Page.c
@@ -1106,7 +1106,7 @@ FindFreePages (
**/
EFI_STATUS
EFIAPI
-CoreAllocatePages (
+CoreInternalAllocatePages (
IN EFI_ALLOCATE_TYPE Type,
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN NumberOfPages,
@@ -1192,6 +1192,41 @@ Done:
return Status;
}
+/**
+ 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
+CoreAllocatePages (
+ IN EFI_ALLOCATE_TYPE Type,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN NumberOfPages,
+ OUT EFI_PHYSICAL_ADDRESS *Memory
+ )
+{
+ EFI_STATUS Status;
+
+ Status = CoreInternalAllocatePages (Type, MemoryType, NumberOfPages, Memory);
+ if (!EFI_ERROR (Status)) {
+ CoreUpdateProfile ((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0), MemoryProfileActionAllocatePages, MemoryType, EFI_PAGES_TO_SIZE (NumberOfPages), (VOID *) (UINTN) *Memory);
+ }
+ return Status;
+}
/**
Frees previous allocated pages.
@@ -1206,7 +1241,7 @@ Done:
**/
EFI_STATUS
EFIAPI
-CoreFreePages (
+CoreInternalFreePages (
IN EFI_PHYSICAL_ADDRESS Memory,
IN UINTN NumberOfPages
)
@@ -1268,6 +1303,33 @@ Done:
}
/**
+ 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
+CoreFreePages (
+ IN EFI_PHYSICAL_ADDRESS Memory,
+ IN UINTN NumberOfPages
+ )
+{
+ EFI_STATUS Status;
+
+ Status = CoreInternalFreePages (Memory, NumberOfPages);
+ if (!EFI_ERROR (Status)) {
+ CoreUpdateProfile ((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0), MemoryProfileActionFreePages, 0, EFI_PAGES_TO_SIZE (NumberOfPages), (VOID *) (UINTN) Memory);
+ }
+ return Status;
+}
+
+/**
This function checks to see if the last memory map descriptor in a memory map
can be merged with any of the other memory map descriptors in a memorymap.
Memory descriptors may be merged if they are adjacent and have the same type