]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/MemoryAllocationLib.h
add ContextTool to workspace/Tools
[mirror_edk2.git] / MdePkg / Include / Library / MemoryAllocationLib.h
CommitLineData
878ddf1f 1/** @file\r
24e25d11 2 Memory Allocation Library Services\r
878ddf1f 3\r
24e25d11 4 Copyright (c) 2006, Intel Corporation \r
5 All rights reserved. This program and the accompanying materials \r
6 are licensed and made available under the terms and conditions of the BSD License \r
7 which accompanies this distribution. The full text of the license may be found at \r
8 http://opensource.org/licenses/bsd-license.php \r
878ddf1f 9\r
24e25d11 10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
878ddf1f 12\r
24e25d11 13 Module Name: MemoryAllocationLib.h\r
878ddf1f 14\r
15**/\r
16\r
17#ifndef __MEMORY_ALLOCATION_LIB_H__\r
18#define __MEMORY_ALLOCATION_LIB_H__\r
19\r
20/**\r
1f33a17f 21 Allocates one or more 4KB pages of type EfiBootServicesData.\r
878ddf1f 22\r
1f33a17f 23 Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the\r
24 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL\r
25 is returned. If there is not enough memory remaining to satisfy the request, then NULL is\r
26 returned.\r
878ddf1f 27\r
1f33a17f 28 @param Pages The number of 4 KB pages to allocate.\r
29\r
30 @return A pointer to the allocated buffer or NULL if allocation fails.\r
878ddf1f 31\r
32**/\r
33VOID *\r
34EFIAPI\r
35AllocatePages (\r
36 IN UINTN Pages\r
1f33a17f 37 );\r
878ddf1f 38\r
39/**\r
1f33a17f 40 Allocates one or more 4KB pages of type EfiRuntimeServicesData.\r
41\r
42 Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the\r
43 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL\r
44 is returned. If there is not enough memory remaining to satisfy the request, then NULL is\r
45 returned.\r
878ddf1f 46\r
1f33a17f 47 @param Pages The number of 4 KB pages to allocate.\r
878ddf1f 48\r
1f33a17f 49 @return A pointer to the allocated buffer or NULL if allocation fails.\r
878ddf1f 50\r
51**/\r
52VOID *\r
53EFIAPI\r
54AllocateRuntimePages (\r
55 IN UINTN Pages\r
1f33a17f 56 );\r
878ddf1f 57\r
58/**\r
1f33a17f 59 Allocates one or more 4KB pages of type EfiReservedMemoryType.\r
878ddf1f 60\r
1f33a17f 61 Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the\r
62 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL\r
63 is returned. If there is not enough memory remaining to satisfy the request, then NULL is\r
64 returned.\r
878ddf1f 65\r
1f33a17f 66 @param Pages The number of 4 KB pages to allocate.\r
67\r
68 @return A pointer to the allocated buffer or NULL if allocation fails.\r
878ddf1f 69\r
70**/\r
71VOID *\r
72EFIAPI\r
73AllocateReservedPages (\r
74 IN UINTN Pages\r
1f33a17f 75 );\r
878ddf1f 76\r
77/**\r
1f33a17f 78 Frees one or more 4KB pages that were previously allocated with one of the page allocation\r
79 functions in the Memory Allocation Library.\r
80\r
81 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer\r
82 must have been allocated on a previous call to the page allocation services of the Memory\r
83 Allocation Library.\r
84 If Buffer was not allocated with a page allocation function in the Memory Allocation Library,\r
85 then ASSERT().\r
86 If Pages is zero, then ASSERT().\r
87 \r
88 @param Buffer Pointer to the buffer of pages to free.\r
89 @param Pages The number of 4 KB pages to free.\r
878ddf1f 90\r
91**/\r
92VOID\r
93EFIAPI\r
94FreePages (\r
95 IN VOID *Buffer,\r
96 IN UINTN Pages\r
1f33a17f 97 );\r
878ddf1f 98\r
99/**\r
1f33a17f 100 Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.\r
101\r
102 Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an\r
103 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is\r
104 returned. If there is not enough memory at the specified alignment remaining to satisfy the\r
105 request, then NULL is returned.\r
106 If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
878ddf1f 107\r
1f33a17f 108 @param Pages The number of 4 KB pages to allocate.\r
109 @param Alignment The requested alignment of the allocation. Must be a power of two.\r
110 If Alignment is zero, then byte alignment is used.\r
878ddf1f 111\r
1f33a17f 112 @return A pointer to the allocated buffer or NULL if allocation fails.\r
878ddf1f 113\r
114**/\r
115VOID *\r
116EFIAPI\r
117AllocateAlignedPages (\r
118 IN UINTN Pages,\r
119 IN UINTN Alignment\r
1f33a17f 120 );\r
878ddf1f 121\r
122/**\r
1f33a17f 123 Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.\r
878ddf1f 124\r
1f33a17f 125 Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an\r
126 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is\r
127 returned. If there is not enough memory at the specified alignment remaining to satisfy the\r
128 request, then NULL is returned.\r
129 If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
878ddf1f 130\r
1f33a17f 131 @param Pages The number of 4 KB pages to allocate.\r
132 @param Alignment The requested alignment of the allocation. Must be a power of two.\r
133 If Alignment is zero, then byte alignment is used.\r
134\r
135 @return A pointer to the allocated buffer or NULL if allocation fails.\r
878ddf1f 136\r
137**/\r
138VOID *\r
139EFIAPI\r
140AllocateAlignedRuntimePages (\r
141 IN UINTN Pages,\r
142 IN UINTN Alignment\r
1f33a17f 143 );\r
878ddf1f 144\r
145/**\r
24e25d11 146 Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.\r
878ddf1f 147\r
1f33a17f 148 Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an\r
149 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is\r
150 returned. If there is not enough memory at the specified alignment remaining to satisfy the\r
151 request, then NULL is returned.\r
152 If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
153\r
154 @param Pages The number of 4 KB pages to allocate.\r
155 @param Alignment The requested alignment of the allocation. Must be a power of two.\r
156 If Alignment is zero, then byte alignment is used.\r
878ddf1f 157\r
1f33a17f 158 @return A pointer to the allocated buffer or NULL if allocation fails.\r
878ddf1f 159\r
160**/\r
161VOID *\r
162EFIAPI\r
163AllocateAlignedReservedPages (\r
164 IN UINTN Pages,\r
165 IN UINTN Alignment\r
1f33a17f 166 );\r
878ddf1f 167\r
168/**\r
1f33a17f 169 Frees one or more 4KB pages that were previously allocated with one of the aligned page\r
170 allocation functions in the Memory Allocation Library.\r
171\r
172 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer\r
173 must have been allocated on a previous call to the aligned page allocation services of the Memory\r
174 Allocation Library.\r
175 If Buffer was not allocated with an aligned page allocation function in the Memory Allocation\r
176 Library, then ASSERT().\r
177 If Pages is zero, then ASSERT().\r
178 \r
179 @param Buffer Pointer to the buffer of pages to free.\r
180 @param Pages The number of 4 KB pages to free.\r
878ddf1f 181\r
182**/\r
183VOID\r
184EFIAPI\r
185FreeAlignedPages (\r
186 IN VOID *Buffer,\r
187 IN UINTN Pages\r
1f33a17f 188 );\r
878ddf1f 189\r
190/**\r
24e25d11 191 Allocates a buffer of type EfiBootServicesData.\r
878ddf1f 192\r
1f33a17f 193 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a\r
194 pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is\r
195 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
878ddf1f 196\r
1f33a17f 197 @param AllocationSize The number of bytes to allocate.\r
198\r
199 @return A pointer to the allocated buffer or NULL if allocation fails.\r
878ddf1f 200\r
201**/\r
202VOID *\r
203EFIAPI\r
204AllocatePool (\r
205 IN UINTN AllocationSize\r
1f33a17f 206 );\r
878ddf1f 207\r
208/**\r
24e25d11 209 Allocates a buffer of type EfiRuntimeServicesData.\r
878ddf1f 210\r
1f33a17f 211 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns\r
212 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is\r
213 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
214\r
215 @param AllocationSize The number of bytes to allocate.\r
878ddf1f 216\r
1f33a17f 217 @return A pointer to the allocated buffer or NULL if allocation fails.\r
878ddf1f 218\r
219**/\r
220VOID *\r
221EFIAPI\r
222AllocateRuntimePool (\r
223 IN UINTN AllocationSize\r
1f33a17f 224 );\r
878ddf1f 225\r
226/**\r
1f33a17f 227 Allocates a buffer of type EfieservedMemoryType.\r
878ddf1f 228\r
1f33a17f 229 Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType and returns\r
230 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is\r
231 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
878ddf1f 232\r
1f33a17f 233 @param AllocationSize The number of bytes to allocate.\r
234\r
235 @return A pointer to the allocated buffer or NULL if allocation fails.\r
878ddf1f 236\r
237**/\r
238VOID *\r
239EFIAPI\r
240AllocateReservedPool (\r
241 IN UINTN AllocationSize\r
1f33a17f 242 );\r
878ddf1f 243\r
244/**\r
24e25d11 245 Allocates and zeros a buffer of type EfiBootServicesData.\r
878ddf1f 246\r
1f33a17f 247 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the\r
248 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a\r
249 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the\r
250 request, then NULL is returned.\r
251\r
252 @param AllocationSize The number of bytes to allocate and zero.\r
878ddf1f 253\r
1f33a17f 254 @return A pointer to the allocated buffer or NULL if allocation fails.\r
878ddf1f 255\r
256**/\r
257VOID *\r
258EFIAPI\r
259AllocateZeroPool (\r
260 IN UINTN AllocationSize\r
1f33a17f 261 );\r
878ddf1f 262\r
263/**\r
24e25d11 264 Allocates and zeros a buffer of type EfiRuntimeServicesData.\r
878ddf1f 265\r
1f33a17f 266 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the\r
267 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a\r
268 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the\r
269 request, then NULL is returned.\r
270\r
271 @param AllocationSize The number of bytes to allocate and zero.\r
878ddf1f 272\r
1f33a17f 273 @return A pointer to the allocated buffer or NULL if allocation fails.\r
878ddf1f 274\r
275**/\r
276VOID *\r
277EFIAPI\r
278AllocateRuntimeZeroPool (\r
279 IN UINTN AllocationSize\r
1f33a17f 280 );\r
878ddf1f 281\r
282/**\r
24e25d11 283 Allocates and zeros a buffer of type EfiReservedMemoryType.\r
878ddf1f 284\r
1f33a17f 285 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the\r
286 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a\r
287 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the\r
288 request, then NULL is returned.\r
878ddf1f 289\r
1f33a17f 290 @param AllocationSize The number of bytes to allocate and zero.\r
291\r
292 @return A pointer to the allocated buffer or NULL if allocation fails.\r
878ddf1f 293\r
294**/\r
295VOID *\r
296EFIAPI\r
297AllocateReservedZeroPool (\r
298 IN UINTN AllocationSize\r
1f33a17f 299 );\r
878ddf1f 300\r
301/**\r
1f33a17f 302 Copies a buffer to an allocated buffer of type EfiBootServicesData.\r
303\r
304 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies\r
305 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
306 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there\r
307 is not enough memory remaining to satisfy the request, then NULL is returned.\r
308 If Buffer is NULL, then ASSERT().\r
309