]>
git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.c
2 Dummy support routines for memory allocation
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include <Uefi/UefiBaseType.h>
12 #include <Library/DebugLib.h>
13 #include <Library/MemoryAllocationLib.h>
16 Allocates one or more 4KB pages of type EfiBootServicesData.
18 Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the
19 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
20 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
23 @param Pages The number of 4 KB pages to allocate.
25 @return A pointer to the allocated buffer or NULL if allocation fails.
39 Allocates one or more 4KB pages of type EfiRuntimeServicesData.
41 Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
42 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
43 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
46 @param Pages The number of 4 KB pages to allocate.
48 @return A pointer to the allocated buffer or NULL if allocation fails.
53 AllocateRuntimePages (
62 Allocates one or more 4KB pages of type EfiReservedMemoryType.
64 Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the
65 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
66 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
69 @param Pages The number of 4 KB pages to allocate.
71 @return A pointer to the allocated buffer or NULL if allocation fails.
76 AllocateReservedPages (
85 Frees one or more 4KB pages that were previously allocated with one of the page allocation
86 functions in the Memory Allocation Library.
88 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
89 must have been allocated on a previous call to the page allocation services of the Memory
90 Allocation Library. If it is not possible to free allocated pages, then this function will
93 If Buffer was not allocated with a page allocation function in the Memory Allocation Library,
95 If Pages is zero, then ASSERT().
97 @param Buffer The pointer to the buffer of pages to free.
98 @param Pages The number of 4 KB pages to free.
112 Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
114 Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an
115 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
116 returned. If there is not enough memory at the specified alignment remaining to satisfy the
117 request, then NULL is returned.
119 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
120 If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
122 @param Pages The number of 4 KB pages to allocate.
123 @param Alignment The requested alignment of the allocation.
124 Must be a power of two.
125 If Alignment is zero, then byte alignment is used.
127 @return A pointer to the allocated buffer or NULL if allocation fails.
132 AllocateAlignedPages (
142 Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.
144 Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an
145 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
146 returned. If there is not enough memory at the specified alignment remaining to satisfy the
147 request, then NULL is returned.
149 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
150 If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
152 @param Pages The number of 4 KB pages to allocate.
153 @param Alignment The requested alignment of the allocation.
154 Must be a power of two.
155 If Alignment is zero, then byte alignment is used.
157 @return A pointer to the allocated buffer or NULL if allocation fails.
162 AllocateAlignedRuntimePages (
172 Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.
174 Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an
175 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
176 returned. If there is not enough memory at the specified alignment remaining to satisfy the
177 request, then NULL is returned.
179 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
180 If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
182 @param Pages The number of 4 KB pages to allocate.
183 @param Alignment The requested alignment of the allocation.
184 Must be a power of two.
185 If Alignment is zero, then byte alignment is used.
187 @return A pointer to the allocated buffer or NULL if allocation fails.
192 AllocateAlignedReservedPages (
202 Frees one or more 4KB pages that were previously allocated with one of the aligned page
203 allocation functions in the Memory Allocation Library.
205 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
206 must have been allocated on a previous call to the aligned page allocation services of the Memory
207 Allocation Library. If it is not possible to free allocated pages, then this function will
210 If Buffer was not allocated with an aligned page allocation function in the Memory Allocation
211 Library, then ASSERT().
212 If Pages is zero, then ASSERT().
214 @param Buffer The pointer to the buffer of pages to free.
215 @param Pages The number of 4 KB pages to free.
229 Allocates a buffer of type EfiBootServicesData.
231 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
232 pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
233 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
235 @param AllocationSize The number of bytes to allocate.
237 @return A pointer to the allocated buffer or NULL if allocation fails.
243 IN UINTN AllocationSize
251 Allocates a buffer of type EfiRuntimeServicesData.
253 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns
254 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
255 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
257 @param AllocationSize The number of bytes to allocate.
259 @return A pointer to the allocated buffer or NULL if allocation fails.
264 AllocateRuntimePool (
265 IN UINTN AllocationSize
273 Allocates a buffer of type EfiReservedMemoryType.
275 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType and returns
276 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
277 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
279 @param AllocationSize The number of bytes to allocate.
281 @return A pointer to the allocated buffer or NULL if allocation fails.
286 AllocateReservedPool (
287 IN UINTN AllocationSize
295 Allocates and zeros a buffer of type EfiBootServicesData.
297 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
298 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
299 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
300 request, then NULL is returned.
302 @param AllocationSize The number of bytes to allocate and zero.
304 @return A pointer to the allocated buffer or NULL if allocation fails.
310 IN UINTN AllocationSize
318 Allocates and zeros a buffer of type EfiRuntimeServicesData.
320 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the
321 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
322 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
323 request, then NULL is returned.
325 @param AllocationSize The number of bytes to allocate and zero.
327 @return A pointer to the allocated buffer or NULL if allocation fails.
332 AllocateRuntimeZeroPool (
333 IN UINTN AllocationSize
341 Allocates and zeros a buffer of type EfiReservedMemoryType.
343 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the
344 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
345 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
346 request, then NULL is returned.
348 @param AllocationSize The number of bytes to allocate and zero.
350 @return A pointer to the allocated buffer or NULL if allocation fails.
355 AllocateReservedZeroPool (
356 IN UINTN AllocationSize
364 Copies a buffer to an allocated buffer of type EfiBootServicesData.
366 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies
367 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
368 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
369 is not enough memory remaining to satisfy the request, then NULL is returned.
371 If Buffer is NULL, then ASSERT().
372 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
374 @param AllocationSize The number of bytes to allocate and zero.
375 @param Buffer The buffer to copy to the allocated buffer.
377 @return A pointer to the allocated buffer or NULL if allocation fails.
383 IN UINTN AllocationSize
,
384 IN CONST VOID
*Buffer
392 Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.
394 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies
395 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
396 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
397 is not enough memory remaining to satisfy the request, then NULL is returned.
399 If Buffer is NULL, then ASSERT().
400 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
402 @param AllocationSize The number of bytes to allocate and zero.
403 @param Buffer The buffer to copy to the allocated buffer.
405 @return A pointer to the allocated buffer or NULL if allocation fails.
410 AllocateRuntimeCopyPool (
411 IN UINTN AllocationSize
,
412 IN CONST VOID
*Buffer
420 Copies a buffer to an allocated buffer of type EfiReservedMemoryType.
422 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies
423 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
424 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
425 is not enough memory remaining to satisfy the request, then NULL is returned.
427 If Buffer is NULL, then ASSERT().
428 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
430 @param AllocationSize The number of bytes to allocate and zero.
431 @param Buffer The buffer to copy to the allocated buffer.
433 @return A pointer to the allocated buffer or NULL if allocation fails.
438 AllocateReservedCopyPool (
439 IN UINTN AllocationSize
,
440 IN CONST VOID
*Buffer
448 Reallocates a buffer of type EfiBootServicesData.
450 Allocates and zeros the number bytes specified by NewSize from memory of type
451 EfiBootServicesData. If OldBuffer is not NULL, then the smaller of OldSize and
452 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
453 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
454 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
455 enough memory remaining to satisfy the request, then NULL is returned.
457 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
458 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
460 @param OldSize The size, in bytes, of OldBuffer.
461 @param NewSize The size, in bytes, of the buffer to reallocate.
462 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
463 parameter that may be NULL.
465 @return A pointer to the allocated buffer or NULL if allocation fails.
473 IN VOID
*OldBuffer OPTIONAL
481 Reallocates a buffer of type EfiRuntimeServicesData.
483 Allocates and zeros the number bytes specified by NewSize from memory of type
484 EfiRuntimeServicesData. If OldBuffer is not NULL, then the smaller of OldSize and
485 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
486 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
487 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
488 enough memory remaining to satisfy the request, then NULL is returned.
490 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
491 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
493 @param OldSize The size, in bytes, of OldBuffer.
494 @param NewSize The size, in bytes, of the buffer to reallocate.
495 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
496 parameter that may be NULL.
498 @return A pointer to the allocated buffer or NULL if allocation fails.
503 ReallocateRuntimePool (
506 IN VOID
*OldBuffer OPTIONAL
514 Reallocates a buffer of type EfiReservedMemoryType.
516 Allocates and zeros the number bytes specified by NewSize from memory of type
517 EfiReservedMemoryType. If OldBuffer is not NULL, then the smaller of OldSize and
518 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
519 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
520 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
521 enough memory remaining to satisfy the request, then NULL is returned.
523 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
524 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
526 @param OldSize The size, in bytes, of OldBuffer.
527 @param NewSize The size, in bytes, of the buffer to reallocate.
528 @param OldBuffer The buffer to copy to the allocated buffer. This is an
529 optional parameter that may be NULL.
531 @return A pointer to the allocated buffer or NULL if allocation fails.
536 ReallocateReservedPool (
539 IN VOID
*OldBuffer OPTIONAL
547 Frees a buffer that was previously allocated with one of the pool allocation functions in the
548 Memory Allocation Library.
550 Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
551 pool allocation services of the Memory Allocation Library. If it is not possible to free pool
552 resources, then this function will perform no actions.
554 If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
557 @param Buffer The pointer to the buffer to free.