]>
git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueMemoryAllocationLib.h
3 Copyright (c) 2004 - 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 EdkIIGlueMemoryAllocationLib.h
19 Public header file for Memory Allocation Lib
23 #ifndef __EDKII_GLUE_MEMORY_ALLOCATION_LIB_H__
24 #define __EDKII_GLUE_MEMORY_ALLOCATION_LIB_H__
27 #define AllocatePages(_PAGES) GlueAllocatePages(_PAGES)
28 #define FreePages(_BUFFER, _PAGES) GlueFreePages(_BUFFER, _PAGES)
29 #define AllocatePool(_SIZE) GlueAllocatePool(_SIZE)
30 #define AllocateZeroPool(_ALLOCATIONSIZE) GlueAllocateZeroPool(_ALLOCATIONSIZE)
31 #define AllocateCopyPool(_ALLOCATIONSIZE, _BUFFER) GlueAllocateCopyPool(_ALLOCATIONSIZE, _BUFFER)
32 #define FreePool(_BUFFER) GlueFreePool(_BUFFER)
36 Allocates one or more 4KB pages of type EfiBootServicesData.
38 Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the
39 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
40 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
43 @param Pages The number of 4 KB pages to allocate.
45 @return A pointer to the allocated buffer or NULL if allocation fails.
55 Allocates one or more 4KB pages of type EfiRuntimeServicesData.
57 Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
58 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
59 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
62 @param Pages The number of 4 KB pages to allocate.
64 @return A pointer to the allocated buffer or NULL if allocation fails.
69 AllocateRuntimePages (
74 Allocates one or more 4KB pages of type EfiReservedMemoryType.
76 Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the
77 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
78 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
81 @param Pages The number of 4 KB pages to allocate.
83 @return A pointer to the allocated buffer or NULL if allocation fails.
88 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
99 If Buffer was not allocated with a page allocation function in the Memory Allocation Library,
101 If Pages is zero, then ASSERT().
103 @param Buffer Pointer to the buffer of pages to free.
104 @param Pages The number of 4 KB pages to free.
115 Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
117 Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an
118 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
119 returned. If there is not enough memory at the specified alignment remaining to satisfy the
120 request, then NULL is returned.
121 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
123 @param Pages The number of 4 KB pages to allocate.
124 @param Alignment The requested alignment of the allocation. 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 (
138 Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.
140 Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an
141 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
142 returned. If there is not enough memory at the specified alignment remaining to satisfy the
143 request, then NULL is returned.
144 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
146 @param Pages The number of 4 KB pages to allocate.
147 @param Alignment The requested alignment of the allocation. Must be a power of two.
148 If Alignment is zero, then byte alignment is used.
150 @return A pointer to the allocated buffer or NULL if allocation fails.
155 AllocateAlignedRuntimePages (
161 Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.
163 Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an
164 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
165 returned. If there is not enough memory at the specified alignment remaining to satisfy the
166 request, then NULL is returned.
167 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
169 @param Pages The number of 4 KB pages to allocate.
170 @param Alignment The requested alignment of the allocation. Must be a power of two.
171 If Alignment is zero, then byte alignment is used.
173 @return A pointer to the allocated buffer or NULL if allocation fails.
178 AllocateAlignedReservedPages (
184 Frees one or more 4KB pages that were previously allocated with one of the aligned page
185 allocation functions in the Memory Allocation Library.
187 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
188 must have been allocated on a previous call to the aligned page allocation services of the Memory
190 If Buffer was not allocated with an aligned page allocation function in the Memory Allocation
191 Library, then ASSERT().
192 If Pages is zero, then ASSERT().
194 @param Buffer Pointer to the buffer of pages to free.
195 @param Pages The number of 4 KB pages to free.
206 Allocates a buffer of type EfiBootServicesData.
208 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
209 pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
210 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
212 @param AllocationSize The number of bytes to allocate.
214 @return A pointer to the allocated buffer or NULL if allocation fails.
220 IN UINTN AllocationSize
224 Allocates a buffer of type EfiRuntimeServicesData.
226 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns
227 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
228 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
230 @param AllocationSize The number of bytes to allocate.
232 @return A pointer to the allocated buffer or NULL if allocation fails.
237 AllocateRuntimePool (
238 IN UINTN AllocationSize
242 Allocates a buffer of type EfieservedMemoryType.
244 Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType and returns
245 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
246 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
248 @param AllocationSize The number of bytes to allocate.
250 @return A pointer to the allocated buffer or NULL if allocation fails.
255 AllocateReservedPool (
256 IN UINTN AllocationSize
260 Allocates and zeros a buffer of type EfiBootServicesData.
262 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
263 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
264 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
265 request, then NULL is returned.
267 @param AllocationSize The number of bytes to allocate and zero.
269 @return A pointer to the allocated buffer or NULL if allocation fails.
274 GlueAllocateZeroPool (
275 IN UINTN AllocationSize
279 Allocates and zeros a buffer of type EfiRuntimeServicesData.
281 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the
282 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
283 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
284 request, then NULL is returned.
286 @param AllocationSize The number of bytes to allocate and zero.
288 @return A pointer to the allocated buffer or NULL if allocation fails.
293 AllocateRuntimeZeroPool (
294 IN UINTN AllocationSize
298 Allocates and zeros a buffer of type EfiReservedMemoryType.
300 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the
301 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
302 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
303 request, then NULL is returned.
305 @param AllocationSize The number of bytes to allocate and zero.
307 @return A pointer to the allocated buffer or NULL if allocation fails.
312 AllocateReservedZeroPool (
313 IN UINTN AllocationSize
317 Copies a buffer to an allocated buffer of type EfiBootServicesData.
319 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies
320 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
321 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
322 is not enough memory remaining to satisfy the request, then NULL is returned.
323 If Buffer is NULL, then ASSERT().
324 If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
326 @param AllocationSize The number of bytes to allocate and zero.
327 @param Buffer The buffer to copy to the allocated buffer.
329 @return A pointer to the allocated buffer or NULL if allocation fails.
334 GlueAllocateCopyPool (
335 IN UINTN AllocationSize
,
336 IN CONST VOID
*Buffer
340 Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.
342 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies
343 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
344 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
345 is not enough memory remaining to satisfy the request, then NULL is returned.
346 If Buffer is NULL, then ASSERT().
347 If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
349 @param AllocationSize The number of bytes to allocate and zero.
350 @param Buffer The buffer to copy to the allocated buffer.
352 @return A pointer to the allocated buffer or NULL if allocation fails.
357 AllocateRuntimeCopyPool (
358 IN UINTN AllocationSize
,
359 IN CONST VOID
*Buffer
363 Copies a buffer to an allocated buffer of type EfiReservedMemoryType.
365 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies
366 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
367 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
368 is not enough memory remaining to satisfy the request, then NULL is returned.
369 If Buffer is NULL, then ASSERT().
370 If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
372 @param AllocationSize The number of bytes to allocate and zero.
373 @param Buffer The buffer to copy to the allocated buffer.
375 @return A pointer to the allocated buffer or NULL if allocation fails.
380 AllocateReservedCopyPool (
381 IN UINTN AllocationSize
,
382 IN CONST VOID
*Buffer
386 Frees a buffer that was previously allocated with one of the pool allocation functions in the
387 Memory Allocation Library.
389 Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
390 pool allocation services of the Memory Allocation Library.
391 If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
394 @param Buffer Pointer to the buffer to free.
404 Allocates a buffer of type EfiBootServicesData at a specified alignment.
406 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an
407 alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
408 then a valid buffer of 0 size is returned. If there is not enough memory at the specified
409 alignment remaining to satisfy the request, then NULL is returned.
410 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
412 @param AllocationSize The number of bytes to allocate.
413 @param Alignment The requested alignment of the allocation. Must be a power of two.
414 If Alignment is zero, then byte alignment is used.
416 @return A pointer to the allocated buffer or NULL if allocation fails.
421 AllocateAlignedPool (
422 IN UINTN AllocationSize
,
427 Allocates a buffer of type EfiRuntimeServicesData at a specified alignment.
429 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an
430 alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
431 then a valid buffer of 0 size is returned. If there is not enough memory at the specified
432 alignment remaining to satisfy the request, then NULL is returned.
433 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
435 @param AllocationSize The number of bytes to allocate.
436 @param Alignment The requested alignment of the allocation. Must be a power of two.
437 If Alignment is zero, then byte alignment is used.
439 @return A pointer to the allocated buffer or NULL if allocation fails.
444 AllocateAlignedRuntimePool (
445 IN UINTN AllocationSize
,
450 Allocates a buffer of type EfieservedMemoryType at a specified alignment.
452 Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an
453 alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
454 then a valid buffer of 0 size is returned. If there is not enough memory at the specified
455 alignment remaining to satisfy the request, then NULL is returned.
456 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
458 @param AllocationSize The number of bytes to allocate.
459 @param Alignment The requested alignment of the allocation. Must be a power of two.
460 If Alignment is zero, then byte alignment is used.
462 @return A pointer to the allocated buffer or NULL if allocation fails.
467 AllocateAlignedReservedPool (
468 IN UINTN AllocationSize
,
473 Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment.
475 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an
476 alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the
477 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
478 is not enough memory at the specified alignment remaining to satisfy the request, then NULL is
480 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
482 @param AllocationSize The number of bytes to allocate.
483 @param Alignment The requested alignment of the allocation. Must be a power of two.
484 If Alignment is zero, then byte alignment is used.
486 @return A pointer to the allocated buffer or NULL if allocation fails.
491 AllocateAlignedZeroPool (
492 IN UINTN AllocationSize
,
497 Allocates and zeros a buffer of type EfiRuntimeServicesData at a specified alignment.
499 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an
500 alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the
501 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
502 is not enough memory at the specified alignment remaining to satisfy the request, then NULL is
504 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
506 @param AllocationSize The number of bytes to allocate.
507 @param Alignment The requested alignment of the allocation. Must be a power of two.
508 If Alignment is zero, then byte alignment is used.
510 @return A pointer to the allocated buffer or NULL if allocation fails.
515 AllocateAlignedRuntimeZeroPool (
516 IN UINTN AllocationSize
,
521 Allocates and zeros a buffer of type EfieservedMemoryType at a specified alignment.
523 Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an
524 alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the
525 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
526 is not enough memory at the specified alignment remaining to satisfy the request, then NULL is
528 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
530 @param AllocationSize The number of bytes to allocate.
531 @param Alignment The requested alignment of the allocation. Must be a power of two.
532 If Alignment is zero, then byte alignment is used.
534 @return A pointer to the allocated buffer or NULL if allocation fails.
539 AllocateAlignedReservedZeroPool (
540 IN UINTN AllocationSize
,
545 Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment.
547 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData type with an
548 alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
549 then a valid buffer of 0 size is returned. If there is not enough memory at the specified
550 alignment remaining to satisfy the request, then NULL is returned.
551 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
553 @param AllocationSize The number of bytes to allocate.
554 @param Buffer The buffer to copy to the allocated buffer.
555 @param Alignment The requested alignment of the allocation. Must be a power of two.
556 If Alignment is zero, then byte alignment is used.
558 @return A pointer to the allocated buffer or NULL if allocation fails.
563 AllocateAlignedCopyPool (
564 IN UINTN AllocationSize
,
565 IN CONST VOID
*Buffer
,
570 Copies a buffer to an allocated buffer of type EfiRuntimeServicesData at a specified alignment.
572 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData type with an
573 alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
574 then a valid buffer of 0 size is returned. If there is not enough memory at the specified
575 alignment remaining to satisfy the request, then NULL is returned.
576 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
578 @param AllocationSize The number of bytes to allocate.
579 @param Buffer The buffer to copy to the allocated buffer.
580 @param Alignment The requested alignment of the allocation. Must be a power of two.
581 If Alignment is zero, then byte alignment is used.
583 @return A pointer to the allocated buffer or NULL if allocation fails.
588 AllocateAlignedRuntimeCopyPool (
589 IN UINTN AllocationSize
,
590 IN CONST VOID
*Buffer
,
595 Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment.
597 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType type with an
598 alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
599 then a valid buffer of 0 size is returned. If there is not enough memory at the specified
600 alignment remaining to satisfy the request, then NULL is returned.
601 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
603 @param AllocationSize The number of bytes to allocate.
604 @param Buffer The buffer to copy to the allocated buffer.
605 @param Alignment The requested alignment of the allocation. Must be a power of two.
606 If Alignment is zero, then byte alignment is used.
608 @return A pointer to the allocated buffer or NULL if allocation fails.
613 AllocateAlignedReservedCopyPool (
614 IN UINTN AllocationSize
,
615 IN CONST VOID
*Buffer
,
620 Frees a buffer that was previously allocated with one of the aligned pool allocation functions
621 in the Memory Allocation Library.
623 Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
624 aligned pool allocation services of the Memory Allocation Library.
625 If Buffer was not allocated with an aligned pool allocation function in the Memory Allocation
626 Library, then ASSERT().
628 @param Buffer Pointer to the buffer to free.