2 Support routines for memory allocation routines for use with drivers.
4 Copyright (c) 2006, Intel Corporation<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 Module Name: MemoryAllocationLib.c
20 Allocates the number of 4KB pages specified by Pages of a certain memory type.
22 @param MemoryType The type of memory to allocate.
23 @param Pages The number of 4 KB pages to allocate.
25 @return A pointer to the allocated buffer. The buffer returned is aligned on a 4KB boundary.<BR>
26 If Pages is 0, then NULL is returned.<BR>
27 If there is not enough memory remaining to satisfy the request, then NULL is returned.
31 InternalAllocatePages (
32 IN EFI_MEMORY_TYPE MemoryType
,
37 EFI_PHYSICAL_ADDRESS Memory
;
43 Status
= gBS
->AllocatePages (AllocateAnyPages
, MemoryType
, Pages
, &Memory
);
44 if (EFI_ERROR (Status
)) {
47 return (VOID
*) (UINTN
) Memory
;
51 Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData.
53 @param Pages The number of 4 KB pages to allocate.
55 @return A pointer to the allocated buffer. The buffer returned is aligned on a 4KB boundary.<BR>
56 If Pages is 0, then NULL is returned.<BR>
57 If there is not enough memory remaining to satisfy the request, then NULL is returned.
66 return InternalAllocatePages (EfiBootServicesData
, Pages
);
70 Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData.
72 @param Pages The number of 4 KB pages to allocate.
74 @return A pointer to the allocated buffer. The buffer returned is aligned on a 4KB boundary.<BR>
75 If Pages is 0, then NULL is returned.<BR>
76 If there is not enough memory remaining to satisfy the request, then NULL is returned.
81 AllocateRuntimePages (
85 return InternalAllocatePages (EfiRuntimeServicesData
, Pages
);
89 Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType.
91 @param Pages The number of 4 KB pages to allocate.
93 @return A pointer to the allocated buffer. The buffer returned is aligned on a 4KB boundary.<BR>
94 If Pages is 0, then NULL is returned.<BR>
95 If there is not enough memory remaining to satisfy the request, then NULL is returned.
100 AllocateReservedPages (
104 return InternalAllocatePages (EfiReservedMemoryType
, Pages
);
108 Frees one or more 4KB pages that were previously allocated with
109 one of the page allocation functions in the Memory Allocation Library.
111 @param Buffer Pointer to the buffer of pages to free.
112 @param Pages The number of 4 KB pages to free.
125 Status
= gBS
->FreePages ((EFI_PHYSICAL_ADDRESS
) (UINTN
) Buffer
, Pages
);
126 ASSERT_EFI_ERROR (Status
);
130 Allocates the number of 4KB pages specified by Pages of a certian memory type
131 with an alignment specified by Alignment.
133 @param MemoryType The type of memory to allocate.
134 @param Pages The number of 4 KB pages to allocate.
135 @param Alignment The requested alignment of the allocation. Must be a power of two.
136 If Alignment is zero, then byte alignment is used.
138 @return The allocated buffer is returned.<BR>
139 If Pages is 0, then NULL is returned.<BR>
140 If there is not enough memory at the specified alignment remaining to satisfy the request, then NULL is returned.
144 InternalAllocateAlignedPages (
145 IN EFI_MEMORY_TYPE MemoryType
,
151 EFI_PHYSICAL_ADDRESS Memory
;
154 UINTN UnalignedPages
;
158 // Alignment must be a power of two or zero.
160 ASSERT ((Alignment
& (Alignment
- 1)) == 0);
165 if (Alignment
> EFI_PAGE_SIZE
) {
167 // Caculate the total number of pages since alignment is larger than page size.
169 AlignmentMask
= Alignment
- 1;
170 RealPages
= Pages
+ EFI_SIZE_TO_PAGES (Alignment
);
172 // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
174 ASSERT (RealPages
> Pages
);
176 Status
= gBS
->AllocatePages (AllocateAnyPages
, MemoryType
, RealPages
, &Memory
);
177 if (EFI_ERROR (Status
)) {
180 AlignedMemory
= ((UINTN
) Memory
+ AlignmentMask
) & ~AlignmentMask
;
181 UnalignedPages
= EFI_SIZE_TO_PAGES ((UINTN
) Memory
- AlignedMemory
);
182 if (UnalignedPages
> 0) {
184 // Free first unaligned page(s).
186 Status
= gBS
->FreePages (Memory
, UnalignedPages
);
187 ASSERT_EFI_ERROR (Status
);
189 Memory
= (EFI_PHYSICAL_ADDRESS
) (AlignedMemory
+ EFI_PAGES_TO_SIZE (Pages
));
190 UnalignedPages
= RealPages
- Pages
- UnalignedPages
;
191 if (UnalignedPages
> 0) {
193 // Free last unaligned page(s).
195 Status
= gBS
->FreePages (Memory
, UnalignedPages
);
196 ASSERT_EFI_ERROR (Status
);
200 // Do not over-allocate pages in this case.
202 Status
= gBS
->AllocatePages (AllocateAnyPages
, MemoryType
, Pages
, &Memory
);
203 if (EFI_ERROR (Status
)) {
206 AlignedMemory
= (UINTN
) Memory
;
208 return (VOID
*) AlignedMemory
;
212 Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData
213 with an alignment specified by Alignment.
215 @param Pages The number of 4 KB pages to allocate.
216 @param Alignment The requested alignment of the allocation. Must be a power of two.
217 If Alignment is zero, then byte alignment is used.
219 @return The allocated buffer is returned.<BR>
220 If Pages is 0, then NULL is returned.<BR>
221 If there is not enough memory at the specified alignment remaining to satisfy the request, then NULL is returned.
226 AllocateAlignedPages (
231 return InternalAllocateAlignedPages (EfiBootServicesData
, Pages
, Alignment
);
235 Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData
236 with an alignment specified by Alignment.
238 @param Pages The number of 4 KB pages to allocate.
239 @param Alignment The requested alignment of the allocation. Must be a power of two.
240 If Alignment is zero, then byte alignment is used.
242 @return The allocated buffer is returned. If Pages is 0, then NULL is returned.
243 If there is not enough memory at the specified alignment remaining to satisfy the request, then NULL is returned.
248 AllocateAlignedRuntimePages (
253 return InternalAllocateAlignedPages (EfiRuntimeServicesData
, Pages
, Alignment
);
257 Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.
259 @param Pages The number of 4 KB pages to allocate.
260 @param Alignment The requested alignment of the allocation. Must be a power of two.
261 If Alignment is zero, then byte alignment is used.
263 @return The allocated buffer is returned. If Pages is 0, then NULL is returned.
264 If there is not enough memory at the specified alignment remaining to satisfy the request, then NULL is returned.
269 AllocateAlignedReservedPages (
274 return InternalAllocateAlignedPages (EfiReservedMemoryType
, Pages
, Alignment
);
278 Frees one or more 4KB pages that were previously allocated with
279 one of the aligned page allocation functions in the Memory Allocation Library.
281 @param Buffer Pointer to the buffer of pages to free.
282 @param Pages The number of 4 KB pages to free.
295 Status
= gBS
->FreePages ((EFI_PHYSICAL_ADDRESS
) (UINTN
) Buffer
, Pages
);
296 ASSERT_EFI_ERROR (Status
);
300 Allocates a buffer of a certain memory type.
302 @param MemoryType The type of memory to allocate.
303 @param AllocationSize The number of bytes to allocate.
305 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
306 If there is not enough memory remaining to satisfy the request, then NULL is returned.
310 InternalAllocatePool (
311 IN EFI_MEMORY_TYPE MemoryType
,
312 IN UINTN AllocationSize
318 Status
= gBS
->AllocatePool (MemoryType
, AllocationSize
, &Memory
);
319 if (EFI_ERROR (Status
)) {
326 Allocates a buffer of type EfiBootServicesData.
328 @param AllocationSize The number of bytes to allocate.
330 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
331 If there is not enough memory remaining to satisfy the request, then NULL is returned.
337 IN UINTN AllocationSize
340 return InternalAllocatePool (EfiBootServicesData
, AllocationSize
);
344 Allocates a buffer of type EfiRuntimeServicesData.
346 @param AllocationSize The number of bytes to allocate.
348 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
349 If there is not enough memory remaining to satisfy the request, then NULL is returned.
354 AllocateRuntimePool (
355 IN UINTN AllocationSize
358 return InternalAllocatePool (EfiRuntimeServicesData
, AllocationSize
);
362 Allocates a buffer of type EfiReservedMemoryType.
364 @param AllocationSize The number of bytes to allocate.
366 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
367 If there is not enough memory remaining to satisfy the request, then NULL is returned.
372 AllocateReservedPool (
373 IN UINTN AllocationSize
376 return InternalAllocatePool (EfiReservedMemoryType
, AllocationSize
);
380 Allocates and zeros a buffer of a certian pool type.
382 @param PoolType The type of memory to allocate.
383 @param AllocationSize The number of bytes to allocate and zero.
385 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
386 If there is not enough memory remaining to satisfy the request, then NULL is returned.
390 InternalAllocateZeroPool (
391 IN EFI_MEMORY_TYPE PoolType
,
392 IN UINTN AllocationSize
396 Memory
= InternalAllocatePool (PoolType
, AllocationSize
);
397 if (Memory
!= NULL
) {
398 Memory
= ZeroMem (Memory
, AllocationSize
);
404 Allocates and zeros a buffer of type EfiBootServicesData.
406 @param AllocationSize The number of bytes to allocate and zero.
408 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
409 If there is not enough memory remaining to satisfy the request, then NULL is returned.
415 IN UINTN AllocationSize
418 return InternalAllocateZeroPool (EfiBootServicesData
, AllocationSize
);
422 Allocates and zeros a buffer of type EfiRuntimeServicesData.
424 @param AllocationSize The number of bytes to allocate and zero.
426 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
427 If there is not enough memory remaining to satisfy the request, then NULL is returned.
432 AllocateRuntimeZeroPool (
433 IN UINTN AllocationSize
436 return InternalAllocateZeroPool (EfiRuntimeServicesData
, AllocationSize
);
440 Allocates and zeros a buffer of type EfiReservedMemoryType.
442 @param AllocationSize The number of bytes to allocate and zero.
444 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
445 If there is not enough memory remaining to satisfy the request, then NULL is returned.
450 AllocateReservedZeroPool (
451 IN UINTN AllocationSize
454 return InternalAllocateZeroPool (EfiReservedMemoryType
, AllocationSize
);
458 Copies a buffer to an allocated buffer of a certian memory type.
460 @param MemoryType The type of pool to allocate.
461 @param AllocationSize The number of bytes to allocate and zero.
462 @param Buffer The buffer to copy to the allocated buffer.
464 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
465 If there is not enough memory remaining to satisfy the request, then NULL is returned.
469 InternalAllocateCopyPool (
470 IN EFI_MEMORY_TYPE PoolType
,
471 IN UINTN AllocationSize
,
472 IN CONST VOID
*Buffer
477 ASSERT (Buffer
!= NULL
);
478 ASSERT (AllocationSize
<= (MAX_ADDRESS
- (UINTN
) Buffer
+ 1));
480 Memory
= InternalAllocatePool (PoolType
, AllocationSize
);
481 if (Memory
!= NULL
) {
482 Memory
= CopyMem (Memory
, Buffer
, AllocationSize
);
488 Copies a buffer to an allocated buffer of type EfiBootServicesData.
490 @param AllocationSize The number of bytes to allocate.
491 @param Buffer The buffer to copy to the allocated buffer.
493 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
494 If there is not enough memory remaining to satisfy the request, then NULL is returned.
500 IN UINTN AllocationSize
,
501 IN CONST VOID
*Buffer
504 return InternalAllocateCopyPool (EfiBootServicesData
, AllocationSize
, Buffer
);
508 Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.
510 @param AllocationSize The number of bytes to allocate.
511 @param Buffer The buffer to copy to the allocated buffer.
513 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
514 If there is not enough memory remaining to satisfy the request, then NULL is returned.
519 AllocateRuntimeCopyPool (
520 IN UINTN AllocationSize
,
521 IN CONST VOID
*Buffer
524 return InternalAllocateCopyPool (EfiRuntimeServicesData
, AllocationSize
, Buffer
);
528 Copies a buffer to an allocated buffer of type EfiReservedMemoryType.
530 @param AllocationSize The number of bytes to allocate.
531 @param Buffer The buffer to copy to the allocated buffer.
533 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
534 If there is not enough memory remaining to satisfy the request, then NULL is returned.
539 AllocateReservedCopyPool (
540 IN UINTN AllocationSize
,
541 IN CONST VOID
*Buffer
544 return InternalAllocateCopyPool (EfiReservedMemoryType
, AllocationSize
, Buffer
);
548 Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment.
550 @param Buffer Pointer to the buffer to free.
561 Status
= gBS
->FreePool (Buffer
);
562 ASSERT_EFI_ERROR (Status
);
566 Allocates a buffer of a certain pool type at a specified alignment.
568 @param PoolType The type of pool to allocate.
569 @param AllocationSize The number of bytes to allocate.
570 @param Alignment The requested alignment of the allocation. Must be a power of two. If Alignment is zero, then byte alignment is used.
572 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
573 If there is not enough memory remaining to satisfy the request, then NULL is returned.
577 InternalAllocateAlignedPool (
578 IN EFI_MEMORY_TYPE PoolType
,
579 IN UINTN AllocationSize
,
584 UINTN AlignedAddress
;
586 UINTN OverAllocationSize
;
587 UINTN RealAllocationSize
;
591 // Alignment must be a power of two or zero.
593 ASSERT ((Alignment
& (Alignment
- 1)) == 0);
595 if (Alignment
== 0) {
596 AlignmentMask
= Alignment
;
598 AlignmentMask
= Alignment
- 1;
601 // Calculate the extra memory size, over-allocate memory pool and get the aligned memory address.
603 OverAllocationSize
= sizeof (RawAddress
) + AlignmentMask
;
604 RealAllocationSize
= AllocationSize
+ OverAllocationSize
;
606 // Make sure that AllocationSize plus OverAllocationSize does not overflow.
608 ASSERT (RealAllocationSize
> AllocationSize
);
610 RawAddress
= InternalAllocatePool (PoolType
, RealAllocationSize
);
611 if (RawAddress
== NULL
) {
614 AlignedAddress
= ((UINTN
) RawAddress
+ OverAllocationSize
) & ~AlignmentMask
;
616 // Save the original memory address just before the aligned address.
618 FreePointer
= (VOID
**)(AlignedAddress
- sizeof (RawAddress
));
619 *FreePointer
= RawAddress
;
621 return (VOID
*) AlignedAddress
;
625 Allocates a buffer of type EfiBootServicesData at a specified alignment.
627 @param AllocationSize The number of bytes to allocate.
628 @param Alignment The requested alignment of the allocation. Must be a power of two. If Alignment is zero, then byte alignment is used.
630 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
631 If there is not enough memory remaining to satisfy the request, then NULL is returned.
636 AllocateAlignedPool (
637 IN UINTN AllocationSize
,
641 return InternalAllocateAlignedPool (EfiBootServicesData
, AllocationSize
, Alignment
);
645 Allocates a buffer of type EfiRuntimeServicesData at a specified alignment.
647 @param AllocationSize The number of bytes to allocate.
648 @param Alignment The requested alignment of the allocation. Must be a power of two.
649 If Alignment is zero, then byte alignment is used.
651 A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
652 If there is not enough memory remaining to satisfy the request, then NULL is returned.
657 AllocateAlignedRuntimePool (
658 IN UINTN AllocationSize
,
662 return InternalAllocateAlignedPool (EfiRuntimeServicesData
, AllocationSize
, Alignment
);
666 Allocates a buffer of type EfiReservedMemoryType at a specified alignment.
668 @param AllocationSize The number of bytes to allocate.
669 @param Alignment The requested alignment of the allocation. Must be a power of two.
670 If Alignment is zero, then byte alignment is used.
672 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
673 If there is not enough memory remaining to satisfy the request, then NULL is returned.
678 AllocateAlignedReservedPool (
679 IN UINTN AllocationSize
,
683 return InternalAllocateAlignedPool (EfiReservedMemoryType
, AllocationSize
, Alignment
);
687 Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment.
689 @param PoolType The type of pool to allocate.
690 @param AllocationSize The number of bytes to allocate.
691 @param Alignment The requested alignment of the allocation. Must be a power of two.
692 If Alignment is zero, then byte alignment is used.
694 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
695 If there is not enough memory remaining to satisfy the request, then NULL is returned.
699 InternalAllocateAlignedZeroPool (
700 IN EFI_MEMORY_TYPE PoolType
,
701 IN UINTN AllocationSize
,
706 Memory
= InternalAllocateAlignedPool (PoolType
, AllocationSize
, Alignment
);
707 if (Memory
!= NULL
) {
708 Memory
= ZeroMem (Memory
, AllocationSize
);
714 Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment.
716 @param AllocationSize The number of bytes to allocate.
717 @param Alignment The requested alignment of the allocation. Must be a power of two.
718 If Alignment is zero, then byte alignment is used.
720 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
721 If there is not enough memory remaining to satisfy the request, then NULL is returned.
726 AllocateAlignedZeroPool (
727 IN UINTN AllocationSize
,
731 return InternalAllocateAlignedZeroPool (EfiBootServicesData
, AllocationSize
, Alignment
);
735 Allocates and zeros a buffer of type EfiRuntimeServicesData at a specified alignment.
737 @param AllocationSize The number of bytes to allocate.
738 @param Alignment The requested alignment of the allocation. Must be a power of two.
739 If Alignment is zero, then byte alignment is used.
741 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
742 If there is not enough memory remaining to satisfy the request, then NULL is returned.
747 AllocateAlignedRuntimeZeroPool (
748 IN UINTN AllocationSize
,
752 return InternalAllocateAlignedZeroPool (EfiRuntimeServicesData
, AllocationSize
, Alignment
);
756 Allocates and zeros a buffer of type EfiReservedMemoryType at a specified alignment.
758 @param AllocationSize The number of bytes to allocate.
759 @param Alignment The requested alignment of the allocation. Must be a power of two.
760 If Alignment is zero, then byte alignment is used.
762 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
763 If there is not enough memory remaining to satisfy the request, then NULL is returned.
768 AllocateAlignedReservedZeroPool (
769 IN UINTN AllocationSize
,
773 return InternalAllocateAlignedZeroPool (EfiReservedMemoryType
, AllocationSize
, Alignment
);
777 Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment.
779 @param PoolType The type of pool to allocate.
780 @param AllocationSize The number of bytes to allocate.
781 @param Buffer The buffer to copy to the allocated buffer.
782 @param Alignment The requested alignment of the allocation. Must be a power of two.
783 If Alignment is zero, then byte alignment is used.
785 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
786 If there is not enough memory remaining to satisfy the request, then NULL is returned.
790 InternalAllocateAlignedCopyPool (
791 IN EFI_MEMORY_TYPE PoolType
,
792 IN UINTN AllocationSize
,
793 IN CONST VOID
*Buffer
,
799 ASSERT (Buffer
!= NULL
);
800 ASSERT (AllocationSize
<= (MAX_ADDRESS
- (UINTN
) Buffer
+ 1));
802 Memory
= InternalAllocateAlignedPool (PoolType
, AllocationSize
, Alignment
);
803 if (Memory
!= NULL
) {
804 Memory
= CopyMem (Memory
, Buffer
, AllocationSize
);
810 Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment.
812 @param AllocationSize The number of bytes to allocate.
813 @param Buffer The buffer to copy to the allocated buffer.
814 @param Alignment The requested alignment of the allocation. Must be a power of two.
815 If Alignment is zero, then byte alignment is used.
817 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
818 If there is not enough memory remaining to satisfy the request, then NULL is returned.
823 AllocateAlignedCopyPool (
824 IN UINTN AllocationSize
,
825 IN CONST VOID
*Buffer
,
829 return InternalAllocateAlignedCopyPool (EfiBootServicesData
, AllocationSize
, Buffer
, Alignment
);
833 Copies a buffer to an allocated buffer of type EfiRuntimeServicesData at a specified alignment.
835 @param AllocationSize The number of bytes to allocate.
836 @param Buffer The buffer to copy to the allocated buffer.
837 @param Alignment The requested alignment of the allocation. Must be a power of two.
838 If Alignment is zero, then byte alignment is used.
840 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
841 If there is not enough memory remaining to satisfy the request, then NULL is returned.
846 AllocateAlignedRuntimeCopyPool (
847 IN UINTN AllocationSize
,
848 IN CONST VOID
*Buffer
,
852 return InternalAllocateAlignedCopyPool (EfiRuntimeServicesData
, AllocationSize
, Buffer
, Alignment
);
856 Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment.
858 @param AllocationSize The number of bytes to allocate.
859 @param Buffer The buffer to copy to the allocated buffer.
860 @param Alignment The requested alignment of the allocation. Must be a power of two.
861 If Alignment is zero, then byte alignment is used.
863 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
864 If there is not enough memory remaining to satisfy the request, then NULL is returned.
869 AllocateAlignedReservedCopyPool (
870 IN UINTN AllocationSize
,
871 IN CONST VOID
*Buffer
,
875 return InternalAllocateAlignedCopyPool (EfiReservedMemoryType
, AllocationSize
, Buffer
, Alignment
);
879 Frees a buffer that was previously allocated with one of the aligned pool allocation functions
880 in the Memory Allocation Library.
882 @param Buffer Pointer to the buffer to free.
896 // Get the pre-saved original address in the over-allocate pool.
898 FreePointer
= (VOID
**)((UINTN
) Buffer
- sizeof (RawAddress
));
899 RawAddress
= *FreePointer
;
901 Status
= gBS
->FreePool (RawAddress
);
902 ASSERT_EFI_ERROR (Status
);