]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/MemoryAllocationLib.h
2 Provides services to allocate and free memory buffers of various memory types and alignments.
4 Copyright (c) 2006 - 2008, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef __MEMORY_ALLOCATION_LIB_H__
16 #define __MEMORY_ALLOCATION_LIB_H__
19 Allocates one or more 4KB pages of type EfiBootServicesData.
21 Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the
22 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
23 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
26 @param Pages The number of 4 KB pages to allocate.
28 @return A pointer to the allocated buffer or NULL if allocation fails.
38 Allocates one or more 4KB pages of type EfiRuntimeServicesData.
40 Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
41 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
42 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
45 @param Pages The number of 4 KB pages to allocate.
47 @return A pointer to the allocated buffer or NULL if allocation fails.
52 AllocateRuntimePages (
57 Allocates one or more 4KB pages of type EfiReservedMemoryType.
59 Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the
60 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
61 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
64 @param Pages The number of 4 KB pages to allocate.
66 @return A pointer to the allocated buffer or NULL if allocation fails.
71 AllocateReservedPages (
76 Frees one or more 4KB pages that were previously allocated with one of the page allocation
77 functions in the Memory Allocation Library.
79 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
80 must have been allocated on a previous call to the page allocation services of the Memory
82 If Buffer was not allocated with a page allocation function in the Memory Allocation Library,
84 If Pages is zero, then ASSERT().
86 @param Buffer Pointer to the buffer of pages to free.
87 @param Pages The number of 4 KB pages to free.
98 Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
100 Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an
101 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
102 returned. If there is not enough memory at the specified alignment remaining to satisfy the
103 request, then NULL is returned.
104 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
106 @param Pages The number of 4 KB pages to allocate.
107 @param Alignment The requested alignment of the allocation. Must be a power of two.
108 If Alignment is zero, then byte alignment is used.
110 @return A pointer to the allocated buffer or NULL if allocation fails.
115 AllocateAlignedPages (
121 Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.
123 Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an
124 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
125 returned. If there is not enough memory at the specified alignment remaining to satisfy the
126 request, then NULL is returned.
127 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
129 @param Pages The number of 4 KB pages to allocate.
130 @param Alignment The requested alignment of the allocation. Must be a power of two.
131 If Alignment is zero, then byte alignment is used.
133 @return A pointer to the allocated buffer or NULL if allocation fails.
138 AllocateAlignedRuntimePages (
144 Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.
146 Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType 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.
150 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
152 @param Pages The number of 4 KB pages to allocate.
153 @param Alignment The requested alignment of the allocation. Must be a power of two.
154 If Alignment is zero, then byte alignment is used.
156 @return A pointer to the allocated buffer or NULL if allocation fails.
161 AllocateAlignedReservedPages (
167 Frees one or more 4KB pages that were previously allocated with one of the aligned page
168 allocation functions in the Memory Allocation Library.
170 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
171 must have been allocated on a previous call to the aligned page allocation services of the Memory
173 If Buffer was not allocated with an aligned page allocation function in the Memory Allocation
174 Library, then ASSERT().
175 If Pages is zero, then ASSERT().
177 @param Buffer Pointer to the buffer of pages to free.
178 @param Pages The number of 4 KB pages to free.
189 Allocates a buffer of type EfiBootServicesData.
191 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
192 pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
193 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
195 @param AllocationSize The number of bytes to allocate.
197 @return A pointer to the allocated buffer or NULL if allocation fails.
203 IN UINTN AllocationSize
207 Allocates a buffer of type EfiRuntimeServicesData.
209 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns
210 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
211 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
213 @param AllocationSize The number of bytes to allocate.
215 @return A pointer to the allocated buffer or NULL if allocation fails.
220 AllocateRuntimePool (
221 IN UINTN AllocationSize
225 Allocates a buffer of type EfieservedMemoryType.
227 Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType and returns
228 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
229 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
231 @param AllocationSize The number of bytes to allocate.
233 @return A pointer to the allocated buffer or NULL if allocation fails.
238 AllocateReservedPool (
239 IN UINTN AllocationSize
243 Allocates and zeros a buffer of type EfiBootServicesData.
245 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
246 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
247 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
248 request, then NULL is returned.
250 @param AllocationSize The number of bytes to allocate and zero.
252 @return A pointer to the allocated buffer or NULL if allocation fails.
258 IN UINTN AllocationSize
262 Allocates and zeros a buffer of type EfiRuntimeServicesData.
264 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the
265 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
266 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
267 request, then NULL is returned.
269 @param AllocationSize The number of bytes to allocate and zero.
271 @return A pointer to the allocated buffer or NULL if allocation fails.
276 AllocateRuntimeZeroPool (
277 IN UINTN AllocationSize
281 Allocates and zeros a buffer of type EfiReservedMemoryType.
283 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the
284 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
285 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
286 request, then NULL is returned.
288 @param AllocationSize The number of bytes to allocate and zero.
290 @return A pointer to the allocated buffer or NULL if allocation fails.
295 AllocateReservedZeroPool (
296 IN UINTN AllocationSize
300 Copies a buffer to an allocated buffer of type EfiBootServicesData.
302 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies
303 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
304 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
305 is not enough memory remaining to satisfy the request, then NULL is returned.
306 If Buffer is NULL, then ASSERT().
307 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
309 @param AllocationSize The number of bytes to allocate and zero.
310 @param Buffer The buffer to copy to the allocated buffer.
312 @return A pointer to the allocated buffer or NULL if allocation fails.
318 IN UINTN AllocationSize
,
319 IN CONST VOID
*Buffer
323 Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.
325 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies
326 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
327 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
328 is not enough memory remaining to satisfy the request, then NULL is returned.
329 If Buffer is NULL, then ASSERT().
330 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
332 @param AllocationSize The number of bytes to allocate and zero.
333 @param Buffer The buffer to copy to the allocated buffer.
335 @return A pointer to the allocated buffer or NULL if allocation fails.
340 AllocateRuntimeCopyPool (
341 IN UINTN AllocationSize
,
342 IN CONST VOID
*Buffer
346 Copies a buffer to an allocated buffer of type EfiReservedMemoryType.
348 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies
349 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
350 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
351 is not enough memory remaining to satisfy the request, then NULL is returned.
352 If Buffer is NULL, then ASSERT().
353 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
355 @param AllocationSize The number of bytes to allocate and zero.
356 @param Buffer The buffer to copy to the allocated buffer.
358 @return A pointer to the allocated buffer or NULL if allocation fails.
363 AllocateReservedCopyPool (
364 IN UINTN AllocationSize
,
365 IN CONST VOID
*Buffer
369 Frees a buffer that was previously allocated with one of the pool allocation functions in the
370 Memory Allocation Library.
372 Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
373 pool allocation services of the Memory Allocation Library.
374 If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
377 @param Buffer Pointer to the buffer to free.