2 Support routines for memory allocation routines
3 based on PeiService for PEI phase drivers.
5 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
14 #include <Library/MemoryAllocationLib.h>
15 #include <Library/PeiServicesLib.h>
16 #include <Library/BaseMemoryLib.h>
17 #include <Library/DebugLib.h>
18 #include <Library/HobLib.h>
22 Allocates one or more 4KB pages of a certain memory type.
24 Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated
25 buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned.
26 If there is not enough memory remaining to satisfy the request, then NULL is returned.
28 @param MemoryType The type of memory to allocate.
29 @param Pages The number of 4 KB pages to allocate.
31 @return A pointer to the allocated buffer or NULL if allocation fails.
35 InternalAllocatePages (
36 IN EFI_MEMORY_TYPE MemoryType
,
41 EFI_PHYSICAL_ADDRESS Memory
;
47 Status
= PeiServicesAllocatePages (MemoryType
, Pages
, &Memory
);
48 if (EFI_ERROR (Status
)) {
52 return (VOID
*) (UINTN
) Memory
;
56 Allocates one or more 4KB pages of type EfiBootServicesData.
58 Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the
59 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
60 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
63 @param Pages The number of 4 KB pages to allocate.
65 @return A pointer to the allocated buffer or NULL if allocation fails.
74 return InternalAllocatePages (EfiBootServicesData
, Pages
);
78 Allocates one or more 4KB pages of type EfiRuntimeServicesData.
80 Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
81 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
82 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
85 @param Pages The number of 4 KB pages to allocate.
87 @return A pointer to the allocated buffer or NULL if allocation fails.
92 AllocateRuntimePages (
96 return InternalAllocatePages (EfiRuntimeServicesData
, Pages
);
100 Allocates one or more 4KB pages of type EfiReservedMemoryType.
102 Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the
103 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
104 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
107 @param Pages The number of 4 KB pages to allocate.
109 @return A pointer to the allocated buffer or NULL if allocation fails.
114 AllocateReservedPages (
118 return InternalAllocatePages (EfiReservedMemoryType
, Pages
);
122 Frees one or more 4KB pages that were previously allocated with one of the page allocation
123 functions in the Memory Allocation Library.
125 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
126 must have been allocated on a previous call to the page allocation services of the Memory
127 Allocation Library. If it is not possible to free allocated pages, then this function will
130 If Buffer was not allocated with a page allocation function in the Memory Allocation Library,
132 If Pages is zero, then ASSERT().
134 @param Buffer The pointer to the buffer of pages to free.
135 @param Pages The number of 4 KB pages to free.
148 Status
= PeiServicesFreePages ((EFI_PHYSICAL_ADDRESS
) (UINTN
) Buffer
, Pages
);
149 ASSERT_EFI_ERROR (Status
);
153 Allocates one or more 4KB pages of a certain memory type at a specified alignment.
155 Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment
156 specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned.
157 If there is not enough memory at the specified alignment remaining to satisfy the request, then
159 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
160 If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
162 @param MemoryType The type of memory to allocate.
163 @param Pages The number of 4 KB pages to allocate.
164 @param Alignment The requested alignment of the allocation.
165 Must be a power of two.
166 If Alignment is zero, then byte alignment is used.
168 @return A pointer to the allocated buffer or NULL if allocation fails.
172 InternalAllocateAlignedPages (
173 IN EFI_MEMORY_TYPE MemoryType
,
179 EFI_PHYSICAL_ADDRESS Memory
;
182 UINTN UnalignedPages
;
186 // Alignment must be a power of two or zero.
188 ASSERT ((Alignment
& (Alignment
- 1)) == 0);
193 if (Alignment
> EFI_PAGE_SIZE
) {
195 // Calculate the total number of pages since alignment is larger than page size.
197 AlignmentMask
= Alignment
- 1;
198 RealPages
= Pages
+ EFI_SIZE_TO_PAGES (Alignment
);
200 // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
202 ASSERT (RealPages
> Pages
);
204 Status
= PeiServicesAllocatePages (MemoryType
, RealPages
, &Memory
);
205 if (EFI_ERROR (Status
)) {
208 AlignedMemory
= ((UINTN
) Memory
+ AlignmentMask
) & ~AlignmentMask
;
209 UnalignedPages
= EFI_SIZE_TO_PAGES (AlignedMemory
- (UINTN
) Memory
);
210 if (UnalignedPages
> 0) {
212 // Free first unaligned page(s).
214 Status
= PeiServicesFreePages (Memory
, UnalignedPages
);
215 ASSERT_EFI_ERROR (Status
);
217 Memory
= AlignedMemory
+ EFI_PAGES_TO_SIZE (Pages
);
218 UnalignedPages
= RealPages
- Pages
- UnalignedPages
;
219 if (UnalignedPages
> 0) {
221 // Free last unaligned page(s).
223 Status
= PeiServicesFreePages (Memory
, UnalignedPages
);
224 ASSERT_EFI_ERROR (Status
);
228 // Do not over-allocate pages in this case.
230 Status
= PeiServicesAllocatePages (MemoryType
, Pages
, &Memory
);
231 if (EFI_ERROR (Status
)) {
234 AlignedMemory
= (UINTN
) Memory
;
236 return (VOID
*) AlignedMemory
;
240 Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
242 Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an
243 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
244 returned. If there is not enough memory at the specified alignment remaining to satisfy the
245 request, then NULL is returned.
247 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
248 If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
250 @param Pages The number of 4 KB pages to allocate.
251 @param Alignment The requested alignment of the allocation.
252 Must be a power of two.
253 If Alignment is zero, then byte alignment is used.
255 @return A pointer to the allocated buffer or NULL if allocation fails.
260 AllocateAlignedPages (
265 return InternalAllocateAlignedPages (EfiBootServicesData
, Pages
, Alignment
);
269 Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.
271 Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an
272 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
273 returned. If there is not enough memory at the specified alignment remaining to satisfy the
274 request, then NULL is returned.
276 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
277 If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
279 @param Pages The number of 4 KB pages to allocate.
280 @param Alignment The requested alignment of the allocation.
281 Must be a power of two.
282 If Alignment is zero, then byte alignment is used.
284 @return A pointer to the allocated buffer or NULL if allocation fails.
289 AllocateAlignedRuntimePages (
294 return InternalAllocateAlignedPages (EfiRuntimeServicesData
, Pages
, Alignment
);
298 Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.
300 Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an
301 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
302 returned. If there is not enough memory at the specified alignment remaining to satisfy the
303 request, then NULL is returned.
305 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
306 If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
308 @param Pages The number of 4 KB pages to allocate.
309 @param Alignment The requested alignment of the allocation.
310 Must be a power of two.
311 If Alignment is zero, then byte alignment is used.
313 @return A pointer to the allocated buffer or NULL if allocation fails.
318 AllocateAlignedReservedPages (
323 return InternalAllocateAlignedPages (EfiReservedMemoryType
, Pages
, Alignment
);
327 Frees one or more 4KB pages that were previously allocated with one of the aligned page
328 allocation functions in the Memory Allocation Library.
330 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
331 must have been allocated on a previous call to the aligned page allocation services of the Memory
332 Allocation Library. If it is not possible to free allocated pages, then this function will
335 If Buffer was not allocated with an aligned page allocation function in the Memory Allocation
336 Library, then ASSERT().
337 If Pages is zero, then ASSERT().
339 @param Buffer The pointer to the buffer of pages to free.
340 @param Pages The number of 4 KB pages to free.
353 Status
= PeiServicesFreePages ((EFI_PHYSICAL_ADDRESS
) (UINTN
) Buffer
, Pages
);
354 ASSERT_EFI_ERROR (Status
);
358 Allocates a buffer of a certain pool type.
360 Allocates the number bytes specified by AllocationSize of a certain pool type and returns a
361 pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
362 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
364 @param MemoryType The type of memory to allocate.
365 @param AllocationSize The number of bytes to allocate.
367 @return A pointer to the allocated buffer or NULL if allocation fails.
371 InternalAllocatePool (
372 IN EFI_MEMORY_TYPE MemoryType
,
373 IN UINTN AllocationSize
377 // If we need lots of small runtime/reserved memory type from PEI in the future,
378 // we can consider providing a more complex algorithm that allocates runtime pages and
379 // provide pool allocations from those pages.
381 return InternalAllocatePages (MemoryType
, EFI_SIZE_TO_PAGES (AllocationSize
));
385 Allocates a buffer of type EfiBootServicesData.
387 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
388 pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
389 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
391 @param AllocationSize The number of bytes to allocate.
393 @return A pointer to the allocated buffer or NULL if allocation fails.
399 IN UINTN AllocationSize
405 Status
= PeiServicesAllocatePool (AllocationSize
, &Buffer
);
406 if (EFI_ERROR (Status
)) {
413 Allocates a buffer of type EfiRuntimeServicesData.
415 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns
416 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
417 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
419 @param AllocationSize The number of bytes to allocate.
421 @return A pointer to the allocated buffer or NULL if allocation fails.
426 AllocateRuntimePool (
427 IN UINTN AllocationSize
430 return InternalAllocatePool (EfiRuntimeServicesData
, AllocationSize
);
434 Allocates a buffer of type EfiReservedMemoryType.
436 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType and returns
437 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
438 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
440 @param AllocationSize The number of bytes to allocate.
442 @return A pointer to the allocated buffer or NULL if allocation fails.
447 AllocateReservedPool (
448 IN UINTN AllocationSize
451 return InternalAllocatePool (EfiReservedMemoryType
, AllocationSize
);
455 Allocates and zeros a buffer of a certain pool type.
457 Allocates the number bytes specified by AllocationSize of a certain pool type, clears the buffer
458 with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid
459 buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request,
460 then NULL is returned.
462 @param PoolType The type of memory to allocate.
463 @param AllocationSize The number of bytes to allocate and zero.
465 @return A pointer to the allocated buffer or NULL if allocation fails.
469 InternalAllocateZeroPool (
470 IN EFI_MEMORY_TYPE PoolType
,
471 IN UINTN AllocationSize
476 Memory
= InternalAllocatePool (PoolType
, AllocationSize
);
477 if (Memory
!= NULL
) {
478 Memory
= ZeroMem (Memory
, AllocationSize
);
484 Allocates and zeros a buffer of type EfiBootServicesData.
486 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
487 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
488 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
489 request, then NULL is returned.
491 @param AllocationSize The number of bytes to allocate and zero.
493 @return A pointer to the allocated buffer or NULL if allocation fails.
499 IN UINTN AllocationSize
504 Memory
= AllocatePool (AllocationSize
);
505 if (Memory
!= NULL
) {
506 Memory
= ZeroMem (Memory
, AllocationSize
);
512 Allocates and zeros a buffer of type EfiRuntimeServicesData.
514 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the
515 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
516 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
517 request, then NULL is returned.
519 @param AllocationSize The number of bytes to allocate and zero.
521 @return A pointer to the allocated buffer or NULL if allocation fails.
526 AllocateRuntimeZeroPool (
527 IN UINTN AllocationSize
530 return InternalAllocateZeroPool (EfiRuntimeServicesData
, AllocationSize
);
534 Allocates and zeros a buffer of type EfiReservedMemoryType.
536 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the
537 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
538 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
539 request, then NULL is returned.
541 @param AllocationSize The number of bytes to allocate and zero.
543 @return A pointer to the allocated buffer or NULL if allocation fails.
548 AllocateReservedZeroPool (
549 IN UINTN AllocationSize
552 return InternalAllocateZeroPool (EfiReservedMemoryType
, AllocationSize
);
556 Copies a buffer to an allocated buffer of a certain pool type.
558 Allocates the number bytes specified by AllocationSize of a certain pool type, copies
559 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
560 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
561 is not enough memory remaining to satisfy the request, then NULL is returned.
562 If Buffer is NULL, then ASSERT().
563 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
565 @param PoolType The type of pool to allocate.
566 @param AllocationSize The number of bytes to allocate and zero.
567 @param Buffer The buffer to copy to the allocated buffer.
569 @return A pointer to the allocated buffer or NULL if allocation fails.
573 InternalAllocateCopyPool (
574 IN EFI_MEMORY_TYPE PoolType
,
575 IN UINTN AllocationSize
,
576 IN CONST VOID
*Buffer
581 ASSERT (Buffer
!= NULL
);
582 ASSERT (AllocationSize
<= (MAX_ADDRESS
- (UINTN
) Buffer
+ 1));
584 Memory
= InternalAllocatePool (PoolType
, AllocationSize
);
585 if (Memory
!= NULL
) {
586 Memory
= CopyMem (Memory
, Buffer
, AllocationSize
);
592 Copies a buffer to an allocated buffer of type EfiBootServicesData.
594 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies
595 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
596 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
597 is not enough memory remaining to satisfy the request, then NULL is returned.
599 If Buffer is NULL, then ASSERT().
600 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
602 @param AllocationSize The number of bytes to allocate and zero.
603 @param Buffer The buffer to copy to the allocated buffer.
605 @return A pointer to the allocated buffer or NULL if allocation fails.
611 IN UINTN AllocationSize
,
612 IN CONST VOID
*Buffer
617 ASSERT (Buffer
!= NULL
);
618 ASSERT (AllocationSize
<= (MAX_ADDRESS
- (UINTN
) Buffer
+ 1));
620 Memory
= AllocatePool (AllocationSize
);
621 if (Memory
!= NULL
) {
622 Memory
= CopyMem (Memory
, Buffer
, AllocationSize
);
628 Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.
630 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies
631 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
632 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
633 is not enough memory remaining to satisfy the request, then NULL is returned.
635 If Buffer is NULL, then ASSERT().
636 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
638 @param AllocationSize The number of bytes to allocate and zero.
639 @param Buffer The buffer to copy to the allocated buffer.
641 @return A pointer to the allocated buffer or NULL if allocation fails.
646 AllocateRuntimeCopyPool (
647 IN UINTN AllocationSize
,
648 IN CONST VOID
*Buffer
651 return InternalAllocateCopyPool (EfiRuntimeServicesData
, AllocationSize
, Buffer
);
655 Copies a buffer to an allocated buffer of type EfiReservedMemoryType.
657 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies
658 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
659 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
660 is not enough memory remaining to satisfy the request, then NULL is returned.
662 If Buffer is NULL, then ASSERT().
663 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
665 @param AllocationSize The number of bytes to allocate and zero.
666 @param Buffer The buffer to copy to the allocated buffer.
668 @return A pointer to the allocated buffer or NULL if allocation fails.
673 AllocateReservedCopyPool (
674 IN UINTN AllocationSize
,
675 IN CONST VOID
*Buffer
678 return InternalAllocateCopyPool (EfiReservedMemoryType
, AllocationSize
, Buffer
);
682 Reallocates a buffer of a specified memory type.
684 Allocates and zeros the number bytes specified by NewSize from memory of the type
685 specified by PoolType. If OldBuffer is not NULL, then the smaller of OldSize and
686 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
687 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
688 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
689 enough memory remaining to satisfy the request, then NULL is returned.
691 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
692 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
694 @param PoolType The type of pool to allocate.
695 @param OldSize The size, in bytes, of OldBuffer.
696 @param NewSize The size, in bytes, of the buffer to reallocate.
697 @param OldBuffer The buffer to copy to the allocated buffer. This is an
698 optional parameter that may be NULL.
700 @return A pointer to the allocated buffer or NULL if allocation fails.
704 InternalReallocatePool (
705 IN EFI_MEMORY_TYPE PoolType
,
708 IN VOID
*OldBuffer OPTIONAL
713 NewBuffer
= InternalAllocateZeroPool (PoolType
, NewSize
);
714 if (NewBuffer
!= NULL
&& OldBuffer
!= NULL
) {
715 CopyMem (NewBuffer
, OldBuffer
, MIN (OldSize
, NewSize
));
716 FreePool (OldBuffer
);
722 Reallocates a buffer of type EfiBootServicesData.
724 Allocates and zeros the number bytes specified by NewSize from memory of type
725 EfiBootServicesData. If OldBuffer is not NULL, then the smaller of OldSize and
726 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
727 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
728 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
729 enough memory remaining to satisfy the request, then NULL is returned.
731 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
732 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
734 @param OldSize The size, in bytes, of OldBuffer.
735 @param NewSize The size, in bytes, of the buffer to reallocate.
736 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
737 parameter that may be NULL.
739 @return A pointer to the allocated buffer or NULL if allocation fails.
747 IN VOID
*OldBuffer OPTIONAL
750 return InternalReallocatePool (EfiBootServicesData
, OldSize
, NewSize
, OldBuffer
);
754 Reallocates a buffer of type EfiRuntimeServicesData.
756 Allocates and zeros the number bytes specified by NewSize from memory of type
757 EfiRuntimeServicesData. If OldBuffer is not NULL, then the smaller of OldSize and
758 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
759 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
760 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
761 enough memory remaining to satisfy the request, then NULL is returned.
763 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
764 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
766 @param OldSize The size, in bytes, of OldBuffer.
767 @param NewSize The size, in bytes, of the buffer to reallocate.
768 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
769 parameter that may be NULL.
771 @return A pointer to the allocated buffer or NULL if allocation fails.
776 ReallocateRuntimePool (
779 IN VOID
*OldBuffer OPTIONAL
782 return InternalReallocatePool (EfiRuntimeServicesData
, OldSize
, NewSize
, OldBuffer
);
786 Reallocates a buffer of type EfiReservedMemoryType.
788 Allocates and zeros the number bytes specified by NewSize from memory of type
789 EfiReservedMemoryType. If OldBuffer is not NULL, then the smaller of OldSize and
790 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
791 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
792 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
793 enough memory remaining to satisfy the request, then NULL is returned.
795 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
796 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
798 @param OldSize The size, in bytes, of OldBuffer.
799 @param NewSize The size, in bytes, of the buffer to reallocate.
800 @param OldBuffer The buffer to copy to the allocated buffer. This is an
801 optional parameter that may be NULL.
803 @return A pointer to the allocated buffer or NULL if allocation fails.
808 ReallocateReservedPool (
811 IN VOID
*OldBuffer OPTIONAL
814 return InternalReallocatePool (EfiReservedMemoryType
, OldSize
, NewSize
, OldBuffer
);
818 Frees a buffer that was previously allocated with one of the pool allocation functions in the
819 Memory Allocation Library.
821 Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
822 pool allocation services of the Memory Allocation Library. If it is not possible to free pool
823 resources, then this function will perform no actions.
825 If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
828 @param Buffer The pointer to the buffer to free.
838 // PEI phase does not support to free pool, so leave it as NOP.