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