2 Support routines for memory allocation routines based
3 on boot services for Dxe phase drivers.
5 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 #include <Library/MemoryAllocationLib.h>
21 #include <Library/UefiBootServicesTableLib.h>
22 #include <Library/BaseMemoryLib.h>
23 #include <Library/DebugLib.h>
26 Allocates one or more 4KB pages of a certain memory type.
28 Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated
29 buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned.
30 If there is not enough memory remaining to satisfy the request, then NULL is returned.
32 @param MemoryType The type of memory to allocate.
33 @param Pages The number of 4 KB pages to allocate.
35 @return A pointer to the allocated buffer or NULL if allocation fails.
39 InternalAllocatePages (
40 IN EFI_MEMORY_TYPE MemoryType
,
45 EFI_PHYSICAL_ADDRESS Memory
;
51 Status
= gBS
->AllocatePages (AllocateAnyPages
, MemoryType
, Pages
, &Memory
);
52 if (EFI_ERROR (Status
)) {
55 return (VOID
*) (UINTN
) Memory
;
59 Allocates one or more 4KB pages of type EfiBootServicesData.
61 Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the
62 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
63 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
66 @param Pages The number of 4 KB pages to allocate.
68 @return A pointer to the allocated buffer or NULL if allocation fails.
77 return InternalAllocatePages (EfiBootServicesData
, Pages
);
81 Allocates one or more 4KB pages of type EfiRuntimeServicesData.
83 Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
84 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
85 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
88 @param Pages The number of 4 KB pages to allocate.
90 @return A pointer to the allocated buffer or NULL if allocation fails.
95 AllocateRuntimePages (
99 return InternalAllocatePages (EfiRuntimeServicesData
, Pages
);
103 Allocates one or more 4KB pages of type EfiReservedMemoryType.
105 Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the
106 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
107 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
110 @param Pages The number of 4 KB pages to allocate.
112 @return A pointer to the allocated buffer or NULL if allocation fails.
117 AllocateReservedPages (
121 return InternalAllocatePages (EfiReservedMemoryType
, Pages
);
125 Frees one or more 4KB pages that were previously allocated with one of the page allocation
126 functions in the Memory Allocation Library.
128 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
129 must have been allocated on a previous call to the page allocation services of the Memory
130 Allocation Library. If it is not possible to free allocated pages, then this function will
133 If Buffer was not allocated with a page allocation function in the Memory Allocation Library,
135 If Pages is zero, then ASSERT().
137 @param Buffer The pointer to the buffer of pages to free.
138 @param Pages The number of 4 KB pages to free.
151 Status
= gBS
->FreePages ((EFI_PHYSICAL_ADDRESS
) (UINTN
) Buffer
, Pages
);
152 ASSERT_EFI_ERROR (Status
);
156 Allocates one or more 4KB pages of a certain memory type at a specified alignment.
158 Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment
159 specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned.
160 If there is not enough memory at the specified alignment remaining to satisfy the request, then
162 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
163 If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
165 @param MemoryType The type of memory to allocate.
166 @param Pages The number of 4 KB pages to allocate.
167 @param Alignment The requested alignment of the allocation. Must be a power of two.
168 If Alignment is zero, then byte alignment is used.
170 @return A pointer to the allocated buffer or NULL if allocation fails.
174 InternalAllocateAlignedPages (
175 IN EFI_MEMORY_TYPE MemoryType
,
181 EFI_PHYSICAL_ADDRESS Memory
;
184 UINTN UnalignedPages
;
188 // Alignment must be a power of two or zero.
190 ASSERT ((Alignment
& (Alignment
- 1)) == 0);
195 if (Alignment
> EFI_PAGE_SIZE
) {
197 // Calculate the total number of pages since alignment is larger than page size.
199 AlignmentMask
= Alignment
- 1;
200 RealPages
= Pages
+ EFI_SIZE_TO_PAGES (Alignment
);
202 // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
204 ASSERT (RealPages
> Pages
);
206 Status
= gBS
->AllocatePages (AllocateAnyPages
, MemoryType
, RealPages
, &Memory
);
207 if (EFI_ERROR (Status
)) {
210 AlignedMemory
= ((UINTN
) Memory
+ AlignmentMask
) & ~AlignmentMask
;
211 UnalignedPages
= EFI_SIZE_TO_PAGES (AlignedMemory
- (UINTN
) Memory
);
212 if (UnalignedPages
> 0) {
214 // Free first unaligned page(s).
216 Status
= gBS
->FreePages (Memory
, UnalignedPages
);
217 ASSERT_EFI_ERROR (Status
);
219 Memory
= AlignedMemory
+ EFI_PAGES_TO_SIZE (Pages
);
220 UnalignedPages
= RealPages
- Pages
- UnalignedPages
;
221 if (UnalignedPages
> 0) {
223 // Free last unaligned page(s).
225 Status
= gBS
->FreePages (Memory
, UnalignedPages
);
226 ASSERT_EFI_ERROR (Status
);
230 // Do not over-allocate pages in this case.
232 Status
= gBS
->AllocatePages (AllocateAnyPages
, MemoryType
, Pages
, &Memory
);
233 if (EFI_ERROR (Status
)) {
236 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. Must be a power of two.
254 If Alignment is zero, then byte alignment is used.
256 @return A pointer to the allocated buffer or NULL if allocation fails.
261 AllocateAlignedPages (
266 return InternalAllocateAlignedPages (EfiBootServicesData
, Pages
, Alignment
);
270 Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.
272 Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an
273 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
274 returned. If there is not enough memory at the specified alignment remaining to satisfy the
275 request, then NULL is returned.
277 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
278 If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
280 @param Pages The number of 4 KB pages to allocate.
281 @param Alignment The requested alignment of the allocation. 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. Must be a power of two.
310 If Alignment is zero, then byte alignment is used.
312 @return A pointer to the allocated buffer or NULL if allocation fails.
317 AllocateAlignedReservedPages (
322 return InternalAllocateAlignedPages (EfiReservedMemoryType
, Pages
, Alignment
);
326 Frees one or more 4KB pages that were previously allocated with one of the aligned page
327 allocation functions in the Memory Allocation Library.
329 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
330 must have been allocated on a previous call to the aligned page allocation services of the Memory
331 Allocation Library. If it is not possible to free allocated pages, then this function will
334 If Buffer was not allocated with an aligned page allocation function in the Memory Allocation
335 Library, then ASSERT().
336 If Pages is zero, then ASSERT().
338 @param Buffer The pointer to the buffer of pages to free.
339 @param Pages The number of 4 KB pages to free.
352 Status
= gBS
->FreePages ((EFI_PHYSICAL_ADDRESS
) (UINTN
) Buffer
, Pages
);
353 ASSERT_EFI_ERROR (Status
);
357 Allocates a buffer of a certain pool type.
359 Allocates the number bytes specified by AllocationSize of a certain pool type and returns a
360 pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
361 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
363 @param MemoryType The type of memory to allocate.
364 @param AllocationSize The number of bytes to allocate.
366 @return A pointer to the allocated buffer or NULL if allocation fails.
370 InternalAllocatePool (
371 IN EFI_MEMORY_TYPE MemoryType
,
372 IN UINTN AllocationSize
378 Status
= gBS
->AllocatePool (MemoryType
, AllocationSize
, &Memory
);
379 if (EFI_ERROR (Status
)) {
386 Allocates a buffer of type EfiBootServicesData.
388 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
389 pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
390 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
392 @param AllocationSize The number of bytes to allocate.
394 @return A pointer to the allocated buffer or NULL if allocation fails.
400 IN UINTN AllocationSize
403 return InternalAllocatePool (EfiBootServicesData
, AllocationSize
);
407 Allocates a buffer of type EfiRuntimeServicesData.
409 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns
410 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
411 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
413 @param AllocationSize The number of bytes to allocate.
415 @return A pointer to the allocated buffer or NULL if allocation fails.
420 AllocateRuntimePool (
421 IN UINTN AllocationSize
424 return InternalAllocatePool (EfiRuntimeServicesData
, AllocationSize
);
428 Allocates a buffer of type EfiReservedMemoryType.
430 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType and returns
431 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
432 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
434 @param AllocationSize The number of bytes to allocate.
436 @return A pointer to the allocated buffer or NULL if allocation fails.
441 AllocateReservedPool (
442 IN UINTN AllocationSize
445 return InternalAllocatePool (EfiReservedMemoryType
, AllocationSize
);
449 Allocates and zeros a buffer of a certain pool type.
451 Allocates the number bytes specified by AllocationSize of a certain pool type, clears the buffer
452 with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid
453 buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request,
454 then NULL is returned.
456 @param PoolType The type of memory to allocate.
457 @param AllocationSize The number of bytes to allocate and zero.
459 @return A pointer to the allocated buffer or NULL if allocation fails.
463 InternalAllocateZeroPool (
464 IN EFI_MEMORY_TYPE PoolType
,
465 IN UINTN AllocationSize
470 Memory
= InternalAllocatePool (PoolType
, AllocationSize
);
471 if (Memory
!= NULL
) {
472 Memory
= ZeroMem (Memory
, AllocationSize
);
478 Allocates and zeros a buffer of type EfiBootServicesData.
480 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
481 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
482 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
483 request, then NULL is returned.
485 @param AllocationSize The number of bytes to allocate and zero.
487 @return A pointer to the allocated buffer or NULL if allocation fails.
493 IN UINTN AllocationSize
496 return InternalAllocateZeroPool (EfiBootServicesData
, AllocationSize
);
500 Allocates and zeros a buffer of type EfiRuntimeServicesData.
502 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the
503 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
504 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
505 request, then NULL is returned.
507 @param AllocationSize The number of bytes to allocate and zero.
509 @return A pointer to the allocated buffer or NULL if allocation fails.
514 AllocateRuntimeZeroPool (
515 IN UINTN AllocationSize
518 return InternalAllocateZeroPool (EfiRuntimeServicesData
, AllocationSize
);
522 Allocates and zeros a buffer of type EfiReservedMemoryType.
524 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the
525 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
526 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
527 request, then NULL is returned.
529 @param AllocationSize The number of bytes to allocate and zero.
531 @return A pointer to the allocated buffer or NULL if allocation fails.
536 AllocateReservedZeroPool (
537 IN UINTN AllocationSize
540 return InternalAllocateZeroPool (EfiReservedMemoryType
, AllocationSize
);
544 Copies a buffer to an allocated buffer of a certain pool type.
546 Allocates the number bytes specified by AllocationSize of a certain pool type, copies
547 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
548 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
549 is not enough memory remaining to satisfy the request, then NULL is returned.
550 If Buffer is NULL, then ASSERT().
551 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
553 @param PoolType The type of pool to allocate.
554 @param AllocationSize The number of bytes to allocate and zero.
555 @param Buffer The buffer to copy to the allocated buffer.
557 @return A pointer to the allocated buffer or NULL if allocation fails.
561 InternalAllocateCopyPool (
562 IN EFI_MEMORY_TYPE PoolType
,
563 IN UINTN AllocationSize
,
564 IN CONST VOID
*Buffer
569 ASSERT (Buffer
!= NULL
);
570 ASSERT (AllocationSize
<= (MAX_ADDRESS
- (UINTN
) Buffer
+ 1));
572 Memory
= InternalAllocatePool (PoolType
, AllocationSize
);
573 if (Memory
!= NULL
) {
574 Memory
= CopyMem (Memory
, Buffer
, AllocationSize
);
580 Copies a buffer to an allocated buffer of type EfiBootServicesData.
582 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies
583 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
584 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
585 is not enough memory remaining to satisfy the request, then NULL is returned.
587 If Buffer is NULL, then ASSERT().
588 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
590 @param AllocationSize The number of bytes to allocate and zero.
591 @param Buffer The buffer to copy to the allocated buffer.
593 @return A pointer to the allocated buffer or NULL if allocation fails.
599 IN UINTN AllocationSize
,
600 IN CONST VOID
*Buffer
603 return InternalAllocateCopyPool (EfiBootServicesData
, AllocationSize
, Buffer
);
607 Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.
609 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies
610 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
611 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
612 is not enough memory remaining to satisfy the request, then NULL is returned.
614 If Buffer is NULL, then ASSERT().
615 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
617 @param AllocationSize The number of bytes to allocate and zero.
618 @param Buffer The buffer to copy to the allocated buffer.
620 @return A pointer to the allocated buffer or NULL if allocation fails.
625 AllocateRuntimeCopyPool (
626 IN UINTN AllocationSize
,
627 IN CONST VOID
*Buffer
630 return InternalAllocateCopyPool (EfiRuntimeServicesData
, AllocationSize
, Buffer
);
634 Copies a buffer to an allocated buffer of type EfiReservedMemoryType.
636 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies
637 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
638 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
639 is not enough memory remaining to satisfy the request, then NULL is returned.
641 If Buffer is NULL, then ASSERT().
642 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
644 @param AllocationSize The number of bytes to allocate and zero.
645 @param Buffer The buffer to copy to the allocated buffer.
647 @return A pointer to the allocated buffer or NULL if allocation fails.
652 AllocateReservedCopyPool (
653 IN UINTN AllocationSize
,
654 IN CONST VOID
*Buffer
657 return InternalAllocateCopyPool (EfiReservedMemoryType
, AllocationSize
, Buffer
);
661 Reallocates a buffer of a specified memory type.
663 Allocates and zeros the number bytes specified by NewSize from memory of the type
664 specified by PoolType. If OldBuffer is not NULL, then the smaller of OldSize and
665 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
666 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
667 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
668 enough memory remaining to satisfy the request, then NULL is returned.
670 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
671 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
673 @param PoolType The type of pool to allocate.
674 @param OldSize The size, in bytes, of OldBuffer.
675 @param NewSize The size, in bytes, of the buffer to reallocate.
676 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
677 parameter that may be NULL.
679 @return A pointer to the allocated buffer or NULL if allocation fails.
683 InternalReallocatePool (
684 IN EFI_MEMORY_TYPE PoolType
,
687 IN VOID
*OldBuffer OPTIONAL
692 NewBuffer
= InternalAllocateZeroPool (PoolType
, NewSize
);
693 if (NewBuffer
!= NULL
&& OldBuffer
!= NULL
) {
694 CopyMem (NewBuffer
, OldBuffer
, MIN (OldSize
, NewSize
));
695 FreePool (OldBuffer
);
701 Reallocates a buffer of type EfiBootServicesData.
703 Allocates and zeros the number bytes specified by NewSize from memory of type
704 EfiBootServicesData. If OldBuffer is not NULL, then the smaller of OldSize and
705 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
706 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
707 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
708 enough memory remaining to satisfy the request, then NULL is returned.
710 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
711 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
713 @param OldSize The size, in bytes, of OldBuffer.
714 @param NewSize The size, in bytes, of the buffer to reallocate.
715 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
716 parameter that may be NULL.
718 @return A pointer to the allocated buffer or NULL if allocation fails.
726 IN VOID
*OldBuffer OPTIONAL
729 return InternalReallocatePool (EfiBootServicesData
, OldSize
, NewSize
, OldBuffer
);
733 Reallocates a buffer of type EfiRuntimeServicesData.
735 Allocates and zeros the number bytes specified by NewSize from memory of type
736 EfiRuntimeServicesData. If OldBuffer is not NULL, then the smaller of OldSize and
737 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
738 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
739 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
740 enough memory remaining to satisfy the request, then NULL is returned.
742 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
743 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
745 @param OldSize The size, in bytes, of OldBuffer.
746 @param NewSize The size, in bytes, of the buffer to reallocate.
747 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
748 parameter that may be NULL.
750 @return A pointer to the allocated buffer or NULL if allocation fails.
755 ReallocateRuntimePool (
758 IN VOID
*OldBuffer OPTIONAL
761 return InternalReallocatePool (EfiRuntimeServicesData
, OldSize
, NewSize
, OldBuffer
);
765 Reallocates a buffer of type EfiReservedMemoryType.
767 Allocates and zeros the number bytes specified by NewSize from memory of type
768 EfiReservedMemoryType. If OldBuffer is not NULL, then the smaller of OldSize and
769 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
770 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
771 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
772 enough memory remaining to satisfy the request, then NULL is returned.
774 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
775 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
777 @param OldSize The size, in bytes, of OldBuffer.
778 @param NewSize The size, in bytes, of the buffer to reallocate.
779 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
780 parameter that may be NULL.
782 @return A pointer to the allocated buffer or NULL if allocation fails.
787 ReallocateReservedPool (
790 IN VOID
*OldBuffer OPTIONAL
793 return InternalReallocatePool (EfiReservedMemoryType
, OldSize
, NewSize
, OldBuffer
);
797 Frees a buffer that was previously allocated with one of the pool allocation functions in the
798 Memory Allocation Library.
800 Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
801 pool allocation services of the Memory Allocation Library. If it is not possible to free pool
802 resources, then this function will perform no actions.
804 If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
807 @param Buffer The pointer to the buffer to free.
818 Status
= gBS
->FreePool (Buffer
);
819 ASSERT_EFI_ERROR (Status
);