]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/MemoryAllocationLib.h
add function header
[mirror_edk2.git] / MdePkg / Include / Library / MemoryAllocationLib.h
CommitLineData
878ddf1f 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
13 Module Name: MemoryAllocationLib.h\r
14\r
15**/\r
16\r
17#ifndef __MEMORY_ALLOCATION_LIB_H__\r
18#define __MEMORY_ALLOCATION_LIB_H__\r
19\r
20/**\r
21 Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData.\r
22\r
23 @param Pages The number of 4 KB pages to allocate.\r
24\r
25 @return\r
26 A pointer to the allocated buffer. The buffer returned is aligned on a 4KB boundary.\r
27 If Pages is 0, then NULL is returned.\r
28 If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
29\r
30**/\r
31VOID *\r
32EFIAPI\r
33AllocatePages (\r
34 IN UINTN Pages\r
35 )\r
36;\r
37\r
38/**\r
39 Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData. \r
40\r
41 @param Pages The number of 4 KB pages to allocate.\r
42\r
43 @return\r
44 A pointer to the allocated buffer. The buffer returned is aligned on a 4KB boundary.\r
45 If Pages is 0, then NULL is returned.\r
46 If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
47\r
48**/\r
49VOID *\r
50EFIAPI\r
51AllocateRuntimePages (\r
52 IN UINTN Pages\r
53 )\r
54;\r
55\r
56/**\r
57 Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType. \r
58\r
59 @param Pages The number of 4 KB pages to allocate.\r
60\r
61 @return\r
62 A pointer to the allocated buffer. The buffer returned is aligned on a 4KB boundary.\r
63 If Pages is 0, then NULL is returned.\r
64 If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
65\r
66**/\r
67VOID *\r
68EFIAPI\r
69AllocateReservedPages (\r
70 IN UINTN Pages\r
71 )\r
72;\r
73\r
74/**\r
75 Frees one or more 4KB pages that were previously allocated with \r
76 one of the page allocation functions in the Memory Allocation Library.\r
77\r
78 @param Buffer Pointer to the buffer of pages to free.\r
79 @param Pages The number of 4 KB pages to free.\r
80\r
81 None.\r
82\r
83**/\r
84VOID\r
85EFIAPI\r
86FreePages (\r
87 IN VOID *Buffer,\r
88 IN UINTN Pages\r
89 )\r
90;\r
91\r
92/**\r
93 Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an alignment specified by Alignment. \r
94\r
95 @param Pages The number of 4 KB pages to allocate.\r
96 @param Alignment The requested alignment of the allocation. Must be a power of two.\r
97 If Alignment is zero, then byte alignment is used.\r
98\r
99 @return\r
100 The allocated buffer is returned. If Pages is 0, then NULL is returned.\r
101 If there is not enough memory at the specified alignment remaining to satisfy the request, then NULL is returned.\r
102\r
103**/\r
104VOID *\r
105EFIAPI\r
106AllocateAlignedPages (\r
107 IN UINTN Pages,\r
108 IN UINTN Alignment\r
109 )\r
110;\r
111\r
112/**\r
113 Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an alignment specified by Alignment. \r
114\r
115 @param Pages The number of 4 KB pages to allocate.\r
116 @param Alignment The requested alignment of the allocation. Must be a power of two.\r
117 If Alignment is zero, then byte alignment is used.\r
118\r
119 @return\r
120 The allocated buffer is returned. If Pages is 0, then NULL is returned.\r
121 If there is not enough memory at the specified alignment remaining to satisfy the request, then NULL is returned.\r
122\r
123**/\r
124VOID *\r
125EFIAPI\r
126AllocateAlignedRuntimePages (\r
127 IN UINTN Pages,\r
128 IN UINTN Alignment\r
129 )\r
130;\r
131\r
132/**\r
133 Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.\r
134\r
135 @param Pages The number of 4 KB pages to allocate.\r
136 @param Alignment The requested alignment of the allocation. Must be a power of two.\r
137 If Alignment is zero, then byte alignment is used.\r
138\r
139 @return\r
140 The allocated buffer is returned. If Pages is 0, then NULL is returned.\r
141 If there is not enough memory at the specified alignment remaining to satisfy the request, then NULL is returned.\r
142\r
143**/\r
144VOID *\r
145EFIAPI\r
146AllocateAlignedReservedPages (\r
147 IN UINTN Pages,\r
148 IN UINTN Alignment\r
149 )\r
150;\r
151\r
152/**\r
153 Frees one or more 4KB pages that were previously allocated with \r
154 one of the aligned page allocation functions in the Memory Allocation Library.\r
155\r
156 @param Buffer Pointer to the buffer of pages to free.\r
157 @param Pages The number of 4 KB pages to free.\r
158\r
159 None.\r
160\r
161**/\r
162VOID\r
163EFIAPI\r
164FreeAlignedPages (\r
165 IN VOID *Buffer,\r
166 IN UINTN Pages\r
167 )\r
168;\r
169\r
170/**\r
171 Allocates a buffer of type EfiBootServicesData.\r
172\r
173 @param AllocationSize The number of bytes to allocate.\r
174\r
175 @return\r
176 A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.\r
177 If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
178\r
179**/\r
180VOID *\r
181EFIAPI\r
182AllocatePool (\r
183 IN UINTN AllocationSize\r
184 )\r
185;\r
186\r
187/**\r
188 Allocates a buffer of type EfiRuntimeServicesData.\r
189\r
190 @param AllocationSize The number of bytes to allocate.\r
191\r
192 @return\r
193 A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.\r
194 If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
195\r
196**/\r
197VOID *\r
198EFIAPI\r
199AllocateRuntimePool (\r
200 IN UINTN AllocationSize\r
201 )\r
202;\r
203\r
204/**\r
205 Allocates a buffer of type EfiReservedMemoryType.\r
206\r
207 @param AllocationSize The number of bytes to allocate.\r
208\r
209 @return\r
210 A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.\r
211 If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
212\r
213**/\r
214VOID *\r
215EFIAPI\r
216AllocateReservedPool (\r
217 IN UINTN AllocationSize\r
218 )\r
219;\r
220\r
221/**\r
222 Allocates and zeros a buffer of type EfiBootServicesData.\r
223\r
224 @param AllocationSize The number of bytes to allocate and zero.\r
225\r
226 @return\r
227 A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.\r
228 If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
229\r
230**/\r
231VOID *\r
232EFIAPI\r
233AllocateZeroPool (\r
234 IN UINTN AllocationSize\r
235 )\r
236;\r
237\r
238/**\r
239 Allocates and zeros a buffer of type EfiRuntimeServicesData.\r
240\r
241 @param AllocationSize The number of bytes to allocate and zero.\r
242\r
243 @return\r
244 A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.\r
245 If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
246\r
247**/\r
248VOID *\r
249EFIAPI\r
250AllocateRuntimeZeroPool (\r
251 IN UINTN AllocationSize\r
252 )\r
253;\r
254\r
255/**\r
256 Allocates and zeros a buffer of type EfiReservedMemoryType.\r
257\r
258 @param AllocationSize The number of bytes to allocate and zero.\r
259\r
260 @return\r
261 A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.\r
262 If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
263\r
264**/\r
265VOID *\r
266EFIAPI\r
267AllocateReservedZeroPool (\r
268 IN UINTN AllocationSize\r
269 )\r
270;\r
271\r
272/**\r
273 Copies a buffer to an allocated buffer of type EfiBootServicesData. \r
274\r
275 @param AllocationSize The number of bytes to allocate.\r
276 @param Buffer The buffer to copy to the allocated buffer.\r
277\r
278 @return\r
279 A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.\r
280 If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
281\r
282**/\r
283VOID *\r
284EFIAPI\r
285AllocateCopyPool (\r
286 IN UINTN AllocationSize,\r
287 IN CONST VOID *Buffer\r
288 )\r
289;\r
290\r
291/**\r
292 Copies a buffer to an allocated buffer of type EfiRuntimeServicesData. \r
293\r
294 @param AllocationSize The number of bytes to allocate.\r
295 @param Buffer The buffer to copy to the allocated buffer.\r
296\r
297 @return\r
298 A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.\r
299 If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
300\r
301**/\r
302VOID *\r
303EFIAPI\r
304AllocateRuntimeCopyPool (\r
305 IN UINTN AllocationSize,\r
306 IN CONST VOID *Buffer\r
307 )\r
308;\r
309\r
310/**\r
311 Copies a buffer to an allocated buffer of type EfiReservedMemoryType. \r
312\r
313 @param AllocationSize The number of bytes to allocate.\r
314 @param Buffer The buffer to copy to the allocated buffer.\r
315\r
316 @return\r
317 A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.\r
318 If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
319\r
320**/\r
321VOID *\r
322EFIAPI\r
323AllocateReservedCopyPool (\r
324 IN UINTN AllocationSize,\r
325 IN CONST VOID *Buffer\r
326 )\r
327;\r
328\r
329/**\r
330 Frees a buffer that was previously allocated with one of the pool allocation functions \r
331 in the Memory Allocation Library.\r
332\r
333 @param Buffer Pointer to the buffer to free.\r
334\r
335 None.\r
336\r
337**/\r
338VOID\r
339EFIAPI\r
340FreePool (\r
341 IN VOID *Buffer\r
342 )\r
343;\r
344\r
345/**\r
346 Allocates a buffer of type EfiBootServicesData at a specified alignment.\r
347\r
348 @param AllocationSize The number of bytes to allocate.\r
349 @param Alignment The requested alignment of the allocation. Must be a power of two.\r
350 If Alignment is zero, then byte alignment is used.\r
351\r
352 @return\r
353 A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.\r
354 If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
355\r
356**/\r
357VOID *\r
358EFIAPI\r
359AllocateAlignedPool (\r
360 IN UINTN AllocationSize,\r
361 IN UINTN Alignment\r
362 )\r
363;\r
364\r
365/**\r
366 Allocates a buffer of type EfiRuntimeServicesData at a specified alignment.\r
367\r
368 @param AllocationSize The number of bytes to allocate.\r
369 @param Alignment The requested alignment of the allocation. Must be a power of two.\r
370 If Alignment is zero, then byte alignment is used.\r
371\r
372 @return\r
373 A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.\r
374 If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
375\r
376**/\r
377VOID *\r
378EFIAPI\r
379AllocateAlignedRuntimePool (\r
380 IN UINTN AllocationSize,\r
381 IN UINTN Alignment\r
382 )\r
383;\r
384\r
385/**\r
386 Allocates a buffer of type EfiReservedMemoryType at a specified alignment.\r
387\r
388 @param AllocationSize The number of bytes to allocate.\r
389 @param Alignment The requested alignment of the allocation. Must be a power of two.\r
390 If Alignment is zero, then byte alignment is used.\r
391\r
392 @return\r
393 A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.\r
394 If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
395\r
396**/\r
397VOID *\r
398EFIAPI\r
399AllocateAlignedReservedPool (\r
400 IN UINTN AllocationSize,\r
401 IN UINTN Alignment\r
402 )\r
403;\r
404\r
405/**\r
406 Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment.\r
407\r
408 @param AllocationSize The number of bytes to allocate.\r
409 @param Alignment The requested alignment of the allocation. Must be a power of two.\r
410 If Alignment is zero, then byte alignment is used.\r
411\r
412 @return\r
413 A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.\r
414 If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
415\r
416**/\r
417VOID *\r
418EFIAPI\r
419AllocateAlignedZeroPool (\r
420 IN UINTN AllocationSize,\r
421 IN UINTN Alignment\r
422 )\r
423;\r
424\r
425/**\r
426 Allocates and zeros a buffer of type EfiRuntimeServicesData at a specified alignment.\r
427\r
428 @param AllocationSize The number of bytes to allocate.\r
429 @param Alignment The requested alignment of the allocation. Must be a power of two.\r
430 If Alignment is zero, then byte alignment is used.\r
431\r
432 @return\r
433 A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.\r
434 If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
435\r
436**/\r
437VOID *\r
438EFIAPI\r
439AllocateAlignedRuntimeZeroPool (\r
440 IN UINTN AllocationSize,\r
441 IN UINTN Alignment\r
442 )\r
443;\r
444\r
445/**\r
446 Allocates and zeros a buffer of type EfiReservedMemoryType at a specified alignment.\r
447\r
448 @param AllocationSize The number of bytes to allocate.\r
449 @param Alignment The requested alignment of the allocation. Must be a power of two.\r
450 If Alignment is zero, then byte alignment is used.\r
451\r
452 @return\r
453 A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.\r
454 If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
455\r
456**/\r
457VOID *\r
458EFIAPI\r
459AllocateAlignedReservedZeroPool (\r
460 IN UINTN AllocationSize,\r
461 IN UINTN Alignment\r
462 )\r
463;\r
464\r
465/**\r
466 Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment.\r
467\r
468 @param AllocationSize The number of bytes to allocate.\r
469 @param Buffer The buffer to copy to the allocated buffer.\r
470 @param Alignment The requested alignment of the allocation. Must be a power of two.\r
471 If Alignment is zero, then byte alignment is used.\r
472\r
473 @return\r
474 A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.\r
475 If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
476\r
477**/\r
478VOID *\r
479EFIAPI\r
480AllocateAlignedCopyPool (\r
481 IN UINTN AllocationSize,\r
482 IN CONST VOID *Buffer,\r
483 IN UINTN Alignment\r
484 )\r
485;\r
486\r
487/**\r
488 Copies a buffer to an allocated buffer of type EfiRuntimeServicesData at a specified alignment.\r
489\r
490 @param AllocationSize The number of bytes to allocate.\r
491 @param Buffer The buffer to copy to the allocated buffer.\r
492 @param Alignment The requested alignment of the allocation. Must be a power of two.\r
493 If Alignment is zero, then byte alignment is used.\r
494\r
495 @return\r
496 A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.\r
497 If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
498\r
499**/\r
500VOID *\r
501EFIAPI\r
502AllocateAlignedRuntimeCopyPool (\r
503 IN UINTN AllocationSize,\r
504 IN CONST VOID *Buffer,\r
505 IN UINTN Alignment\r
506 )\r
507;\r
508\r
509/**\r
510 Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment.\r
511\r
512 @param AllocationSize The number of bytes to allocate.\r
513 @param Buffer The buffer to copy to the allocated buffer.\r
514 @param Alignment The requested alignment of the allocation. Must be a power of two.\r
515 If Alignment is zero, then byte alignment is used.\r
516\r
517 @return\r
518 A pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned.\r
519 If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
520\r
521**/\r
522VOID *\r
523EFIAPI\r
524AllocateAlignedReservedCopyPool (\r
525 IN UINTN AllocationSize,\r
526 IN CONST VOID *Buffer,\r
527 IN UINTN Alignment\r
528 )\r
529;\r
530\r
531/**\r
532 Frees a buffer that was previously allocated with one of the aligned pool allocation functions \r
533 in the Memory Allocation Library.\r
534\r
535 @param Buffer Pointer to the buffer to free.\r
536\r
537 None.\r
538\r
539**/\r
540VOID\r
541EFIAPI\r
542FreeAlignedPool (\r
543 IN VOID *Buffer\r
544 )\r
545;\r
546\r
547#endif\r