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