]>
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 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include <Uefi/UefiBaseType.h>
19 #include <Library/DebugLib.h>
20 #include <Library/MemoryAllocationLib.h>
24 Allocates one or more 4KB pages of type EfiBootServicesData.
26 Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the
27 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
28 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
31 @param Pages The number of 4 KB pages to allocate.
33 @return A pointer to the allocated buffer or NULL if allocation fails.
47 Allocates one or more 4KB pages of type EfiRuntimeServicesData.
49 Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
50 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
51 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
54 @param Pages The number of 4 KB pages to allocate.
56 @return A pointer to the allocated buffer or NULL if allocation fails.
61 AllocateRuntimePages (
70 Allocates one or more 4KB pages of type EfiReservedMemoryType.
72 Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the
73 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
74 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
77 @param Pages The number of 4 KB pages to allocate.
79 @return A pointer to the allocated buffer or NULL if allocation fails.
84 AllocateReservedPages (
93 Frees one or more 4KB pages that were previously allocated with one of the page allocation
94 functions in the Memory Allocation Library.
96 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
97 must have been allocated on a previous call to the page allocation services of the Memory
98 Allocation Library. If it is not possible to free allocated pages, then this function will
101 If Buffer was not allocated with a page allocation function in the Memory Allocation Library,
103 If Pages is zero, then ASSERT().
105 @param Buffer The pointer to the buffer of pages to free.
106 @param Pages The number of 4 KB pages to free.
120 Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
122 Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an
123 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
124 returned. If there is not enough memory at the specified alignment remaining to satisfy the
125 request, then NULL is returned.
127 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
128 If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
130 @param Pages The number of 4 KB pages to allocate.
131 @param Alignment The requested alignment of the allocation.
132 Must be a power of two.
133 If Alignment is zero, then byte alignment is used.
135 @return A pointer to the allocated buffer or NULL if allocation fails.
140 AllocateAlignedPages (
150 Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.
152 Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an
153 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
154 returned. If there is not enough memory at the specified alignment remaining to satisfy the
155 request, then NULL is returned.
157 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
158 If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
160 @param Pages The number of 4 KB pages to allocate.
161 @param Alignment The requested alignment of the allocation.
162 Must be a power of two.
163 If Alignment is zero, then byte alignment is used.
165 @return A pointer to the allocated buffer or NULL if allocation fails.
170 AllocateAlignedRuntimePages (
180 Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.
182 Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an
183 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
184 returned. If there is not enough memory at the specified alignment remaining to satisfy the
185 request, then NULL is returned.
187 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
188 If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
190 @param Pages The number of 4 KB pages to allocate.
191 @param Alignment The requested alignment of the allocation.
192 Must be a power of two.
193 If Alignment is zero, then byte alignment is used.
195 @return A pointer to the allocated buffer or NULL if allocation fails.
200 AllocateAlignedReservedPages (
210 Frees one or more 4KB pages that were previously allocated with one of the aligned page
211 allocation functions in the Memory Allocation Library.
213 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
214 must have been allocated on a previous call to the aligned page allocation services of the Memory
215 Allocation Library. If it is not possible to free allocated pages, then this function will
218 If Buffer was not allocated with an aligned page allocation function in the Memory Allocation
219 Library, then ASSERT().
220 If Pages is zero, then ASSERT().
222 @param Buffer The pointer to the buffer of pages to free.
223 @param Pages The number of 4 KB pages to free.
237 Allocates a buffer of type EfiBootServicesData.
239 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
240 pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
241 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
243 @param AllocationSize The number of bytes to allocate.
245 @return A pointer to the allocated buffer or NULL if allocation fails.
251 IN UINTN AllocationSize
259 Allocates a buffer of type EfiRuntimeServicesData.
261 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns
262 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
263 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
265 @param AllocationSize The number of bytes to allocate.
267 @return A pointer to the allocated buffer or NULL if allocation fails.
272 AllocateRuntimePool (
273 IN UINTN AllocationSize
281 Allocates a buffer of type EfiReservedMemoryType.
283 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType and returns
284 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
285 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
287 @param AllocationSize The number of bytes to allocate.
289 @return A pointer to the allocated buffer or NULL if allocation fails.
294 AllocateReservedPool (
295 IN UINTN AllocationSize
303 Allocates and zeros a buffer of type EfiBootServicesData.
305 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
306 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
307 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
308 request, then NULL is returned.
310 @param AllocationSize The number of bytes to allocate and zero.
312 @return A pointer to the allocated buffer or NULL if allocation fails.
318 IN UINTN AllocationSize
326 Allocates and zeros a buffer of type EfiRuntimeServicesData.
328 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the
329 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
330 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
331 request, then NULL is returned.
333 @param AllocationSize The number of bytes to allocate and zero.
335 @return A pointer to the allocated buffer or NULL if allocation fails.
340 AllocateRuntimeZeroPool (
341 IN UINTN AllocationSize
349 Allocates and zeros a buffer of type EfiReservedMemoryType.
351 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the
352 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
353 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
354 request, then NULL is returned.
356 @param AllocationSize The number of bytes to allocate and zero.
358 @return A pointer to the allocated buffer or NULL if allocation fails.
363 AllocateReservedZeroPool (
364 IN UINTN AllocationSize
372 Copies a buffer to an allocated buffer of type EfiBootServicesData.
374 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies
375 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
376 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
377 is not enough memory remaining to satisfy the request, then NULL is returned.
379 If Buffer is NULL, then ASSERT().
380 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
382 @param AllocationSize The number of bytes to allocate and zero.
383 @param Buffer The buffer to copy to the allocated buffer.
385 @return A pointer to the allocated buffer or NULL if allocation fails.
391 IN UINTN AllocationSize
,
392 IN CONST VOID
*Buffer
400 Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.
402 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies
403 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
404 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
405 is not enough memory remaining to satisfy the request, then NULL is returned.
407 If Buffer is NULL, then ASSERT().
408 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
410 @param AllocationSize The number of bytes to allocate and zero.
411 @param Buffer The buffer to copy to the allocated buffer.
413 @return A pointer to the allocated buffer or NULL if allocation fails.
418 AllocateRuntimeCopyPool (
419 IN UINTN AllocationSize
,
420 IN CONST VOID
*Buffer
428 Copies a buffer to an allocated buffer of type EfiReservedMemoryType.
430 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies
431 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
432 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
433 is not enough memory remaining to satisfy the request, then NULL is returned.
435 If Buffer is NULL, then ASSERT().
436 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
438 @param AllocationSize The number of bytes to allocate and zero.
439 @param Buffer The buffer to copy to the allocated buffer.
441 @return A pointer to the allocated buffer or NULL if allocation fails.
446 AllocateReservedCopyPool (
447 IN UINTN AllocationSize
,
448 IN CONST VOID
*Buffer
456 Reallocates a buffer of type EfiBootServicesData.
458 Allocates and zeros the number bytes specified by NewSize from memory of type
459 EfiBootServicesData. If OldBuffer is not NULL, then the smaller of OldSize and
460 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
461 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
462 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
463 enough memory remaining to satisfy the request, then NULL is returned.
465 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
466 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
468 @param OldSize The size, in bytes, of OldBuffer.
469 @param NewSize The size, in bytes, of the buffer to reallocate.
470 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
471 parameter that may be NULL.
473 @return A pointer to the allocated buffer or NULL if allocation fails.
481 IN VOID
*OldBuffer OPTIONAL
489 Reallocates a buffer of type EfiRuntimeServicesData.
491 Allocates and zeros the number bytes specified by NewSize from memory of type
492 EfiRuntimeServicesData. If OldBuffer is not NULL, then the smaller of OldSize and
493 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
494 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
495 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
496 enough memory remaining to satisfy the request, then NULL is returned.
498 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
499 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
501 @param OldSize The size, in bytes, of OldBuffer.
502 @param NewSize The size, in bytes, of the buffer to reallocate.
503 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
504 parameter that may be NULL.
506 @return A pointer to the allocated buffer or NULL if allocation fails.
511 ReallocateRuntimePool (
514 IN VOID
*OldBuffer OPTIONAL
522 Reallocates a buffer of type EfiReservedMemoryType.
524 Allocates and zeros the number bytes specified by NewSize from memory of type
525 EfiReservedMemoryType. If OldBuffer is not NULL, then the smaller of OldSize and
526 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
527 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
528 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
529 enough memory remaining to satisfy the request, then NULL is returned.
531 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
532 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
534 @param OldSize The size, in bytes, of OldBuffer.
535 @param NewSize The size, in bytes, of the buffer to reallocate.
536 @param OldBuffer The buffer to copy to the allocated buffer. This is an
537 optional parameter that may be NULL.
539 @return A pointer to the allocated buffer or NULL if allocation fails.
544 ReallocateReservedPool (
547 IN VOID
*OldBuffer OPTIONAL
555 Frees a buffer that was previously allocated with one of the pool allocation functions in the
556 Memory Allocation Library.
558 Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
559 pool allocation services of the Memory Allocation Library. If it is not possible to free pool
560 resources, then this function will perform no actions.
562 If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
565 @param Buffer The pointer to the buffer to free.