]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c
ArmPkg: Invalidate cache after allocating UC memory
[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
45//\r
46// Assume all of memory has the same cache attributes, unless we do our magic\r
47//\r
48UINT64 gAttributes;\r
49\r
50typedef struct {\r
51 EFI_PHYSICAL_ADDRESS Base;\r
52 VOID *Allocation;\r
53 UINTN Pages;\r
54 EFI_MEMORY_TYPE MemoryType;\r
55 BOOLEAN Allocated;\r
56 LIST_ENTRY Link;\r
57} FREE_PAGE_NODE;\r
58\r
59STATIC LIST_ENTRY mPageList = INITIALIZE_LIST_HEAD_VARIABLE (mPageList);\r
60// Track the size of the non-allocated buffer in the linked-list\r
61STATIC UINTN mFreedBufferSize = 0;\r
62\r
63/**\r
64 * This function firstly checks if the requested allocation can fit into one\r
65 * of the previously allocated buffer.\r
66 * If the requested allocation does not fit in the existing pool then\r
67 * the function makes a new allocation.\r
68 *\r
69 * @param MemoryType Type of memory requested for the new allocation\r
70 * @param Pages Number of requested page\r
71 * @param Alignment Required alignment\r
72 * @param Allocation Address of the newly allocated buffer\r
73 *\r
74 * @return EFI_SUCCESS If the function manage to allocate a buffer\r
75 * @return !EFI_SUCCESS If the function did not manage to allocate a buffer\r
76 */\r
77STATIC\r
78EFI_STATUS\r
79AllocatePagesFromList (\r
80 IN EFI_MEMORY_TYPE MemoryType,\r
81 IN UINTN Pages,\r
82 IN UINTN Alignment,\r
83 OUT VOID **Allocation\r
84 )\r
85{\r
86 EFI_STATUS Status;\r
87 LIST_ENTRY *Link;\r
88 FREE_PAGE_NODE *Node;\r
89 FREE_PAGE_NODE *NewNode;\r
90 UINTN AlignmentMask;\r
91 EFI_PHYSICAL_ADDRESS Memory;\r
92 EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor;\r
93\r
94 // Alignment must be a power of two or zero.\r
95 ASSERT ((Alignment & (Alignment - 1)) == 0);\r
96\r
97 //\r
98 // Look in our list for the smallest page that could satisfy the new allocation\r
99 //\r
100 NewNode = NULL;\r
101 for (Link = mPageList.ForwardLink; Link != &mPageList; Link = Link->ForwardLink) {\r
102 Node = BASE_CR (Link, FREE_PAGE_NODE, Link);\r
103 if ((Node->Allocated == FALSE) && (Node->MemoryType == MemoryType)) {\r
104 // We have a node that fits our requirements\r
105 if (((UINTN)Node->Base & (Alignment - 1)) == 0) {\r
106 // We found a page that matches the page size\r
107 if (Node->Pages == Pages) {\r
108 Node->Allocated = TRUE;\r
109 Node->Allocation = (VOID*)(UINTN)Node->Base;\r
110 *Allocation = Node->Allocation;\r
111\r
112 // Update the size of the freed buffer\r
113 mFreedBufferSize -= Pages * EFI_PAGE_SIZE;\r
114 return EFI_SUCCESS;\r
115 } else if (Node->Pages > Pages) {\r
116 if (NewNode == NULL) {\r
117 // It is the first node that could contain our new allocation\r
118 NewNode = Node;\r
119 } else if (NewNode->Pages > Node->Pages) {\r
120 // This node offers a smaller number of page.\r
121 NewNode = Node;\r
122 }\r
123 }\r
124 }\r
125 }\r
126 }\r
127 // Check if we have found a node that could contain our new allocation\r
128 if (NewNode != NULL) {\r
129 NewNode->Allocated = TRUE;\r
130 NewNode->Allocation = (VOID*)(UINTN)NewNode->Base;\r
131 *Allocation = NewNode->Allocation;\r
132 mFreedBufferSize -= NewNode->Pages * EFI_PAGE_SIZE;\r
133 return EFI_SUCCESS;\r
134 }\r
135\r
136 //\r
137 // Otherwise, we need to allocate a new buffer\r
138 //\r
139\r
140 // We do not want to over-allocate in case the alignment requirement does not\r
141 // require extra pages\r
142 if (Alignment > EFI_PAGE_SIZE) {\r
143 AlignmentMask = Alignment - 1;\r
144 Pages += EFI_SIZE_TO_PAGES (Alignment);\r
145 } else {\r
146 AlignmentMask = 0;\r
147 }\r
148\r
149 Status = gBS->AllocatePages (AllocateAnyPages, MemoryType, Pages, &Memory);\r
150 if (EFI_ERROR (Status)) {\r
151 return Status;\r
152 }\r
153\r
154 Status = gDS->GetMemorySpaceDescriptor (Memory, &Descriptor);\r
155 if (!EFI_ERROR (Status)) {\r
156 // We are making an assumption that all of memory has the same default attributes\r
157 gAttributes = Descriptor.Attributes;\r
158 } else {\r
159 gBS->FreePages (Memory, Pages);\r
160 return Status;\r
161 }\r
162\r
163 Status = gDS->SetMemorySpaceAttributes (Memory, EFI_PAGES_TO_SIZE (Pages), EFI_MEMORY_WC);\r
164 if (EFI_ERROR (Status)) {\r
165 gBS->FreePages (Memory, Pages);\r
166 return Status;\r
167 }\r
168\r
169 InvalidateDataCacheRange ((VOID *)(UINTN)Memory, EFI_PAGES_TO_SIZE (Pages));\r
170\r
171 NewNode = AllocatePool (sizeof (FREE_PAGE_NODE));\r
172 if (NewNode == NULL) {\r
173 ASSERT (FALSE);\r
174 gBS->FreePages (Memory, Pages);\r
175 return EFI_OUT_OF_RESOURCES;\r
176 }\r
177\r
178 NewNode->Base = Memory;\r
179 NewNode->Allocation = (VOID*)(((UINTN)Memory + AlignmentMask) & ~AlignmentMask);\r
180 NewNode->Pages = Pages;\r
181 NewNode->Allocated = TRUE;\r
182 NewNode->MemoryType = MemoryType;\r
183\r
184 InsertTailList (&mPageList, &NewNode->Link);\r
185\r
186 *Allocation = NewNode->Allocation;\r
187 return EFI_SUCCESS;\r
188}\r
189\r
190/**\r
191 * Free the memory allocation\r
192 *\r
193 * This function will actually try to find the allocation in the linked list.\r
194 * And it will then mark the entry as freed.\r
195 *\r
196 * @param Allocation Base address of the buffer to free\r
197 *\r
198 * @return EFI_SUCCESS The allocation has been freed\r
199 * @return EFI_NOT_FOUND The allocation was not found in the pool.\r
200 * @return EFI_INVALID_PARAMETER If Allocation is NULL\r
201 *\r
202 */\r
203STATIC\r
204EFI_STATUS\r
205FreePagesFromList (\r
206 IN VOID *Allocation\r
207 )\r
208{\r
209 LIST_ENTRY *Link;\r
210 FREE_PAGE_NODE *Node;\r
211\r
212 if (Allocation == NULL) {\r
213 return EFI_INVALID_PARAMETER;\r
214 }\r
215\r
216 for (Link = mPageList.ForwardLink; Link != &mPageList; Link = Link->ForwardLink) {\r
217 Node = BASE_CR (Link, FREE_PAGE_NODE, Link);\r
218 if ((UINTN)Node->Allocation == (UINTN)Allocation) {\r
219 Node->Allocated = FALSE;\r
220\r
221 // Update the size of the freed buffer\r
222 mFreedBufferSize += Node->Pages * EFI_PAGE_SIZE;\r
223\r
224 // If the size of the non-allocated reaches the threshold we raise a warning.\r
225 // It might be an expected behaviour in some cases.\r
226 // We might device to free some of these buffers later on.\r
227 if (mFreedBufferSize > PcdGet64 (PcdArmFreeUncachedMemorySizeThreshold)) {\r
228 DEBUG ((EFI_D_WARN, "Warning: The list of non-allocated buffer has reach the threshold.\n"));\r
229 }\r
230 return EFI_SUCCESS;\r
231 }\r
232 }\r
233\r
234 return EFI_NOT_FOUND;\r
235}\r
236\r
237/**\r
238 * This function is automatically invoked when the driver exits\r
239 * It frees all the non-allocated memory buffer.\r
240 * This function is not responsible to free allocated buffer (eg: case of memory leak,\r
241 * runtime allocation).\r
242 */\r
243EFI_STATUS\r
244EFIAPI\r
245UncachedMemoryAllocationLibDestructor (\r
246 IN EFI_HANDLE ImageHandle,\r
247 IN EFI_SYSTEM_TABLE *SystemTable\r
248 )\r
249{\r
250 LIST_ENTRY *Link;\r
251 FREE_PAGE_NODE *OldNode;\r
252\r
253 // Test if the list is empty\r
254 Link = mPageList.ForwardLink;\r
255 if (Link == &mPageList) {\r
256 return EFI_SUCCESS;\r
257 }\r
258\r
259 // Free all the pages and nodes\r
260 do {\r
261 OldNode = BASE_CR (Link, FREE_PAGE_NODE, Link);\r
262 // Point to the next entry\r
263 Link = Link->ForwardLink;\r
264\r
265 // We only free the non-allocated buffer\r
266 if (OldNode->Allocated == FALSE) {\r
267 gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)OldNode->Base, OldNode->Pages);\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 = ArmDataCacheLineLength ();\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