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