TianoCore EDK2 master
Loading...
Searching...
No Matches
MemoryAttributesTable.c
Go to the documentation of this file.
1
9#include <PiDxe.h>
10#include <Library/BaseLib.h>
15#include <Library/DebugLib.h>
16#include <Library/UefiLib.h>
18
19#include <Guid/EventGroup.h>
20
22
23#include "DxeMain.h"
24#include "HeapGuard.h"
25
59EFIAPI
61 IN OUT UINTN *MemoryMapSize,
62 IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,
63 OUT UINTN *MapKey,
64 OUT UINTN *DescriptorSize,
65 OUT UINT32 *DescriptorVersion
66 );
67
68#define PREVIOUS_MEMORY_DESCRIPTOR(MemoryDescriptor, Size) \
69 ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)(MemoryDescriptor) - (Size)))
70
71#define IMAGE_PROPERTIES_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('I','P','P','D')
72
73typedef struct {
74 UINT32 Signature;
75 UINTN ImageRecordCount;
76 UINTN CodeSegmentCountMax;
77 LIST_ENTRY ImageRecordList;
79
80STATIC IMAGE_PROPERTIES_PRIVATE_DATA mImagePropertiesPrivateData = {
81 IMAGE_PROPERTIES_PRIVATE_DATA_SIGNATURE,
82 0,
83 0,
84 INITIALIZE_LIST_HEAD_VARIABLE (mImagePropertiesPrivateData.ImageRecordList)
85};
86
87STATIC EFI_LOCK mMemoryAttributesTableLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY);
88
89BOOLEAN mMemoryAttributesTableEnable = TRUE;
90EFI_MEMORY_ATTRIBUTES_TABLE *mMemoryAttributesTable = NULL;
91BOOLEAN mMemoryAttributesTableReadyToBoot = FALSE;
92BOOLEAN gMemoryAttributesTableForwardCfi = TRUE;
93
98VOID
100 VOID
101 )
102{
103 UINTN MemoryMapSize;
104 EFI_MEMORY_DESCRIPTOR *MemoryMap;
105 EFI_MEMORY_DESCRIPTOR *MemoryMapStart;
106 UINTN MapKey;
107 UINTN DescriptorSize;
108 UINT32 DescriptorVersion;
109 UINTN Index;
110 EFI_STATUS Status;
111 UINT32 RuntimeEntryCount;
112 EFI_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable;
113 EFI_MEMORY_DESCRIPTOR *MemoryAttributesEntry;
114
115 if (gMemoryMapTerminated) {
116 //
117 // Directly return after MemoryMap terminated.
118 //
119 return;
120 }
121
122 if (!mMemoryAttributesTableEnable) {
123 DEBUG ((DEBUG_VERBOSE, "Cannot install Memory Attributes Table "));
124 DEBUG ((DEBUG_VERBOSE, "because Runtime Driver Section Alignment is not %dK.\n", RUNTIME_PAGE_ALLOCATION_GRANULARITY >> 10));
125 return;
126 }
127
128 if (mMemoryAttributesTable == NULL) {
129 //
130 // InstallConfigurationTable here to occupy one entry for MemoryAttributesTable
131 // before GetMemoryMap below, as InstallConfigurationTable may allocate runtime
132 // memory for the new entry.
133 //
134 Status = gBS->InstallConfigurationTable (&gEfiMemoryAttributesTableGuid, (VOID *)(UINTN)MAX_ADDRESS);
135 ASSERT_EFI_ERROR (Status);
136 }
137
138 MemoryMapSize = 0;
139 MemoryMap = NULL;
141 &MemoryMapSize,
142 MemoryMap,
143 &MapKey,
144 &DescriptorSize,
145 &DescriptorVersion
146 );
147 ASSERT (Status == EFI_BUFFER_TOO_SMALL);
148
149 do {
150 MemoryMap = AllocatePool (MemoryMapSize);
151 if (MemoryMap == NULL) {
152 ASSERT (MemoryMap != NULL);
153 return;
154 }
155
157 &MemoryMapSize,
158 MemoryMap,
159 &MapKey,
160 &DescriptorSize,
161 &DescriptorVersion
162 );
163 if (EFI_ERROR (Status)) {
164 FreePool (MemoryMap);
165 }
166 } while (Status == EFI_BUFFER_TOO_SMALL);
167
168 MemoryMapStart = MemoryMap;
169 RuntimeEntryCount = 0;
170 for (Index = 0; Index < MemoryMapSize/DescriptorSize; Index++) {
171 switch (MemoryMap->Type) {
174 RuntimeEntryCount++;
175 break;
176 }
177
178 MemoryMap = NEXT_MEMORY_DESCRIPTOR (MemoryMap, DescriptorSize);
179 }
180
181 //
182 // Allocate MemoryAttributesTable
183 //
184 MemoryAttributesTable = AllocatePool (sizeof (EFI_MEMORY_ATTRIBUTES_TABLE) + DescriptorSize * RuntimeEntryCount);
185 if (MemoryAttributesTable == NULL) {
186 ASSERT (MemoryAttributesTable != NULL);
187 FreePool (MemoryMapStart);
188 return;
189 }
190
191 MemoryAttributesTable->Version = EFI_MEMORY_ATTRIBUTES_TABLE_VERSION;
192 MemoryAttributesTable->NumberOfEntries = RuntimeEntryCount;
193 MemoryAttributesTable->DescriptorSize = (UINT32)DescriptorSize;
194 if (gMemoryAttributesTableForwardCfi) {
195 MemoryAttributesTable->Flags = EFI_MEMORY_ATTRIBUTES_FLAGS_RT_FORWARD_CONTROL_FLOW_GUARD;
196 } else {
197 MemoryAttributesTable->Flags = 0;
198 }
199
200 DEBUG ((DEBUG_VERBOSE, "MemoryAttributesTable:\n"));
201 DEBUG ((DEBUG_VERBOSE, " Version - 0x%08x\n", MemoryAttributesTable->Version));
202 DEBUG ((DEBUG_VERBOSE, " NumberOfEntries - 0x%08x\n", MemoryAttributesTable->NumberOfEntries));
203 DEBUG ((DEBUG_VERBOSE, " DescriptorSize - 0x%08x\n", MemoryAttributesTable->DescriptorSize));
204 MemoryAttributesEntry = (EFI_MEMORY_DESCRIPTOR *)(MemoryAttributesTable + 1);
205 MemoryMap = MemoryMapStart;
206 for (Index = 0; Index < MemoryMapSize/DescriptorSize; Index++) {
207 switch (MemoryMap->Type) {
210 CopyMem (MemoryAttributesEntry, MemoryMap, DescriptorSize);
211 MemoryAttributesEntry->Attribute &= (EFI_MEMORY_RO|EFI_MEMORY_XP|EFI_MEMORY_RUNTIME);
212 DEBUG ((DEBUG_VERBOSE, "Entry (0x%x)\n", MemoryAttributesEntry));
213 DEBUG ((DEBUG_VERBOSE, " Type - 0x%x\n", MemoryAttributesEntry->Type));
214 DEBUG ((DEBUG_VERBOSE, " PhysicalStart - 0x%016lx\n", MemoryAttributesEntry->PhysicalStart));
215 DEBUG ((DEBUG_VERBOSE, " VirtualStart - 0x%016lx\n", MemoryAttributesEntry->VirtualStart));
216 DEBUG ((DEBUG_VERBOSE, " NumberOfPages - 0x%016lx\n", MemoryAttributesEntry->NumberOfPages));
217 DEBUG ((DEBUG_VERBOSE, " Attribute - 0x%016lx\n", MemoryAttributesEntry->Attribute));
218 MemoryAttributesEntry = NEXT_MEMORY_DESCRIPTOR (MemoryAttributesEntry, DescriptorSize);
219 break;
220 }
221
222 MemoryMap = NEXT_MEMORY_DESCRIPTOR (MemoryMap, DescriptorSize);
223 }
224
225 MemoryMap = MemoryMapStart;
226 FreePool (MemoryMap);
227
228 //
229 // Update configuratoin table for MemoryAttributesTable.
230 //
231 Status = gBS->InstallConfigurationTable (&gEfiMemoryAttributesTableGuid, MemoryAttributesTable);
232 ASSERT_EFI_ERROR (Status);
233
234 if (mMemoryAttributesTable != NULL) {
235 FreePool (mMemoryAttributesTable);
236 }
237
238 mMemoryAttributesTable = MemoryAttributesTable;
239}
240
246VOID
248 IN EFI_MEMORY_TYPE MemoryType
249 )
250{
251 //
252 // Install MemoryAttributesTable after ReadyToBoot on runtime memory allocation.
253 //
254 if (mMemoryAttributesTableReadyToBoot &&
255 ((MemoryType == EfiRuntimeServicesCode) || (MemoryType == EfiRuntimeServicesData)))
256 {
258 }
259}
260
267VOID
268EFIAPI
270 IN EFI_EVENT Event,
271 IN VOID *Context
272 )
273{
275 mMemoryAttributesTableReadyToBoot = TRUE;
276}
277
285VOID
286EFIAPI
288 IN EFI_EVENT Event,
289 IN VOID *Context
290 )
291{
293
295 if ( mImagePropertiesPrivateData.ImageRecordCount > 0) {
296 DEBUG ((DEBUG_INFO, "DXE - Total Runtime Image Count: 0x%x\n", mImagePropertiesPrivateData.ImageRecordCount));
297 DEBUG ((DEBUG_INFO, "DXE - Dump Runtime Image Records:\n"));
298 DumpImageRecords (&mImagePropertiesPrivateData.ImageRecordList);
299 }
300
302}
303
307VOID
308EFIAPI
310 VOID
311 )
312{
313 EFI_STATUS Status;
314 EFI_EVENT ReadyToBootEvent;
315 EFI_EVENT EndOfDxeEvent;
316
317 //
318 // Construct the table at ReadyToBoot.
319 //
320 Status = CoreCreateEventInternal (
321 EVT_NOTIFY_SIGNAL,
322 TPL_CALLBACK,
324 NULL,
325 &gEfiEventReadyToBootGuid,
326 &ReadyToBootEvent
327 );
328 ASSERT_EFI_ERROR (Status);
329
330 //
331 // Construct the initial table at EndOfDxe,
332 // then SMM can consume this information.
333 // Use TPL_NOTIFY here, as such SMM code (TPL_CALLBACK)
334 // can run after it.
335 //
336 Status = CoreCreateEventInternal (
337 EVT_NOTIFY_SIGNAL,
338 TPL_NOTIFY,
340 NULL,
341 &gEfiEndOfDxeEventGroupGuid,
342 &EndOfDxeEvent
343 );
344 ASSERT_EFI_ERROR (Status);
345 return;
346}
347
348//
349// Below functions are for MemoryMap
350//
351
355STATIC
356VOID
358 VOID
359 )
360{
361 CoreAcquireLock (&mMemoryAttributesTableLock);
362}
363
367STATIC
368VOID
370 VOID
371 )
372{
373 CoreReleaseLock (&mMemoryAttributesTableLock);
374}
375
387VOID
389 IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,
390 IN OUT UINTN *MemoryMapSize,
391 IN UINTN DescriptorSize
392 )
393{
394 EFI_MEMORY_DESCRIPTOR *MemoryMapEntry;
395 EFI_MEMORY_DESCRIPTOR *MemoryMapEnd;
396 UINT64 MemoryBlockLength;
397 EFI_MEMORY_DESCRIPTOR *NewMemoryMapEntry;
398 EFI_MEMORY_DESCRIPTOR *NextMemoryMapEntry;
399
400 MemoryMapEntry = MemoryMap;
401 NewMemoryMapEntry = MemoryMap;
402 MemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)MemoryMap + *MemoryMapSize);
403 while ((UINTN)MemoryMapEntry < (UINTN)MemoryMapEnd) {
404 CopyMem (NewMemoryMapEntry, MemoryMapEntry, DescriptorSize);
405 NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
406
407 do {
408 if ((UINTN)NextMemoryMapEntry < (UINTN)MemoryMapEnd) {
409 MergeGuardPages (NewMemoryMapEntry, NextMemoryMapEntry->PhysicalStart);
410 }
411
412 MemoryBlockLength = LShiftU64 (NewMemoryMapEntry->NumberOfPages, EFI_PAGE_SHIFT);
413 if (((UINTN)NextMemoryMapEntry < (UINTN)MemoryMapEnd) &&
414 (NewMemoryMapEntry->Type == NextMemoryMapEntry->Type) &&
415 (NewMemoryMapEntry->Attribute == NextMemoryMapEntry->Attribute) &&
416 ((NewMemoryMapEntry->PhysicalStart + MemoryBlockLength) == NextMemoryMapEntry->PhysicalStart))
417 {
418 NewMemoryMapEntry->NumberOfPages += NextMemoryMapEntry->NumberOfPages;
419 NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (NextMemoryMapEntry, DescriptorSize);
420 continue;
421 } else {
422 MemoryMapEntry = PREVIOUS_MEMORY_DESCRIPTOR (NextMemoryMapEntry, DescriptorSize);
423 break;
424 }
425 } while (TRUE);
426
427 MemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
428 NewMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (NewMemoryMapEntry, DescriptorSize);
429 }
430
431 *MemoryMapSize = (UINTN)NewMemoryMapEntry - (UINTN)MemoryMap;
432
433 return;
434}
435
445STATIC
446VOID
448 IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,
449 IN UINTN MemoryMapSize,
450 IN UINTN DescriptorSize
451 )
452{
453 EFI_MEMORY_DESCRIPTOR *MemoryMapEntry;
454 EFI_MEMORY_DESCRIPTOR *MemoryMapEnd;
455
456 MemoryMapEntry = MemoryMap;
457 MemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)MemoryMap + MemoryMapSize);
458 while ((UINTN)MemoryMapEntry < (UINTN)MemoryMapEnd) {
459 if ((MemoryMapEntry->Attribute & EFI_MEMORY_ACCESS_MASK) == 0) {
460 switch (MemoryMapEntry->Type) {
462 // If at this point the attributes have not been set on an EfiRuntimeServicesCode
463 // region, the memory range must not contain a loaded image. It's possible these
464 // non-image EfiRuntimeServicesCode regions are part of the unused memory bucket.
465 // It could also be that this region was explicitly allocated outside of the PE
466 // loader but the UEFI spec requires that all EfiRuntimeServicesCode regions contain
467 // EFI modules. In either case, set the attributes to RO and XP.
468 MemoryMapEntry->Attribute |= (EFI_MEMORY_RO | EFI_MEMORY_XP);
469 break;
471 MemoryMapEntry->Attribute |= EFI_MEMORY_XP;
472 break;
473 default:
474 break;
475 }
476 }
477
478 MemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
479 }
480
481 return;
482}
483
517EFIAPI
519 IN OUT UINTN *MemoryMapSize,
520 IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,
521 OUT UINTN *MapKey,
522 OUT UINTN *DescriptorSize,
523 OUT UINT32 *DescriptorVersion
524 )
525{
526 EFI_STATUS Status;
527 UINTN OldMemoryMapSize;
528 UINTN AdditionalRecordCount;
529
530 //
531 // If PE code/data is not aligned, just return.
532 //
533 if (!mMemoryAttributesTableEnable) {
534 return CoreGetMemoryMap (MemoryMapSize, MemoryMap, MapKey, DescriptorSize, DescriptorVersion);
535 }
536
537 if (MemoryMapSize == NULL) {
538 return EFI_INVALID_PARAMETER;
539 }
540
542
543 AdditionalRecordCount = (2 * mImagePropertiesPrivateData.CodeSegmentCountMax + 3) * mImagePropertiesPrivateData.ImageRecordCount;
544
545 OldMemoryMapSize = *MemoryMapSize;
546 Status = CoreGetMemoryMap (MemoryMapSize, MemoryMap, MapKey, DescriptorSize, DescriptorVersion);
547 if (Status == EFI_BUFFER_TOO_SMALL) {
548 *MemoryMapSize = *MemoryMapSize + (*DescriptorSize) * AdditionalRecordCount;
549 } else if (Status == EFI_SUCCESS) {
550 ASSERT (MemoryMap != NULL);
551 if (OldMemoryMapSize - *MemoryMapSize < (*DescriptorSize) * AdditionalRecordCount) {
552 *MemoryMapSize = *MemoryMapSize + (*DescriptorSize) * AdditionalRecordCount;
553 //
554 // Need update status to buffer too small
555 //
556 Status = EFI_BUFFER_TOO_SMALL;
557 } else {
558 //
559 // Split PE code/data
560 //
561 SplitTable (MemoryMapSize, MemoryMap, *DescriptorSize, &mImagePropertiesPrivateData.ImageRecordList, AdditionalRecordCount);
562
563 //
564 // Set RuntimeData to XP
565 //
566 EnforceMemoryMapAttribute (MemoryMap, *MemoryMapSize, *DescriptorSize);
567
568 //
569 // Merge same type to save entry size
570 //
571 MergeMemoryMap (MemoryMap, MemoryMapSize, *DescriptorSize);
572 }
573 }
574
576 return Status;
577}
578
579//
580// Below functions are for ImageRecord
581//
582
588VOID
590 IN EFI_RUNTIME_IMAGE_ENTRY *RuntimeImage
591 )
592{
593 EFI_STATUS Status;
594 IMAGE_PROPERTIES_RECORD *ImageRecord;
595 CHAR8 *PdbPointer;
596 UINT32 RequiredAlignment;
597
598 DEBUG ((DEBUG_VERBOSE, "InsertImageRecord - 0x%x\n", RuntimeImage));
599
600 ImageRecord = AllocatePool (sizeof (*ImageRecord));
601 if (ImageRecord == NULL) {
602 return;
603 }
604
605 InitializeListHead (&ImageRecord->Link);
606 InitializeListHead (&ImageRecord->CodeSegmentList);
607
608 PdbPointer = PeCoffLoaderGetPdbPointer ((VOID *)(UINTN)RuntimeImage->ImageBase);
609 if (PdbPointer != NULL) {
610 DEBUG ((DEBUG_VERBOSE, " Image - %a\n", PdbPointer));
611 }
612
613 RequiredAlignment = RUNTIME_PAGE_ALLOCATION_GRANULARITY;
615 RuntimeImage->ImageBase,
616 RuntimeImage->ImageSize,
617 &RequiredAlignment,
618 ImageRecord
619 );
620
621 if (EFI_ERROR (Status)) {
622 if (Status == EFI_ABORTED) {
623 mMemoryAttributesTableEnable = FALSE;
624 }
625
626 Status = EFI_ABORTED;
627 goto Finish;
628 }
629
630 if (ImageRecord->CodeSegmentCount == 0) {
631 mMemoryAttributesTableEnable = FALSE;
632 DEBUG ((DEBUG_ERROR, "!!!!!!!! InsertImageRecord - CodeSegmentCount is 0 !!!!!!!!\n"));
633 if (PdbPointer != NULL) {
634 DEBUG ((DEBUG_ERROR, "!!!!!!!! Image - %a !!!!!!!!\n", PdbPointer));
635 }
636
637 Status = EFI_ABORTED;
638 goto Finish;
639 }
640
641 //
642 // Check overlap all section in ImageBase/Size
643 //
644 if (!IsImageRecordCodeSectionValid (ImageRecord)) {
645 DEBUG ((DEBUG_ERROR, "IsImageRecordCodeSectionValid - FAIL\n"));
646 Status = EFI_ABORTED;
647 goto Finish;
648 }
649
650 InsertTailList (&mImagePropertiesPrivateData.ImageRecordList, &ImageRecord->Link);
651 mImagePropertiesPrivateData.ImageRecordCount++;
652
653 if (mImagePropertiesPrivateData.CodeSegmentCountMax < ImageRecord->CodeSegmentCount) {
654 mImagePropertiesPrivateData.CodeSegmentCountMax = ImageRecord->CodeSegmentCount;
655 }
656
657 SortImageRecord (&mImagePropertiesPrivateData.ImageRecordList);
658
659Finish:
660 if (EFI_ERROR (Status) && (ImageRecord != NULL)) {
661 DeleteImagePropertiesRecord (ImageRecord);
662 }
663
664 return;
665}
666
672VOID
674 IN EFI_RUNTIME_IMAGE_ENTRY *RuntimeImage
675 )
676{
677 IMAGE_PROPERTIES_RECORD *ImageRecord;
678
679 DEBUG ((DEBUG_VERBOSE, "RemoveImageRecord - 0x%x\n", RuntimeImage));
680 DEBUG ((DEBUG_VERBOSE, "RemoveImageRecord - 0x%016lx - 0x%016lx\n", (EFI_PHYSICAL_ADDRESS)(UINTN)RuntimeImage->ImageBase, RuntimeImage->ImageSize));
681
682 ImageRecord = FindImageRecord ((EFI_PHYSICAL_ADDRESS)(UINTN)RuntimeImage->ImageBase, RuntimeImage->ImageSize, &mImagePropertiesPrivateData.ImageRecordList);
683 if (ImageRecord == NULL) {
684 DEBUG ((DEBUG_ERROR, "!!!!!!!! ImageRecord not found !!!!!!!!\n"));
685 return;
686 }
687
688 DeleteImagePropertiesRecord (ImageRecord);
689
690 mImagePropertiesPrivateData.ImageRecordCount--;
691}
UINT64 UINTN
#define MAX_ADDRESS
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
Definition: LinkedList.c:182
#define INITIALIZE_LIST_HEAD_VARIABLE(ListHead)
Definition: BaseLib.h:2884
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
Definition: LShiftU64.c:28
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
Definition: LinkedList.c:259
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID MergeGuardPages(IN EFI_MEMORY_DESCRIPTOR *MemoryMapEntry, IN EFI_PHYSICAL_ADDRESS MaxAddress)
Definition: HeapGuard.c:1476
EFI_STATUS EFIAPI CoreCreateEventInternal(IN UINT32 Type, IN EFI_TPL NotifyTpl, IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL, IN CONST VOID *NotifyContext OPTIONAL, IN CONST EFI_GUID *EventGroup OPTIONAL, OUT EFI_EVENT *Event)
Definition: Event.c:366
VOID CoreAcquireLock(IN EFI_LOCK *Lock)
Definition: Library.c:59
VOID CoreReleaseLock(IN EFI_LOCK *Lock)
Definition: Library.c:80
EFI_STATUS EFIAPI CoreGetMemoryMap(IN OUT UINTN *MemoryMapSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, OUT UINTN *MapKey, OUT UINTN *DescriptorSize, OUT UINT32 *DescriptorVersion)
Definition: Page.c:2020
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI SplitTable(IN OUT UINTN *MemoryMapSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN DescriptorSize, IN LIST_ENTRY *ImageRecordList, IN UINTN NumberOfAdditionalDescriptors)
VOID EFIAPI DeleteImagePropertiesRecord(IN IMAGE_PROPERTIES_RECORD *ImageRecord)
BOOLEAN EFIAPI IsImageRecordCodeSectionValid(IN IMAGE_PROPERTIES_RECORD *ImageRecord)
IMAGE_PROPERTIES_RECORD *EFIAPI FindImageRecord(IN EFI_PHYSICAL_ADDRESS ImageBase, IN UINT64 ImageSize, IN LIST_ENTRY *ImageRecordList)
EFI_STATUS EFIAPI CreateImagePropertiesRecord(IN CONST VOID *ImageBase, IN CONST UINT64 ImageSize, IN CONST UINT32 *Alignment OPTIONAL, OUT IMAGE_PROPERTIES_RECORD *ImageRecord)
VOID EFIAPI DumpImageRecords(IN LIST_ENTRY *ImageRecordList)
EFI_STATUS EFIAPI SortImageRecord(IN LIST_ENTRY *ImageRecordList)
VOID InsertImageRecord(IN EFI_RUNTIME_IMAGE_ENTRY *RuntimeImage)
VOID EFIAPI CoreInitializeMemoryAttributesTable(VOID)
EFI_STATUS EFIAPI CoreGetMemoryMapWithSeparatedImageSection(IN OUT UINTN *MemoryMapSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, OUT UINTN *MapKey, OUT UINTN *DescriptorSize, OUT UINT32 *DescriptorVersion)
VOID MergeMemoryMap(IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN OUT UINTN *MemoryMapSize, IN UINTN DescriptorSize)
VOID EFIAPI InstallMemoryAttributesTableOnEndOfDxe(IN EFI_EVENT Event, IN VOID *Context)
STATIC VOID CoreAcquiremMemoryAttributesTableLock(VOID)
STATIC VOID CoreReleasemMemoryAttributesTableLock(VOID)
STATIC VOID EnforceMemoryMapAttribute(IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN MemoryMapSize, IN UINTN DescriptorSize)
VOID EFIAPI InstallMemoryAttributesTableOnReadyToBoot(IN EFI_EVENT Event, IN VOID *Context)
VOID InstallMemoryAttributesTable(VOID)
VOID InstallMemoryAttributesTableOnMemoryAllocation(IN EFI_MEMORY_TYPE MemoryType)
VOID RemoveImageRecord(IN EFI_RUNTIME_IMAGE_ENTRY *RuntimeImage)
#define NULL
Definition: Base.h:319
#define STATIC
Definition: Base.h:264
#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 ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:463
#define DEBUG_CODE_BEGIN()
Definition: DebugLib.h:565
#define DEBUG(Expression)
Definition: DebugLib.h:435
#define DEBUG_CODE_END()
Definition: DebugLib.h:579
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
#define EFI_INITIALIZE_LOCK_VARIABLE(Priority)
Definition: UefiLib.h:313
EFI_MEMORY_TYPE
@ EfiRuntimeServicesCode
@ EfiRuntimeServicesData
EFI_VIRTUAL_ADDRESS VirtualStart
Definition: UefiSpec.h:171
EFI_PHYSICAL_ADDRESS PhysicalStart
Definition: UefiSpec.h:165