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 Memory
= InternalAllocatePool (PoolType
, AllocationSize
);
478 if (Memory
!= NULL
) {
479 Memory
= CopyMem (Memory
, Buffer
, AllocationSize
);
485 Copies a buffer to an allocated buffer of type EfiBootServicesData.
487 @param AllocationSize The number of bytes to allocate.
488 @param Buffer The buffer to copy to the allocated buffer.
490 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
491 If there is not enough memory remaining to satisfy the request, then NULL is returned.
497 IN UINTN AllocationSize
,
498 IN CONST VOID
*Buffer
501 return InternalAllocateCopyPool (EfiBootServicesData
, AllocationSize
, Buffer
);
505 Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.
507 @param AllocationSize The number of bytes to allocate.
508 @param Buffer The buffer to copy to the allocated buffer.
510 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
511 If there is not enough memory remaining to satisfy the request, then NULL is returned.
516 AllocateRuntimeCopyPool (
517 IN UINTN AllocationSize
,
518 IN CONST VOID
*Buffer
521 return InternalAllocateCopyPool (EfiRuntimeServicesData
, AllocationSize
, Buffer
);
525 Copies a buffer to an allocated buffer of type EfiReservedMemoryType.
527 @param AllocationSize The number of bytes to allocate.
528 @param Buffer The buffer to copy to the allocated buffer.
530 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
531 If there is not enough memory remaining to satisfy the request, then NULL is returned.
536 AllocateReservedCopyPool (
537 IN UINTN AllocationSize
,
538 IN CONST VOID
*Buffer
541 return InternalAllocateCopyPool (EfiReservedMemoryType
, AllocationSize
, Buffer
);
545 Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment.
547 @param Buffer Pointer to the buffer to free.
558 Status
= gBS
->FreePool (Buffer
);
559 ASSERT_EFI_ERROR (Status
);
563 Allocates a buffer of a certain pool type at a specified alignment.
565 @param PoolType The type of pool to allocate.
566 @param AllocationSize The number of bytes to allocate.
567 @param Alignment The requested alignment of the allocation. Must be a power of two. If Alignment is zero, then byte alignment is used.
569 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
570 If there is not enough memory remaining to satisfy the request, then NULL is returned.
574 InternalAllocateAlignedPool (
575 IN EFI_MEMORY_TYPE PoolType
,
576 IN UINTN AllocationSize
,
581 UINTN AlignedAddress
;
583 UINTN OverAllocationSize
;
584 UINTN RealAllocationSize
;
588 // Alignment must be a power of two or zero.
590 ASSERT ((Alignment
& (Alignment
- 1)) == 0);
592 if (Alignment
== 0) {
593 AlignmentMask
= Alignment
;
595 AlignmentMask
= Alignment
- 1;
598 // Calculate the extra memory size, over-allocate memory pool and get the aligned memory address.
600 OverAllocationSize
= sizeof (RawAddress
) + AlignmentMask
;
601 RealAllocationSize
= AllocationSize
+ OverAllocationSize
;
603 // Make sure that AllocationSize plus OverAllocationSize does not overflow.
605 ASSERT (RealAllocationSize
> AllocationSize
);
607 RawAddress
= InternalAllocatePool (PoolType
, RealAllocationSize
);
608 if (RawAddress
== NULL
) {
611 AlignedAddress
= ((UINTN
) RawAddress
+ OverAllocationSize
) & ~AlignmentMask
;
613 // Save the original memory address just before the aligned address.
615 FreePointer
= (VOID
**)(AlignedAddress
- sizeof (RawAddress
));
616 *FreePointer
= RawAddress
;
618 return (VOID
*) AlignedAddress
;
622 Allocates a buffer of type EfiBootServicesData at a specified alignment.
624 @param AllocationSize The number of bytes to allocate.
625 @param Alignment The requested alignment of the allocation. Must be a power of two. If Alignment is zero, then byte alignment is used.
627 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
628 If there is not enough memory remaining to satisfy the request, then NULL is returned.
633 AllocateAlignedPool (
634 IN UINTN AllocationSize
,
638 return InternalAllocateAlignedPool (EfiBootServicesData
, AllocationSize
, Alignment
);
642 Allocates a buffer of type EfiRuntimeServicesData at a specified alignment.
644 @param AllocationSize The number of bytes to allocate.
645 @param Alignment The requested alignment of the allocation. Must be a power of two.
646 If Alignment is zero, then byte alignment is used.
648 A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
649 If there is not enough memory remaining to satisfy the request, then NULL is returned.
654 AllocateAlignedRuntimePool (
655 IN UINTN AllocationSize
,
659 return InternalAllocateAlignedPool (EfiRuntimeServicesData
, AllocationSize
, Alignment
);
663 Allocates a buffer of type EfiReservedMemoryType at a specified alignment.
665 @param AllocationSize The number of bytes to allocate.
666 @param Alignment The requested alignment of the allocation. Must be a power of two.
667 If Alignment is zero, then byte alignment is used.
669 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
670 If there is not enough memory remaining to satisfy the request, then NULL is returned.
675 AllocateAlignedReservedPool (
676 IN UINTN AllocationSize
,
680 return InternalAllocateAlignedPool (EfiReservedMemoryType
, AllocationSize
, Alignment
);
684 Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment.
686 @param PoolType The type of pool to allocate.
687 @param AllocationSize The number of bytes to allocate.
688 @param Alignment The requested alignment of the allocation. Must be a power of two.
689 If Alignment is zero, then byte alignment is used.
691 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
692 If there is not enough memory remaining to satisfy the request, then NULL is returned.
696 InternalAllocateAlignedZeroPool (
697 IN EFI_MEMORY_TYPE PoolType
,
698 IN UINTN AllocationSize
,
703 Memory
= InternalAllocateAlignedPool (PoolType
, AllocationSize
, Alignment
);
704 if (Memory
!= NULL
) {
705 Memory
= ZeroMem (Memory
, AllocationSize
);
711 Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment.
713 @param AllocationSize The number of bytes to allocate.
714 @param Alignment The requested alignment of the allocation. Must be a power of two.
715 If Alignment is zero, then byte alignment is used.
717 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
718 If there is not enough memory remaining to satisfy the request, then NULL is returned.
723 AllocateAlignedZeroPool (
724 IN UINTN AllocationSize
,
728 return InternalAllocateAlignedZeroPool (EfiBootServicesData
, AllocationSize
, Alignment
);
732 Allocates and zeros a buffer of type EfiRuntimeServicesData at a specified alignment.
734 @param AllocationSize The number of bytes to allocate.
735 @param Alignment The requested alignment of the allocation. Must be a power of two.
736 If Alignment is zero, then byte alignment is used.
738 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
739 If there is not enough memory remaining to satisfy the request, then NULL is returned.
744 AllocateAlignedRuntimeZeroPool (
745 IN UINTN AllocationSize
,
749 return InternalAllocateAlignedZeroPool (EfiRuntimeServicesData
, AllocationSize
, Alignment
);
753 Allocates and zeros a buffer of type EfiReservedMemoryType at a specified alignment.
755 @param AllocationSize The number of bytes to allocate.
756 @param Alignment The requested alignment of the allocation. Must be a power of two.
757 If Alignment is zero, then byte alignment is used.
759 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
760 If there is not enough memory remaining to satisfy the request, then NULL is returned.
765 AllocateAlignedReservedZeroPool (
766 IN UINTN AllocationSize
,
770 return InternalAllocateAlignedZeroPool (EfiReservedMemoryType
, AllocationSize
, Alignment
);
774 Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment.
776 @param PoolType The type of pool to allocate.
777 @param AllocationSize The number of bytes to allocate.
778 @param Buffer The buffer to copy to the allocated buffer.
779 @param Alignment The requested alignment of the allocation. Must be a power of two.
780 If Alignment is zero, then byte alignment is used.
782 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
783 If there is not enough memory remaining to satisfy the request, then NULL is returned.
787 InternalAllocateAlignedCopyPool (
788 IN EFI_MEMORY_TYPE PoolType
,
789 IN UINTN AllocationSize
,
790 IN CONST VOID
*Buffer
,
796 Memory
= InternalAllocateAlignedPool (PoolType
, AllocationSize
, Alignment
);
797 if (Memory
!= NULL
) {
798 Memory
= CopyMem (Memory
, Buffer
, AllocationSize
);
804 Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment.
806 @param AllocationSize The number of bytes to allocate.
807 @param Buffer The buffer to copy to the allocated buffer.
808 @param Alignment The requested alignment of the allocation. Must be a power of two.
809 If Alignment is zero, then byte alignment is used.
811 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
812 If there is not enough memory remaining to satisfy the request, then NULL is returned.
817 AllocateAlignedCopyPool (
818 IN UINTN AllocationSize
,
819 IN CONST VOID
*Buffer
,
823 return InternalAllocateAlignedCopyPool (EfiBootServicesData
, AllocationSize
, Buffer
, Alignment
);
827 Copies a buffer to an allocated buffer of type EfiRuntimeServicesData at a specified alignment.
829 @param AllocationSize The number of bytes to allocate.
830 @param Buffer The buffer to copy to the allocated buffer.
831 @param Alignment The requested alignment of the allocation. Must be a power of two.
832 If Alignment is zero, then byte alignment is used.
834 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
835 If there is not enough memory remaining to satisfy the request, then NULL is returned.
840 AllocateAlignedRuntimeCopyPool (
841 IN UINTN AllocationSize
,
842 IN CONST VOID
*Buffer
,
846 return InternalAllocateAlignedCopyPool (EfiRuntimeServicesData
, AllocationSize
, Buffer
, Alignment
);
850 Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment.
852 @param AllocationSize The number of bytes to allocate.
853 @param Buffer The buffer to copy to the allocated buffer.
854 @param Alignment The requested alignment of the allocation. Must be a power of two.
855 If Alignment is zero, then byte alignment is used.
857 @return A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.
858 If there is not enough memory remaining to satisfy the request, then NULL is returned.
863 AllocateAlignedReservedCopyPool (
864 IN UINTN AllocationSize
,
865 IN CONST VOID
*Buffer
,
869 return InternalAllocateAlignedCopyPool (EfiReservedMemoryType
, AllocationSize
, Buffer
, Alignment
);
873 Frees a buffer that was previously allocated with one of the aligned pool allocation functions
874 in the Memory Allocation Library.
876 @param Buffer Pointer to the buffer to free.
890 // Get the pre-saved original address in the over-allocate pool.
892 FreePointer
= (VOID
**)((UINTN
) Buffer
- sizeof (RawAddress
));
893 RawAddress
= *FreePointer
;
895 Status
= gBS
->FreePool (RawAddress
);
896 ASSERT_EFI_ERROR (Status
);