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
12 #include <Library/MemoryAllocationLib.h>
13 #include <Library/PeiServicesLib.h>
14 #include <Library/BaseMemoryLib.h>
15 #include <Library/DebugLib.h>
16 #include <Library/HobLib.h>
19 Allocates one or more 4KB pages of a certain memory type.
21 Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated
22 buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned.
23 If there is not enough memory remaining to satisfy the request, then NULL is returned.
25 @param MemoryType The type of memory to allocate.
26 @param Pages The number of 4 KB pages to allocate.
28 @return A pointer to the allocated buffer or NULL if allocation fails.
32 InternalAllocatePages (
33 IN EFI_MEMORY_TYPE MemoryType
,
38 EFI_PHYSICAL_ADDRESS Memory
;
44 Status
= PeiServicesAllocatePages (MemoryType
, Pages
, &Memory
);
45 if (EFI_ERROR (Status
)) {
49 return (VOID
*)(UINTN
)Memory
;
53 Allocates one or more 4KB pages of type EfiBootServicesData.
55 Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the
56 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
57 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
60 @param Pages The number of 4 KB pages to allocate.
62 @return A pointer to the allocated buffer or NULL if allocation fails.
71 return InternalAllocatePages (EfiBootServicesData
, Pages
);
75 Allocates one or more 4KB pages of type EfiRuntimeServicesData.
77 Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
78 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
79 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
82 @param Pages The number of 4 KB pages to allocate.
84 @return A pointer to the allocated buffer or NULL if allocation fails.
89 AllocateRuntimePages (
93 return InternalAllocatePages (EfiRuntimeServicesData
, Pages
);
97 Allocates one or more 4KB pages of type EfiReservedMemoryType.
99 Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the
100 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
101 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
104 @param Pages The number of 4 KB pages to allocate.
106 @return A pointer to the allocated buffer or NULL if allocation fails.
111 AllocateReservedPages (
115 return InternalAllocatePages (EfiReservedMemoryType
, Pages
);
119 Frees one or more 4KB pages that were previously allocated with one of the page allocation
120 functions in the Memory Allocation Library.
122 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
123 must have been allocated on a previous call to the page allocation services of the Memory
124 Allocation Library. If it is not possible to free allocated pages, then this function will
127 If Buffer was not allocated with a page allocation function in the Memory Allocation Library,
129 If Pages is zero, then ASSERT().
131 @param Buffer The pointer to the buffer of pages to free.
132 @param Pages The number of 4 KB pages to free.
145 Status
= PeiServicesFreePages ((EFI_PHYSICAL_ADDRESS
)(UINTN
)Buffer
, Pages
);
146 ASSERT_EFI_ERROR (Status
);
150 Allocates one or more 4KB pages of a certain memory type at a specified alignment.
152 Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment
153 specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned.
154 If there is not enough memory at the specified alignment remaining to satisfy the request, then
156 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
157 If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
159 @param MemoryType The type of memory to allocate.
160 @param Pages The number of 4 KB pages to allocate.
161 @param Alignment The requested alignment of the allocation.
162 Must be a power of two.
163 If Alignment is zero, then byte alignment is used.
165 @return A pointer to the allocated buffer or NULL if allocation fails.
169 InternalAllocateAlignedPages (
170 IN EFI_MEMORY_TYPE MemoryType
,
176 EFI_PHYSICAL_ADDRESS Memory
;
179 UINTN UnalignedPages
;
183 // Alignment must be a power of two or zero.
185 ASSERT ((Alignment
& (Alignment
- 1)) == 0);
191 if (Alignment
> EFI_PAGE_SIZE
) {
193 // Calculate the total number of pages since alignment is larger than page size.
195 AlignmentMask
= Alignment
- 1;
196 RealPages
= Pages
+ EFI_SIZE_TO_PAGES (Alignment
);
198 // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
200 ASSERT (RealPages
> Pages
);
202 Status
= PeiServicesAllocatePages (MemoryType
, RealPages
, &Memory
);
203 if (EFI_ERROR (Status
)) {
207 AlignedMemory
= ((UINTN
)Memory
+ AlignmentMask
) & ~AlignmentMask
;
208 UnalignedPages
= EFI_SIZE_TO_PAGES (AlignedMemory
- (UINTN
)Memory
);
209 if (UnalignedPages
> 0) {
211 // Free first unaligned page(s).
213 Status
= PeiServicesFreePages (Memory
, UnalignedPages
);
214 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
)) {
235 AlignedMemory
= (UINTN
)Memory
;
238 return (VOID
*)AlignedMemory
;
242 Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
244 Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an
245 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
246 returned. If there is not enough memory at the specified alignment remaining to satisfy the
247 request, then NULL is returned.
249 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
250 If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
252 @param Pages The number of 4 KB pages to allocate.
253 @param Alignment The requested alignment of the allocation.
254 Must be a power of two.
255 If Alignment is zero, then byte alignment is used.
257 @return A pointer to the allocated buffer or NULL if allocation fails.
262 AllocateAlignedPages (
267 return InternalAllocateAlignedPages (EfiBootServicesData
, Pages
, Alignment
);
271 Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.
273 Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an
274 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
275 returned. If there is not enough memory at the specified alignment remaining to satisfy the
276 request, then NULL is returned.
278 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
279 If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
281 @param Pages The number of 4 KB pages to allocate.
282 @param Alignment The requested alignment of the allocation.
283 Must be a power of two.
284 If Alignment is zero, then byte alignment is used.
286 @return A pointer to the allocated buffer or NULL if allocation fails.
291 AllocateAlignedRuntimePages (
296 return InternalAllocateAlignedPages (EfiRuntimeServicesData
, Pages
, Alignment
);
300 Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.
302 Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an
303 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
304 returned. If there is not enough memory at the specified alignment remaining to satisfy the
305 request, then NULL is returned.
307 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
308 If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
310 @param Pages The number of 4 KB pages to allocate.
311 @param Alignment The requested alignment of the allocation.
312 Must be a power of two.
313 If Alignment is zero, then byte alignment is used.
315 @return A pointer to the allocated buffer or NULL if allocation fails.
320 AllocateAlignedReservedPages (
325 return InternalAllocateAlignedPages (EfiReservedMemoryType
, Pages
, Alignment
);
329 Frees one or more 4KB pages that were previously allocated with one of the aligned page
330 allocation functions in the Memory Allocation Library.
332 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
333 must have been allocated on a previous call to the aligned page allocation services of the Memory
334 Allocation Library. If it is not possible to free allocated pages, then this function will
337 If Buffer was not allocated with an aligned page allocation function in the Memory Allocation
338 Library, then ASSERT().
339 If Pages is zero, then ASSERT().
341 @param Buffer The pointer to the buffer of pages to free.
342 @param Pages The number of 4 KB pages to free.
355 Status
= PeiServicesFreePages ((EFI_PHYSICAL_ADDRESS
)(UINTN
)Buffer
, Pages
);
356 ASSERT_EFI_ERROR (Status
);
360 Allocates a buffer of a certain pool type.
362 Allocates the number bytes specified by AllocationSize of a certain pool type and returns a
363 pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
364 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
366 @param MemoryType The type of memory to allocate.
367 @param AllocationSize The number of bytes to allocate.
369 @return A pointer to the allocated buffer or NULL if allocation fails.
373 InternalAllocatePool (
374 IN EFI_MEMORY_TYPE MemoryType
,
375 IN UINTN AllocationSize
379 // If we need lots of small runtime/reserved memory type from PEI in the future,
380 // we can consider providing a more complex algorithm that allocates runtime pages and
381 // provide pool allocations from those pages.
383 return InternalAllocatePages (MemoryType
, EFI_SIZE_TO_PAGES (AllocationSize
));
387 Allocates a buffer of type EfiBootServicesData.
389 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
390 pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
391 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
393 @param AllocationSize The number of bytes to allocate.
395 @return A pointer to the allocated buffer or NULL if allocation fails.
401 IN UINTN AllocationSize
407 Status
= PeiServicesAllocatePool (AllocationSize
, &Buffer
);
408 if (EFI_ERROR (Status
)) {
416 Allocates a buffer of type EfiRuntimeServicesData.
418 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns
419 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
420 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
422 @param AllocationSize The number of bytes to allocate.
424 @return A pointer to the allocated buffer or NULL if allocation fails.
429 AllocateRuntimePool (
430 IN UINTN AllocationSize
433 return InternalAllocatePool (EfiRuntimeServicesData
, AllocationSize
);
437 Allocates a buffer of type EfiReservedMemoryType.
439 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType and returns
440 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
441 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
443 @param AllocationSize The number of bytes to allocate.
445 @return A pointer to the allocated buffer or NULL if allocation fails.
450 AllocateReservedPool (
451 IN UINTN AllocationSize
454 return InternalAllocatePool (EfiReservedMemoryType
, AllocationSize
);
458 Allocates and zeros a buffer of a certain pool type.
460 Allocates the number bytes specified by AllocationSize of a certain pool type, clears the buffer
461 with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid
462 buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request,
463 then NULL is returned.
465 @param PoolType The type of memory to allocate.
466 @param AllocationSize The number of bytes to allocate and zero.
468 @return A pointer to the allocated buffer or NULL if allocation fails.
472 InternalAllocateZeroPool (
473 IN EFI_MEMORY_TYPE PoolType
,
474 IN UINTN AllocationSize
479 Memory
= InternalAllocatePool (PoolType
, AllocationSize
);
480 if (Memory
!= NULL
) {
481 Memory
= ZeroMem (Memory
, AllocationSize
);
488 Allocates and zeros a buffer of type EfiBootServicesData.
490 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
491 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
492 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
493 request, then NULL is returned.
495 @param AllocationSize The number of bytes to allocate and zero.
497 @return A pointer to the allocated buffer or NULL if allocation fails.
503 IN UINTN AllocationSize
508 Memory
= AllocatePool (AllocationSize
);
509 if (Memory
!= NULL
) {
510 Memory
= ZeroMem (Memory
, AllocationSize
);
517 Allocates and zeros a buffer of type EfiRuntimeServicesData.
519 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the
520 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
521 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
522 request, then NULL is returned.
524 @param AllocationSize The number of bytes to allocate and zero.
526 @return A pointer to the allocated buffer or NULL if allocation fails.
531 AllocateRuntimeZeroPool (
532 IN UINTN AllocationSize
535 return InternalAllocateZeroPool (EfiRuntimeServicesData
, AllocationSize
);
539 Allocates and zeros a buffer of type EfiReservedMemoryType.
541 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the
542 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
543 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
544 request, then NULL is returned.
546 @param AllocationSize The number of bytes to allocate and zero.
548 @return A pointer to the allocated buffer or NULL if allocation fails.
553 AllocateReservedZeroPool (
554 IN UINTN AllocationSize
557 return InternalAllocateZeroPool (EfiReservedMemoryType
, AllocationSize
);
561 Copies a buffer to an allocated buffer of a certain pool type.
563 Allocates the number bytes specified by AllocationSize of a certain pool type, copies
564 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
565 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
566 is not enough memory remaining to satisfy the request, then NULL is returned.
567 If Buffer is NULL, then ASSERT().
568 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
570 @param PoolType The type of pool to allocate.
571 @param AllocationSize The number of bytes to allocate and zero.
572 @param Buffer The buffer to copy to the allocated buffer.
574 @return A pointer to the allocated buffer or NULL if allocation fails.
578 InternalAllocateCopyPool (
579 IN EFI_MEMORY_TYPE PoolType
,
580 IN UINTN AllocationSize
,
581 IN CONST VOID
*Buffer
586 ASSERT (Buffer
!= NULL
);
587 ASSERT (AllocationSize
<= (MAX_ADDRESS
- (UINTN
)Buffer
+ 1));
589 Memory
= InternalAllocatePool (PoolType
, AllocationSize
);
590 if (Memory
!= NULL
) {
591 Memory
= CopyMem (Memory
, Buffer
, AllocationSize
);
598 Copies a buffer to an allocated buffer of type EfiBootServicesData.
600 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies
601 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
602 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
603 is not enough memory remaining to satisfy the request, then NULL is returned.
605 If Buffer is NULL, then ASSERT().
606 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
608 @param AllocationSize The number of bytes to allocate and zero.
609 @param Buffer The buffer to copy to the allocated buffer.
611 @return A pointer to the allocated buffer or NULL if allocation fails.
617 IN UINTN AllocationSize
,
618 IN CONST VOID
*Buffer
623 ASSERT (Buffer
!= NULL
);
624 ASSERT (AllocationSize
<= (MAX_ADDRESS
- (UINTN
)Buffer
+ 1));
626 Memory
= AllocatePool (AllocationSize
);
627 if (Memory
!= NULL
) {
628 Memory
= CopyMem (Memory
, Buffer
, AllocationSize
);
635 Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.
637 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies
638 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
639 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
640 is not enough memory remaining to satisfy the request, then NULL is returned.
642 If Buffer is NULL, then ASSERT().
643 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
645 @param AllocationSize The number of bytes to allocate and zero.
646 @param Buffer The buffer to copy to the allocated buffer.
648 @return A pointer to the allocated buffer or NULL if allocation fails.
653 AllocateRuntimeCopyPool (
654 IN UINTN AllocationSize
,
655 IN CONST VOID
*Buffer
658 return InternalAllocateCopyPool (EfiRuntimeServicesData
, AllocationSize
, Buffer
);
662 Copies a buffer to an allocated buffer of type EfiReservedMemoryType.
664 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies
665 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
666 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
667 is not enough memory remaining to satisfy the request, then NULL is returned.
669 If Buffer is NULL, then ASSERT().
670 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
672 @param AllocationSize The number of bytes to allocate and zero.
673 @param Buffer The buffer to copy to the allocated buffer.
675 @return A pointer to the allocated buffer or NULL if allocation fails.
680 AllocateReservedCopyPool (
681 IN UINTN AllocationSize
,
682 IN CONST VOID
*Buffer
685 return InternalAllocateCopyPool (EfiReservedMemoryType
, AllocationSize
, Buffer
);
689 Reallocates a buffer of a specified memory type.
691 Allocates and zeros the number bytes specified by NewSize from memory of the type
692 specified by PoolType. If OldBuffer is not NULL, then the smaller of OldSize and
693 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
694 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
695 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
696 enough memory remaining to satisfy the request, then NULL is returned.
698 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
699 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
701 @param PoolType The type of pool to allocate.
702 @param OldSize The size, in bytes, of OldBuffer.
703 @param NewSize The size, in bytes, of the buffer to reallocate.
704 @param OldBuffer The buffer to copy to the allocated buffer. This is an
705 optional parameter that may be NULL.
707 @return A pointer to the allocated buffer or NULL if allocation fails.
711 InternalReallocatePool (
712 IN EFI_MEMORY_TYPE PoolType
,
715 IN VOID
*OldBuffer OPTIONAL
720 NewBuffer
= InternalAllocateZeroPool (PoolType
, NewSize
);
721 if ((NewBuffer
!= NULL
) && (OldBuffer
!= NULL
)) {
722 CopyMem (NewBuffer
, OldBuffer
, MIN (OldSize
, NewSize
));
723 FreePool (OldBuffer
);
730 Reallocates a buffer of type EfiBootServicesData.
732 Allocates and zeros the number bytes specified by NewSize from memory of type
733 EfiBootServicesData. If OldBuffer is not NULL, then the smaller of OldSize and
734 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
735 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
736 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
737 enough memory remaining to satisfy the request, then NULL is returned.
739 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
740 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
742 @param OldSize The size, in bytes, of OldBuffer.
743 @param NewSize The size, in bytes, of the buffer to reallocate.
744 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
745 parameter that may be NULL.
747 @return A pointer to the allocated buffer or NULL if allocation fails.
755 IN VOID
*OldBuffer OPTIONAL
758 return InternalReallocatePool (EfiBootServicesData
, OldSize
, NewSize
, OldBuffer
);
762 Reallocates a buffer of type EfiRuntimeServicesData.
764 Allocates and zeros the number bytes specified by NewSize from memory of type
765 EfiRuntimeServicesData. If OldBuffer is not NULL, then the smaller of OldSize and
766 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
767 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
768 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
769 enough memory remaining to satisfy the request, then NULL is returned.
771 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
772 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
774 @param OldSize The size, in bytes, of OldBuffer.
775 @param NewSize The size, in bytes, of the buffer to reallocate.
776 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
777 parameter that may be NULL.
779 @return A pointer to the allocated buffer or NULL if allocation fails.
784 ReallocateRuntimePool (
787 IN VOID
*OldBuffer OPTIONAL
790 return InternalReallocatePool (EfiRuntimeServicesData
, OldSize
, NewSize
, OldBuffer
);
794 Reallocates a buffer of type EfiReservedMemoryType.
796 Allocates and zeros the number bytes specified by NewSize from memory of type
797 EfiReservedMemoryType. If OldBuffer is not NULL, then the smaller of OldSize and
798 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
799 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
800 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
801 enough memory remaining to satisfy the request, then NULL is returned.
803 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
804 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
806 @param OldSize The size, in bytes, of OldBuffer.
807 @param NewSize The size, in bytes, of the buffer to reallocate.
808 @param OldBuffer The buffer to copy to the allocated buffer. This is an
809 optional parameter that may be NULL.
811 @return A pointer to the allocated buffer or NULL if allocation fails.
816 ReallocateReservedPool (
819 IN VOID
*OldBuffer OPTIONAL
822 return InternalReallocatePool (EfiReservedMemoryType
, OldSize
, NewSize
, OldBuffer
);
826 Frees a buffer that was previously allocated with one of the pool allocation functions in the
827 Memory Allocation Library.
829 Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
830 pool allocation services of the Memory Allocation Library. If it is not possible to free pool
831 resources, then this function will perform no actions.
833 If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
836 @param Buffer The pointer to the buffer to free.
846 // PEI phase does not support to free pool, so leave it as NOP.