aboutsummaryrefslogtreecommitdiffstats
path: root/MdePkg/Library/PeiMemoryAllocationLib
diff options
context:
space:
mode:
Diffstat (limited to 'MdePkg/Library/PeiMemoryAllocationLib')
-rw-r--r--MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c310
-rw-r--r--MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf11
-rw-r--r--MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.uni7
3 files changed, 111 insertions, 217 deletions
diff --git a/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c b/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c
index bb67805f2e05..7ed72e6b75c2 100644
--- a/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c
+++ b/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c
@@ -1,15 +1,9 @@
/** @file
- Support routines for memory allocation routines
+ Support routines for memory allocation routines
based on PeiService for PEI phase drivers.
- Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -39,12 +33,12 @@
**/
VOID *
InternalAllocatePages (
- IN EFI_MEMORY_TYPE MemoryType,
+ IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages
)
{
EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS Memory;
+ EFI_PHYSICAL_ADDRESS Memory;
if (Pages == 0) {
return NULL;
@@ -132,11 +126,11 @@ AllocateReservedPages (
must have been allocated on a previous call to the 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 a page allocation function in the Memory Allocation Library,
then ASSERT().
If Pages is zero, then ASSERT().
-
+
@param Buffer The pointer to the buffer of pages to free.
@param Pages The number of 4 KB pages to free.
@@ -148,10 +142,11 @@ FreePages (
IN UINTN Pages
)
{
+ EFI_STATUS Status;
+
ASSERT (Pages != 0);
- //
- // PEI phase does not support to free pages, so leave it as NOP.
- //
+ Status = PeiServicesFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
+ ASSERT_EFI_ERROR (Status);
}
/**
@@ -166,7 +161,7 @@ FreePages (
@param MemoryType The type of memory to allocate.
@param Pages The number of 4 KB pages to allocate.
- @param Alignment The requested alignment of the allocation.
+ @param Alignment The requested alignment of the allocation.
Must be a power of two.
If Alignment is zero, then byte alignment is used.
@@ -175,20 +170,17 @@ FreePages (
**/
VOID *
InternalAllocateAlignedPages (
- IN EFI_MEMORY_TYPE MemoryType,
+ IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
IN UINTN Alignment
)
{
- EFI_PHYSICAL_ADDRESS Memory;
- EFI_PHYSICAL_ADDRESS AlignedMemory;
- EFI_PEI_HOB_POINTERS Hob;
- BOOLEAN SkipBeforeMemHob;
- BOOLEAN SkipAfterMemHob;
- EFI_PHYSICAL_ADDRESS HobBaseAddress;
- UINT64 HobLength;
- EFI_MEMORY_TYPE HobMemoryType;
- UINTN TotalPages;
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS Memory;
+ UINTN AlignedMemory;
+ UINTN AlignmentMask;
+ UINTN UnalignedPages;
+ UINTN RealPages;
//
// Alignment must be a power of two or zero.
@@ -198,139 +190,50 @@ InternalAllocateAlignedPages (
if (Pages == 0) {
return NULL;
}
- //
- // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
- //
- ASSERT (Pages <= (MAX_ADDRESS - EFI_SIZE_TO_PAGES (Alignment)));
-
- //
- // We would rather waste some memory to save PEI code size.
- // meaning in addition to the requested size for the aligned mem,
- // we simply reserve an overhead memory equal to Alignmemt(page-aligned), no matter what.
- // The overhead mem size could be reduced later with more involved malloc mechanisms
- // (e.g., somthing that can detect the alignment boundary before allocating memory or
- // can request that memory be allocated at a certain address that is aleady aligned).
- //
- TotalPages = Pages + (Alignment <= EFI_PAGE_SIZE ? 0 : EFI_SIZE_TO_PAGES(Alignment));
- Memory = (EFI_PHYSICAL_ADDRESS) (UINTN) InternalAllocatePages (MemoryType, TotalPages);
- if (Memory == 0) {
- DEBUG((DEBUG_INFO, "Out of memory resource! \n"));
- return NULL;
- }
- DEBUG ((DEBUG_INFO, "Allocated Memory unaligned: Address = 0x%LX, Pages = 0x%X, Type = %d \n", Memory, TotalPages, (UINTN) MemoryType));
-
- //
- // Alignment calculation
- //
- AlignedMemory = Memory;
if (Alignment > EFI_PAGE_SIZE) {
- AlignedMemory = ALIGN_VALUE (Memory, Alignment);
- }
- DEBUG ((DEBUG_INFO, "After aligning to 0x%X bytes: Address = 0x%LX, Pages = 0x%X \n", Alignment, AlignedMemory, Pages));
-
- //
- // In general three HOBs cover the total allocated space.
- // The aligned portion is covered by the aligned mem HOB and
- // the unaligned(to be freed) portions before and after the aligned portion are covered by newly created HOBs.
- //
- // Before mem HOB covers the region between "Memory" and "AlignedMemory"
- // Aligned mem HOB covers the region between "AlignedMemory" and "AlignedMemory + EFI_PAGES_TO_SIZE(Pages)"
- // After mem HOB covers the region between "AlignedMemory + EFI_PAGES_TO_SIZE(Pages)" and "Memory + EFI_PAGES_TO_SIZE(TotalPages)"
- //
- // The before or after mem HOBs need to be skipped under special cases where the aligned portion
- // touches either the top or bottom of the original allocated space.
- //
- SkipBeforeMemHob = FALSE;
- SkipAfterMemHob = FALSE;
- if (Memory == AlignedMemory) {
- SkipBeforeMemHob = TRUE;
- }
- if ((Memory + EFI_PAGES_TO_SIZE(TotalPages)) == (AlignedMemory + EFI_PAGES_TO_SIZE(Pages))) {
//
- // This condition is never met in the current implementation.
- // There is always some after-mem since the overhead mem(used in TotalPages)
- // is no less than Alignment.
+ // Calculate the total number of pages since alignment is larger than page size.
//
- SkipAfterMemHob = TRUE;
- }
-
- //
- // Search for the mem HOB referring to the original(unaligned) allocation
- // and update the size and type if needed.
- //
- Hob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
- while (Hob.Raw != NULL) {
- if (Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress == Memory) {
- break;
- }
- Hob.Raw = GET_NEXT_HOB (Hob);
- Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw);
- }
- ASSERT (Hob.Raw != NULL);
- if (SkipBeforeMemHob) {
+ AlignmentMask = Alignment - 1;
+ RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
//
- // Use this HOB as aligned mem HOB as there is no portion before it.
+ // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
//
- HobLength = EFI_PAGES_TO_SIZE(Pages);
- Hob.MemoryAllocation->AllocDescriptor.MemoryLength = HobLength;
+ ASSERT (RealPages > Pages);
+
+ Status = PeiServicesAllocatePages (MemoryType, RealPages, &Memory);
+ if (EFI_ERROR (Status)) {
+ return NULL;
+ }
+ AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;
+ UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN) Memory);
+ if (UnalignedPages > 0) {
+ //
+ // Free first unaligned page(s).
+ //
+ Status = PeiServicesFreePages (Memory, UnalignedPages);
+ ASSERT_EFI_ERROR (Status);
+ }
+ Memory = AlignedMemory + EFI_PAGES_TO_SIZE (Pages);
+ UnalignedPages = RealPages - Pages - UnalignedPages;
+ if (UnalignedPages > 0) {
+ //
+ // Free last unaligned page(s).
+ //
+ Status = PeiServicesFreePages (Memory, UnalignedPages);
+ ASSERT_EFI_ERROR (Status);
+ }
} else {
//
- // Use this HOB as before mem HOB and create a new HOB for the aligned portion
+ // Do not over-allocate pages in this case.
//
- HobLength = (AlignedMemory - Memory);
- Hob.MemoryAllocation->AllocDescriptor.MemoryLength = HobLength;
- Hob.MemoryAllocation->AllocDescriptor.MemoryType = EfiConventionalMemory;
- }
-
- HobBaseAddress = Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress;
- HobMemoryType = Hob.MemoryAllocation->AllocDescriptor.MemoryType;
-
- //
- // Build the aligned mem HOB if needed
- //
- if (!SkipBeforeMemHob) {
- DEBUG((DEBUG_INFO, "Updated before-mem HOB with BaseAddress = %LX, Length = %LX, MemoryType = %d \n",
- HobBaseAddress, HobLength, (UINTN) HobMemoryType));
-
- HobBaseAddress = AlignedMemory;
- HobLength = EFI_PAGES_TO_SIZE(Pages);
- HobMemoryType = MemoryType;
-
- BuildMemoryAllocationHob (
- HobBaseAddress,
- HobLength,
- HobMemoryType
- );
-
- DEBUG((DEBUG_INFO, "Created aligned-mem HOB with BaseAddress = %LX, Length = %LX, MemoryType = %d \n",
- HobBaseAddress, HobLength, (UINTN) HobMemoryType));
- } else {
- if (HobBaseAddress != 0) {
- DEBUG((DEBUG_INFO, "Updated aligned-mem HOB with BaseAddress = %LX, Length = %LX, MemoryType = %d \n",
- HobBaseAddress, HobLength, (UINTN) HobMemoryType));
+ Status = PeiServicesAllocatePages (MemoryType, Pages, &Memory);
+ if (EFI_ERROR (Status)) {
+ return NULL;
}
+ AlignedMemory = (UINTN) Memory;
}
-
-
- //
- // Build the after mem HOB if needed
- //
- if (!SkipAfterMemHob) {
- HobBaseAddress = AlignedMemory + EFI_PAGES_TO_SIZE(Pages);
- HobLength = (Memory + EFI_PAGES_TO_SIZE(TotalPages)) - (AlignedMemory + EFI_PAGES_TO_SIZE(Pages));
- HobMemoryType = EfiConventionalMemory;
-
- BuildMemoryAllocationHob (
- HobBaseAddress,
- HobLength,
- HobMemoryType
- );
-
- DEBUG((DEBUG_INFO, "Created after-mem HOB with BaseAddress = %LX, Length = %LX, MemoryType = %d \n",
- HobBaseAddress, HobLength, (UINTN) HobMemoryType));
- }
-
- return (VOID *) (UINTN) AlignedMemory;
+ return (VOID *) AlignedMemory;
}
/**
@@ -340,12 +243,12 @@ InternalAllocateAlignedPages (
alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
returned. If there is not enough memory at the specified alignment remaining to satisfy the
request, then NULL is returned.
-
+
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
@param Pages The number of 4 KB pages to allocate.
- @param Alignment The requested alignment of the allocation.
+ @param Alignment The requested alignment of the allocation.
Must be a power of two.
If Alignment is zero, then byte alignment is used.
@@ -369,12 +272,12 @@ AllocateAlignedPages (
alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
returned. If there is not enough memory at the specified alignment remaining to satisfy the
request, then NULL is returned.
-
+
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
@param Pages The number of 4 KB pages to allocate.
- @param Alignment The requested alignment of the allocation.
+ @param Alignment The requested alignment of the allocation.
Must be a power of two.
If Alignment is zero, then byte alignment is used.
@@ -398,12 +301,12 @@ AllocateAlignedRuntimePages (
alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
returned. If there is not enough memory at the specified alignment remaining to satisfy the
request, then NULL is returned.
-
+
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
@param Pages The number of 4 KB pages to allocate.
- @param Alignment The requested alignment of the allocation.
+ @param Alignment The requested alignment of the allocation.
Must be a power of two.
If Alignment is zero, then byte alignment is used.
@@ -426,13 +329,13 @@ 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. If it is not possible to free allocated pages, then this function will
+ 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 The pointer to the buffer of pages to free.
@param Pages The number of 4 KB pages to free.
@@ -444,10 +347,11 @@ FreeAlignedPages (
IN UINTN Pages
)
{
+ EFI_STATUS Status;
+
ASSERT (Pages != 0);
- //
- // PEI phase does not support to free pages, so leave it as NOP.
- //
+ Status = PeiServicesFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
+ ASSERT_EFI_ERROR (Status);
}
/**
@@ -465,14 +369,14 @@ FreeAlignedPages (
**/
VOID *
InternalAllocatePool (
- IN EFI_MEMORY_TYPE MemoryType,
+ IN EFI_MEMORY_TYPE MemoryType,
IN UINTN AllocationSize
)
{
//
- // If we need lots of small runtime/reserved memory type from PEI in the future,
- // we can consider providing a more complex algorithm that allocates runtime pages and
- // provide pool allocations from those pages.
+ // If we need lots of small runtime/reserved memory type from PEI in the future,
+ // we can consider providing a more complex algorithm that allocates runtime pages and
+ // provide pool allocations from those pages.
//
return InternalAllocatePages (MemoryType, EFI_SIZE_TO_PAGES (AllocationSize));
}
@@ -497,7 +401,7 @@ AllocatePool (
{
EFI_STATUS Status;
VOID *Buffer;
-
+
Status = PeiServicesAllocatePool (AllocationSize, &Buffer);
if (EFI_ERROR (Status)) {
Buffer = NULL;
@@ -563,9 +467,9 @@ AllocateReservedPool (
**/
VOID *
InternalAllocateZeroPool (
- IN EFI_MEMORY_TYPE PoolType,
+ IN EFI_MEMORY_TYPE PoolType,
IN UINTN AllocationSize
- )
+ )
{
VOID *Memory;
@@ -656,7 +560,7 @@ AllocateReservedZeroPool (
allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
is not enough memory remaining to satisfy the request, then NULL is returned.
If Buffer is NULL, then ASSERT().
- If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+ If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
@param PoolType The type of pool to allocate.
@param AllocationSize The number of bytes to allocate and zero.
@@ -667,10 +571,10 @@ AllocateReservedZeroPool (
**/
VOID *
InternalAllocateCopyPool (
- IN EFI_MEMORY_TYPE PoolType,
+ IN EFI_MEMORY_TYPE PoolType,
IN UINTN AllocationSize,
IN CONST VOID *Buffer
- )
+ )
{
VOID *Memory;
@@ -682,7 +586,7 @@ InternalAllocateCopyPool (
Memory = CopyMem (Memory, Buffer, AllocationSize);
}
return Memory;
-}
+}
/**
Copies a buffer to an allocated buffer of type EfiBootServicesData.
@@ -691,9 +595,9 @@ InternalAllocateCopyPool (
AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
is not enough memory remaining to satisfy the request, then NULL is returned.
-
+
If Buffer is NULL, then ASSERT().
- If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+ If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
@param AllocationSize The number of bytes to allocate and zero.
@param Buffer The buffer to copy to the allocated buffer.
@@ -727,9 +631,9 @@ AllocateCopyPool (
AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
is not enough memory remaining to satisfy the request, then NULL is returned.
-
+
If Buffer is NULL, then ASSERT().
- If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+ If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
@param AllocationSize The number of bytes to allocate and zero.
@param Buffer The buffer to copy to the allocated buffer.
@@ -754,9 +658,9 @@ AllocateRuntimeCopyPool (
AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
is not enough memory remaining to satisfy the request, then NULL is returned.
-
+
If Buffer is NULL, then ASSERT().
- If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+ If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
@param AllocationSize The number of bytes to allocate and zero.
@param Buffer The buffer to copy to the allocated buffer.
@@ -778,19 +682,19 @@ AllocateReservedCopyPool (
Reallocates a buffer of a specified memory type.
Allocates and zeros the number bytes specified by NewSize from memory of the type
- specified by PoolType. If OldBuffer is not NULL, then the smaller of OldSize and
- NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
- OldBuffer is freed. A pointer to the newly allocated buffer is returned.
- If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
+ specified by PoolType. If OldBuffer is not NULL, then the smaller of OldSize and
+ NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
+ OldBuffer is freed. A pointer to the newly allocated buffer is returned.
+ If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
enough memory remaining to satisfy the request, then NULL is returned.
-
+
If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
@param PoolType The type of pool to allocate.
@param OldSize The size, in bytes, of OldBuffer.
@param NewSize The size, in bytes, of the buffer to reallocate.
- @param OldBuffer The buffer to copy to the allocated buffer. This is an
+ @param OldBuffer The buffer to copy to the allocated buffer. This is an
optional parameter that may be NULL.
@return A pointer to the allocated buffer or NULL if allocation fails.
@@ -798,7 +702,7 @@ AllocateReservedCopyPool (
**/
VOID *
InternalReallocatePool (
- IN EFI_MEMORY_TYPE PoolType,
+ IN EFI_MEMORY_TYPE PoolType,
IN UINTN OldSize,
IN UINTN NewSize,
IN VOID *OldBuffer OPTIONAL
@@ -818,18 +722,18 @@ InternalReallocatePool (
Reallocates a buffer of type EfiBootServicesData.
Allocates and zeros the number bytes specified by NewSize from memory of type
- EfiBootServicesData. If OldBuffer is not NULL, then the smaller of OldSize and
- NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
- OldBuffer is freed. A pointer to the newly allocated buffer is returned.
- If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
+ EfiBootServicesData. If OldBuffer is not NULL, then the smaller of OldSize and
+ NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
+ OldBuffer is freed. A pointer to the newly allocated buffer is returned.
+ If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
enough memory remaining to satisfy the request, then NULL is returned.
-
+
If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
@param OldSize The size, in bytes, of OldBuffer.
@param NewSize The size, in bytes, of the buffer to reallocate.
- @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
+ @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
parameter that may be NULL.
@return A pointer to the allocated buffer or NULL if allocation fails.
@@ -850,10 +754,10 @@ ReallocatePool (
Reallocates a buffer of type EfiRuntimeServicesData.
Allocates and zeros the number bytes specified by NewSize from memory of type
- EfiRuntimeServicesData. If OldBuffer is not NULL, then the smaller of OldSize and
- NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
- OldBuffer is freed. A pointer to the newly allocated buffer is returned.
- If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
+ EfiRuntimeServicesData. If OldBuffer is not NULL, then the smaller of OldSize and
+ NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
+ OldBuffer is freed. A pointer to the newly allocated buffer is returned.
+ If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
enough memory remaining to satisfy the request, then NULL is returned.
If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
@@ -861,7 +765,7 @@ ReallocatePool (
@param OldSize The size, in bytes, of OldBuffer.
@param NewSize The size, in bytes, of the buffer to reallocate.
- @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
+ @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
parameter that may be NULL.
@return A pointer to the allocated buffer or NULL if allocation fails.
@@ -882,10 +786,10 @@ ReallocateRuntimePool (
Reallocates a buffer of type EfiReservedMemoryType.
Allocates and zeros the number bytes specified by NewSize from memory of type
- EfiReservedMemoryType. If OldBuffer is not NULL, then the smaller of OldSize and
- NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
- OldBuffer is freed. A pointer to the newly allocated buffer is returned.
- If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
+ EfiReservedMemoryType. If OldBuffer is not NULL, then the smaller of OldSize and
+ NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
+ OldBuffer is freed. A pointer to the newly allocated buffer is returned.
+ If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
enough memory remaining to satisfy the request, then NULL is returned.
If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
@@ -893,7 +797,7 @@ ReallocateRuntimePool (
@param OldSize The size, in bytes, of OldBuffer.
@param NewSize The size, in bytes, of the buffer to reallocate.
- @param OldBuffer The buffer to copy to the allocated buffer. This is an
+ @param OldBuffer The buffer to copy to the allocated buffer. This is an
optional parameter that may be NULL.
@return A pointer to the allocated buffer or NULL if allocation fails.
@@ -917,7 +821,7 @@ ReallocateReservedPool (
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. If it is not possible to free pool
resources, then this function will perform 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/PeiMemoryAllocationLib.inf b/MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
index 9f0ae450c13d..c7a17f186970 100644
--- a/MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
+++ b/MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
@@ -4,14 +4,9 @@
# Memory Allocation Library that uses PEI Services to allocate memory.
# Free operations are ignored.
#
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
-# This program and the accompanying materials
-# 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
-# http://opensource.org/licenses/bsd-license.php.
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
#
#
##
@@ -27,7 +22,7 @@
#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC (EBC is for build only)
+# VALID_ARCHITECTURES = IA32 X64 EBC (EBC is for build only)
#
[Sources]
diff --git a/MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.uni b/MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.uni
index 6f84d69cec2b..f492b6240a88 100644
--- a/MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.uni
+++ b/MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.uni
@@ -6,12 +6,7 @@
//
// Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
//
-// This program and the accompanying materials
-// 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
-// http://opensource.org/licenses/bsd-license.php.
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+// SPDX-License-Identifier: BSD-2-Clause-Patent
//
// **/