1*0d1ba665SWarner Losh /** @file 2*0d1ba665SWarner Losh Provides services to allocate and free memory buffers of various memory types and alignments. 3*0d1ba665SWarner Losh 4*0d1ba665SWarner Losh The Memory Allocation Library abstracts various common memory allocation operations. This library 5*0d1ba665SWarner Losh allows code to be written in a phase-independent manner because the allocation of memory in PEI, DXE, 6*0d1ba665SWarner Losh and SMM (for example) is done via a different mechanism. Using a common library interface makes it 7*0d1ba665SWarner Losh much easier to port algorithms from phase to phase. 8*0d1ba665SWarner Losh 9*0d1ba665SWarner Losh Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR> 10*0d1ba665SWarner Losh This program and the accompanying materials 11*0d1ba665SWarner Losh are licensed and made available under the terms and conditions of the BSD License 12*0d1ba665SWarner Losh which accompanies this distribution. The full text of the license may be found at 13*0d1ba665SWarner Losh http://opensource.org/licenses/bsd-license.php 14*0d1ba665SWarner Losh 15*0d1ba665SWarner Losh THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 16*0d1ba665SWarner Losh WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 17*0d1ba665SWarner Losh 18*0d1ba665SWarner Losh **/ 19*0d1ba665SWarner Losh 20*0d1ba665SWarner Losh #ifndef __MEMORY_ALLOCATION_LIB_H__ 21*0d1ba665SWarner Losh #define __MEMORY_ALLOCATION_LIB_H__ 22*0d1ba665SWarner Losh 23*0d1ba665SWarner Losh /** 24*0d1ba665SWarner Losh Allocates one or more 4KB pages of type EfiBootServicesData. 25*0d1ba665SWarner Losh 26*0d1ba665SWarner Losh Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the 27*0d1ba665SWarner Losh allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL 28*0d1ba665SWarner Losh is returned. If there is not enough memory remaining to satisfy the request, then NULL is 29*0d1ba665SWarner Losh returned. 30*0d1ba665SWarner Losh 31*0d1ba665SWarner Losh @param Pages The number of 4 KB pages to allocate. 32*0d1ba665SWarner Losh 33*0d1ba665SWarner Losh @return A pointer to the allocated buffer or NULL if allocation fails. 34*0d1ba665SWarner Losh 35*0d1ba665SWarner Losh **/ 36*0d1ba665SWarner Losh VOID * 37*0d1ba665SWarner Losh EFIAPI 38*0d1ba665SWarner Losh AllocatePages ( 39*0d1ba665SWarner Losh IN UINTN Pages 40*0d1ba665SWarner Losh ); 41*0d1ba665SWarner Losh 42*0d1ba665SWarner Losh /** 43*0d1ba665SWarner Losh Allocates one or more 4KB pages of type EfiRuntimeServicesData. 44*0d1ba665SWarner Losh 45*0d1ba665SWarner Losh Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the 46*0d1ba665SWarner Losh allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL 47*0d1ba665SWarner Losh is returned. If there is not enough memory remaining to satisfy the request, then NULL is 48*0d1ba665SWarner Losh returned. 49*0d1ba665SWarner Losh 50*0d1ba665SWarner Losh @param Pages The number of 4 KB pages to allocate. 51*0d1ba665SWarner Losh 52*0d1ba665SWarner Losh @return A pointer to the allocated buffer or NULL if allocation fails. 53*0d1ba665SWarner Losh 54*0d1ba665SWarner Losh **/ 55*0d1ba665SWarner Losh VOID * 56*0d1ba665SWarner Losh EFIAPI 57*0d1ba665SWarner Losh AllocateRuntimePages ( 58*0d1ba665SWarner Losh IN UINTN Pages 59*0d1ba665SWarner Losh ); 60*0d1ba665SWarner Losh 61*0d1ba665SWarner Losh /** 62*0d1ba665SWarner Losh Allocates one or more 4KB pages of type EfiReservedMemoryType. 63*0d1ba665SWarner Losh 64*0d1ba665SWarner Losh Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the 65*0d1ba665SWarner Losh allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL 66*0d1ba665SWarner Losh is returned. If there is not enough memory remaining to satisfy the request, then NULL is 67*0d1ba665SWarner Losh returned. 68*0d1ba665SWarner Losh 69*0d1ba665SWarner Losh @param Pages The number of 4 KB pages to allocate. 70*0d1ba665SWarner Losh 71*0d1ba665SWarner Losh @return A pointer to the allocated buffer or NULL if allocation fails. 72*0d1ba665SWarner Losh 73*0d1ba665SWarner Losh **/ 74*0d1ba665SWarner Losh VOID * 75*0d1ba665SWarner Losh EFIAPI 76*0d1ba665SWarner Losh AllocateReservedPages ( 77*0d1ba665SWarner Losh IN UINTN Pages 78*0d1ba665SWarner Losh ); 79*0d1ba665SWarner Losh 80*0d1ba665SWarner Losh /** 81*0d1ba665SWarner Losh Frees one or more 4KB pages that were previously allocated with one of the page allocation 82*0d1ba665SWarner Losh functions in the Memory Allocation Library. 83*0d1ba665SWarner Losh 84*0d1ba665SWarner Losh Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer 85*0d1ba665SWarner Losh must have been allocated on a previous call to the page allocation services of the Memory 86*0d1ba665SWarner Losh Allocation Library. If it is not possible to free allocated pages, then this function will 87*0d1ba665SWarner Losh perform no actions. 88*0d1ba665SWarner Losh 89*0d1ba665SWarner Losh If Buffer was not allocated with a page allocation function in the Memory Allocation Library, 90*0d1ba665SWarner Losh then ASSERT(). 91*0d1ba665SWarner Losh If Pages is zero, then ASSERT(). 92*0d1ba665SWarner Losh 93*0d1ba665SWarner Losh @param Buffer Pointer to the buffer of pages to free. 94*0d1ba665SWarner Losh @param Pages The number of 4 KB pages to free. 95*0d1ba665SWarner Losh 96*0d1ba665SWarner Losh **/ 97*0d1ba665SWarner Losh VOID 98*0d1ba665SWarner Losh EFIAPI 99*0d1ba665SWarner Losh FreePages ( 100*0d1ba665SWarner Losh IN VOID *Buffer, 101*0d1ba665SWarner Losh IN UINTN Pages 102*0d1ba665SWarner Losh ); 103*0d1ba665SWarner Losh 104*0d1ba665SWarner Losh /** 105*0d1ba665SWarner Losh Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment. 106*0d1ba665SWarner Losh 107*0d1ba665SWarner Losh Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an 108*0d1ba665SWarner Losh alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is 109*0d1ba665SWarner Losh returned. If there is not enough memory at the specified alignment remaining to satisfy the 110*0d1ba665SWarner Losh request, then NULL is returned. 111*0d1ba665SWarner Losh 112*0d1ba665SWarner Losh If Alignment is not a power of two and Alignment is not zero, then ASSERT(). 113*0d1ba665SWarner Losh If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT(). 114*0d1ba665SWarner Losh 115*0d1ba665SWarner Losh @param Pages The number of 4 KB pages to allocate. 116*0d1ba665SWarner Losh @param Alignment The requested alignment of the allocation. Must be a power of two. 117*0d1ba665SWarner Losh If Alignment is zero, then byte alignment is used. 118*0d1ba665SWarner Losh 119*0d1ba665SWarner Losh @return A pointer to the allocated buffer or NULL if allocation fails. 120*0d1ba665SWarner Losh 121*0d1ba665SWarner Losh **/ 122*0d1ba665SWarner Losh VOID * 123*0d1ba665SWarner Losh EFIAPI 124*0d1ba665SWarner Losh AllocateAlignedPages ( 125*0d1ba665SWarner Losh IN UINTN Pages, 126*0d1ba665SWarner Losh IN UINTN Alignment 127*0d1ba665SWarner Losh ); 128*0d1ba665SWarner Losh 129*0d1ba665SWarner Losh /** 130*0d1ba665SWarner Losh Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment. 131*0d1ba665SWarner Losh 132*0d1ba665SWarner Losh Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an 133*0d1ba665SWarner Losh alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is 134*0d1ba665SWarner Losh returned. If there is not enough memory at the specified alignment remaining to satisfy the 135*0d1ba665SWarner Losh request, then NULL is returned. 136*0d1ba665SWarner Losh 137*0d1ba665SWarner Losh If Alignment is not a power of two and Alignment is not zero, then ASSERT(). 138*0d1ba665SWarner Losh If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT(). 139*0d1ba665SWarner Losh 140*0d1ba665SWarner Losh @param Pages The number of 4 KB pages to allocate. 141*0d1ba665SWarner Losh @param Alignment The requested alignment of the allocation. Must be a power of two. 142*0d1ba665SWarner Losh If Alignment is zero, then byte alignment is used. 143*0d1ba665SWarner Losh 144*0d1ba665SWarner Losh @return A pointer to the allocated buffer or NULL if allocation fails. 145*0d1ba665SWarner Losh 146*0d1ba665SWarner Losh **/ 147*0d1ba665SWarner Losh VOID * 148*0d1ba665SWarner Losh EFIAPI 149*0d1ba665SWarner Losh AllocateAlignedRuntimePages ( 150*0d1ba665SWarner Losh IN UINTN Pages, 151*0d1ba665SWarner Losh IN UINTN Alignment 152*0d1ba665SWarner Losh ); 153*0d1ba665SWarner Losh 154*0d1ba665SWarner Losh /** 155*0d1ba665SWarner Losh Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment. 156*0d1ba665SWarner Losh 157*0d1ba665SWarner Losh Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an 158*0d1ba665SWarner Losh alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is 159*0d1ba665SWarner Losh returned. If there is not enough memory at the specified alignment remaining to satisfy the 160*0d1ba665SWarner Losh request, then NULL is returned. 161*0d1ba665SWarner Losh 162*0d1ba665SWarner Losh If Alignment is not a power of two and Alignment is not zero, then ASSERT(). 163*0d1ba665SWarner Losh If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT(). 164*0d1ba665SWarner Losh 165*0d1ba665SWarner Losh @param Pages The number of 4 KB pages to allocate. 166*0d1ba665SWarner Losh @param Alignment The requested alignment of the allocation. Must be a power of two. 167*0d1ba665SWarner Losh If Alignment is zero, then byte alignment is used. 168*0d1ba665SWarner Losh 169*0d1ba665SWarner Losh @return A pointer to the allocated buffer or NULL if allocation fails. 170*0d1ba665SWarner Losh 171*0d1ba665SWarner Losh **/ 172*0d1ba665SWarner Losh VOID * 173*0d1ba665SWarner Losh EFIAPI 174*0d1ba665SWarner Losh AllocateAlignedReservedPages ( 175*0d1ba665SWarner Losh IN UINTN Pages, 176*0d1ba665SWarner Losh IN UINTN Alignment 177*0d1ba665SWarner Losh ); 178*0d1ba665SWarner Losh 179*0d1ba665SWarner Losh /** 180*0d1ba665SWarner Losh Frees one or more 4KB pages that were previously allocated with one of the aligned page 181*0d1ba665SWarner Losh allocation functions in the Memory Allocation Library. 182*0d1ba665SWarner Losh 183*0d1ba665SWarner Losh Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer 184*0d1ba665SWarner Losh must have been allocated on a previous call to the aligned page allocation services of the Memory 185*0d1ba665SWarner Losh Allocation Library. If it is not possible to free allocated pages, then this function will 186*0d1ba665SWarner Losh perform no actions. 187*0d1ba665SWarner Losh 188*0d1ba665SWarner Losh If Buffer was not allocated with an aligned page allocation function in the Memory Allocation 189*0d1ba665SWarner Losh Library, then ASSERT(). 190*0d1ba665SWarner Losh If Pages is zero, then ASSERT(). 191*0d1ba665SWarner Losh 192*0d1ba665SWarner Losh @param Buffer Pointer to the buffer of pages to free. 193*0d1ba665SWarner Losh @param Pages The number of 4 KB pages to free. 194*0d1ba665SWarner Losh 195*0d1ba665SWarner Losh **/ 196*0d1ba665SWarner Losh VOID 197*0d1ba665SWarner Losh EFIAPI 198*0d1ba665SWarner Losh FreeAlignedPages ( 199*0d1ba665SWarner Losh IN VOID *Buffer, 200*0d1ba665SWarner Losh IN UINTN Pages 201*0d1ba665SWarner Losh ); 202*0d1ba665SWarner Losh 203*0d1ba665SWarner Losh /** 204*0d1ba665SWarner Losh Allocates a buffer of type EfiBootServicesData. 205*0d1ba665SWarner Losh 206*0d1ba665SWarner Losh Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a 207*0d1ba665SWarner Losh pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is 208*0d1ba665SWarner Losh returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. 209*0d1ba665SWarner Losh 210*0d1ba665SWarner Losh @param AllocationSize The number of bytes to allocate. 211*0d1ba665SWarner Losh 212*0d1ba665SWarner Losh @return A pointer to the allocated buffer or NULL if allocation fails. 213*0d1ba665SWarner Losh 214*0d1ba665SWarner Losh **/ 215*0d1ba665SWarner Losh VOID * 216*0d1ba665SWarner Losh EFIAPI 217*0d1ba665SWarner Losh AllocatePool ( 218*0d1ba665SWarner Losh IN UINTN AllocationSize 219*0d1ba665SWarner Losh ); 220*0d1ba665SWarner Losh 221*0d1ba665SWarner Losh /** 222*0d1ba665SWarner Losh Allocates a buffer of type EfiRuntimeServicesData. 223*0d1ba665SWarner Losh 224*0d1ba665SWarner Losh Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns 225*0d1ba665SWarner Losh a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is 226*0d1ba665SWarner Losh returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. 227*0d1ba665SWarner Losh 228*0d1ba665SWarner Losh @param AllocationSize The number of bytes to allocate. 229*0d1ba665SWarner Losh 230*0d1ba665SWarner Losh @return A pointer to the allocated buffer or NULL if allocation fails. 231*0d1ba665SWarner Losh 232*0d1ba665SWarner Losh **/ 233*0d1ba665SWarner Losh VOID * 234*0d1ba665SWarner Losh EFIAPI 235*0d1ba665SWarner Losh AllocateRuntimePool ( 236*0d1ba665SWarner Losh IN UINTN AllocationSize 237*0d1ba665SWarner Losh ); 238*0d1ba665SWarner Losh 239*0d1ba665SWarner Losh /** 240*0d1ba665SWarner Losh Allocates a buffer of type EfiReservedMemoryType. 241*0d1ba665SWarner Losh 242*0d1ba665SWarner Losh Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType and returns 243*0d1ba665SWarner Losh a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is 244*0d1ba665SWarner Losh returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. 245*0d1ba665SWarner Losh 246*0d1ba665SWarner Losh @param AllocationSize The number of bytes to allocate. 247*0d1ba665SWarner Losh 248*0d1ba665SWarner Losh @return A pointer to the allocated buffer or NULL if allocation fails. 249*0d1ba665SWarner Losh 250*0d1ba665SWarner Losh **/ 251*0d1ba665SWarner Losh VOID * 252*0d1ba665SWarner Losh EFIAPI 253*0d1ba665SWarner Losh AllocateReservedPool ( 254*0d1ba665SWarner Losh IN UINTN AllocationSize 255*0d1ba665SWarner Losh ); 256*0d1ba665SWarner Losh 257*0d1ba665SWarner Losh /** 258*0d1ba665SWarner Losh Allocates and zeros a buffer of type EfiBootServicesData. 259*0d1ba665SWarner Losh 260*0d1ba665SWarner Losh Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the 261*0d1ba665SWarner Losh buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a 262*0d1ba665SWarner Losh valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the 263*0d1ba665SWarner Losh request, then NULL is returned. 264*0d1ba665SWarner Losh 265*0d1ba665SWarner Losh @param AllocationSize The number of bytes to allocate and zero. 266*0d1ba665SWarner Losh 267*0d1ba665SWarner Losh @return A pointer to the allocated buffer or NULL if allocation fails. 268*0d1ba665SWarner Losh 269*0d1ba665SWarner Losh **/ 270*0d1ba665SWarner Losh VOID * 271*0d1ba665SWarner Losh EFIAPI 272*0d1ba665SWarner Losh AllocateZeroPool ( 273*0d1ba665SWarner Losh IN UINTN AllocationSize 274*0d1ba665SWarner Losh ); 275*0d1ba665SWarner Losh 276*0d1ba665SWarner Losh /** 277*0d1ba665SWarner Losh Allocates and zeros a buffer of type EfiRuntimeServicesData. 278*0d1ba665SWarner Losh 279*0d1ba665SWarner Losh Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the 280*0d1ba665SWarner Losh buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a 281*0d1ba665SWarner Losh valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the 282*0d1ba665SWarner Losh request, then NULL is returned. 283*0d1ba665SWarner Losh 284*0d1ba665SWarner Losh @param AllocationSize The number of bytes to allocate and zero. 285*0d1ba665SWarner Losh 286*0d1ba665SWarner Losh @return A pointer to the allocated buffer or NULL if allocation fails. 287*0d1ba665SWarner Losh 288*0d1ba665SWarner Losh **/ 289*0d1ba665SWarner Losh VOID * 290*0d1ba665SWarner Losh EFIAPI 291*0d1ba665SWarner Losh AllocateRuntimeZeroPool ( 292*0d1ba665SWarner Losh IN UINTN AllocationSize 293*0d1ba665SWarner Losh ); 294*0d1ba665SWarner Losh 295*0d1ba665SWarner Losh /** 296*0d1ba665SWarner Losh Allocates and zeros a buffer of type EfiReservedMemoryType. 297*0d1ba665SWarner Losh 298*0d1ba665SWarner Losh Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the 299*0d1ba665SWarner Losh buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a 300*0d1ba665SWarner Losh valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the 301*0d1ba665SWarner Losh request, then NULL is returned. 302*0d1ba665SWarner Losh 303*0d1ba665SWarner Losh @param AllocationSize The number of bytes to allocate and zero. 304*0d1ba665SWarner Losh 305*0d1ba665SWarner Losh @return A pointer to the allocated buffer or NULL if allocation fails. 306*0d1ba665SWarner Losh 307*0d1ba665SWarner Losh **/ 308*0d1ba665SWarner Losh VOID * 309*0d1ba665SWarner Losh EFIAPI 310*0d1ba665SWarner Losh AllocateReservedZeroPool ( 311*0d1ba665SWarner Losh IN UINTN AllocationSize 312*0d1ba665SWarner Losh ); 313*0d1ba665SWarner Losh 314*0d1ba665SWarner Losh /** 315*0d1ba665SWarner Losh Copies a buffer to an allocated buffer of type EfiBootServicesData. 316*0d1ba665SWarner Losh 317*0d1ba665SWarner Losh Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies 318*0d1ba665SWarner Losh AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the 319*0d1ba665SWarner Losh allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there 320*0d1ba665SWarner Losh is not enough memory remaining to satisfy the request, then NULL is returned. 321*0d1ba665SWarner Losh 322*0d1ba665SWarner Losh If Buffer is NULL, then ASSERT(). 323*0d1ba665SWarner Losh If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 324*0d1ba665SWarner Losh 325*0d1ba665SWarner Losh @param AllocationSize The number of bytes to allocate and zero. 326*0d1ba665SWarner Losh @param Buffer The buffer to copy to the allocated buffer. 327*0d1ba665SWarner Losh 328*0d1ba665SWarner Losh @return A pointer to the allocated buffer or NULL if allocation fails. 329*0d1ba665SWarner Losh 330*0d1ba665SWarner Losh **/ 331*0d1ba665SWarner Losh VOID * 332*0d1ba665SWarner Losh EFIAPI 333*0d1ba665SWarner Losh AllocateCopyPool ( 334*0d1ba665SWarner Losh IN UINTN AllocationSize, 335*0d1ba665SWarner Losh IN CONST VOID *Buffer 336*0d1ba665SWarner Losh ); 337*0d1ba665SWarner Losh 338*0d1ba665SWarner Losh /** 339*0d1ba665SWarner Losh Copies a buffer to an allocated buffer of type EfiRuntimeServicesData. 340*0d1ba665SWarner Losh 341*0d1ba665SWarner Losh Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies 342*0d1ba665SWarner Losh AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the 343*0d1ba665SWarner Losh allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there 344*0d1ba665SWarner Losh is not enough memory remaining to satisfy the request, then NULL is returned. 345*0d1ba665SWarner Losh 346*0d1ba665SWarner Losh If Buffer is NULL, then ASSERT(). 347*0d1ba665SWarner Losh If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 348*0d1ba665SWarner Losh 349*0d1ba665SWarner Losh @param AllocationSize The number of bytes to allocate and zero. 350*0d1ba665SWarner Losh @param Buffer The buffer to copy to the allocated buffer. 351*0d1ba665SWarner Losh 352*0d1ba665SWarner Losh @return A pointer to the allocated buffer or NULL if allocation fails. 353*0d1ba665SWarner Losh 354*0d1ba665SWarner Losh **/ 355*0d1ba665SWarner Losh VOID * 356*0d1ba665SWarner Losh EFIAPI 357*0d1ba665SWarner Losh AllocateRuntimeCopyPool ( 358*0d1ba665SWarner Losh IN UINTN AllocationSize, 359*0d1ba665SWarner Losh IN CONST VOID *Buffer 360*0d1ba665SWarner Losh ); 361*0d1ba665SWarner Losh 362*0d1ba665SWarner Losh /** 363*0d1ba665SWarner Losh Copies a buffer to an allocated buffer of type EfiReservedMemoryType. 364*0d1ba665SWarner Losh 365*0d1ba665SWarner Losh Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies 366*0d1ba665SWarner Losh AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the 367*0d1ba665SWarner Losh allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there 368*0d1ba665SWarner Losh is not enough memory remaining to satisfy the request, then NULL is returned. 369*0d1ba665SWarner Losh 370*0d1ba665SWarner Losh If Buffer is NULL, then ASSERT(). 371*0d1ba665SWarner Losh If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 372*0d1ba665SWarner Losh 373*0d1ba665SWarner Losh @param AllocationSize The number of bytes to allocate and zero. 374*0d1ba665SWarner Losh @param Buffer The buffer to copy to the allocated buffer. 375*0d1ba665SWarner Losh 376*0d1ba665SWarner Losh @return A pointer to the allocated buffer or NULL if allocation fails. 377*0d1ba665SWarner Losh 378*0d1ba665SWarner Losh **/ 379*0d1ba665SWarner Losh VOID * 380*0d1ba665SWarner Losh EFIAPI 381*0d1ba665SWarner Losh AllocateReservedCopyPool ( 382*0d1ba665SWarner Losh IN UINTN AllocationSize, 383*0d1ba665SWarner Losh IN CONST VOID *Buffer 384*0d1ba665SWarner Losh ); 385*0d1ba665SWarner Losh 386*0d1ba665SWarner Losh /** 387*0d1ba665SWarner Losh Reallocates a buffer of type EfiBootServicesData. 388*0d1ba665SWarner Losh 389*0d1ba665SWarner Losh Allocates and zeros the number bytes specified by NewSize from memory of type 390*0d1ba665SWarner Losh EfiBootServicesData. If OldBuffer is not NULL, then the smaller of OldSize and 391*0d1ba665SWarner Losh NewSize bytes are copied from OldBuffer to the newly allocated buffer, and 392*0d1ba665SWarner Losh OldBuffer is freed. A pointer to the newly allocated buffer is returned. 393*0d1ba665SWarner Losh If NewSize is 0, then a valid buffer of 0 size is returned. If there is not 394*0d1ba665SWarner Losh enough memory remaining to satisfy the request, then NULL is returned. 395*0d1ba665SWarner Losh 396*0d1ba665SWarner Losh If the allocation of the new buffer is successful and the smaller of NewSize and OldSize 397*0d1ba665SWarner Losh is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT(). 398*0d1ba665SWarner Losh 399*0d1ba665SWarner Losh @param OldSize The size, in bytes, of OldBuffer. 400*0d1ba665SWarner Losh @param NewSize The size, in bytes, of the buffer to reallocate. 401*0d1ba665SWarner Losh @param OldBuffer The buffer to copy to the allocated buffer. This is an optional 402*0d1ba665SWarner Losh parameter that may be NULL. 403*0d1ba665SWarner Losh 404*0d1ba665SWarner Losh @return A pointer to the allocated buffer or NULL if allocation fails. 405*0d1ba665SWarner Losh 406*0d1ba665SWarner Losh **/ 407*0d1ba665SWarner Losh VOID * 408*0d1ba665SWarner Losh EFIAPI 409*0d1ba665SWarner Losh ReallocatePool ( 410*0d1ba665SWarner Losh IN UINTN OldSize, 411*0d1ba665SWarner Losh IN UINTN NewSize, 412*0d1ba665SWarner Losh IN VOID *OldBuffer OPTIONAL 413*0d1ba665SWarner Losh ); 414*0d1ba665SWarner Losh 415*0d1ba665SWarner Losh /** 416*0d1ba665SWarner Losh Reallocates a buffer of type EfiRuntimeServicesData. 417*0d1ba665SWarner Losh 418*0d1ba665SWarner Losh Allocates and zeros the number bytes specified by NewSize from memory of type 419*0d1ba665SWarner Losh EfiRuntimeServicesData. If OldBuffer is not NULL, then the smaller of OldSize and 420*0d1ba665SWarner Losh NewSize bytes are copied from OldBuffer to the newly allocated buffer, and 421*0d1ba665SWarner Losh OldBuffer is freed. A pointer to the newly allocated buffer is returned. 422*0d1ba665SWarner Losh If NewSize is 0, then a valid buffer of 0 size is returned. If there is not 423*0d1ba665SWarner Losh enough memory remaining to satisfy the request, then NULL is returned. 424*0d1ba665SWarner Losh 425*0d1ba665SWarner Losh If the allocation of the new buffer is successful and the smaller of NewSize and OldSize 426*0d1ba665SWarner Losh is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT(). 427*0d1ba665SWarner Losh 428*0d1ba665SWarner Losh @param OldSize The size, in bytes, of OldBuffer. 429*0d1ba665SWarner Losh @param NewSize The size, in bytes, of the buffer to reallocate. 430*0d1ba665SWarner Losh @param OldBuffer The buffer to copy to the allocated buffer. This is an optional 431*0d1ba665SWarner Losh parameter that may be NULL. 432*0d1ba665SWarner Losh 433*0d1ba665SWarner Losh @return A pointer to the allocated buffer or NULL if allocation fails. 434*0d1ba665SWarner Losh 435*0d1ba665SWarner Losh **/ 436*0d1ba665SWarner Losh VOID * 437*0d1ba665SWarner Losh EFIAPI 438*0d1ba665SWarner Losh ReallocateRuntimePool ( 439*0d1ba665SWarner Losh IN UINTN OldSize, 440*0d1ba665SWarner Losh IN UINTN NewSize, 441*0d1ba665SWarner Losh IN VOID *OldBuffer OPTIONAL 442*0d1ba665SWarner Losh ); 443*0d1ba665SWarner Losh 444*0d1ba665SWarner Losh /** 445*0d1ba665SWarner Losh Reallocates a buffer of type EfiReservedMemoryType. 446*0d1ba665SWarner Losh 447*0d1ba665SWarner Losh Allocates and zeros the number bytes specified by NewSize from memory of type 448*0d1ba665SWarner Losh EfiReservedMemoryType. If OldBuffer is not NULL, then the smaller of OldSize and 449*0d1ba665SWarner Losh NewSize bytes are copied from OldBuffer to the newly allocated buffer, and 450*0d1ba665SWarner Losh OldBuffer is freed. A pointer to the newly allocated buffer is returned. 451*0d1ba665SWarner Losh If NewSize is 0, then a valid buffer of 0 size is returned. If there is not 452*0d1ba665SWarner Losh enough memory remaining to satisfy the request, then NULL is returned. 453*0d1ba665SWarner Losh 454*0d1ba665SWarner Losh If the allocation of the new buffer is successful and the smaller of NewSize and OldSize 455*0d1ba665SWarner Losh is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT(). 456*0d1ba665SWarner Losh 457*0d1ba665SWarner Losh @param OldSize The size, in bytes, of OldBuffer. 458*0d1ba665SWarner Losh @param NewSize The size, in bytes, of the buffer to reallocate. 459*0d1ba665SWarner Losh @param OldBuffer The buffer to copy to the allocated buffer. This is an optional 460*0d1ba665SWarner Losh parameter that may be NULL. 461*0d1ba665SWarner Losh 462*0d1ba665SWarner Losh @return A pointer to the allocated buffer or NULL if allocation fails. 463*0d1ba665SWarner Losh 464*0d1ba665SWarner Losh **/ 465*0d1ba665SWarner Losh VOID * 466*0d1ba665SWarner Losh EFIAPI 467*0d1ba665SWarner Losh ReallocateReservedPool ( 468*0d1ba665SWarner Losh IN UINTN OldSize, 469*0d1ba665SWarner Losh IN UINTN NewSize, 470*0d1ba665SWarner Losh IN VOID *OldBuffer OPTIONAL 471*0d1ba665SWarner Losh ); 472*0d1ba665SWarner Losh 473*0d1ba665SWarner Losh /** 474*0d1ba665SWarner Losh Frees a buffer that was previously allocated with one of the pool allocation functions in the 475*0d1ba665SWarner Losh Memory Allocation Library. 476*0d1ba665SWarner Losh 477*0d1ba665SWarner Losh Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the 478*0d1ba665SWarner Losh pool allocation services of the Memory Allocation Library. If it is not possible to free pool 479*0d1ba665SWarner Losh resources, then this function will perform no actions. 480*0d1ba665SWarner Losh 481*0d1ba665SWarner Losh If Buffer was not allocated with a pool allocation function in the Memory Allocation Library, 482*0d1ba665SWarner Losh then ASSERT(). 483*0d1ba665SWarner Losh 484*0d1ba665SWarner Losh @param Buffer Pointer to the buffer to free. 485*0d1ba665SWarner Losh 486*0d1ba665SWarner Losh **/ 487*0d1ba665SWarner Losh VOID 488*0d1ba665SWarner Losh EFIAPI 489*0d1ba665SWarner Losh FreePool ( 490*0d1ba665SWarner Losh IN VOID *Buffer 491*0d1ba665SWarner Losh ); 492*0d1ba665SWarner Losh 493*0d1ba665SWarner Losh #endif 494