]>
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
11 #include <Uefi/UefiBaseType.h>
13 #include <Library/DebugLib.h>
14 #include <Library/MemoryAllocationLib.h>
18 Allocates one or more 4KB pages of type EfiBootServicesData.
20 Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the
21 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
22 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
25 @param Pages The number of 4 KB pages to allocate.
27 @return A pointer to the allocated buffer or NULL if allocation fails.
41 Allocates one or more 4KB pages of type EfiRuntimeServicesData.
43 Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
44 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
45 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
48 @param Pages The number of 4 KB pages to allocate.
50 @return A pointer to the allocated buffer or NULL if allocation fails.
55 AllocateRuntimePages (
64 Allocates one or more 4KB pages of type EfiReservedMemoryType.
66 Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the
67 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
68 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
71 @param Pages The number of 4 KB pages to allocate.
73 @return A pointer to the allocated buffer or NULL if allocation fails.
78 AllocateReservedPages (
87 Frees one or more 4KB pages that were previously allocated with one of the page allocation
88 functions in the Memory Allocation Library.
90 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
91 must have been allocated on a previous call to the page allocation services of the Memory
92 Allocation Library. If it is not possible to free allocated pages, then this function will
95 If Buffer was not allocated with a page allocation function in the Memory Allocation Library,
97 If Pages is zero, then ASSERT().
99 @param Buffer The pointer to the buffer of pages to free.
100 @param Pages The number of 4 KB pages to free.
114 Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
116 Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an
117 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
118 returned. If there is not enough memory at the specified alignment remaining to satisfy the
119 request, then NULL is returned.
121 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
122 If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
124 @param Pages The number of 4 KB pages to allocate.
125 @param Alignment The requested alignment of the allocation.
126 Must be a power of two.
127 If Alignment is zero, then byte alignment is used.
129 @return A pointer to the allocated buffer or NULL if allocation fails.
134 AllocateAlignedPages (
144 Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.
146 Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an
147 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
148 returned. If there is not enough memory at the specified alignment remaining to satisfy the
149 request, then NULL is returned.
151 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
152 If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
154 @param Pages The number of 4 KB pages to allocate.
155 @param Alignment The requested alignment of the allocation.
156 Must be a power of two.
157 If Alignment is zero, then byte alignment is used.
159 @return A pointer to the allocated buffer or NULL if allocation fails.
164 AllocateAlignedRuntimePages (
174 Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.
176 Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an
177 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
178 returned. If there is not enough memory at the specified alignment remaining to satisfy the
179 request, then NULL is returned.
181 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
182 If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
184 @param Pages The number of 4 KB pages to allocate.
185 @param Alignment The requested alignment of the allocation.
186 Must be a power of two.
187 If Alignment is zero, then byte alignment is used.
189 @return A pointer to the allocated buffer or NULL if allocation fails.
194 AllocateAlignedReservedPages (
204 Frees one or more 4KB pages that were previously allocated with one of the aligned page
205 allocation functions in the Memory Allocation Library.
207 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
208 must have been allocated on a previous call to the aligned page allocation services of the Memory
209 Allocation Library. If it is not possible to free allocated pages, then this function will
212 If Buffer was not allocated with an aligned page allocation function in the Memory Allocation
213 Library, then ASSERT().
214 If Pages is zero, then ASSERT().
216 @param Buffer The pointer to the buffer of pages to free.
217 @param Pages The number of 4 KB pages to free.
231 Allocates a buffer of type EfiBootServicesData.
233 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
234 pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
235 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
237 @param AllocationSize The number of bytes to allocate.
239 @return A pointer to the allocated buffer or NULL if allocation fails.
245 IN UINTN AllocationSize
253 Allocates a buffer of type EfiRuntimeServicesData.
255 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns
256 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
257 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
259 @param AllocationSize The number of bytes to allocate.
261 @return A pointer to the allocated buffer or NULL if allocation fails.
266 AllocateRuntimePool (
267 IN UINTN AllocationSize
275 Allocates a buffer of type EfiReservedMemoryType.
277 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType and returns
278 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
279 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
281 @param AllocationSize The number of bytes to allocate.
283 @return A pointer to the allocated buffer or NULL if allocation fails.
288 AllocateReservedPool (
289 IN UINTN AllocationSize
297 Allocates and zeros a buffer of type EfiBootServicesData.
299 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
300 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
301 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
302 request, then NULL is returned.
304 @param AllocationSize The number of bytes to allocate and zero.
306 @return A pointer to the allocated buffer or NULL if allocation fails.
312 IN UINTN AllocationSize
320 Allocates and zeros a buffer of type EfiRuntimeServicesData.
322 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the
323 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
324 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
325 request, then NULL is returned.
327 @param AllocationSize The number of bytes to allocate and zero.
329 @return A pointer to the allocated buffer or NULL if allocation fails.
334 AllocateRuntimeZeroPool (
335 IN UINTN AllocationSize
343 Allocates and zeros a buffer of type EfiReservedMemoryType.
345 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the
346 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
347 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
348 request, then NULL is returned.
350 @param AllocationSize The number of bytes to allocate and zero.
352 @return A pointer to the allocated buffer or NULL if allocation fails.
357 AllocateReservedZeroPool (
358 IN UINTN AllocationSize
366 Copies a buffer to an allocated buffer of type EfiBootServicesData.
368 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies
369 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
370 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
371 is not enough memory remaining to satisfy the request, then NULL is returned.
373 If Buffer is NULL, then ASSERT().
374 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
376 @param AllocationSize The number of bytes to allocate and zero.
377 @param Buffer The buffer to copy to the allocated buffer.
379 @return A pointer to the allocated buffer or NULL if allocation fails.
385 IN UINTN AllocationSize
,
386 IN CONST VOID
*Buffer
394 Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.
396 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies
397 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
398 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
399 is not enough memory remaining to satisfy the request, then NULL is returned.
401 If Buffer is NULL, then ASSERT().
402 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
404 @param AllocationSize The number of bytes to allocate and zero.
405 @param Buffer The buffer to copy to the allocated buffer.
407 @return A pointer to the allocated buffer or NULL if allocation fails.
412 AllocateRuntimeCopyPool (
413 IN UINTN AllocationSize
,
414 IN CONST VOID
*Buffer
422 Copies a buffer to an allocated buffer of type EfiReservedMemoryType.
424 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies
425 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
426 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
427 is not enough memory remaining to satisfy the request, then NULL is returned.
429 If Buffer is NULL, then ASSERT().
430 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
432 @param AllocationSize The number of bytes to allocate and zero.
433 @param Buffer The buffer to copy to the allocated buffer.
435 @return A pointer to the allocated buffer or NULL if allocation fails.
440 AllocateReservedCopyPool (
441 IN UINTN AllocationSize
,
442 IN CONST VOID
*Buffer
450 Reallocates a buffer of type EfiBootServicesData.
452 Allocates and zeros the number bytes specified by NewSize from memory of type
453 EfiBootServicesData. If OldBuffer is not NULL, then the smaller of OldSize and
454 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
455 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
456 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
457 enough memory remaining to satisfy the request, then NULL is returned.
459 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
460 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
462 @param OldSize The size, in bytes, of OldBuffer.
463 @param NewSize The size, in bytes, of the buffer to reallocate.
464 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
465 parameter that may be NULL.
467 @return A pointer to the allocated buffer or NULL if allocation fails.
475 IN VOID
*OldBuffer OPTIONAL
483 Reallocates a buffer of type EfiRuntimeServicesData.
485 Allocates and zeros the number bytes specified by NewSize from memory of type
486 EfiRuntimeServicesData. If OldBuffer is not NULL, then the smaller of OldSize and
487 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
488 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
489 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
490 enough memory remaining to satisfy the request, then NULL is returned.
492 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
493 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
495 @param OldSize The size, in bytes, of OldBuffer.
496 @param NewSize The size, in bytes, of the buffer to reallocate.
497 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
498 parameter that may be NULL.
500 @return A pointer to the allocated buffer or NULL if allocation fails.
505 ReallocateRuntimePool (
508 IN VOID
*OldBuffer OPTIONAL
516 Reallocates a buffer of type EfiReservedMemoryType.
518 Allocates and zeros the number bytes specified by NewSize from memory of type
519 EfiReservedMemoryType. If OldBuffer is not NULL, then the smaller of OldSize and
520 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
521 OldBuffer is freed. A pointer to the newly allocated buffer is returned.
522 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
523 enough memory remaining to satisfy the request, then NULL is returned.
525 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
526 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
528 @param OldSize The size, in bytes, of OldBuffer.
529 @param NewSize The size, in bytes, of the buffer to reallocate.
530 @param OldBuffer The buffer to copy to the allocated buffer. This is an
531 optional parameter that may be NULL.
533 @return A pointer to the allocated buffer or NULL if allocation fails.
538 ReallocateReservedPool (
541 IN VOID
*OldBuffer OPTIONAL
549 Frees a buffer that was previously allocated with one of the pool allocation functions in the
550 Memory Allocation Library.
552 Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
553 pool allocation services of the Memory Allocation Library. If it is not possible to free pool
554 resources, then this function will perform no actions.
556 If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
559 @param Buffer The pointer to the buffer to free.