TianoCore EDK2 master
Loading...
Searching...
No Matches
Pool.c
Go to the documentation of this file.
1
9#include "DxeMain.h"
10#include "Imem.h"
11#include "HeapGuard.h"
12
13STATIC EFI_LOCK mPoolMemoryLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY);
14
15#define POOL_FREE_SIGNATURE SIGNATURE_32('p','f','r','0')
16typedef struct {
17 UINT32 Signature;
18 UINT32 Index;
19 LIST_ENTRY Link;
20} POOL_FREE;
21
22#define POOL_HEAD_SIGNATURE SIGNATURE_32('p','h','d','0')
23#define POOLPAGE_HEAD_SIGNATURE SIGNATURE_32('p','h','d','1')
24typedef struct {
25 UINT32 Signature;
26 UINT32 Reserved;
27 EFI_MEMORY_TYPE Type;
28 UINTN Size;
29 CHAR8 Data[1];
30} POOL_HEAD;
31
32#define SIZE_OF_POOL_HEAD OFFSET_OF(POOL_HEAD,Data)
33
34#define POOL_TAIL_SIGNATURE SIGNATURE_32('p','t','a','l')
35typedef struct {
36 UINT32 Signature;
37 UINT32 Reserved;
38 UINTN Size;
39} POOL_TAIL;
40
41#define POOL_OVERHEAD (SIZE_OF_POOL_HEAD + sizeof(POOL_TAIL))
42
43#define HEAD_TO_TAIL(a) \
44 ((POOL_TAIL *) (((CHAR8 *) (a)) + (a)->Size - sizeof(POOL_TAIL)));
45
46//
47// Each element is the sum of the 2 previous ones: this allows us to migrate
48// blocks between bins by splitting them up, while not wasting too much memory
49// as we would in a strict power-of-2 sequence
50//
51STATIC CONST UINT16 mPoolSizeTable[] = {
52 128, 256, 384, 640, 1024, 1664, 2688, 4352, 7040, 11392, 18432, 29824
53};
54
55#define SIZE_TO_LIST(a) (GetPoolIndexFromSize (a))
56#define LIST_TO_SIZE(a) (mPoolSizeTable [a])
57
58#define MAX_POOL_LIST (ARRAY_SIZE (mPoolSizeTable))
59
60#define MAX_POOL_SIZE (MAX_ADDRESS - POOL_OVERHEAD)
61
62//
63// Globals
64//
65
66#define POOL_SIGNATURE SIGNATURE_32('p','l','s','t')
67typedef struct {
68 INTN Signature;
69 UINTN Used;
70 EFI_MEMORY_TYPE MemoryType;
71 LIST_ENTRY FreeList[MAX_POOL_LIST];
72 LIST_ENTRY Link;
73} POOL;
74
75//
76// Pool header for each memory type.
77//
78POOL mPoolHead[EfiMaxMemoryType];
79
80//
81// List of pool header to search for the appropriate memory type.
82//
83LIST_ENTRY mPoolHeadList = INITIALIZE_LIST_HEAD_VARIABLE (mPoolHeadList);
84
96 UINTN Size
97 )
98{
99 UINTN Index;
100
101 for (Index = 0; Index < MAX_POOL_LIST; Index++) {
102 if (mPoolSizeTable[Index] >= Size) {
103 return Index;
104 }
105 }
106
107 return MAX_POOL_LIST;
108}
109
114VOID
116 VOID
117 )
118{
119 UINTN Type;
120 UINTN Index;
121
122 for (Type = 0; Type < EfiMaxMemoryType; Type++) {
123 mPoolHead[Type].Signature = 0;
124 mPoolHead[Type].Used = 0;
125 mPoolHead[Type].MemoryType = (EFI_MEMORY_TYPE)Type;
126 for (Index = 0; Index < MAX_POOL_LIST; Index++) {
127 InitializeListHead (&mPoolHead[Type].FreeList[Index]);
128 }
129 }
130}
131
140POOL *
142 IN EFI_MEMORY_TYPE MemoryType
143 )
144{
145 LIST_ENTRY *Link;
146 POOL *Pool;
147 UINTN Index;
148
149 if ((UINT32)MemoryType < EfiMaxMemoryType) {
150 return &mPoolHead[MemoryType];
151 }
152
153 //
154 // MemoryType values in the range 0x80000000..0xFFFFFFFF are reserved for use by UEFI
155 // OS loaders that are provided by operating system vendors.
156 // MemoryType values in the range 0x70000000..0x7FFFFFFF are reserved for OEM use.
157 //
158 if ((UINT32)MemoryType >= MEMORY_TYPE_OEM_RESERVED_MIN) {
159 for (Link = mPoolHeadList.ForwardLink; Link != &mPoolHeadList; Link = Link->ForwardLink) {
160 Pool = CR (Link, POOL, Link, POOL_SIGNATURE);
161 if (Pool->MemoryType == MemoryType) {
162 return Pool;
163 }
164 }
165
167 if (Pool == NULL) {
168 return NULL;
169 }
170
171 Pool->Signature = POOL_SIGNATURE;
172 Pool->Used = 0;
173 Pool->MemoryType = MemoryType;
174 for (Index = 0; Index < MAX_POOL_LIST; Index++) {
175 InitializeListHead (&Pool->FreeList[Index]);
176 }
177
178 InsertHeadList (&mPoolHeadList, &Pool->Link);
179
180 return Pool;
181 }
182
183 return NULL;
184}
185
202EFIAPI
204 IN EFI_MEMORY_TYPE PoolType,
205 IN UINTN Size,
206 OUT VOID **Buffer
207 )
208{
209 EFI_STATUS Status;
210 BOOLEAN NeedGuard;
211
212 //
213 // If it's not a valid type, fail it
214 //
215 if (((PoolType >= EfiMaxMemoryType) && (PoolType < MEMORY_TYPE_OEM_RESERVED_MIN)) ||
216 (PoolType == EfiConventionalMemory) || (PoolType == EfiPersistentMemory) || (PoolType == EfiUnacceptedMemoryType))
217 {
218 return EFI_INVALID_PARAMETER;
219 }
220
221 if (Buffer == NULL) {
222 return EFI_INVALID_PARAMETER;
223 }
224
225 *Buffer = NULL;
226
227 //
228 // If size is too large, fail it
229 // Base on the EFI spec, return status of EFI_OUT_OF_RESOURCES
230 //
231 if (Size > MAX_POOL_SIZE) {
232 return EFI_OUT_OF_RESOURCES;
233 }
234
235 NeedGuard = IsPoolTypeToGuard (PoolType) && !mOnGuarding;
236
237 //
238 // Acquire the memory lock and make the allocation
239 //
240 Status = CoreAcquireLockOrFail (&mPoolMemoryLock);
241 if (EFI_ERROR (Status)) {
242 return EFI_OUT_OF_RESOURCES;
243 }
244
245 *Buffer = CoreAllocatePoolI (PoolType, Size, NeedGuard);
246 CoreReleaseLock (&mPoolMemoryLock);
247 return (*Buffer != NULL) ? EFI_SUCCESS : EFI_OUT_OF_RESOURCES;
248}
249
266EFIAPI
268 IN EFI_MEMORY_TYPE PoolType,
269 IN UINTN Size,
270 OUT VOID **Buffer
271 )
272{
273 EFI_STATUS Status;
274
275 Status = CoreInternalAllocatePool (PoolType, Size, Buffer);
276 if (!EFI_ERROR (Status)) {
279 MemoryProfileActionAllocatePool,
280 PoolType,
281 Size,
282 *Buffer,
283 NULL
284 );
286 }
287
288 return Status;
289}
290
303STATIC
304VOID *
306 IN EFI_MEMORY_TYPE PoolType,
307 IN UINTN NoPages,
308 IN UINTN Granularity,
309 IN BOOLEAN NeedGuard
310 )
311{
312 VOID *Buffer;
313 EFI_STATUS Status;
314
315 Status = CoreAcquireLockOrFail (&gMemoryLock);
316 if (EFI_ERROR (Status)) {
317 return NULL;
318 }
319
320 Buffer = CoreAllocatePoolPages (PoolType, NoPages, Granularity, NeedGuard);
322
323 if (Buffer != NULL) {
324 if (NeedGuard) {
325 SetGuardForMemory ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, NoPages);
326 }
327
330 PoolType,
332 EFI_PAGES_TO_SIZE (NoPages)
333 );
334 }
335
336 return Buffer;
337}
338
350VOID *
352 IN EFI_MEMORY_TYPE PoolType,
353 IN UINTN Size,
354 IN BOOLEAN NeedGuard
355 )
356{
357 POOL *Pool;
358 POOL_FREE *Free;
359 POOL_HEAD *Head;
360 POOL_TAIL *Tail;
361 CHAR8 *NewPage;
362 VOID *Buffer;
363 UINTN Index;
364 UINTN FSize;
365 UINTN Offset, MaxOffset;
366 UINTN NoPages;
367 UINTN Granularity;
368 BOOLEAN HasPoolTail;
369 BOOLEAN PageAsPool;
370
371 ASSERT_LOCKED (&mPoolMemoryLock);
372
373 if ((PoolType == EfiReservedMemoryType) ||
374 (PoolType == EfiACPIMemoryNVS) ||
375 (PoolType == EfiRuntimeServicesCode) ||
376 (PoolType == EfiRuntimeServicesData))
377 {
378 Granularity = RUNTIME_PAGE_ALLOCATION_GRANULARITY;
379 } else {
381 }
382
383 //
384 // The heap guard system does not support non-EFI_PAGE_SIZE alignments.
385 // Architectures that require larger RUNTIME_PAGE_ALLOCATION_GRANULARITY
386 // will have the runtime memory regions unguarded. OSes do not
387 // map guard pages anyway, so this is a minimal loss. Not guarding prevents
388 // alignment mismatches
389 //
390 if (Granularity != EFI_PAGE_SIZE) {
391 NeedGuard = FALSE;
392 }
393
394 //
395 // Adjust the size by the pool header & tail overhead
396 //
397
398 HasPoolTail = !(NeedGuard &&
399 ((PcdGet8 (PcdHeapGuardPropertyMask) & BIT7) == 0));
400 PageAsPool = (IsHeapGuardEnabled (GUARD_HEAP_TYPE_FREED) && !mOnGuarding);
401
402 //
403 // Adjusting the Size to be of proper alignment so that
404 // we don't get an unaligned access fault later when
405 // pool_Tail is being initialized
406 //
407 Size = ALIGN_VARIABLE (Size);
408
409 Size += POOL_OVERHEAD;
410 Index = SIZE_TO_LIST (Size);
411 Pool = LookupPoolHead (PoolType);
412 if (Pool == NULL) {
413 return NULL;
414 }
415
416 Head = NULL;
417
418 //
419 // If allocation is over max size, just allocate pages for the request
420 // (slow)
421 //
422 if ((Index >= SIZE_TO_LIST (Granularity)) || NeedGuard || PageAsPool) {
423 if (!HasPoolTail) {
424 Size -= sizeof (POOL_TAIL);
425 }
426
427 NoPages = EFI_SIZE_TO_PAGES (Size) + EFI_SIZE_TO_PAGES (Granularity) - 1;
428 NoPages &= ~(UINTN)(EFI_SIZE_TO_PAGES (Granularity) - 1);
429 Head = CoreAllocatePoolPagesI (PoolType, NoPages, Granularity, NeedGuard);
430 if (Head == NULL) {
431 return NULL;
432 }
433
434 if (NeedGuard) {
435 Head = AdjustPoolHeadA ((EFI_PHYSICAL_ADDRESS)(UINTN)Head, NoPages, Size);
436 }
437
438 goto Done;
439 }
440
441 //
442 // If there's no free pool in the proper list size, go get some more pages
443 //
444 if (IsListEmpty (&Pool->FreeList[Index])) {
445 Offset = LIST_TO_SIZE (Index);
446 MaxOffset = Granularity;
447
448 //
449 // Check the bins holding larger blocks, and carve one up if needed
450 //
451 while (++Index < SIZE_TO_LIST (Granularity)) {
452 if (!IsListEmpty (&Pool->FreeList[Index])) {
453 Free = CR (Pool->FreeList[Index].ForwardLink, POOL_FREE, Link, POOL_FREE_SIGNATURE);
454 RemoveEntryList (&Free->Link);
455 NewPage = (VOID *)Free;
456 MaxOffset = LIST_TO_SIZE (Index);
457 goto Carve;
458 }
459 }
460
461 //
462 // Get another page
463 //
464 NewPage = CoreAllocatePoolPagesI (
465 PoolType,
466 EFI_SIZE_TO_PAGES (Granularity),
467 Granularity,
468 NeedGuard
469 );
470 if (NewPage == NULL) {
471 goto Done;
472 }
473
474 //
475 // Serve the allocation request from the head of the allocated block
476 //
477Carve:
478 Head = (POOL_HEAD *)NewPage;
479
480 //
481 // Carve up remaining space into free pool blocks
482 //
483 Index--;
484 while (Offset < MaxOffset) {
485 ASSERT (Index < MAX_POOL_LIST);
486 FSize = LIST_TO_SIZE (Index);
487
488 while (Offset + FSize <= MaxOffset) {
489 Free = (POOL_FREE *)&NewPage[Offset];
490 Free->Signature = POOL_FREE_SIGNATURE;
491 Free->Index = (UINT32)Index;
492 InsertHeadList (&Pool->FreeList[Index], &Free->Link);
493 Offset += FSize;
494 }
495
496 Index -= 1;
497 }
498
499 ASSERT (Offset == MaxOffset);
500 goto Done;
501 }
502
503 //
504 // Remove entry from free pool list
505 //
506 Free = CR (Pool->FreeList[Index].ForwardLink, POOL_FREE, Link, POOL_FREE_SIGNATURE);
507 RemoveEntryList (&Free->Link);
508
509 Head = (POOL_HEAD *)Free;
510
511Done:
512 Buffer = NULL;
513
514 if (Head != NULL) {
515 //
516 // Account the allocation
517 //
518 Pool->Used += Size;
519
520 //
521 // If we have a pool buffer, fill in the header & tail info
522 //
523 Head->Signature = (PageAsPool) ? POOLPAGE_HEAD_SIGNATURE : POOL_HEAD_SIGNATURE;
524 Head->Size = Size;
525 Head->Type = (EFI_MEMORY_TYPE)PoolType;
526 Buffer = Head->Data;
527
528 if (HasPoolTail) {
529 Tail = HEAD_TO_TAIL (Head);
530 Tail->Signature = POOL_TAIL_SIGNATURE;
531 Tail->Size = Size;
532
533 Size -= POOL_OVERHEAD;
534 } else {
535 Size -= SIZE_OF_POOL_HEAD;
536 }
537
538 DEBUG_CLEAR_MEMORY (Buffer, Size);
539
540 DEBUG ((
541 DEBUG_POOL,
542 "AllocatePoolI: Type %x, Addr %p (len %lx) %,ld\n",
543 PoolType,
544 Buffer,
545 (UINT64)Size,
546 (UINT64)Pool->Used
547 ));
548 } else {
549 DEBUG ((DEBUG_ERROR | DEBUG_POOL, "AllocatePool: failed to allocate %ld bytes\n", (UINT64)Size));
550 }
551
552 return Buffer;
553}
554
566EFIAPI
568 IN VOID *Buffer,
569 OUT EFI_MEMORY_TYPE *PoolType OPTIONAL
570 )
571{
572 EFI_STATUS Status;
573
574 if (Buffer == NULL) {
575 return EFI_INVALID_PARAMETER;
576 }
577
578 CoreAcquireLock (&mPoolMemoryLock);
579 Status = CoreFreePoolI (Buffer, PoolType);
580 CoreReleaseLock (&mPoolMemoryLock);
581 return Status;
582}
583
594EFIAPI
596 IN VOID *Buffer
597 )
598{
599 EFI_STATUS Status;
600 EFI_MEMORY_TYPE PoolType;
601
602 Status = CoreInternalFreePool (Buffer, &PoolType);
603 if (!EFI_ERROR (Status)) {
606 MemoryProfileActionFreePool,
607 PoolType,
608 0,
609 Buffer,
610 NULL
611 );
613 }
614
615 return Status;
616}
617
626STATIC
627VOID
629 IN EFI_MEMORY_TYPE PoolType,
631 IN UINTN NoPages
632 )
633{
635 CoreFreePoolPages (Memory, NoPages);
637
638 GuardFreedPagesChecked (Memory, NoPages);
640 PoolType,
643 EFI_PAGES_TO_SIZE (NoPages)
644 );
645}
646
655STATIC
656VOID
658 IN EFI_MEMORY_TYPE PoolType,
660 IN UINTN NoPages
661 )
662{
663 EFI_PHYSICAL_ADDRESS MemoryGuarded;
664 UINTN NoPagesGuarded;
665
666 MemoryGuarded = Memory;
667 NoPagesGuarded = NoPages;
668
669 AdjustMemoryF (&Memory, &NoPages);
670 //
671 // It's safe to unset Guard page inside memory lock because there should
672 // be no memory allocation occurred in updating memory page attribute at
673 // this point. And unsetting Guard page before free will prevent Guard
674 // page just freed back to pool from being allocated right away before
675 // marking it usable (from non-present to present).
676 //
677 UnsetGuardForMemory (MemoryGuarded, NoPagesGuarded);
678 if (NoPages > 0) {
679 CoreFreePoolPagesI (PoolType, Memory, NoPages);
680 }
681}
682
696 IN VOID *Buffer,
697 OUT EFI_MEMORY_TYPE *PoolType OPTIONAL
698 )
699{
700 POOL *Pool;
701 POOL_HEAD *Head;
702 POOL_TAIL *Tail;
703 POOL_FREE *Free;
704 UINTN Index;
705 UINTN NoPages;
706 UINTN Size;
707 CHAR8 *NewPage;
708 UINTN Offset;
709 BOOLEAN AllFree;
710 UINTN Granularity;
711 BOOLEAN IsGuarded;
712 BOOLEAN HasPoolTail;
713 BOOLEAN PageAsPool;
714
715 ASSERT (Buffer != NULL);
716 //
717 // Get the head & tail of the pool entry
718 //
719 Head = BASE_CR (Buffer, POOL_HEAD, Data);
720 ASSERT (Head != NULL);
721
722 if ((Head->Signature != POOL_HEAD_SIGNATURE) &&
723 (Head->Signature != POOLPAGE_HEAD_SIGNATURE))
724 {
725 ASSERT (
726 Head->Signature == POOL_HEAD_SIGNATURE ||
727 Head->Signature == POOLPAGE_HEAD_SIGNATURE
728 );
729 return EFI_INVALID_PARAMETER;
730 }
731
732 IsGuarded = IsPoolTypeToGuard (Head->Type) &&
734 HasPoolTail = !(IsGuarded &&
735 ((PcdGet8 (PcdHeapGuardPropertyMask) & BIT7) == 0));
736 PageAsPool = (Head->Signature == POOLPAGE_HEAD_SIGNATURE);
737
738 if (HasPoolTail) {
739 Tail = HEAD_TO_TAIL (Head);
740 ASSERT (Tail != NULL);
741
742 //
743 // Debug
744 //
745 ASSERT (Tail->Signature == POOL_TAIL_SIGNATURE);
746 ASSERT (Head->Size == Tail->Size);
747
748 if (Tail->Signature != POOL_TAIL_SIGNATURE) {
749 return EFI_INVALID_PARAMETER;
750 }
751
752 if (Head->Size != Tail->Size) {
753 return EFI_INVALID_PARAMETER;
754 }
755 }
756
757 ASSERT_LOCKED (&mPoolMemoryLock);
758
759 //
760 // Determine the pool type and account for it
761 //
762 Size = Head->Size;
763 Pool = LookupPoolHead (Head->Type);
764 if (Pool == NULL) {
765 return EFI_INVALID_PARAMETER;
766 }
767
768 Pool->Used -= Size;
769 DEBUG ((DEBUG_POOL, "FreePool: %p (len %lx) %,ld\n", Head->Data, (UINT64)(Head->Size - POOL_OVERHEAD), (UINT64)Pool->Used));
770
771 if ((Head->Type == EfiReservedMemoryType) ||
772 (Head->Type == EfiACPIMemoryNVS) ||
773 (Head->Type == EfiRuntimeServicesCode) ||
774 (Head->Type == EfiRuntimeServicesData))
775 {
776 Granularity = RUNTIME_PAGE_ALLOCATION_GRANULARITY;
777 } else {
779 }
780
781 if (PoolType != NULL) {
782 *PoolType = Head->Type;
783 }
784
785 //
786 // Determine the pool list
787 //
788 Index = SIZE_TO_LIST (Size);
789 DEBUG_CLEAR_MEMORY (Head, Size);
790
791 //
792 // If it's not on the list, it must be pool pages
793 //
794 if ((Index >= SIZE_TO_LIST (Granularity)) || IsGuarded || PageAsPool) {
795 //
796 // Return the memory pages back to free memory
797 //
798 NoPages = EFI_SIZE_TO_PAGES (Size) + EFI_SIZE_TO_PAGES (Granularity) - 1;
799 NoPages &= ~(UINTN)(EFI_SIZE_TO_PAGES (Granularity) - 1);
800 if (IsGuarded) {
801 Head = AdjustPoolHeadF ((EFI_PHYSICAL_ADDRESS)(UINTN)Head, NoPages, Size);
803 Pool->MemoryType,
805 NoPages
806 );
807 } else {
809 Pool->MemoryType,
811 NoPages
812 );
813 }
814 } else {
815 //
816 // Put the pool entry onto the free pool list
817 //
818 Free = (POOL_FREE *)Head;
819 ASSERT (Free != NULL);
820 Free->Signature = POOL_FREE_SIGNATURE;
821 Free->Index = (UINT32)Index;
822 InsertHeadList (&Pool->FreeList[Index], &Free->Link);
823
824 //
825 // See if all the pool entries in the same page as Free are freed pool
826 // entries
827 //
828 NewPage = (CHAR8 *)((UINTN)Free & ~(Granularity - 1));
829 Free = (POOL_FREE *)&NewPage[0];
830 ASSERT (Free != NULL);
831
832 if (Free->Signature == POOL_FREE_SIGNATURE) {
833 AllFree = TRUE;
834 Offset = 0;
835
836 while ((Offset < Granularity) && (AllFree)) {
837 Free = (POOL_FREE *)&NewPage[Offset];
838 ASSERT (Free != NULL);
839 if (Free->Signature != POOL_FREE_SIGNATURE) {
840 AllFree = FALSE;
841 }
842
843 Offset += LIST_TO_SIZE (Free->Index);
844 }
845
846 if (AllFree) {
847 //
848 // All of the pool entries in the same page as Free are free pool
849 // entries
850 // Remove all of these pool entries from the free loop lists.
851 //
852 Free = (POOL_FREE *)&NewPage[0];
853 ASSERT (Free != NULL);
854 Offset = 0;
855
856 while (Offset < Granularity) {
857 Free = (POOL_FREE *)&NewPage[Offset];
858 ASSERT (Free != NULL);
859 RemoveEntryList (&Free->Link);
860 Offset += LIST_TO_SIZE (Free->Index);
861 }
862
863 //
864 // Free the page
865 //
867 Pool->MemoryType,
868 (EFI_PHYSICAL_ADDRESS)(UINTN)NewPage,
869 EFI_SIZE_TO_PAGES (Granularity)
870 );
871 }
872 }
873 }
874
875 //
876 // If this is an OS/OEM specific memory type, then check to see if the last
877 // portion of that memory type has been freed. If it has, then free the
878 // list entry for that memory type
879 //
880 if (((UINT32)Pool->MemoryType >= MEMORY_TYPE_OEM_RESERVED_MIN) && (Pool->Used == 0)) {
881 RemoveEntryList (&Pool->Link);
882 CoreFreePoolI (Pool, NULL);
883 }
884
885 return EFI_SUCCESS;
886}
#define DEFAULT_PAGE_ALLOCATION_GRANULARITY
UINT64 UINTN
INT64 INTN
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
Definition: LinkedList.c:403
LIST_ENTRY *EFIAPI InsertHeadList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
Definition: LinkedList.c:218
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
Definition: LinkedList.c:590
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
Definition: LinkedList.c:182
#define INITIALIZE_LIST_HEAD_VARIABLE(ListHead)
Definition: BaseLib.h:2884
VOID SetGuardForMemory(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NumberOfPages)
Definition: HeapGuard.c:690
VOID AdjustMemoryF(IN OUT EFI_PHYSICAL_ADDRESS *Memory, IN OUT UINTN *NumberOfPages)
Definition: HeapGuard.c:884
VOID EFIAPI GuardFreedPagesChecked(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINTN Pages)
Definition: HeapGuard.c:1350
VOID * AdjustPoolHeadF(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NoPages, IN UINTN Size)
Definition: HeapGuard.c:1047
BOOLEAN IsHeapGuardEnabled(UINT8 GuardType)
Definition: HeapGuard.c:674
VOID UnsetGuardForMemory(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NumberOfPages)
Definition: HeapGuard.c:726
BOOLEAN IsPoolTypeToGuard(IN EFI_MEMORY_TYPE MemoryType)
Definition: HeapGuard.c:637
BOOLEAN EFIAPI IsMemoryGuarded(IN EFI_PHYSICAL_ADDRESS Address)
Definition: HeapGuard.c:486
VOID * AdjustPoolHeadA(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NoPages, IN UINTN Size)
Definition: HeapGuard.c:1016
EFI_STATUS CoreAcquireLockOrFail(IN EFI_LOCK *Lock)
Definition: Library.c:29
VOID CoreAcquireLock(IN EFI_LOCK *Lock)
Definition: Library.c:59
VOID CoreReleaseLock(IN EFI_LOCK *Lock)
Definition: Library.c:80
EFI_STATUS EFIAPI CoreUpdateProfile(IN EFI_PHYSICAL_ADDRESS CallerAddress, IN MEMORY_PROFILE_ACTION Action, IN EFI_MEMORY_TYPE MemoryType, IN UINTN Size, IN VOID *Buffer, IN CHAR8 *ActionString OPTIONAL)
EFI_STATUS EFIAPI ApplyMemoryProtectionPolicy(IN EFI_MEMORY_TYPE OldType, IN EFI_MEMORY_TYPE NewType, IN EFI_PHYSICAL_ADDRESS Memory, IN UINT64 Length)
VOID InstallMemoryAttributesTableOnMemoryAllocation(IN EFI_MEMORY_TYPE MemoryType)
VOID * CoreAllocatePoolPages(IN EFI_MEMORY_TYPE PoolType, IN UINTN NumberOfPages, IN UINTN Alignment, IN BOOLEAN NeedGuard)
Definition: Page.c:2527
VOID CoreReleaseMemoryLock(VOID)
Definition: Page.c:115
VOID CoreAcquireMemoryLock(VOID)
Definition: Page.c:103
VOID CoreFreePoolPages(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NumberOfPages)
Definition: Page.c:2571
EFI_STATUS EFIAPI CoreInternalFreePool(IN VOID *Buffer, OUT EFI_MEMORY_TYPE *PoolType OPTIONAL)
Definition: Pool.c:567
POOL * LookupPoolHead(IN EFI_MEMORY_TYPE MemoryType)
Definition: Pool.c:141
EFI_STATUS CoreFreePoolI(IN VOID *Buffer, OUT EFI_MEMORY_TYPE *PoolType OPTIONAL)
Definition: Pool.c:695
EFI_STATUS EFIAPI CoreInternalAllocatePool(IN EFI_MEMORY_TYPE PoolType, IN UINTN Size, OUT VOID **Buffer)
Definition: Pool.c:203
STATIC VOID CoreFreePoolPagesI(IN EFI_MEMORY_TYPE PoolType, IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NoPages)
Definition: Pool.c:628
STATIC UINTN GetPoolIndexFromSize(UINTN Size)
Definition: Pool.c:95
STATIC VOID * CoreAllocatePoolPagesI(IN EFI_MEMORY_TYPE PoolType, IN UINTN NoPages, IN UINTN Granularity, IN BOOLEAN NeedGuard)
Definition: Pool.c:305
EFI_STATUS EFIAPI CoreAllocatePool(IN EFI_MEMORY_TYPE PoolType, IN UINTN Size, OUT VOID **Buffer)
Definition: Pool.c:267
VOID CoreInitializePool(VOID)
Definition: Pool.c:115
STATIC VOID CoreFreePoolPagesWithGuard(IN EFI_MEMORY_TYPE PoolType, IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NoPages)
Definition: Pool.c:657
VOID * CoreAllocatePoolI(IN EFI_MEMORY_TYPE PoolType, IN UINTN Size, IN BOOLEAN NeedGuard)
Definition: Pool.c:351
EFI_STATUS EFIAPI CoreFreePool(IN VOID *Buffer)
Definition: Pool.c:595
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define ALIGN_VARIABLE(Value)
Definition: Base.h:977
#define RETURN_ADDRESS(L)
Definition: Base.h:1379
#define VOID
Definition: Base.h:269
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define BASE_CR(Record, TYPE, Field)
Definition: Base.h:891
#define DEBUG(Expression)
Definition: DebugLib.h:435
#define CR(Record, TYPE, Field, TestSignature)
Definition: DebugLib.h:660
#define DEBUG_CLEAR_MEMORY(Address, Length)
Definition: DebugLib.h:606
#define PcdGet8(TokenName)
Definition: PcdLib.h:336
VOID EFIAPI FreeList(IN LIST_ENTRY *ListHead)
Definition: PrmInfo.c:63
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
#define EFI_PAGES_TO_SIZE(Pages)
Definition: UefiBaseType.h:213
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SIZE_TO_PAGES(Size)
Definition: UefiBaseType.h:200
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
#define EFI_INITIALIZE_LOCK_VARIABLE(Priority)
Definition: UefiLib.h:313
#define ASSERT_LOCKED(LockParameter)
Definition: UefiLib.h:331
EFI_MEMORY_TYPE
@ EfiBootServicesData
@ EfiPersistentMemory
@ EfiReservedMemoryType
@ EfiConventionalMemory
@ EfiACPIMemoryNVS
@ EfiUnacceptedMemoryType
@ EfiRuntimeServicesCode
@ EfiRuntimeServicesData
Definition: Pool.c:16
Definition: Pool.c:24
Definition: Pool.c:35
Definition: Pool.c:67