]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/MemoryAllocationLib.h
added some comments in BaseLib
[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
24e25d11 21 Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData.\r
878ddf1f 22\r
24e25d11 23 @param Pages The number of 4 KB pages to allocate.\r
878ddf1f 24\r
24e25d11 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
878ddf1f 29\r
30**/\r
31VOID *\r
32EFIAPI\r
33AllocatePages (\r
34 IN UINTN Pages\r
35 )\r
36;\r
37\r
38/**\r
24e25d11 39 Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData. \r
878ddf1f 40\r
24e25d11 41 @param Pages The number of 4 KB pages to allocate.\r
878ddf1f 42\r
24e25d11 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
878ddf1f 47\r
48**/\r
49VOID *\r
50EFIAPI\r
51AllocateRuntimePages (\r
52 IN UINTN Pages\r
53 )\r
54;\r
55\r
56/**\r
24e25d11 57 Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType. \r
878ddf1f 58\r
24e25d11 59 @param Pages The number of 4 KB pages to allocate.\r
878ddf1f 60\r
24e25d11 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
878ddf1f 65\r
66**/\r
67VOID *\r
68EFIAPI\r
69AllocateReservedPages (\r
70 IN UINTN Pages\r
71 )\r
72;\r
73\r
74/**\r
24e25d11 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
878ddf1f 77\r
24e25d11 78 @param Buffer Pointer to the buffer of pages to free.\r
79 @param Pages The number of 4 KB pages to free.\r
878ddf1f 80\r
24e25d11 81 None.\r
878ddf1f 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
24e25d11 93 Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an alignment specified by Alignment. \r
878ddf1f 94\r
24e25d11 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
878ddf1f 98\r
24e25d11 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
878ddf1f 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
24e25d11 113 Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an alignment specified by Alignment. \r
878ddf1f 114\r
24e25d11 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
878ddf1f 118\r
24e25d11 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
878ddf1f 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
24e25d11 133 Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.\r
878ddf1f 134\r
24e25d11 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
878ddf1f 138\r
24e25d11 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
878ddf1f 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
24e25d11 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
878ddf1f 155\r
24e25d11 156 @param Buffer Pointer to the buffer of pages to free.\r
157 @param Pages The number of 4 KB pages to free.\r
878ddf1f 158\r
24e25d11 159 None.\r
878ddf1f 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
24e25d11 171 Allocates a buffer of type EfiBootServicesData.\r
878ddf1f 172\r
24e25d11 173 @param AllocationSize The number of bytes to allocate.\r
878ddf1f 174\r
24e25d11 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
878ddf1f 178\r
179**/\r
180VOID *\r
181EFIAPI\r
182AllocatePool (\r
183 IN UINTN AllocationSize\r
184 )\r
185;\r
186\r
187/**\r
24e25d11 188 Allocates a buffer of type EfiRuntimeServicesData.\r
878ddf1f 189\r
24e25d11 190 @param AllocationSize The number of bytes to allocate.\r
878ddf1f 191\r
24e25d11 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
878ddf1f 195\r
196**/\r
197VOID *\r
198EFIAPI\r
199AllocateRuntimePool (\r
200 IN UINTN AllocationSize\r
201 )\r
202;\r
203\r
204/**\r
24e25d11 205 Allocates a buffer of type EfiReservedMemoryType.\r
878ddf1f 206\r
24e25d11 207 @param AllocationSize The number of bytes to allocate.\r
878ddf1f 208\r
24e25d11 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
878ddf1f 212\r
213**/\r
214VOID *\r
215EFIAPI\r
216AllocateReservedPool (\r
217 IN UINTN AllocationSize\r
218 )\r
219;\r
220\r
221/**\r
24e25d11 222 Allocates and zeros a buffer of type EfiBootServicesData.\r
878ddf1f 223\r
24e25d11 224 @param AllocationSize The number of bytes to allocate and zero.\r
878ddf1f 225\r
24e25d11 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
878ddf1f 229\r
230**/\r
231VOID *\r
232EFIAPI\r
233AllocateZeroPool (\r
234 IN UINTN AllocationSize\r
235 )\r
236;\r
237\r
238/**\r
24e25d11 239 Allocates and zeros a buffer of type EfiRuntimeServicesData.\r
878ddf1f 240\r
24e25d11 241 @param AllocationSize The number of bytes to allocate and zero.\r
878ddf1f 242\r
24e25d11 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
878ddf1f 246\r
247**/\r
248VOID *\r
249EFIAPI\r
250AllocateRuntimeZeroPool (\r
251 IN UINTN AllocationSize\r
252 )\r
253;\r
254\r
255/**\r
24e25d11 256 Allocates and zeros a buffer of type EfiReservedMemoryType.\r
878ddf1f 257\r
24e25d11 258 @param AllocationSize The number of bytes to allocate and zero.\r
878ddf1f 259\r
24e25d11 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
878ddf1f 263\r
264**/\r
265VOID *\r
266EFIAPI\r
267AllocateReservedZeroPool (\r
268 IN UINTN AllocationSize\r
269 )\r
270;\r
271\r
272/**\r
24e25d11 273 Copies a buffer to an allocated buffer of type EfiBootServicesData. \r
878ddf1f 274\r
24e25d11 275 @param AllocationSize The number of bytes to allocate.\r
276 @param Buffer The buffer to copy to the allocated buffer.\r
878ddf1f 277\r
24e25d11 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
878ddf1f 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
24e25d11 292 Copies a buffer to an allocated buffer of type EfiRuntimeServicesData. \r
878ddf1f 293\r
24e25d11 294 @param AllocationSize The number of bytes to allocate.\r
295 @param Buffer The buffer to copy to the allocated buffer.\r
878ddf1f 296\r
24e25d11 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
878ddf1f 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
24e25d11 311 Copies a buffer to an allocated buffer of type EfiReservedMemoryType. \r
878ddf1f 312\r
24e25d11 313 @param AllocationSize The number of bytes to allocate.\r
314 @param Buffer The buffer to copy to the allocated buffer.\r
878ddf1f 315\r
24e25d11 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
878ddf1f 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
24e25d11 330 Frees a buffer that was previously allocated with one of the pool allocation functions \r
331 in the Memory Allocation Library.\r
878ddf1f 332\r
24e25d11 333 @param Buffer Pointer to the buffer to free.\r
878ddf1f 334\r
24e25d11 335 None.\r
878ddf1f 336\r
337**/\r
338VOID\r
339EFIAPI\r
340FreePool (\r
341 IN VOID *Buffer\r
342 )\r
343;\r
344\r
345/**\r
24e25d11 346 Allocates a buffer of type EfiBootServicesData at a specified alignment.\r
878ddf1f 347\r
24e25d11 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
878ddf1f 351\r
24e25d11 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
878ddf1f 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
24e25d11 366 Allocates a buffer of type EfiRuntimeServicesData at a specified alignment.\r
878ddf1f 367\r
24e25d11 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
878ddf1f 371\r
24e25d11 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
878ddf1f 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
24e25d11 386 Allocates a buffer of type EfiReservedMemoryType at a specified alignment.\r
878ddf1f 387\r
24e25d11 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
878ddf1f 391\r
24e25d11 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
878ddf1f 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
24e25d11 406 Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment.\r
878ddf1f 407\r
24e25d11 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
878ddf1f 411\r
24e25d11 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
878ddf1f 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
24e25d11 426 Allocates and zeros a buffer of type EfiRuntimeServicesData at a specified alignment.\r
878ddf1f 427\r
24e25d11 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
878ddf1f 431\r
24e25d11 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
878ddf1f 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
24e25d11 446 Allocates and zeros a buffer of type EfiReservedMemoryType at a specified alignment.\r
878ddf1f 447\r
24e25d11 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
878ddf1f 451\r
24e25d11 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
878ddf1f 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
24e25d11 466 Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment.\r
878ddf1f 467\r
24e25d11 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
878ddf1f 472\r
24e25d11 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
878ddf1f 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
24e25d11 488 Copies a buffer to an allocated buffer of type EfiRuntimeServicesData at a specified alignment.\r
878ddf1f 489\r
24e25d11 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
878ddf1f 494\r
24e25d11 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
878ddf1f 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
24e25d11 510 Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment.\r
878ddf1f 511\r
24e25d11 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
878ddf1f 516\r
24e25d11 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
878ddf1f 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
24e25d11 532 Frees a buffer that was previously allocated with one of the aligned pool allocation functions \r
533 in the Memory Allocation Library.\r
878ddf1f 534\r
24e25d11 535 @param Buffer Pointer to the buffer to free.\r
878ddf1f 536\r
24e25d11 537 None.\r
878ddf1f 538\r
539**/\r
540VOID\r
541EFIAPI\r
542FreeAlignedPool (\r
543 IN VOID *Buffer\r
544 )\r
545;\r
546\r
547#endif\r