]>
Commit | Line | Data |
---|---|---|
fb3df220 | 1 | /** @file\r |
2 | Memory Allocation Library Services\r | |
3 | \r | |
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 | |
9 | \r | |
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 | |
12 | \r | |
fb3df220 | 13 | **/\r |
14 | \r | |
15 | #ifndef __MEMORY_ALLOCATION_LIB_H__\r | |
16 | #define __MEMORY_ALLOCATION_LIB_H__\r | |
17 | \r | |
18 | /**\r | |
19 | Allocates one or more 4KB pages of type EfiBootServicesData.\r | |
20 | \r | |
21 | Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the\r | |
22 | allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL\r | |
23 | is returned. If there is not enough memory remaining to satisfy the request, then NULL is\r | |
24 | returned.\r | |
25 | \r | |
26 | @param Pages The number of 4 KB pages to allocate.\r | |
27 | \r | |
28 | @return A pointer to the allocated buffer or NULL if allocation fails.\r | |
29 | \r | |
30 | **/\r | |
31 | VOID *\r | |
32 | EFIAPI\r | |
33 | AllocatePages (\r | |
34 | IN UINTN Pages\r | |
35 | );\r | |
36 | \r | |
37 | /**\r | |
38 | Allocates one or more 4KB pages of type EfiRuntimeServicesData.\r | |
39 | \r | |
40 | Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the\r | |
41 | allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL\r | |
42 | is returned. If there is not enough memory remaining to satisfy the request, then NULL is\r | |
43 | returned.\r | |
44 | \r | |
45 | @param Pages The number of 4 KB pages to allocate.\r | |
46 | \r | |
47 | @return A pointer to the allocated buffer or NULL if allocation fails.\r | |
48 | \r | |
49 | **/\r | |
50 | VOID *\r | |
51 | EFIAPI\r | |
52 | AllocateRuntimePages (\r | |
53 | IN UINTN Pages\r | |
54 | );\r | |
55 | \r | |
56 | /**\r | |
57 | Allocates one or more 4KB pages of type EfiReservedMemoryType.\r | |
58 | \r | |
59 | Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the\r | |
60 | allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL\r | |
61 | is returned. If there is not enough memory remaining to satisfy the request, then NULL is\r | |
62 | returned.\r | |
63 | \r | |
64 | @param Pages The number of 4 KB pages to allocate.\r | |
65 | \r | |
66 | @return A pointer to the allocated buffer or NULL if allocation fails.\r | |
67 | \r | |
68 | **/\r | |
69 | VOID *\r | |
70 | EFIAPI\r | |
71 | AllocateReservedPages (\r | |
72 | IN UINTN Pages\r | |
73 | );\r | |
74 | \r | |
75 | /**\r | |
76 | Frees one or more 4KB pages that were previously allocated with one of the page allocation\r | |
77 | functions in the Memory Allocation Library.\r | |
78 | \r | |
79 | Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer\r | |
80 | must have been allocated on a previous call to the page allocation services of the Memory\r | |
81 | Allocation Library.\r | |
82 | If Buffer was not allocated with a page allocation function in the Memory Allocation Library,\r | |
83 | then ASSERT().\r | |
84 | If Pages is zero, then ASSERT().\r | |
85 | \r | |
86 | @param Buffer Pointer to the buffer of pages to free.\r | |
87 | @param Pages The number of 4 KB pages to free.\r | |
88 | \r | |
89 | **/\r | |
90 | VOID\r | |
91 | EFIAPI\r | |
92 | FreePages (\r | |
93 | IN VOID *Buffer,\r | |
94 | IN UINTN Pages\r | |
95 | );\r | |
96 | \r | |
97 | /**\r | |
98 | Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.\r | |
99 | \r | |
100 | Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an\r | |
101 | alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is\r | |
102 | returned. If there is not enough memory at the specified alignment remaining to satisfy the\r | |
103 | request, then NULL is returned.\r | |
104 | If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r | |
105 | \r | |
106 | @param Pages The number of 4 KB pages to allocate.\r | |
107 | @param Alignment The requested alignment of the allocation. Must be a power of two.\r | |
108 | If Alignment is zero, then byte alignment is used.\r | |
109 | \r | |
110 | @return A pointer to the allocated buffer or NULL if allocation fails.\r | |
111 | \r | |
112 | **/\r | |
113 | VOID *\r | |
114 | EFIAPI\r | |
115 | AllocateAlignedPages (\r | |
116 | IN UINTN Pages,\r | |
117 | IN UINTN Alignment\r | |
118 | );\r | |
119 | \r | |
120 | /**\r | |
121 | Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.\r | |
122 | \r | |
123 | Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an\r | |
124 | alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is\r | |
125 | returned. If there is not enough memory at the specified alignment remaining to satisfy the\r | |
126 | request, then NULL is returned.\r | |
127 | If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r | |
128 | \r | |
129 | @param Pages The number of 4 KB pages to allocate.\r | |
130 | @param Alignment The requested alignment of the allocation. Must be a power of two.\r | |
131 | If Alignment is zero, then byte alignment is used.\r | |
132 | \r | |
133 | @return A pointer to the allocated buffer or NULL if allocation fails.\r | |
134 | \r | |
135 | **/\r | |
136 | VOID *\r | |
137 | EFIAPI\r | |
138 | AllocateAlignedRuntimePages (\r | |
139 | IN UINTN Pages,\r | |
140 | IN UINTN Alignment\r | |
141 | );\r | |
142 | \r | |
143 | /**\r | |
144 | Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.\r | |
145 | \r | |
146 | Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an\r | |
147 | alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is\r | |
148 | returned. If there is not enough memory at the specified alignment remaining to satisfy the\r | |
149 | request, then NULL is returned.\r | |
150 | If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r | |
151 | \r | |
152 | @param Pages The number of 4 KB pages to allocate.\r | |
153 | @param Alignment The requested alignment of the allocation. Must be a power of two.\r | |
154 | If Alignment is zero, then byte alignment is used.\r | |
155 | \r | |
156 | @return A pointer to the allocated buffer or NULL if allocation fails.\r | |
157 | \r | |
158 | **/\r | |
159 | VOID *\r | |
160 | EFIAPI\r | |
161 | AllocateAlignedReservedPages (\r | |
162 | IN UINTN Pages,\r | |
163 | IN UINTN Alignment\r | |
164 | );\r | |
165 | \r | |
166 | /**\r | |
167 | Frees one or more 4KB pages that were previously allocated with one of the aligned page\r | |
168 | allocation functions in the Memory Allocation Library.\r | |
169 | \r | |
170 | Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer\r | |
171 | must have been allocated on a previous call to the aligned page allocation services of the Memory\r | |
172 | Allocation Library.\r | |
173 | If Buffer was not allocated with an aligned page allocation function in the Memory Allocation\r | |
174 | Library, then ASSERT().\r | |
175 | If Pages is zero, then ASSERT().\r | |
176 | \r | |
177 | @param Buffer Pointer to the buffer of pages to free.\r | |
178 | @param Pages The number of 4 KB pages to free.\r | |
179 | \r | |
180 | **/\r | |
181 | VOID\r | |
182 | EFIAPI\r | |
183 | FreeAlignedPages (\r | |
184 | IN VOID *Buffer,\r | |
185 | IN UINTN Pages\r | |
186 | );\r | |
187 | \r | |
188 | /**\r | |
189 | Allocates a buffer of type EfiBootServicesData.\r | |
190 | \r | |
191 | Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a\r | |
192 | pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is\r | |
193 | returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.\r | |
194 | \r | |
195 | @param AllocationSize The number of bytes to allocate.\r | |
196 | \r | |
197 | @return A pointer to the allocated buffer or NULL if allocation fails.\r | |
198 | \r | |
199 | **/\r | |
200 | VOID *\r | |
201 | EFIAPI\r | |
202 | AllocatePool (\r | |
203 | IN UINTN AllocationSize\r | |
204 | );\r | |
205 | \r | |
206 | /**\r | |
207 | Allocates a buffer of type EfiRuntimeServicesData.\r | |
208 | \r | |
209 | Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns\r | |
210 | a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is\r | |
211 | returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.\r | |
212 | \r | |
213 | @param AllocationSize The number of bytes to allocate.\r | |
214 | \r | |
215 | @return A pointer to the allocated buffer or NULL if allocation fails.\r | |
216 | \r | |
217 | **/\r | |
218 | VOID *\r | |
219 | EFIAPI\r | |
220 | AllocateRuntimePool (\r | |
221 | IN UINTN AllocationSize\r | |
222 | );\r | |
223 | \r | |
224 | /**\r | |
225 | Allocates a buffer of type EfieservedMemoryType.\r | |
226 | \r | |
227 | Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType and returns\r | |
228 | a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is\r | |
229 | returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.\r | |
230 | \r | |
231 | @param AllocationSize The number of bytes to allocate.\r | |
232 | \r | |
233 | @return A pointer to the allocated buffer or NULL if allocation fails.\r | |
234 | \r | |
235 | **/\r | |
236 | VOID *\r | |
237 | EFIAPI\r | |
238 | AllocateReservedPool (\r | |
239 | IN UINTN AllocationSize\r | |
240 | );\r | |
241 | \r | |
242 | /**\r | |
243 | Allocates and zeros a buffer of type EfiBootServicesData.\r | |
244 | \r | |
245 | Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the\r | |
246 | buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a\r | |
247 | valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the\r | |
248 | request, then NULL is returned.\r | |
249 | \r | |
250 | @param AllocationSize The number of bytes to allocate and zero.\r | |
251 | \r | |
252 | @return A pointer to the allocated buffer or NULL if allocation fails.\r | |
253 | \r | |
254 | **/\r | |
255 | VOID *\r | |
256 | EFIAPI\r | |
257 | AllocateZeroPool (\r | |
258 | IN UINTN AllocationSize\r | |
259 | );\r | |
260 | \r | |
261 | /**\r | |
262 | Allocates and zeros a buffer of type EfiRuntimeServicesData.\r | |
263 | \r | |
264 | Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the\r | |
265 | buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a\r | |
266 | valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the\r | |
267 | request, then NULL is returned.\r | |
268 | \r | |
269 | @param AllocationSize The number of bytes to allocate and zero.\r | |
270 | \r | |
271 | @return A pointer to the allocated buffer or NULL if allocation fails.\r | |
272 | \r | |
273 | **/\r | |
274 | VOID *\r | |
275 | EFIAPI\r | |
276 | AllocateRuntimeZeroPool (\r | |
277 | IN UINTN AllocationSize\r | |
278 | );\r | |
279 | \r | |
280 | /**\r | |
281 | Allocates and zeros a buffer of type EfiReservedMemoryType.\r | |
282 | \r | |
283 | Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the\r | |
284 | buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a\r | |
285 | valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the\r | |
286 | request, then NULL is returned.\r | |
287 | \r | |
288 | @param AllocationSize The number of bytes to allocate and zero.\r | |
289 | \r | |
290 | @return A pointer to the allocated buffer or NULL if allocation fails.\r | |
291 | \r | |
292 | **/\r | |
293 | VOID *\r | |
294 | EFIAPI\r | |
295 | AllocateReservedZeroPool (\r | |
296 | IN UINTN AllocationSize\r | |
297 | );\r | |
298 | \r | |
299 | /**\r | |
300 | Copies a buffer to an allocated buffer of type EfiBootServicesData.\r | |
301 | \r | |
302 | Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies\r | |
303 | AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r | |
304 | allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there\r | |
305 | is not enough memory remaining to satisfy the request, then NULL is returned.\r | |
306 | If Buffer is NULL, then ASSERT().\r | |
cc4e0485 | 307 | If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r |
fb3df220 | 308 | \r |
309 | @param AllocationSize The number of bytes to allocate and zero.\r | |
310 | @param Buffer The buffer to copy to the allocated buffer.\r | |
311 | \r | |
312 | @return A pointer to the allocated buffer or NULL if allocation fails.\r | |
313 | \r | |
314 | **/\r | |
315 | VOID *\r | |
316 | EFIAPI\r | |
317 | AllocateCopyPool (\r | |
318 | IN UINTN AllocationSize,\r | |
319 | IN CONST VOID *Buffer\r | |
320 | );\r | |
321 | \r | |
322 | /**\r | |
323 | Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.\r | |
324 | \r | |
325 | Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies\r | |
326 | AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r | |
327 | allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there\r | |
328 | is not enough memory remaining to satisfy the request, then NULL is returned.\r | |
329 | If Buffer is NULL, then ASSERT().\r | |
cc4e0485 | 330 | If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r |
fb3df220 | 331 | \r |
332 | @param AllocationSize The number of bytes to allocate and zero.\r | |
333 | @param Buffer The buffer to copy to the allocated buffer.\r | |
334 | \r | |
335 | @return A pointer to the allocated buffer or NULL if allocation fails.\r | |
336 | \r | |
337 | **/\r | |
338 | VOID *\r | |
339 | EFIAPI\r | |
340 | AllocateRuntimeCopyPool (\r | |
341 | IN UINTN AllocationSize,\r | |
342 | IN CONST VOID *Buffer\r | |
343 | );\r | |
344 | \r | |
345 | /**\r | |
346 | Copies a buffer to an allocated buffer of type EfiReservedMemoryType.\r | |
347 | \r | |
348 | Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies\r | |
349 | AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r | |
350 | allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there\r | |
351 | is not enough memory remaining to satisfy the request, then NULL is returned.\r | |
352 | If Buffer is NULL, then ASSERT().\r | |
cc4e0485 | 353 | If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r |
fb3df220 | 354 | \r |
355 | @param AllocationSize The number of bytes to allocate and zero.\r | |
356 | @param Buffer The buffer to copy to the allocated buffer.\r | |
357 | \r | |
358 | @return A pointer to the allocated buffer or NULL if allocation fails.\r | |
359 | \r | |
360 | **/\r | |
361 | VOID *\r | |
362 | EFIAPI\r | |
363 | AllocateReservedCopyPool (\r | |
364 | IN UINTN AllocationSize,\r | |
365 | IN CONST VOID *Buffer\r | |
366 | );\r | |
367 | \r | |
368 | /**\r | |
369 | Frees a buffer that was previously allocated with one of the pool allocation functions in the\r | |
370 | Memory Allocation Library.\r | |
371 | \r | |
372 | Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the\r | |
373 | pool allocation services of the Memory Allocation Library.\r | |
374 | If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,\r | |
375 | then ASSERT().\r | |
376 | \r | |
377 | @param Buffer Pointer to the buffer to free.\r | |
378 | \r | |
379 | **/\r | |
380 | VOID\r | |
381 | EFIAPI\r | |
382 | FreePool (\r | |
383 | IN VOID *Buffer\r | |
384 | );\r | |
385 | \r | |
9199040c | 386 | /**\r |
387 | Frees buffer that were previously allocated with one of the\r | |
388 | memory allocation functions in the Memory Allocation Library.\r | |
389 | \r | |
390 | @param Buffer Pointer to the buffer of pages\r | |
391 | to free.\r | |
392 | \r | |
393 | **/\r | |
7d582d6b | 394 | VOID\r |
395 | EFIAPI\r | |
396 | SafeFreePool (\r | |
397 | IN VOID *Buffer\r | |
398 | );\r | |
399 | \r | |
fb3df220 | 400 | #endif\r |