]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c
ArmPkg/UncachedMemoryAllocationLib: map uncached allocations non-executable
[mirror_edk2.git] / ArmPkg / Library / UncachedMemoryAllocationLib / UncachedMemoryAllocationLib.c
... / ...
CommitLineData
1/** @file\r
2 UncachedMemoryAllocation lib that uses DXE Service to change cachability for\r
3 a buffer.\r
4\r
5 Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r
6 Copyright (c) 2014, AMR Ltd. All rights reserved.<BR>\r
7\r
8 This program and the accompanying materials\r
9 are licensed and made available under the terms and conditions of the BSD License\r
10 which accompanies this distribution. The full text of the license may be found at\r
11 http://opensource.org/licenses/bsd-license.php\r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16**/\r
17\r
18#include <Base.h>\r
19#include <Library/BaseLib.h>\r
20#include <Library/BaseMemoryLib.h>\r
21#include <Library/MemoryAllocationLib.h>\r
22#include <Library/DebugLib.h>\r
23#include <Library/UefiBootServicesTableLib.h>\r
24#include <Library/UncachedMemoryAllocationLib.h>\r
25#include <Library/PcdLib.h>\r
26#include <Library/ArmLib.h>\r
27#include <Library/DxeServicesTableLib.h>\r
28#include <Library/CacheMaintenanceLib.h>\r
29\r
30VOID *\r
31UncachedInternalAllocatePages (\r
32 IN EFI_MEMORY_TYPE MemoryType,\r
33 IN UINTN Pages\r
34 );\r
35\r
36VOID *\r
37UncachedInternalAllocateAlignedPages (\r
38 IN EFI_MEMORY_TYPE MemoryType,\r
39 IN UINTN Pages,\r
40 IN UINTN Alignment\r
41 );\r
42\r
43\r
44\r
45typedef struct {\r
46 EFI_PHYSICAL_ADDRESS Base;\r
47 VOID *Allocation;\r
48 UINTN Pages;\r
49 EFI_MEMORY_TYPE MemoryType;\r
50 BOOLEAN Allocated;\r
51 LIST_ENTRY Link;\r
52 UINT64 Attributes;\r
53} FREE_PAGE_NODE;\r
54\r
55STATIC LIST_ENTRY mPageList = INITIALIZE_LIST_HEAD_VARIABLE (mPageList);\r
56// Track the size of the non-allocated buffer in the linked-list\r
57STATIC UINTN mFreedBufferSize = 0;\r
58\r
59/**\r
60 * This function firstly checks if the requested allocation can fit into one\r
61 * of the previously allocated buffer.\r
62 * If the requested allocation does not fit in the existing pool then\r
63 * the function makes a new allocation.\r
64 *\r
65 * @param MemoryType Type of memory requested for the new allocation\r
66 * @param Pages Number of requested page\r
67 * @param Alignment Required alignment\r
68 * @param Allocation Address of the newly allocated buffer\r
69 *\r
70 * @return EFI_SUCCESS If the function manage to allocate a buffer\r
71 * @return !EFI_SUCCESS If the function did not manage to allocate a buffer\r
72 */\r
73STATIC\r
74EFI_STATUS\r
75AllocatePagesFromList (\r
76 IN EFI_MEMORY_TYPE MemoryType,\r
77 IN UINTN Pages,\r
78 IN UINTN Alignment,\r
79 OUT VOID **Allocation\r
80 )\r
81{\r
82 EFI_STATUS Status;\r
83 LIST_ENTRY *Link;\r
84 FREE_PAGE_NODE *Node;\r
85 FREE_PAGE_NODE *NewNode;\r
86 UINTN AlignmentMask;\r
87 EFI_PHYSICAL_ADDRESS Memory;\r
88 EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor;\r
89\r
90 // Alignment must be a power of two or zero.\r
91 ASSERT ((Alignment & (Alignment - 1)) == 0);\r
92\r
93 //\r
94 // Look in our list for the smallest page that could satisfy the new allocation\r
95 //\r
96 Node = NULL;\r
97 NewNode = NULL;\r
98 for (Link = mPageList.ForwardLink; Link != &mPageList; Link = Link->ForwardLink) {\r
99 Node = BASE_CR (Link, FREE_PAGE_NODE, Link);\r
100 if ((Node->Allocated == FALSE) && (Node->MemoryType == MemoryType)) {\r
101 // We have a node that fits our requirements\r
102 if (((UINTN)Node->Base & (Alignment - 1)) == 0) {\r
103 // We found a page that matches the page size\r
104 if (Node->Pages == Pages) {\r
105 Node->Allocated = TRUE;\r
106 Node->Allocation = (VOID*)(UINTN)Node->Base;\r
107 *Allocation = Node->Allocation;\r
108\r
109 // Update the size of the freed buffer\r
110 mFreedBufferSize -= Pages * EFI_PAGE_SIZE;\r
111 return EFI_SUCCESS;\r
112 } else if (Node->Pages > Pages) {\r
113 if (NewNode == NULL) {\r
114 // It is the first node that could contain our new allocation\r
115 NewNode = Node;\r
116 } else if (NewNode->Pages > Node->Pages) {\r
117 // This node offers a smaller number of page.\r
118 NewNode = Node;\r
119 }\r
120 }\r
121 }\r
122 }\r
123 }\r
124 // Check if we have found a node that could contain our new allocation\r
125 if (NewNode != NULL) {\r
126 NewNode->Allocated = TRUE;\r
127 NewNode->Allocation = (VOID*)(UINTN)NewNode->Base;\r
128 *Allocation = NewNode->Allocation;\r
129 mFreedBufferSize -= NewNode->Pages * EFI_PAGE_SIZE;\r
130 return EFI_SUCCESS;\r
131 }\r
132\r
133 //\r
134 // Otherwise, we need to allocate a new buffer\r
135 //\r
136\r
137 // We do not want to over-allocate in case the alignment requirement does not\r
138 // require extra pages\r
139 if (Alignment > EFI_PAGE_SIZE) {\r
140 AlignmentMask = Alignment - 1;\r
141 Pages += EFI_SIZE_TO_PAGES (Alignment);\r
142 } else {\r
143 AlignmentMask = 0;\r
144 }\r
145\r
146 Status = gBS->AllocatePages (AllocateAnyPages, MemoryType, Pages, &Memory);\r
147 if (EFI_ERROR (Status)) {\r
148 return Status;\r
149 }\r
150\r
151 Status = gDS->GetMemorySpaceDescriptor (Memory, &Descriptor);\r
152 if (EFI_ERROR (Status)) {\r
153 gBS->FreePages (Memory, Pages);\r
154 return Status;\r
155 }\r
156\r
157 Status = gDS->SetMemorySpaceAttributes (Memory, EFI_PAGES_TO_SIZE (Pages),\r
158 EFI_MEMORY_WC | EFI_MEMORY_XP);\r
159 if (EFI_ERROR (Status)) {\r
160 gBS->FreePages (Memory, Pages);\r
161 return Status;\r
162 }\r
163\r
164 InvalidateDataCacheRange ((VOID *)(UINTN)Memory, EFI_PAGES_TO_SIZE (Pages));\r
165\r
166 NewNode = AllocatePool (sizeof (FREE_PAGE_NODE));\r
167 if (NewNode == NULL) {\r
168 ASSERT (FALSE);\r
169 gBS->FreePages (Memory, Pages);\r
170 return EFI_OUT_OF_RESOURCES;\r
171 }\r
172\r
173 NewNode->Base = Memory;\r
174 NewNode->Allocation = (VOID*)(((UINTN)Memory + AlignmentMask) & ~AlignmentMask);\r
175 NewNode->Pages = Pages;\r
176 NewNode->Allocated = TRUE;\r
177 NewNode->MemoryType = MemoryType;\r
178 NewNode->Attributes = Descriptor.Attributes;\r
179\r
180 InsertTailList (&mPageList, &NewNode->Link);\r
181\r
182 *Allocation = NewNode->Allocation;\r
183 return EFI_SUCCESS;\r
184}\r
185\r
186/**\r
187 * Free the memory allocation\r
188 *\r
189 * This function will actually try to find the allocation in the linked list.\r
190 * And it will then mark the entry as freed.\r
191 *\r
192 * @param Allocation Base address of the buffer to free\r
193 *\r
194 * @return EFI_SUCCESS The allocation has been freed\r
195 * @return EFI_NOT_FOUND The allocation was not found in the pool.\r
196 * @return EFI_INVALID_PARAMETER If Allocation is NULL\r
197 *\r
198 */\r
199STATIC\r
200EFI_STATUS\r
201FreePagesFromList (\r
202 IN VOID *Allocation\r
203 )\r
204{\r
205 LIST_ENTRY *Link;\r
206 FREE_PAGE_NODE *Node;\r
207\r
208 if (Allocation == NULL) {\r
209 return EFI_INVALID_PARAMETER;\r
210 }\r
211\r
212 for (Link = mPageList.ForwardLink; Link != &mPageList; Link = Link->ForwardLink) {\r
213 Node = BASE_CR (Link, FREE_PAGE_NODE, Link);\r
214 if ((UINTN)Node->Allocation == (UINTN)Allocation) {\r
215 Node->Allocated = FALSE;\r
216\r
217 // Update the size of the freed buffer\r
218 mFreedBufferSize += Node->Pages * EFI_PAGE_SIZE;\r
219\r
220 // If the size of the non-allocated reaches the threshold we raise a warning.\r
221 // It might be an expected behaviour in some cases.\r
222 // We might device to free some of these buffers later on.\r
223 if (mFreedBufferSize > PcdGet64 (PcdArmFreeUncachedMemorySizeThreshold)) {\r
224 DEBUG ((EFI_D_WARN, "Warning: The list of non-allocated buffer has reach the threshold.\n"));\r
225 }\r
226 return EFI_SUCCESS;\r
227 }\r
228 }\r
229\r
230 return EFI_NOT_FOUND;\r
231}\r
232\r
233/**\r
234 * This function is automatically invoked when the driver exits\r
235 * It frees all the non-allocated memory buffer.\r
236 * This function is not responsible to free allocated buffer (eg: case of memory leak,\r
237 * runtime allocation).\r
238 */\r
239EFI_STATUS\r
240EFIAPI\r
241UncachedMemoryAllocationLibDestructor (\r
242 IN EFI_HANDLE ImageHandle,\r
243 IN EFI_SYSTEM_TABLE *SystemTable\r
244 )\r
245{\r
246 LIST_ENTRY *Link;\r
247 FREE_PAGE_NODE *OldNode;\r
248\r
249 // Test if the list is empty\r
250 Link = mPageList.ForwardLink;\r
251 if (Link == &mPageList) {\r
252 return EFI_SUCCESS;\r
253 }\r
254\r
255 // Free all the pages and nodes\r
256 do {\r
257 OldNode = BASE_CR (Link, FREE_PAGE_NODE, Link);\r
258 // Point to the next entry\r
259 Link = Link->ForwardLink;\r
260\r
261 // We only free the non-allocated buffer\r
262 if (OldNode->Allocated == FALSE) {\r
263 gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)OldNode->Base, OldNode->Pages);\r
264\r
265 gDS->SetMemorySpaceAttributes ((EFI_PHYSICAL_ADDRESS)(UINTN)OldNode->Base,\r
266 EFI_PAGES_TO_SIZE (OldNode->Pages), OldNode->Attributes);\r
267\r
268 RemoveEntryList (&OldNode->Link);\r
269 FreePool (OldNode);\r
270 }\r
271 } while (Link != &mPageList);\r
272\r
273 return EFI_SUCCESS;\r
274}\r
275\r
276/**\r
277 Converts a cached or uncached address to a physical address suitable for use in SoC registers.\r
278\r
279 @param VirtualAddress The pointer to convert.\r
280\r
281 @return The physical address of the supplied virtual pointer.\r
282\r
283**/\r
284EFI_PHYSICAL_ADDRESS\r
285ConvertToPhysicalAddress (\r
286 IN VOID *VirtualAddress\r
287 )\r
288{\r
289 return (EFI_PHYSICAL_ADDRESS)(UINTN)VirtualAddress;\r
290}\r
291\r
292\r
293VOID *\r
294UncachedInternalAllocatePages (\r
295 IN EFI_MEMORY_TYPE MemoryType,\r
296 IN UINTN Pages\r
297 )\r
298{\r
299 return UncachedInternalAllocateAlignedPages (MemoryType, Pages, EFI_PAGE_SIZE);\r
300}\r
301\r
302\r
303VOID *\r
304EFIAPI\r
305UncachedAllocatePages (\r
306 IN UINTN Pages\r
307 )\r
308{\r
309 return UncachedInternalAllocatePages (EfiBootServicesData, Pages);\r
310}\r
311\r
312VOID *\r
313EFIAPI\r
314UncachedAllocateRuntimePages (\r
315 IN UINTN Pages\r
316 )\r
317{\r
318 return UncachedInternalAllocatePages (EfiRuntimeServicesData, Pages);\r
319}\r
320\r
321VOID *\r
322EFIAPI\r
323UncachedAllocateReservedPages (\r
324 IN UINTN Pages\r
325 )\r
326{\r
327 return UncachedInternalAllocatePages (EfiReservedMemoryType, Pages);\r
328}\r
329\r
330\r
331\r
332VOID\r
333EFIAPI\r
334UncachedFreePages (\r
335 IN VOID *Buffer,\r
336 IN UINTN Pages\r
337 )\r
338{\r
339 UncachedFreeAlignedPages (Buffer, Pages);\r
340 return;\r
341}\r
342\r
343\r
344VOID *\r
345UncachedInternalAllocateAlignedPages (\r
346 IN EFI_MEMORY_TYPE MemoryType,\r
347 IN UINTN Pages,\r
348 IN UINTN Alignment\r
349 )\r
350{\r
351 EFI_STATUS Status;\r
352 VOID *Allocation;\r
353\r
354 if (Pages == 0) {\r
355 return NULL;\r
356 }\r
357\r
358 Allocation = NULL;\r
359 Status = AllocatePagesFromList (MemoryType, Pages, Alignment, &Allocation);\r
360 if (EFI_ERROR (Status)) {\r
361 ASSERT_EFI_ERROR (Status);\r
362 return NULL;\r
363 } else {\r
364 return Allocation;\r
365 }\r
366}\r
367\r
368\r
369VOID\r
370EFIAPI\r
371UncachedFreeAlignedPages (\r
372 IN VOID *Buffer,\r
373 IN UINTN Pages\r
374 )\r
375{\r
376 FreePagesFromList (Buffer);\r
377}\r
378\r
379\r
380VOID *\r
381UncachedInternalAllocateAlignedPool (\r
382 IN EFI_MEMORY_TYPE PoolType,\r
383 IN UINTN AllocationSize,\r
384 IN UINTN Alignment\r
385 )\r
386{\r
387 VOID *AlignedAddress;\r
388\r
389 //\r
390 // Alignment must be a power of two or zero.\r
391 //\r
392 ASSERT ((Alignment & (Alignment - 1)) == 0);\r
393\r
394 if (Alignment < EFI_PAGE_SIZE) {\r
395 Alignment = EFI_PAGE_SIZE;\r
396 }\r
397\r
398 AlignedAddress = UncachedInternalAllocateAlignedPages (PoolType, EFI_SIZE_TO_PAGES (AllocationSize), Alignment);\r
399 if (AlignedAddress == NULL) {\r
400 return NULL;\r
401 }\r
402\r
403 return (VOID *) AlignedAddress;\r
404}\r
405\r
406VOID *\r
407EFIAPI\r
408UncachedAllocateAlignedPool (\r
409 IN UINTN AllocationSize,\r
410 IN UINTN Alignment\r
411 )\r
412{\r
413 return UncachedInternalAllocateAlignedPool (EfiBootServicesData, AllocationSize, Alignment);\r
414}\r
415\r
416VOID *\r
417EFIAPI\r
418UncachedAllocateAlignedRuntimePool (\r
419 IN UINTN AllocationSize,\r
420 IN UINTN Alignment\r
421 )\r
422{\r
423 return UncachedInternalAllocateAlignedPool (EfiRuntimeServicesData, AllocationSize, Alignment);\r
424}\r
425\r
426VOID *\r
427EFIAPI\r
428UncachedAllocateAlignedReservedPool (\r
429 IN UINTN AllocationSize,\r
430 IN UINTN Alignment\r
431 )\r
432{\r
433 return UncachedInternalAllocateAlignedPool (EfiReservedMemoryType, AllocationSize, Alignment);\r
434}\r
435\r
436VOID *\r
437UncachedInternalAllocateAlignedZeroPool (\r
438 IN EFI_MEMORY_TYPE PoolType,\r
439 IN UINTN AllocationSize,\r
440 IN UINTN Alignment\r
441 )\r
442{\r
443 VOID *Memory;\r
444 Memory = UncachedInternalAllocateAlignedPool (PoolType, AllocationSize, Alignment);\r
445 if (Memory != NULL) {\r
446 Memory = ZeroMem (Memory, AllocationSize);\r
447 }\r
448 return Memory;\r
449}\r
450\r
451VOID *\r
452EFIAPI\r
453UncachedAllocateAlignedZeroPool (\r
454 IN UINTN AllocationSize,\r
455 IN UINTN Alignment\r
456 )\r
457{\r
458 return UncachedInternalAllocateAlignedZeroPool (EfiBootServicesData, AllocationSize, Alignment);\r
459}\r
460\r
461VOID *\r
462EFIAPI\r
463UncachedAllocateAlignedRuntimeZeroPool (\r
464 IN UINTN AllocationSize,\r
465 IN UINTN Alignment\r
466 )\r
467{\r
468 return UncachedInternalAllocateAlignedZeroPool (EfiRuntimeServicesData, AllocationSize, Alignment);\r
469}\r
470\r
471VOID *\r
472EFIAPI\r
473UncachedAllocateAlignedReservedZeroPool (\r
474 IN UINTN AllocationSize,\r
475 IN UINTN Alignment\r
476 )\r
477{\r
478 return UncachedInternalAllocateAlignedZeroPool (EfiReservedMemoryType, AllocationSize, Alignment);\r
479}\r
480\r
481VOID *\r
482UncachedInternalAllocateAlignedCopyPool (\r
483 IN EFI_MEMORY_TYPE PoolType,\r
484 IN UINTN AllocationSize,\r
485 IN CONST VOID *Buffer,\r
486 IN UINTN Alignment\r
487 )\r
488{\r
489 VOID *Memory;\r
490\r
491 ASSERT (Buffer != NULL);\r
492 ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
493\r
494 Memory = UncachedInternalAllocateAlignedPool (PoolType, AllocationSize, Alignment);\r
495 if (Memory != NULL) {\r
496 Memory = CopyMem (Memory, Buffer, AllocationSize);\r
497 }\r
498 return Memory;\r
499}\r
500\r
501VOID *\r
502EFIAPI\r
503UncachedAllocateAlignedCopyPool (\r
504 IN UINTN AllocationSize,\r
505 IN CONST VOID *Buffer,\r
506 IN UINTN Alignment\r
507 )\r
508{\r
509 return UncachedInternalAllocateAlignedCopyPool (EfiBootServicesData, AllocationSize, Buffer, Alignment);\r
510}\r
511\r
512VOID *\r
513EFIAPI\r
514UncachedAllocateAlignedRuntimeCopyPool (\r
515 IN UINTN AllocationSize,\r
516 IN CONST VOID *Buffer,\r
517 IN UINTN Alignment\r
518 )\r
519{\r
520 return UncachedInternalAllocateAlignedCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer, Alignment);\r
521}\r
522\r
523VOID *\r
524EFIAPI\r
525UncachedAllocateAlignedReservedCopyPool (\r
526 IN UINTN AllocationSize,\r
527 IN CONST VOID *Buffer,\r
528 IN UINTN Alignment\r
529 )\r
530{\r
531 return UncachedInternalAllocateAlignedCopyPool (EfiReservedMemoryType, AllocationSize, Buffer, Alignment);\r
532}\r
533\r
534VOID\r
535EFIAPI\r
536UncachedFreeAlignedPool (\r
537 IN VOID *Allocation\r
538 )\r
539{\r
540 UncachedFreePages (Allocation, 0);\r
541}\r
542\r
543VOID *\r
544UncachedInternalAllocatePool (\r
545 IN EFI_MEMORY_TYPE MemoryType,\r
546 IN UINTN AllocationSize\r
547 )\r
548{\r
549 UINTN CacheLineLength = ArmCacheWritebackGranule ();\r
550 return UncachedInternalAllocateAlignedPool (MemoryType, AllocationSize, CacheLineLength);\r
551}\r
552\r
553VOID *\r
554EFIAPI\r
555UncachedAllocatePool (\r
556 IN UINTN AllocationSize\r
557 )\r
558{\r
559 return UncachedInternalAllocatePool (EfiBootServicesData, AllocationSize);\r
560}\r
561\r
562VOID *\r
563EFIAPI\r
564UncachedAllocateRuntimePool (\r
565 IN UINTN AllocationSize\r
566 )\r
567{\r
568 return UncachedInternalAllocatePool (EfiRuntimeServicesData, AllocationSize);\r
569}\r
570\r
571VOID *\r
572EFIAPI\r
573UncachedAllocateReservedPool (\r
574 IN UINTN AllocationSize\r
575 )\r
576{\r
577 return UncachedInternalAllocatePool (EfiReservedMemoryType, AllocationSize);\r
578}\r
579\r
580VOID *\r
581UncachedInternalAllocateZeroPool (\r
582 IN EFI_MEMORY_TYPE PoolType,\r
583 IN UINTN AllocationSize\r
584 )\r
585{\r
586 VOID *Memory;\r
587\r
588 Memory = UncachedInternalAllocatePool (PoolType, AllocationSize);\r
589 if (Memory != NULL) {\r
590 Memory = ZeroMem (Memory, AllocationSize);\r
591 }\r
592 return Memory;\r
593}\r
594\r
595VOID *\r
596EFIAPI\r
597UncachedAllocateZeroPool (\r
598 IN UINTN AllocationSize\r
599 )\r
600{\r
601 return UncachedInternalAllocateZeroPool (EfiBootServicesData, AllocationSize);\r
602}\r
603\r
604VOID *\r
605EFIAPI\r
606UncachedAllocateRuntimeZeroPool (\r
607 IN UINTN AllocationSize\r
608 )\r
609{\r
610 return UncachedInternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize);\r
611}\r
612\r
613VOID *\r
614EFIAPI\r
615UncachedAllocateReservedZeroPool (\r
616 IN UINTN AllocationSize\r
617 )\r
618{\r
619 return UncachedInternalAllocateZeroPool (EfiReservedMemoryType, AllocationSize);\r
620}\r
621\r
622VOID *\r
623UncachedInternalAllocateCopyPool (\r
624 IN EFI_MEMORY_TYPE PoolType,\r
625 IN UINTN AllocationSize,\r
626 IN CONST VOID *Buffer\r
627 )\r
628{\r
629 VOID *Memory;\r
630\r
631 ASSERT (Buffer != NULL);\r
632 ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
633\r
634 Memory = UncachedInternalAllocatePool (PoolType, AllocationSize);\r
635 if (Memory != NULL) {\r
636 Memory = CopyMem (Memory, Buffer, AllocationSize);\r
637 }\r
638 return Memory;\r
639}\r
640\r
641VOID *\r
642EFIAPI\r
643UncachedAllocateCopyPool (\r
644 IN UINTN AllocationSize,\r
645 IN CONST VOID *Buffer\r
646 )\r
647{\r
648 return UncachedInternalAllocateCopyPool (EfiBootServicesData, AllocationSize, Buffer);\r
649}\r
650\r
651VOID *\r
652EFIAPI\r
653UncachedAllocateRuntimeCopyPool (\r
654 IN UINTN AllocationSize,\r
655 IN CONST VOID *Buffer\r
656 )\r
657{\r
658 return UncachedInternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer);\r
659}\r
660\r
661VOID *\r
662EFIAPI\r
663UncachedAllocateReservedCopyPool (\r
664 IN UINTN AllocationSize,\r
665 IN CONST VOID *Buffer\r
666 )\r
667{\r
668 return UncachedInternalAllocateCopyPool (EfiReservedMemoryType, AllocationSize, Buffer);\r
669}\r
670\r
671VOID\r
672EFIAPI\r
673UncachedFreePool (\r
674 IN VOID *Buffer\r
675 )\r
676{\r
677 UncachedFreeAlignedPool (Buffer);\r
678}\r
679\r
680VOID\r
681EFIAPI\r
682UncachedSafeFreePool (\r
683 IN VOID *Buffer\r
684 )\r
685{\r
686 if (Buffer != NULL) {\r
687 UncachedFreePool (Buffer);\r
688 Buffer = NULL;\r
689 }\r
690}\r
691\r