xref: /freebsd-src/sys/contrib/edk2/Include/Library/MemoryAllocationLib.h (revision 3245fa215aca18d135839a15c80ae1c905666a37)
10d1ba665SWarner Losh /** @file
20d1ba665SWarner Losh   Provides services to allocate and free memory buffers of various memory types and alignments.
30d1ba665SWarner Losh 
40d1ba665SWarner Losh   The Memory Allocation Library abstracts various common memory allocation operations. This library
50d1ba665SWarner Losh   allows code to be written in a phase-independent manner because the allocation of memory in PEI, DXE,
60d1ba665SWarner Losh   and SMM (for example) is done via a different mechanism. Using a common library interface makes it
70d1ba665SWarner Losh   much easier to port algorithms from phase to phase.
80d1ba665SWarner Losh 
9*3245fa21SMitchell Horne Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
10*3245fa21SMitchell Horne SPDX-License-Identifier: BSD-2-Clause-Patent
110d1ba665SWarner Losh 
120d1ba665SWarner Losh **/
130d1ba665SWarner Losh 
140d1ba665SWarner Losh #ifndef __MEMORY_ALLOCATION_LIB_H__
150d1ba665SWarner Losh #define __MEMORY_ALLOCATION_LIB_H__
160d1ba665SWarner Losh 
170d1ba665SWarner Losh /**
180d1ba665SWarner Losh   Allocates one or more 4KB pages of type EfiBootServicesData.
190d1ba665SWarner Losh 
200d1ba665SWarner Losh   Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the
210d1ba665SWarner Losh   allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL
220d1ba665SWarner Losh   is returned.  If there is not enough memory remaining to satisfy the request, then NULL is
230d1ba665SWarner Losh   returned.
240d1ba665SWarner Losh 
250d1ba665SWarner Losh   @param  Pages                 The number of 4 KB pages to allocate.
260d1ba665SWarner Losh 
270d1ba665SWarner Losh   @return A pointer to the allocated buffer or NULL if allocation fails.
280d1ba665SWarner Losh 
290d1ba665SWarner Losh **/
300d1ba665SWarner Losh VOID *
310d1ba665SWarner Losh EFIAPI
320d1ba665SWarner Losh AllocatePages (
330d1ba665SWarner Losh   IN UINTN  Pages
340d1ba665SWarner Losh   );
350d1ba665SWarner Losh 
360d1ba665SWarner Losh /**
370d1ba665SWarner Losh   Allocates one or more 4KB pages of type EfiRuntimeServicesData.
380d1ba665SWarner Losh 
390d1ba665SWarner Losh   Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
400d1ba665SWarner Losh   allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL
410d1ba665SWarner Losh   is returned.  If there is not enough memory remaining to satisfy the request, then NULL is
420d1ba665SWarner Losh   returned.
430d1ba665SWarner Losh 
440d1ba665SWarner Losh   @param  Pages                 The number of 4 KB pages to allocate.
450d1ba665SWarner Losh 
460d1ba665SWarner Losh   @return A pointer to the allocated buffer or NULL if allocation fails.
470d1ba665SWarner Losh 
480d1ba665SWarner Losh **/
490d1ba665SWarner Losh VOID *
500d1ba665SWarner Losh EFIAPI
510d1ba665SWarner Losh AllocateRuntimePages (
520d1ba665SWarner Losh   IN UINTN  Pages
530d1ba665SWarner Losh   );
540d1ba665SWarner Losh 
550d1ba665SWarner Losh /**
560d1ba665SWarner Losh   Allocates one or more 4KB pages of type EfiReservedMemoryType.
570d1ba665SWarner Losh 
580d1ba665SWarner Losh   Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the
590d1ba665SWarner Losh   allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL
600d1ba665SWarner Losh   is returned.  If there is not enough memory remaining to satisfy the request, then NULL is
610d1ba665SWarner Losh   returned.
620d1ba665SWarner Losh 
630d1ba665SWarner Losh   @param  Pages                 The number of 4 KB pages to allocate.
640d1ba665SWarner Losh 
650d1ba665SWarner Losh   @return A pointer to the allocated buffer or NULL if allocation fails.
660d1ba665SWarner Losh 
670d1ba665SWarner Losh **/
680d1ba665SWarner Losh VOID *
690d1ba665SWarner Losh EFIAPI
700d1ba665SWarner Losh AllocateReservedPages (
710d1ba665SWarner Losh   IN UINTN  Pages
720d1ba665SWarner Losh   );
730d1ba665SWarner Losh 
740d1ba665SWarner Losh /**
750d1ba665SWarner Losh   Frees one or more 4KB pages that were previously allocated with one of the page allocation
760d1ba665SWarner Losh   functions in the Memory Allocation Library.
770d1ba665SWarner Losh 
780d1ba665SWarner Losh   Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer.  Buffer
790d1ba665SWarner Losh   must have been allocated on a previous call to the page allocation services of the Memory
800d1ba665SWarner Losh   Allocation Library.  If it is not possible to free allocated pages, then this function will
810d1ba665SWarner Losh   perform no actions.
820d1ba665SWarner Losh 
830d1ba665SWarner Losh   If Buffer was not allocated with a page allocation function in the Memory Allocation Library,
840d1ba665SWarner Losh   then ASSERT().
850d1ba665SWarner Losh   If Pages is zero, then ASSERT().
860d1ba665SWarner Losh 
870d1ba665SWarner Losh   @param  Buffer                Pointer to the buffer of pages to free.
880d1ba665SWarner Losh   @param  Pages                 The number of 4 KB pages to free.
890d1ba665SWarner Losh 
900d1ba665SWarner Losh **/
910d1ba665SWarner Losh VOID
920d1ba665SWarner Losh EFIAPI
930d1ba665SWarner Losh FreePages (
940d1ba665SWarner Losh   IN VOID   *Buffer,
950d1ba665SWarner Losh   IN UINTN  Pages
960d1ba665SWarner Losh   );
970d1ba665SWarner Losh 
980d1ba665SWarner Losh /**
990d1ba665SWarner Losh   Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
1000d1ba665SWarner Losh 
1010d1ba665SWarner Losh   Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an
1020d1ba665SWarner Losh   alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is
1030d1ba665SWarner Losh   returned.  If there is not enough memory at the specified alignment remaining to satisfy the
1040d1ba665SWarner Losh   request, then NULL is returned.
1050d1ba665SWarner Losh 
1060d1ba665SWarner Losh   If Alignment is not a power of two and Alignment is not zero, then ASSERT().
1070d1ba665SWarner Losh   If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
1080d1ba665SWarner Losh 
1090d1ba665SWarner Losh   @param  Pages                 The number of 4 KB pages to allocate.
1100d1ba665SWarner Losh   @param  Alignment             The requested alignment of the allocation.  Must be a power of two.
1110d1ba665SWarner Losh                                 If Alignment is zero, then byte alignment is used.
1120d1ba665SWarner Losh 
1130d1ba665SWarner Losh   @return A pointer to the allocated buffer or NULL if allocation fails.
1140d1ba665SWarner Losh 
1150d1ba665SWarner Losh **/
1160d1ba665SWarner Losh VOID *
1170d1ba665SWarner Losh EFIAPI
1180d1ba665SWarner Losh AllocateAlignedPages (
1190d1ba665SWarner Losh   IN UINTN  Pages,
1200d1ba665SWarner Losh   IN UINTN  Alignment
1210d1ba665SWarner Losh   );
1220d1ba665SWarner Losh 
1230d1ba665SWarner Losh /**
1240d1ba665SWarner Losh   Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.
1250d1ba665SWarner Losh 
1260d1ba665SWarner Losh   Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an
1270d1ba665SWarner Losh   alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is
1280d1ba665SWarner Losh   returned.  If there is not enough memory at the specified alignment remaining to satisfy the
1290d1ba665SWarner Losh   request, then NULL is returned.
1300d1ba665SWarner Losh 
1310d1ba665SWarner Losh   If Alignment is not a power of two and Alignment is not zero, then ASSERT().
1320d1ba665SWarner Losh   If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
1330d1ba665SWarner Losh 
1340d1ba665SWarner Losh   @param  Pages                 The number of 4 KB pages to allocate.
1350d1ba665SWarner Losh   @param  Alignment             The requested alignment of the allocation.  Must be a power of two.
1360d1ba665SWarner Losh                                 If Alignment is zero, then byte alignment is used.
1370d1ba665SWarner Losh 
1380d1ba665SWarner Losh   @return A pointer to the allocated buffer or NULL if allocation fails.
1390d1ba665SWarner Losh 
1400d1ba665SWarner Losh **/
1410d1ba665SWarner Losh VOID *
1420d1ba665SWarner Losh EFIAPI
1430d1ba665SWarner Losh AllocateAlignedRuntimePages (
1440d1ba665SWarner Losh   IN UINTN  Pages,
1450d1ba665SWarner Losh   IN UINTN  Alignment
1460d1ba665SWarner Losh   );
1470d1ba665SWarner Losh 
1480d1ba665SWarner Losh /**
1490d1ba665SWarner Losh   Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.
1500d1ba665SWarner Losh 
1510d1ba665SWarner Losh   Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an
1520d1ba665SWarner Losh   alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is
1530d1ba665SWarner Losh   returned.  If there is not enough memory at the specified alignment remaining to satisfy the
1540d1ba665SWarner Losh   request, then NULL is returned.
1550d1ba665SWarner Losh 
1560d1ba665SWarner Losh   If Alignment is not a power of two and Alignment is not zero, then ASSERT().
1570d1ba665SWarner Losh   If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
1580d1ba665SWarner Losh 
1590d1ba665SWarner Losh   @param  Pages                 The number of 4 KB pages to allocate.
1600d1ba665SWarner Losh   @param  Alignment             The requested alignment of the allocation.  Must be a power of two.
1610d1ba665SWarner Losh                                 If Alignment is zero, then byte alignment is used.
1620d1ba665SWarner Losh 
1630d1ba665SWarner Losh   @return A pointer to the allocated buffer or NULL if allocation fails.
1640d1ba665SWarner Losh 
1650d1ba665SWarner Losh **/
1660d1ba665SWarner Losh VOID *
1670d1ba665SWarner Losh EFIAPI
1680d1ba665SWarner Losh AllocateAlignedReservedPages (
1690d1ba665SWarner Losh   IN UINTN  Pages,
1700d1ba665SWarner Losh   IN UINTN  Alignment
1710d1ba665SWarner Losh   );
1720d1ba665SWarner Losh 
1730d1ba665SWarner Losh /**
1740d1ba665SWarner Losh   Frees one or more 4KB pages that were previously allocated with one of the aligned page
1750d1ba665SWarner Losh   allocation functions in the Memory Allocation Library.
1760d1ba665SWarner Losh 
1770d1ba665SWarner Losh   Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer.  Buffer
1780d1ba665SWarner Losh   must have been allocated on a previous call to the aligned page allocation services of the Memory
1790d1ba665SWarner Losh   Allocation Library.  If it is not possible to free allocated pages, then this function will
1800d1ba665SWarner Losh   perform no actions.
1810d1ba665SWarner Losh 
1820d1ba665SWarner Losh   If Buffer was not allocated with an aligned page allocation function in the Memory Allocation
1830d1ba665SWarner Losh   Library, then ASSERT().
1840d1ba665SWarner Losh   If Pages is zero, then ASSERT().
1850d1ba665SWarner Losh 
1860d1ba665SWarner Losh   @param  Buffer                Pointer to the buffer of pages to free.
1870d1ba665SWarner Losh   @param  Pages                 The number of 4 KB pages to free.
1880d1ba665SWarner Losh 
1890d1ba665SWarner Losh **/
1900d1ba665SWarner Losh VOID
1910d1ba665SWarner Losh EFIAPI
1920d1ba665SWarner Losh FreeAlignedPages (
1930d1ba665SWarner Losh   IN VOID   *Buffer,
1940d1ba665SWarner Losh   IN UINTN  Pages
1950d1ba665SWarner Losh   );
1960d1ba665SWarner Losh 
1970d1ba665SWarner Losh /**
1980d1ba665SWarner Losh   Allocates a buffer of type EfiBootServicesData.
1990d1ba665SWarner Losh 
2000d1ba665SWarner Losh   Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
2010d1ba665SWarner Losh   pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is
2020d1ba665SWarner Losh   returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.
2030d1ba665SWarner Losh 
2040d1ba665SWarner Losh   @param  AllocationSize        The number of bytes to allocate.
2050d1ba665SWarner Losh 
2060d1ba665SWarner Losh   @return A pointer to the allocated buffer or NULL if allocation fails.
2070d1ba665SWarner Losh 
2080d1ba665SWarner Losh **/
2090d1ba665SWarner Losh VOID *
2100d1ba665SWarner Losh EFIAPI
2110d1ba665SWarner Losh AllocatePool (
2120d1ba665SWarner Losh   IN UINTN  AllocationSize
2130d1ba665SWarner Losh   );
2140d1ba665SWarner Losh 
2150d1ba665SWarner Losh /**
2160d1ba665SWarner Losh   Allocates a buffer of type EfiRuntimeServicesData.
2170d1ba665SWarner Losh 
2180d1ba665SWarner Losh   Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns
2190d1ba665SWarner Losh   a pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is
2200d1ba665SWarner Losh   returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.
2210d1ba665SWarner Losh 
2220d1ba665SWarner Losh   @param  AllocationSize        The number of bytes to allocate.
2230d1ba665SWarner Losh 
2240d1ba665SWarner Losh   @return A pointer to the allocated buffer or NULL if allocation fails.
2250d1ba665SWarner Losh 
2260d1ba665SWarner Losh **/
2270d1ba665SWarner Losh VOID *
2280d1ba665SWarner Losh EFIAPI
2290d1ba665SWarner Losh AllocateRuntimePool (
2300d1ba665SWarner Losh   IN UINTN  AllocationSize
2310d1ba665SWarner Losh   );
2320d1ba665SWarner Losh 
2330d1ba665SWarner Losh /**
2340d1ba665SWarner Losh   Allocates a buffer of type EfiReservedMemoryType.
2350d1ba665SWarner Losh 
2360d1ba665SWarner Losh   Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType and returns
2370d1ba665SWarner Losh   a pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is
2380d1ba665SWarner Losh   returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.
2390d1ba665SWarner Losh 
2400d1ba665SWarner Losh   @param  AllocationSize        The number of bytes to allocate.
2410d1ba665SWarner Losh 
2420d1ba665SWarner Losh   @return A pointer to the allocated buffer or NULL if allocation fails.
2430d1ba665SWarner Losh 
2440d1ba665SWarner Losh **/
2450d1ba665SWarner Losh VOID *
2460d1ba665SWarner Losh EFIAPI
2470d1ba665SWarner Losh AllocateReservedPool (
2480d1ba665SWarner Losh   IN UINTN  AllocationSize
2490d1ba665SWarner Losh   );
2500d1ba665SWarner Losh 
2510d1ba665SWarner Losh /**
2520d1ba665SWarner Losh   Allocates and zeros a buffer of type EfiBootServicesData.
2530d1ba665SWarner Losh 
2540d1ba665SWarner Losh   Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
2550d1ba665SWarner Losh   buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a
2560d1ba665SWarner Losh   valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the
2570d1ba665SWarner Losh   request, then NULL is returned.
2580d1ba665SWarner Losh 
2590d1ba665SWarner Losh   @param  AllocationSize        The number of bytes to allocate and zero.
2600d1ba665SWarner Losh 
2610d1ba665SWarner Losh   @return A pointer to the allocated buffer or NULL if allocation fails.
2620d1ba665SWarner Losh 
2630d1ba665SWarner Losh **/
2640d1ba665SWarner Losh VOID *
2650d1ba665SWarner Losh EFIAPI
2660d1ba665SWarner Losh AllocateZeroPool (
2670d1ba665SWarner Losh   IN UINTN  AllocationSize
2680d1ba665SWarner Losh   );
2690d1ba665SWarner Losh 
2700d1ba665SWarner Losh /**
2710d1ba665SWarner Losh   Allocates and zeros a buffer of type EfiRuntimeServicesData.
2720d1ba665SWarner Losh 
2730d1ba665SWarner Losh   Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the
2740d1ba665SWarner Losh   buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a
2750d1ba665SWarner Losh   valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the
2760d1ba665SWarner Losh   request, then NULL is returned.
2770d1ba665SWarner Losh 
2780d1ba665SWarner Losh   @param  AllocationSize        The number of bytes to allocate and zero.
2790d1ba665SWarner Losh 
2800d1ba665SWarner Losh   @return A pointer to the allocated buffer or NULL if allocation fails.
2810d1ba665SWarner Losh 
2820d1ba665SWarner Losh **/
2830d1ba665SWarner Losh VOID *
2840d1ba665SWarner Losh EFIAPI
2850d1ba665SWarner Losh AllocateRuntimeZeroPool (
2860d1ba665SWarner Losh   IN UINTN  AllocationSize
2870d1ba665SWarner Losh   );
2880d1ba665SWarner Losh 
2890d1ba665SWarner Losh /**
2900d1ba665SWarner Losh   Allocates and zeros a buffer of type EfiReservedMemoryType.
2910d1ba665SWarner Losh 
2920d1ba665SWarner Losh   Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the
2930d1ba665SWarner Losh   buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a
2940d1ba665SWarner Losh   valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the
2950d1ba665SWarner Losh   request, then NULL is returned.
2960d1ba665SWarner Losh 
2970d1ba665SWarner Losh   @param  AllocationSize        The number of bytes to allocate and zero.
2980d1ba665SWarner Losh 
2990d1ba665SWarner Losh   @return A pointer to the allocated buffer or NULL if allocation fails.
3000d1ba665SWarner Losh 
3010d1ba665SWarner Losh **/
3020d1ba665SWarner Losh VOID *
3030d1ba665SWarner Losh EFIAPI
3040d1ba665SWarner Losh AllocateReservedZeroPool (
3050d1ba665SWarner Losh   IN UINTN  AllocationSize
3060d1ba665SWarner Losh   );
3070d1ba665SWarner Losh 
3080d1ba665SWarner Losh /**
3090d1ba665SWarner Losh   Copies a buffer to an allocated buffer of type EfiBootServicesData.
3100d1ba665SWarner Losh 
3110d1ba665SWarner Losh   Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies
3120d1ba665SWarner Losh   AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
3130d1ba665SWarner Losh   allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there
3140d1ba665SWarner Losh   is not enough memory remaining to satisfy the request, then NULL is returned.
3150d1ba665SWarner Losh 
3160d1ba665SWarner Losh   If Buffer is NULL, then ASSERT().
3170d1ba665SWarner Losh   If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3180d1ba665SWarner Losh 
3190d1ba665SWarner Losh   @param  AllocationSize        The number of bytes to allocate and zero.
3200d1ba665SWarner Losh   @param  Buffer                The buffer to copy to the allocated buffer.
3210d1ba665SWarner Losh 
3220d1ba665SWarner Losh   @return A pointer to the allocated buffer or NULL if allocation fails.
3230d1ba665SWarner Losh 
3240d1ba665SWarner Losh **/
3250d1ba665SWarner Losh VOID *
3260d1ba665SWarner Losh EFIAPI
3270d1ba665SWarner Losh AllocateCopyPool (
3280d1ba665SWarner Losh   IN UINTN       AllocationSize,
3290d1ba665SWarner Losh   IN CONST VOID  *Buffer
3300d1ba665SWarner Losh   );
3310d1ba665SWarner Losh 
3320d1ba665SWarner Losh /**
3330d1ba665SWarner Losh   Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.
3340d1ba665SWarner Losh 
3350d1ba665SWarner Losh   Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies
3360d1ba665SWarner Losh   AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
3370d1ba665SWarner Losh   allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there
3380d1ba665SWarner Losh   is not enough memory remaining to satisfy the request, then NULL is returned.
3390d1ba665SWarner Losh 
3400d1ba665SWarner Losh   If Buffer is NULL, then ASSERT().
3410d1ba665SWarner Losh   If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3420d1ba665SWarner Losh 
3430d1ba665SWarner Losh   @param  AllocationSize        The number of bytes to allocate and zero.
3440d1ba665SWarner Losh   @param  Buffer                The buffer to copy to the allocated buffer.
3450d1ba665SWarner Losh 
3460d1ba665SWarner Losh   @return A pointer to the allocated buffer or NULL if allocation fails.
3470d1ba665SWarner Losh 
3480d1ba665SWarner Losh **/
3490d1ba665SWarner Losh VOID *
3500d1ba665SWarner Losh EFIAPI
3510d1ba665SWarner Losh AllocateRuntimeCopyPool (
3520d1ba665SWarner Losh   IN UINTN       AllocationSize,
3530d1ba665SWarner Losh   IN CONST VOID  *Buffer
3540d1ba665SWarner Losh   );
3550d1ba665SWarner Losh 
3560d1ba665SWarner Losh /**
3570d1ba665SWarner Losh   Copies a buffer to an allocated buffer of type EfiReservedMemoryType.
3580d1ba665SWarner Losh 
3590d1ba665SWarner Losh   Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies
3600d1ba665SWarner Losh   AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
3610d1ba665SWarner Losh   allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there
3620d1ba665SWarner Losh   is not enough memory remaining to satisfy the request, then NULL is returned.
3630d1ba665SWarner Losh 
3640d1ba665SWarner Losh   If Buffer is NULL, then ASSERT().
3650d1ba665SWarner Losh   If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3660d1ba665SWarner Losh 
3670d1ba665SWarner Losh   @param  AllocationSize        The number of bytes to allocate and zero.
3680d1ba665SWarner Losh   @param  Buffer                The buffer to copy to the allocated buffer.
3690d1ba665SWarner Losh 
3700d1ba665SWarner Losh   @return A pointer to the allocated buffer or NULL if allocation fails.
3710d1ba665SWarner Losh 
3720d1ba665SWarner Losh **/
3730d1ba665SWarner Losh VOID *
3740d1ba665SWarner Losh EFIAPI
3750d1ba665SWarner Losh AllocateReservedCopyPool (
3760d1ba665SWarner Losh   IN UINTN       AllocationSize,
3770d1ba665SWarner Losh   IN CONST VOID  *Buffer
3780d1ba665SWarner Losh   );
3790d1ba665SWarner Losh 
3800d1ba665SWarner Losh /**
3810d1ba665SWarner Losh   Reallocates a buffer of type EfiBootServicesData.
3820d1ba665SWarner Losh 
3830d1ba665SWarner Losh   Allocates and zeros the number bytes specified by NewSize from memory of type
3840d1ba665SWarner Losh   EfiBootServicesData.  If OldBuffer is not NULL, then the smaller of OldSize and
3850d1ba665SWarner Losh   NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
3860d1ba665SWarner Losh   OldBuffer is freed.  A pointer to the newly allocated buffer is returned.
3870d1ba665SWarner Losh   If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not
3880d1ba665SWarner Losh   enough memory remaining to satisfy the request, then NULL is returned.
3890d1ba665SWarner Losh 
3900d1ba665SWarner Losh   If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
3910d1ba665SWarner Losh   is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
3920d1ba665SWarner Losh 
3930d1ba665SWarner Losh   @param  OldSize        The size, in bytes, of OldBuffer.
3940d1ba665SWarner Losh   @param  NewSize        The size, in bytes, of the buffer to reallocate.
3950d1ba665SWarner Losh   @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional
3960d1ba665SWarner Losh                          parameter that may be NULL.
3970d1ba665SWarner Losh 
3980d1ba665SWarner Losh   @return A pointer to the allocated buffer or NULL if allocation fails.
3990d1ba665SWarner Losh 
4000d1ba665SWarner Losh **/
4010d1ba665SWarner Losh VOID *
4020d1ba665SWarner Losh EFIAPI
4030d1ba665SWarner Losh ReallocatePool (
4040d1ba665SWarner Losh   IN UINTN  OldSize,
4050d1ba665SWarner Losh   IN UINTN  NewSize,
4060d1ba665SWarner Losh   IN VOID   *OldBuffer  OPTIONAL
4070d1ba665SWarner Losh   );
4080d1ba665SWarner Losh 
4090d1ba665SWarner Losh /**
4100d1ba665SWarner Losh   Reallocates a buffer of type EfiRuntimeServicesData.
4110d1ba665SWarner Losh 
4120d1ba665SWarner Losh   Allocates and zeros the number bytes specified by NewSize from memory of type
4130d1ba665SWarner Losh   EfiRuntimeServicesData.  If OldBuffer is not NULL, then the smaller of OldSize and
4140d1ba665SWarner Losh   NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
4150d1ba665SWarner Losh   OldBuffer is freed.  A pointer to the newly allocated buffer is returned.
4160d1ba665SWarner Losh   If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not
4170d1ba665SWarner Losh   enough memory remaining to satisfy the request, then NULL is returned.
4180d1ba665SWarner Losh 
4190d1ba665SWarner Losh   If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
4200d1ba665SWarner Losh   is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
4210d1ba665SWarner Losh 
4220d1ba665SWarner Losh   @param  OldSize        The size, in bytes, of OldBuffer.
4230d1ba665SWarner Losh   @param  NewSize        The size, in bytes, of the buffer to reallocate.
4240d1ba665SWarner Losh   @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional
4250d1ba665SWarner Losh                          parameter that may be NULL.
4260d1ba665SWarner Losh 
4270d1ba665SWarner Losh   @return A pointer to the allocated buffer or NULL if allocation fails.
4280d1ba665SWarner Losh 
4290d1ba665SWarner Losh **/
4300d1ba665SWarner Losh VOID *
4310d1ba665SWarner Losh EFIAPI
4320d1ba665SWarner Losh ReallocateRuntimePool (
4330d1ba665SWarner Losh   IN UINTN  OldSize,
4340d1ba665SWarner Losh   IN UINTN  NewSize,
4350d1ba665SWarner Losh   IN VOID   *OldBuffer  OPTIONAL
4360d1ba665SWarner Losh   );
4370d1ba665SWarner Losh 
4380d1ba665SWarner Losh /**
4390d1ba665SWarner Losh   Reallocates a buffer of type EfiReservedMemoryType.
4400d1ba665SWarner Losh 
4410d1ba665SWarner Losh   Allocates and zeros the number bytes specified by NewSize from memory of type
4420d1ba665SWarner Losh   EfiReservedMemoryType.  If OldBuffer is not NULL, then the smaller of OldSize and
4430d1ba665SWarner Losh   NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
4440d1ba665SWarner Losh   OldBuffer is freed.  A pointer to the newly allocated buffer is returned.
4450d1ba665SWarner Losh   If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not
4460d1ba665SWarner Losh   enough memory remaining to satisfy the request, then NULL is returned.
4470d1ba665SWarner Losh 
4480d1ba665SWarner Losh   If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
4490d1ba665SWarner Losh   is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
4500d1ba665SWarner Losh 
4510d1ba665SWarner Losh   @param  OldSize        The size, in bytes, of OldBuffer.
4520d1ba665SWarner Losh   @param  NewSize        The size, in bytes, of the buffer to reallocate.
4530d1ba665SWarner Losh   @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional
4540d1ba665SWarner Losh                          parameter that may be NULL.
4550d1ba665SWarner Losh 
4560d1ba665SWarner Losh   @return A pointer to the allocated buffer or NULL if allocation fails.
4570d1ba665SWarner Losh 
4580d1ba665SWarner Losh **/
4590d1ba665SWarner Losh VOID *
4600d1ba665SWarner Losh EFIAPI
4610d1ba665SWarner Losh ReallocateReservedPool (
4620d1ba665SWarner Losh   IN UINTN  OldSize,
4630d1ba665SWarner Losh   IN UINTN  NewSize,
4640d1ba665SWarner Losh   IN VOID   *OldBuffer  OPTIONAL
4650d1ba665SWarner Losh   );
4660d1ba665SWarner Losh 
4670d1ba665SWarner Losh /**
4680d1ba665SWarner Losh   Frees a buffer that was previously allocated with one of the pool allocation functions in the
4690d1ba665SWarner Losh   Memory Allocation Library.
4700d1ba665SWarner Losh 
4710d1ba665SWarner Losh   Frees the buffer specified by Buffer.  Buffer must have been allocated on a previous call to the
4720d1ba665SWarner Losh   pool allocation services of the Memory Allocation Library.  If it is not possible to free pool
4730d1ba665SWarner Losh   resources, then this function will perform no actions.
4740d1ba665SWarner Losh 
4750d1ba665SWarner Losh   If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
4760d1ba665SWarner Losh   then ASSERT().
4770d1ba665SWarner Losh 
4780d1ba665SWarner Losh   @param  Buffer                Pointer to the buffer to free.
4790d1ba665SWarner Losh 
4800d1ba665SWarner Losh **/
4810d1ba665SWarner Losh VOID
4820d1ba665SWarner Losh EFIAPI
4830d1ba665SWarner Losh FreePool (
4840d1ba665SWarner Losh   IN VOID   *Buffer
4850d1ba665SWarner Losh   );
4860d1ba665SWarner Losh 
4870d1ba665SWarner Losh #endif
488