summaryrefslogtreecommitdiff
path: root/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
diff options
context:
space:
mode:
authorSami Mujawar <sami.mujawar@arm.com>2025-04-28 16:38:32 +0300
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2026-04-21 19:55:40 +0300
commitb5f11993237d547c2056fc6fb6ff917c6d6d9e0a (patch)
treea28420dfe9a3ac4e684a814a18f930ba1fdae3c7 /EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
parent691b92fe05cdea1f757ad7a71184f64f3841b6e3 (diff)
downloadedk2-b5f11993237d547c2056fc6fb6ff917c6d6d9e0a.tar.xz
EmbeddedPkg: Add missing FreeAlignedPages() implementation
The PrePiMemoryAllocationLib supports AllocateAlignedPages(), however is missing the corresponding FreeAlignedPages(). Although the FreeAlignedPages() in PrePiMemoryAllocationLib does not support the ability to free pages in the PrePei Memory Allocator and the allocated memory is lost, it would be good to have an empty implementation of FreeAlignedPages() so that implementations utilises the correct deallocation function. Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Diffstat (limited to 'EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c')
-rw-r--r--EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
index 5f66950636..fe96cd18cf 100644
--- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
+++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
@@ -282,6 +282,40 @@ FreePages (
}
/**
+ Frees one or more 4KB pages that were previously allocated with one of the aligned page
+ allocation functions in the Memory Allocation Library.
+
+ Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
+ must have been allocated on a previous call to the aligned page allocation services of the Memory
+ Allocation Library. If it is not possible to free allocated pages, then this function will
+ perform no actions.
+
+ If Buffer was not allocated with an aligned page allocation function in the Memory Allocation
+ Library, then ASSERT().
+ If Pages is zero, then ASSERT().
+
+ @param Buffer Pointer to the buffer of pages to free.
+ @param Pages The number of 4 KB pages to free.
+
+**/
+VOID
+EFIAPI
+FreeAlignedPages (
+ IN VOID *Buffer,
+ IN UINTN Pages
+ )
+{
+ ASSERT (ADDRESS_IS_ALIGNED (Buffer, EFI_PAGE_SIZE));
+ ASSERT (Pages != 0);
+ // For now, we do not support the ability to free pages in the PrePei Memory Allocator.
+ // The allocated memory is lost.
+ DEBUG ((
+ DEBUG_INFO,
+ "PrePei allocator cannot free pages; allocated memory is not reclaimed.\n"
+ ));
+}
+
+/**
Allocates a buffer of type EfiBootServicesData.
Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a