#include <Library/PeCoffGetEntryPointLib.h>\r
#include <Protocol/Runtime.h>\r
\r
-#include <Guid/PropertiesTable.h>\r
-\r
#include "DxeMain.h"\r
#include "HeapGuard.h"\r
\r
INITIALIZE_LIST_HEAD_VARIABLE (mImagePropertiesPrivateData.ImageRecordList)\r
};\r
\r
-EFI_PROPERTIES_TABLE mPropertiesTable = {\r
- EFI_PROPERTIES_TABLE_VERSION,\r
- sizeof(EFI_PROPERTIES_TABLE),\r
- EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA\r
-};\r
-\r
EFI_LOCK mPropertiesTableLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY);\r
\r
-BOOLEAN mPropertiesTableEnable;\r
-\r
BOOLEAN mPropertiesTableEndOfDxe = FALSE;\r
\r
+extern BOOLEAN mMemoryAttributesTableEnable;\r
+\r
//\r
// Below functions are for MemoryMap\r
//\r
//\r
// DATA\r
//\r
- if (!mPropertiesTableEnable) {\r
- NewRecord->Type = TempRecord.Type;\r
- } else {\r
- NewRecord->Type = EfiRuntimeServicesData;\r
- }\r
+ NewRecord->Type = TempRecord.Type;\r
NewRecord->PhysicalStart = TempRecord.PhysicalStart;\r
NewRecord->VirtualStart = 0;\r
NewRecord->NumberOfPages = EfiSizeToPages(ImageRecordCodeSection->CodeSegmentBase - NewRecord->PhysicalStart);\r
//\r
// CODE\r
//\r
- if (!mPropertiesTableEnable) {\r
- NewRecord->Type = TempRecord.Type;\r
- } else {\r
- NewRecord->Type = EfiRuntimeServicesCode;\r
- }\r
+ NewRecord->Type = TempRecord.Type;\r
NewRecord->PhysicalStart = ImageRecordCodeSection->CodeSegmentBase;\r
NewRecord->VirtualStart = 0;\r
NewRecord->NumberOfPages = EfiSizeToPages(ImageRecordCodeSection->CodeSegmentSize);\r
// Final DATA\r
//\r
if (TempRecord.PhysicalStart < ImageEnd) {\r
- if (!mPropertiesTableEnable) {\r
- NewRecord->Type = TempRecord.Type;\r
- } else {\r
- NewRecord->Type = EfiRuntimeServicesData;\r
- }\r
+ NewRecord->Type = TempRecord.Type;\r
NewRecord->PhysicalStart = TempRecord.PhysicalStart;\r
NewRecord->VirtualStart = 0;\r
NewRecord->NumberOfPages = EfiSizeToPages (ImageEnd - TempRecord.PhysicalStart);\r
//\r
NewRecord = PREVIOUS_MEMORY_DESCRIPTOR (NewRecord, DescriptorSize);\r
IsLastRecordData = FALSE;\r
- if (!mPropertiesTableEnable) {\r
- if ((NewRecord->Attribute & EFI_MEMORY_XP) != 0) {\r
- IsLastRecordData = TRUE;\r
- }\r
- } else {\r
- if (NewRecord->Type == EfiRuntimeServicesData) {\r
- IsLastRecordData = TRUE;\r
- }\r
+ if ((NewRecord->Attribute & EFI_MEMORY_XP) != 0) {\r
+ IsLastRecordData = TRUE;\r
}\r
if (IsLastRecordData) {\r
//\r
// Last record is CODE, create a new DATA entry.\r
//\r
NewRecord = NEXT_MEMORY_DESCRIPTOR (NewRecord, DescriptorSize);\r
- if (!mPropertiesTableEnable) {\r
- NewRecord->Type = TempRecord.Type;\r
- } else {\r
- NewRecord->Type = EfiRuntimeServicesData;\r
- }\r
+ NewRecord->Type = TempRecord.Type;\r
NewRecord->PhysicalStart = TempRecord.PhysicalStart;\r
NewRecord->VirtualStart = 0;\r
NewRecord->NumberOfPages = TempRecord.NumberOfPages;\r
//\r
// If PE code/data is not aligned, just return.\r
//\r
- if ((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) == 0) {\r
+ if (!mMemoryAttributesTableEnable) {\r
return CoreGetMemoryMap (MemoryMapSize, MemoryMap, MapKey, DescriptorSize, DescriptorVersion);\r
}\r
\r
)\r
{\r
if (((SectionAlignment & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) != 0) &&\r
- ((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) != 0)) {\r
+ mMemoryAttributesTableEnable) {\r
DEBUG ((EFI_D_VERBOSE, "SetPropertiesTableSectionAlignment - Clear\n"));\r
- mPropertiesTable.MemoryProtectionAttribute &= ~((UINT64)EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA);\r
- gBS->GetMemoryMap = CoreGetMemoryMap;\r
- gBS->Hdr.CRC32 = 0;\r
- gBS->CalculateCrc32 ((UINT8 *)gBS, gBS->Hdr.HeaderSize, &gBS->Hdr.CRC32);\r
+ mMemoryAttributesTableEnable = FALSE;\r
}\r
}\r
\r
}\r
}\r
\r
-/**\r
- Dump image record.\r
-**/\r
-STATIC\r
-VOID\r
-DumpImageRecord (\r
- VOID\r
- )\r
-{\r
- IMAGE_PROPERTIES_RECORD *ImageRecord;\r
- LIST_ENTRY *ImageRecordLink;\r
- LIST_ENTRY *ImageRecordList;\r
- UINTN Index;\r
-\r
- ImageRecordList = &mImagePropertiesPrivateData.ImageRecordList;\r
-\r
- for (ImageRecordLink = ImageRecordList->ForwardLink, Index= 0;\r
- ImageRecordLink != ImageRecordList;\r
- ImageRecordLink = ImageRecordLink->ForwardLink, Index++) {\r
- ImageRecord = CR (\r
- ImageRecordLink,\r
- IMAGE_PROPERTIES_RECORD,\r
- Link,\r
- IMAGE_PROPERTIES_RECORD_SIGNATURE\r
- );\r
- DEBUG ((EFI_D_VERBOSE, " Image[%d]: 0x%016lx - 0x%016lx\n", Index, ImageRecord->ImageBase, ImageRecord->ImageSize));\r
- }\r
-}\r
-\r
/**\r
Insert image record.\r
\r
)\r
{\r
mPropertiesTableEndOfDxe = TRUE;\r
- if (PcdGetBool (PcdPropertiesTableEnable)) {\r
- EFI_STATUS Status;\r
-\r
- Status = gBS->InstallConfigurationTable (&gEfiPropertiesTableGuid, &mPropertiesTable);\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- DEBUG ((EFI_D_INFO, "MemoryProtectionAttribute - 0x%016lx\n", mPropertiesTable.MemoryProtectionAttribute));\r
- if ((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) == 0) {\r
- DEBUG ((EFI_D_ERROR, "MemoryProtectionAttribute NON_EXECUTABLE_PE_DATA is not set, "));\r
- DEBUG ((EFI_D_ERROR, "because Runtime Driver Section Alignment is not %dK.\n", RUNTIME_PAGE_ALLOCATION_GRANULARITY >> 10));\r
- return ;\r
- }\r
-\r
- gBS->GetMemoryMap = CoreGetMemoryMapWithSeparatedImageSection;\r
- gBS->Hdr.CRC32 = 0;\r
- gBS->CalculateCrc32 ((UINT8 *)gBS, gBS->Hdr.HeaderSize, &gBS->Hdr.CRC32);\r
-\r
- DEBUG ((EFI_D_VERBOSE, "Total Image Count - 0x%x\n", mImagePropertiesPrivateData.ImageRecordCount));\r
- DEBUG ((EFI_D_VERBOSE, "Dump ImageRecord:\n"));\r
- DumpImageRecord ();\r
-\r
- mPropertiesTableEnable = TRUE;\r
- }\r
}\r
\r
/**\r