From 6e10b70a62dee17d7913b20f5323c1e75bd13417 Mon Sep 17 00:00:00 2001 From: mdkinney Date: Sat, 9 May 2009 01:13:40 +0000 Subject: Clarify that FreePages(), FreeAlignedPages(), and FreePool() may perform n actions if those operations are not possible. For example, the PEI Phase does not provide any services to free allocated pages or allocated pool memory. Update comments in PeiMemoryAllocationLib and UefiMemoryAllocationLib to match updates to MemoryAllocationLib.h. Add ASSERT() statements in PeiMemoryAllocationLib for the FreePages() and FreeAlignedPages() if Pages is 0. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8275 6f19259b-4bc3-4df7-8a09-765794883524 --- MdePkg/Include/Library/MemoryAllocationLib.h | 9 ++++++--- MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c | 11 ++++++++--- MdePkg/Library/UefiMemoryAllocationLib/MemoryAllocationLib.c | 9 ++++++--- 3 files changed, 20 insertions(+), 9 deletions(-) (limited to 'MdePkg') diff --git a/MdePkg/Include/Library/MemoryAllocationLib.h b/MdePkg/Include/Library/MemoryAllocationLib.h index 74f7673cd7..8cc93f2bae 100644 --- a/MdePkg/Include/Library/MemoryAllocationLib.h +++ b/MdePkg/Include/Library/MemoryAllocationLib.h @@ -83,7 +83,8 @@ AllocateReservedPages ( 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 page allocation services of the Memory - Allocation Library. + Allocation Library. If it is not possible to free allocated pages, then this function will + peform no actions. If Buffer was not allocated with a page allocation function in the Memory Allocation Library, then ASSERT(). @@ -178,7 +179,8 @@ AllocateAlignedReservedPages ( 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. + Allocation Library. If it is not possible to free allocated pages, then this function will + peform no actions. If Buffer was not allocated with an aligned page allocation function in the Memory Allocation Library, then ASSERT(). @@ -470,7 +472,8 @@ ReallocateReservedPool ( Memory Allocation Library. Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the - pool allocation services of the Memory Allocation Library. + pool allocation services of the Memory Allocation Library. If it is not possible to free pool + resources, then this function will peform no actions. If Buffer was not allocated with a pool allocation function in the Memory Allocation Library, then ASSERT(). diff --git a/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c b/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c index f9e723ef2f..4e5f8fadd4 100644 --- a/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c +++ b/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c @@ -128,7 +128,8 @@ AllocateReservedPages ( 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 page allocation services of the Memory - Allocation Library. + Allocation Library. If it is not possible to free allocated pages, then this function will + peform no actions. If Buffer was not allocated with a page allocation function in the Memory Allocation Library, then ASSERT(). @@ -145,6 +146,7 @@ FreePages ( IN UINTN Pages ) { + ASSERT (Pages != 0); // // PEI phase does not support to free pages, so leave it as NOP. // @@ -288,7 +290,8 @@ AllocateAlignedReservedPages ( 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. + Allocation Library. If it is not possible to free allocated pages, then this function will + peform no actions. If Buffer was not allocated with an aligned page allocation function in the Memory Allocation Library, then ASSERT(). @@ -305,6 +308,7 @@ FreeAlignedPages ( IN UINTN Pages ) { + ASSERT (Pages != 0); // // PEI phase does not support to free pages, so leave it as NOP. // @@ -775,7 +779,8 @@ ReallocateReservedPool ( Memory Allocation Library. Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the - pool allocation services of the Memory Allocation Library. + pool allocation services of the Memory Allocation Library. If it is not possible to free pool + resources, then this function will peform no actions. If Buffer was not allocated with a pool allocation function in the Memory Allocation Library, then ASSERT(). diff --git a/MdePkg/Library/UefiMemoryAllocationLib/MemoryAllocationLib.c b/MdePkg/Library/UefiMemoryAllocationLib/MemoryAllocationLib.c index 2a9f128424..08bb2921ab 100644 --- a/MdePkg/Library/UefiMemoryAllocationLib/MemoryAllocationLib.c +++ b/MdePkg/Library/UefiMemoryAllocationLib/MemoryAllocationLib.c @@ -127,7 +127,8 @@ AllocateReservedPages ( 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 page allocation services of the Memory - Allocation Library. + Allocation Library. If it is not possible to free allocated pages, then this function will + peform no actions. If Buffer was not allocated with a page allocation function in the Memory Allocation Library, then ASSERT(). @@ -323,7 +324,8 @@ AllocateAlignedReservedPages ( 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. + Allocation Library. If it is not possible to free allocated pages, then this function will + peform no actions. If Buffer was not allocated with an aligned page allocation function in the Memory Allocation Library, then ASSERT(). @@ -792,7 +794,8 @@ ReallocateReservedPool ( Memory Allocation Library. Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the - pool allocation services of the Memory Allocation Library. + pool allocation services of the Memory Allocation Library. If it is not possible to free pool + resources, then this function will peform no actions. If Buffer was not allocated with a pool allocation function in the Memory Allocation Library, then ASSERT(). -- cgit v1.2.3