#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
# @Prompt Flag to request system reboot after processing capsule.\r
gEfiMdeModulePkgTokenSpaceGuid.PcdSystemRebootAfterCapsuleProcessFlag|0x0001|UINT16|0x0000006d\r
\r
- ## Publish PropertiesTable or not.\r
- #\r
- # If this PCD is TRUE, DxeCore publishs PropertiesTable.\r
- # DxeCore evaluates if all runtime drivers has 4K aligned PE sections. If all\r
- # PE sections in runtime drivers are 4K aligned, DxeCore sets BIT0 in\r
- # PropertiesTable. Or DxeCore clears BIT0 in PropertiesTable.\r
- # If this PCD is FALSE, DxeCore does not publish PropertiesTable.\r
- #\r
- # If PropertiesTable has BIT0 set, DxeCore uses below policy in UEFI memory map:\r
- # 1) Use EfiRuntimeServicesCode for runtime driver PE image code section and\r
- # use EfiRuntimeServicesData for runtime driver PE image header and other section.\r
- # 2) Set EfiRuntimeServicesCode to be EFI_MEMORY_RO.\r
- # 3) Set EfiRuntimeServicesData to be EFI_MEMORY_XP.\r
- # 4) Set EfiMemoryMappedIO and EfiMemoryMappedIOPortSpace to be EFI_MEMORY_XP.\r
- #\r
- # NOTE: Platform need gurantee this PCD is set correctly. Platform should set\r
- # this PCD to be TURE if and only if all runtime driver has seperated Code/Data\r
- # section. If PE code/data sections are merged, the result is unpredictable.\r
- #\r
- # UEFI 2.6 specification does not recommend to use this BIT0 attribute.\r
- #\r
- # @Prompt Publish UEFI PropertiesTable.\r
- gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|FALSE|BOOLEAN|0x0000006e\r
-\r
## Default OEM ID for ACPI table creation, its length must be 0x6 bytes to follow ACPI specification.\r
# @Prompt Default OEM ID for ACPI table creation.\r
gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId|"INTEL "|VOID*|0x30001034\r
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFrontPageFormSetGuid_HELP #language en-US "This PCD points to the front page formset GUID\n"\r
"Compare the FormsetGuid or ClassGuid with this PCD value can detect whether in front page"\r
\r
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPropertiesTableEnable_PROMPT #language en-US "Publish UEFI PropertiesTable."\r
-\r
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPropertiesTableEnable_HELP #language en-US "Publish PropertiesTable or not.\n"\r
- "\n"\r
- "If this PCD is TRUE, DxeCore publishs PropertiesTable.\n"\r
- "DxeCore evaluates if all runtime drivers has 4K aligned PE sections. If all\n"\r
- "PE sections in runtime drivers are 4K aligned, DxeCore sets BIT0 in\n"\r
- "PropertiesTable. Or DxeCore clears BIT0 in PropertiesTable.\n"\r
- "If this PCD is FALSE, DxeCore does not publish PropertiesTable.\n"\r
- "\n"\r
- "If PropertiesTable has BIT0 set, DxeCore uses below policy in UEFI memory map:\n"\r
- "1) Use EfiRuntimeServicesCode for runtime driver PE image code section and\n"\r
- "use EfiRuntimeServicesData for runtime driver PE image header and other section.\n"\r
- "2) Set EfiRuntimeServicesCode to be EFI_MEMORY_RO.\n"\r
- "3) Set EfiRuntimeServicesData to be EFI_MEMORY_XP.\n"\r
- "4) Set EfiMemoryMappedIO and EfiMemoryMappedIOPortSpace to be EFI_MEMORY_XP.\n"\r
- "\n"\r
- "NOTE: Platform need gurantee this PCD is set correctly. Platform should set\n"\r
- "this PCD to be TURE if and only if all runtime driver has seperated Code/Data\n"\r
- "section. If PE code/data sections are merged, the result is unpredictable.\n"\r
-\r
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdShadowPeimOnBoot_HELP #language en-US "Indicates if to shadow PEIM and PeiCore after memory is ready.<BR><BR>\n"\r
"This PCD is used on other boot path except for S3 boot.\n"\r
"TRUE - Shadow PEIM and PeiCore after memory is ready.<BR>\n"\r