2 Support routines for memory allocation routines
3 based on PeiService for PEI phase drivers.
5 Copyright (c) 2006 - 2013, 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/PeiServicesLib.h>
22 #include <Library/BaseMemoryLib.h>
23 #include <Library/DebugLib.h>
24 #include <Library/HobLib.h>
28 Allocates one or more 4KB pages of a certain memory type.
30 Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated
31 buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned.
32 If there is not enough memory remaining to satisfy the request, then NULL is returned.
34 @param MemoryType The type of memory to allocate.
35 @param Pages The number of 4 KB pages to allocate.
37 @return A pointer to the allocated buffer or NULL if allocation fails.
41 InternalAllocatePages (
42 IN EFI_MEMORY_TYPE MemoryType
,
47 EFI_PHYSICAL_ADDRESS Memory
;
48 EFI_MEMORY_TYPE RequestType
;
49 EFI_PEI_HOB_POINTERS Hob
;
55 RequestType
= MemoryType
;
56 if (MemoryType
== EfiReservedMemoryType
) {
58 // PEI AllocatePages() doesn't support EfiReservedMemoryType.
59 // Change RequestType to EfiBootServicesData for memory allocation.
61 RequestType
= EfiBootServicesData
;
64 Status
= PeiServicesAllocatePages (RequestType
, Pages
, &Memory
);
65 if (EFI_ERROR (Status
)) {
69 if (MemoryType
== EfiReservedMemoryType
) {
71 // Memory type needs to be updated to EfiReservedMemoryType. Per PI spec Volume 1,
72 // PEI AllocatePages() will automate the creation of the Memory Allocation HOB types.
73 // Search Memory Allocation HOB and find the matched memory region,
74 // then change its memory type to EfiReservedMemoryType.
76 Hob
.Raw
= GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION
);
77 while (Hob
.Raw
!= NULL
&& Hob
.MemoryAllocation
->AllocDescriptor
.MemoryBaseAddress
!= Memory
) {
78 Hob
.Raw
= GET_NEXT_HOB (Hob
);
79 Hob
.Raw
= GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION
, Hob
.Raw
);
81 ASSERT (Hob
.Raw
!= NULL
);
82 Hob
.MemoryAllocation
->AllocDescriptor
.MemoryType
= EfiReservedMemoryType
;
85 return (VOID
*) (UINTN
) Memory
;
89 Allocates one or more 4KB pages of type EfiBootServicesData.
91 Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the
92 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
93 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
96 @param Pages The number of 4 KB pages to allocate.
98 @return A pointer to the allocated buffer or NULL if allocation fails.
107 return InternalAllocatePages (EfiBootServicesData
, Pages
);
111 Allocates one or more 4KB pages of type EfiRuntimeServicesData.
113 Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
114 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
115 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
118 @param Pages The number of 4 KB pages to allocate.
120 @return A pointer to the allocated buffer or NULL if allocation fails.
125 AllocateRuntimePages (
129 return InternalAllocatePages (EfiRuntimeServicesData
, Pages
);
133 Allocates one or more 4KB pages of type EfiReservedMemoryType.
135 Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the
136 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
137 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
140 @param Pages The number of 4 KB pages to allocate.
142 @return A pointer to the allocated buffer or NULL if allocation fails.
147 AllocateReservedPages (
151 return InternalAllocatePages (EfiReservedMemoryType
, Pages
);
155 Frees one or more 4KB pages that were previously allocated with one of the page allocation
156 functions in the Memory Allocation Library.
158 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
159 must have been allocated on a previous call to the page allocation services of the Memory
160 Allocation Library. If it is not possible to free allocated pages, then this function will
163 If Buffer was not allocated with a page allocation function in the Memory Allocation Library,
165 If Pages is zero, then ASSERT().
167 @param Buffer The pointer to the buffer of pages to free.
168 @param Pages The number of 4 KB pages to free.
180 // PEI phase does not support to free pages, so leave it as NOP.
185 Allocates one or more 4KB pages of a certain memory type at a specified alignment.
187 Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment
188 specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned.
189 If there is not enough memory at the specified alignment remaining to satisfy the request, then
191 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
193 @param MemoryType The type of memory to allocate.
194 @param Pages The number of 4 KB pages to allocate.
195 @param Alignment The requested alignment of the allocation.
196 Must be a power of two.
197 If Alignment is zero, then byte alignment is used.
199 @return A pointer to the allocated buffer or NULL if allocation fails.
203 InternalAllocateAlignedPages (
204 IN EFI_MEMORY_TYPE MemoryType
,
213 // Alignment must be a power of two or zero.
215 ASSERT ((Alignment
& (Alignment
- 1)) == 0);
221 // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
223 ASSERT (Pages
<= (MAX_ADDRESS
- EFI_SIZE_TO_PAGES (Alignment
)));
225 // We would rather waste some memory to save PEI code size.
227 Memory
= InternalAllocatePages (MemoryType
, Pages
+ EFI_SIZE_TO_PAGES (Alignment
));
228 if (Alignment
== 0) {
229 AlignmentMask
= Alignment
;
231 AlignmentMask
= Alignment
- 1;
233 return (VOID
*) (UINTN
) (((UINTN
) Memory
+ AlignmentMask
) & ~AlignmentMask
);
237 Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
239 Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an
240 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
241 returned. If there is not enough memory at the specified alignment remaining to satisfy the
242 request, then NULL is returned.
244 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
246 @param Pages The number of 4 KB pages to allocate.
247 @param Alignment The requested alignment of the allocation.
248 Must be a power of two.
249 If Alignment is zero, then byte alignment is used.
251 @return A pointer to the allocated buffer or NULL if allocation fails.
256 AllocateAlignedPages (
261 return InternalAllocateAlignedPages (EfiBootServicesData
, Pages
, Alignment
);
265 Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.
267 Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an
268 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
269 returned. If there is not enough memory at the specified alignment remaining to satisfy the
270 request, then NULL is returned.
272 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
274 @param Pages The number of 4 KB pages to allocate.
275 @param Alignment The requested alignment of the allocation.
276 Must be a power of two.
277 If Alignment is zero, then byte alignment is used.
279 @return A pointer to the allocated buffer or NULL if allocation fails.
284 AllocateAlignedRuntimePages (
289 return InternalAllocateAlignedPages (EfiRuntimeServicesData
, Pages
, Alignment
);
293 Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.
295 Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an
296 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
297 returned. If there is not enough memory at the specified alignment remaining to satisfy the
298 request, then NULL is returned.
300 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
302 @param Pages The number of 4 KB pages to allocate.
303 @param Alignment The requested alignment of the allocation.
304 Must be a power of two.
305 If Alignment is zero, then byte alignment is used.
307 @return A pointer to the allocated buffer or NULL if allocation fails.
312 AllocateAlignedReservedPages (
317 return InternalAllocateAlignedPages (EfiReservedMemoryType
, Pages
, Alignment
);
321 Frees one or more 4KB pages that were previously allocated with one of the aligned page
322 allocation functions in the Memory Allocation Library.
324 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
325 must have been allocated on a previous call to the aligned page allocation services of the Memory
326 Allocation Library. If it is not possible to free allocated pages, then this function will
329 If Buffer was not allocated with an aligned page allocation function in the Memory Allocation
330 Library, then ASSERT().
331 If Pages is zero, then ASSERT().
333 @param Buffer The pointer to the buffer of pages to free.
334 @param Pages The number of 4 KB pages to free.
346 // PEI phase does not support to free pages, so leave it as NOP.
351 Allocates a buffer of a certain pool type.
353 Allocates the number bytes specified by AllocationSize of a certain pool type and returns a
354 pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
355 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
357 @param MemoryType The type of memory to allocate.
358 @param AllocationSize The number of bytes to allocate.
360 @return A pointer to the allocated buffer or NULL if allocation fails.
364 InternalAllocatePool (
365 IN EFI_MEMORY_TYPE MemoryType
,
366 IN UINTN AllocationSize
370 // If we need lots of small runtime/reserved memory type from PEI in the future,
371 // we can consider providing a more complex algorithm that allocates runtime pages and
372 // provide pool allocations from those pages.
374 return InternalAllocatePages (MemoryType
, EFI_SIZE_TO_PAGES (AllocationSize
));
378 Allocates a buffer of type EfiBootServicesData.
380 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
381 pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
382 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
384 @param AllocationSize The number of bytes to allocate.
386 @return A pointer to the allocated buffer or NULL if allocation fails.
392 IN UINTN AllocationSize
398 Status
= PeiServicesAllocatePool (AllocationSize
, &Buffer
);
399 if (EFI_ERROR (Status
)) {
406 Allocates a buffer of type EfiRuntimeServicesData.
408 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns
409 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
410 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
412 @param AllocationSize The number of bytes to allocate.
414 @return A pointer to the allocated buffer or NULL if allocation fails.
419 AllocateRuntimePool (
420 IN UINTN AllocationSize
423 return InternalAllocatePool (EfiRuntimeServicesData
, AllocationSize
);
427 Allocates a buffer of type EfiReservedMemoryType.
429 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType and returns
430 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
431 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
433 @param AllocationSize The number of bytes to allocate.
435 @return A pointer to the allocated buffer or NULL if allocation fails.
440 AllocateReservedPool (
441 IN UINTN AllocationSize
444 return InternalAllocatePool (EfiReservedMemoryType
, AllocationSize
);
448 Allocates and zeros a buffer of a certain pool type.
450 Allocates the number bytes specified by AllocationSize of a certain pool type, clears the buffer
451 with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid
452 buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request,
453 then NULL is returned.
455 @param PoolType The type of memory to allocate.
456 @param AllocationSize The number of bytes to allocate and zero.
458 @return A pointer to the allocated buffer or NULL if allocation fails.
462 InternalAllocateZeroPool (
463 IN EFI_MEMORY_TYPE PoolType
,
464 IN UINTN AllocationSize
469 Memory
= InternalAllocatePool (PoolType
, AllocationSize
);
470 if (Memory
!= NULL
) {
471 Memory
= ZeroMem (Memory
, AllocationSize
);
477 Allocates and zeros a buffer of type EfiBootServicesData.
479 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
480 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
481 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
482 request, then NULL is returned.
484 @param AllocationSize The number of bytes to allocate and zero.
486 @return A pointer to the allocated buffer or NULL if allocation fails.
492 IN UINTN AllocationSize
497 Memory
= AllocatePool (AllocationSize
);
498 if (Memory
!= NULL
) {
499 Memory
= ZeroMem (Memory
, AllocationSize
);
505 Allocates and zeros a buffer of type EfiRuntimeServicesData.
507 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the
508 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
509 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
510 request, then NULL is returned.
512 @param AllocationSize The number of bytes to allocate and zero.
514 @return A pointer to the allocated buffer or NULL if allocation fails.
519 AllocateRuntimeZeroPool (
520 IN UINTN AllocationSize
523 return InternalAllocateZeroPool (EfiRuntimeServicesData
, AllocationSize
);
527 Allocates and zeros a buffer of type EfiReservedMemoryType.
529 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the
530 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
531 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
532 request, then NULL is returned.
534 @param AllocationSize The number of bytes to allocate and zero.
536 @return A pointer to the allocated buffer or NULL if allocation fails.
541 AllocateReservedZeroPool (
542 IN UINTN AllocationSize
545 return InternalAllocateZeroPool (EfiReservedMemoryType
, AllocationSize
);
549 Copies a buffer to an allocated buffer of a certain pool type.
551 Allocates the number bytes specified by AllocationSize of a certain pool type, copies
552 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
553 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
554 is not enough memory remaining to satisfy the request, then NULL is returned.
555 If Buffer is NULL, then ASSERT().
556 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
558 @param PoolType The type of pool to allocate.
559 @param AllocationSize The number of bytes to allocate and zero.
560 @param Buffer The buffer to copy to the allocated buffer.
562 @return A pointer to the allocated buffer or NULL if allocation fails.
566 InternalAllocateCopyPool (
567 IN EFI_MEMORY_TYPE PoolType
,
568 IN UINTN AllocationSize
,
569 IN CONST VOID
*Buffer
574 ASSERT (Buffer
!= NULL
);
575 ASSERT (AllocationSize
<= (MAX_ADDRESS
- (UINTN
) Buffer
+ 1));
577 Memory
= InternalAllocatePool (PoolType
, AllocationSize
);
578 if (Memory
!= NULL
) {
579 Memory
= CopyMem (Memory
, Buffer
, AllocationSize
);
585 Copies a buffer to an allocated buffer of type EfiBootServicesData.
587 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies
588 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
589 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
590 is not enough memory remaining to satisfy the request, then NULL is returned.
592 If Buffer is NULL, then ASSERT().
593 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
595 @param AllocationSize The number of bytes to allocate and zero.
596 @param Buffer The buffer to copy to the allocated buffer.
598 @return A pointer to the allocated buffer or NULL if allocation fails.
604 IN UINTN AllocationSize
,
605 IN CONST VOID
*Buffer
610 ASSERT (Buffer
!= NULL
);
611 ASSERT (AllocationSize
<= (MAX_ADDRESS
- (UINTN
) Buffer
+ 1));
613 Memory
= AllocatePool (AllocationSize
);
614 if (Memory
!= NULL
) {
615 Memory
= CopyMem (Memory
, Buffer
, AllocationSize
);
621 Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.
623 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies
624 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
625 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
626 is not enough memory remaining to satisfy the request, then NULL is returned.
628 If Buffer is NULL, then ASSERT().
629 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
631 @param AllocationSize The number of bytes to allocate and zero.
632 @param Buffer The buffer to copy to the allocated buffer.
634 @return A pointer to the allocated buffer or NULL if allocation fails.
639 AllocateRuntimeCopyPool (
640 IN UINTN AllocationSize
,
641 IN CONST VOID
*Buffer
644 return InternalAllocateCopyPool (EfiRuntimeServicesData
, AllocationSize
, Buffer
);
648 Copies a buffer to an allocated buffer of type EfiReservedMemoryType.
650 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies
651 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
652 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
653 is not enough memory remaining to satisfy the request, then NULL is returned.
655 If Buffer is NULL, then ASSERT().
656 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
658 @param AllocationSize The number of bytes to allocate and zero.
659 @param Buffer The buffer to copy to the allocated buffer.
661 @return A pointer to the allocated buffer or NULL if allocation fails.
666 AllocateReservedCopyPool (
667 IN UINTN AllocationSize
,
668 IN CONST VOID
*Buffer
671 return InternalAllocateCopyPool (EfiReservedMemoryType
, AllocationSize
, Buffer
);
675 Reallocates a buffer of a specified memory type.
677 Allocates and zeros the number bytes specified by NewSize from memory of the type
678 specified by PoolType. If OldBuffer is not NULL, then the smaller of OldSize and
679 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
680 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
681 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
682 enough memory remaining to satisfy the request, then NULL is returned.
684 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
685 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
687 @param PoolType The type of pool to allocate.
688 @param OldSize The size, in bytes, of OldBuffer.
689 @param NewSize The size, in bytes, of the buffer to reallocate.
690 @param OldBuffer The buffer to copy to the allocated buffer. This is an
691 optional parameter that may be NULL.
693 @return A pointer to the allocated buffer or NULL if allocation fails.
697 InternalReallocatePool (
698 IN EFI_MEMORY_TYPE PoolType
,
701 IN VOID
*OldBuffer OPTIONAL
706 NewBuffer
= InternalAllocateZeroPool (PoolType
, NewSize
);
707 if (NewBuffer
!= NULL
&& OldBuffer
!= NULL
) {
708 CopyMem (NewBuffer
, OldBuffer
, MIN (OldSize
, NewSize
));
709 FreePool (OldBuffer
);
715 Reallocates a buffer of type EfiBootServicesData.
717 Allocates and zeros the number bytes specified by NewSize from memory of type
718 EfiBootServicesData. If OldBuffer is not NULL, then the smaller of OldSize and
719 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
720 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
721 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
722 enough memory remaining to satisfy the request, then NULL is returned.
724 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
725 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
727 @param OldSize The size, in bytes, of OldBuffer.
728 @param NewSize The size, in bytes, of the buffer to reallocate.
729 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
730 parameter that may be NULL.
732 @return A pointer to the allocated buffer or NULL if allocation fails.
740 IN VOID
*OldBuffer OPTIONAL
743 return InternalReallocatePool (EfiBootServicesData
, OldSize
, NewSize
, OldBuffer
);
747 Reallocates a buffer of type EfiRuntimeServicesData.
749 Allocates and zeros the number bytes specified by NewSize from memory of type
750 EfiRuntimeServicesData. If OldBuffer is not NULL, then the smaller of OldSize and
751 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
752 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
753 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
754 enough memory remaining to satisfy the request, then NULL is returned.
756 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
757 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
759 @param OldSize The size, in bytes, of OldBuffer.
760 @param NewSize The size, in bytes, of the buffer to reallocate.
761 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
762 parameter that may be NULL.
764 @return A pointer to the allocated buffer or NULL if allocation fails.
769 ReallocateRuntimePool (
772 IN VOID
*OldBuffer OPTIONAL
775 return InternalReallocatePool (EfiRuntimeServicesData
, OldSize
, NewSize
, OldBuffer
);
779 Reallocates a buffer of type EfiReservedMemoryType.
781 Allocates and zeros the number bytes specified by NewSize from memory of type
782 EfiReservedMemoryType. If OldBuffer is not NULL, then the smaller of OldSize and
783 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
784 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
785 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
786 enough memory remaining to satisfy the request, then NULL is returned.
788 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
789 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
791 @param OldSize The size, in bytes, of OldBuffer.
792 @param NewSize The size, in bytes, of the buffer to reallocate.
793 @param OldBuffer The buffer to copy to the allocated buffer. This is an
794 optional parameter that may be NULL.
796 @return A pointer to the allocated buffer or NULL if allocation fails.
801 ReallocateReservedPool (
804 IN VOID
*OldBuffer OPTIONAL
807 return InternalReallocatePool (EfiReservedMemoryType
, OldSize
, NewSize
, OldBuffer
);
811 Frees a buffer that was previously allocated with one of the pool allocation functions in the
812 Memory Allocation Library.
814 Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
815 pool allocation services of the Memory Allocation Library. If it is not possible to free pool
816 resources, then this function will perform no actions.
818 If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
821 @param Buffer The pointer to the buffer to free.
831 // PEI phase does not support to free pool, so leave it as NOP.