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