ResourceAttributes = (\r
EFI_RESOURCE_ATTRIBUTE_PRESENT |\r
EFI_RESOURCE_ATTRIBUTE_INITIALIZED |\r
- EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |\r
EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |\r
EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |\r
EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE |\r
FdTop = (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdFdBaseAddress) + (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdFdSize);\r
\r
// EDK2 does not have the concept of boot firmware copied into DRAM. To avoid the DXE\r
- // core to overwrite this area we must mark the region with the attribute non-present\r
+ // core to overwrite this area we must create a memory allocation HOB for the region,\r
+ // but this only works if we split off the underlying resource descriptor as well.\r
if ((PcdGet64 (PcdFdBaseAddress) >= PcdGet64 (PcdSystemMemoryBase)) && (FdTop <= SystemMemoryTop)) {\r
Found = FALSE;\r
\r
ResourceTop = NextHob.ResourceDescriptor->PhysicalStart + ResourceLength;\r
\r
if (PcdGet64 (PcdFdBaseAddress) == NextHob.ResourceDescriptor->PhysicalStart) {\r
- if (SystemMemoryTop == FdTop) {\r
- NextHob.ResourceDescriptor->ResourceAttribute = ResourceAttributes & ~EFI_RESOURCE_ATTRIBUTE_PRESENT;\r
- } else {\r
- // Create the System Memory HOB for the firmware with the non-present attribute\r
+ if (SystemMemoryTop != FdTop) {\r
+ // Create the System Memory HOB for the firmware\r
BuildResourceDescriptorHob (EFI_RESOURCE_SYSTEM_MEMORY,\r
- ResourceAttributes & ~EFI_RESOURCE_ATTRIBUTE_PRESENT,\r
+ ResourceAttributes,\r
PcdGet64 (PcdFdBaseAddress),\r
PcdGet32 (PcdFdSize));\r
\r
NextHob.ResourceDescriptor->ResourceLength -= PcdGet32(PcdFdSize);\r
}\r
} else {\r
- // Create the System Memory HOB for the firmware with the non-present attribute\r
+ // Create the System Memory HOB for the firmware\r
BuildResourceDescriptorHob (EFI_RESOURCE_SYSTEM_MEMORY,\r
- ResourceAttributes & ~EFI_RESOURCE_ATTRIBUTE_PRESENT,\r
+ ResourceAttributes,\r
PcdGet64 (PcdFdBaseAddress),\r
PcdGet32 (PcdFdSize));\r
\r
ResourceTop - FdTop);\r
}\r
}\r
+\r
+ // Mark the memory covering the Firmware Device as boot services data\r
+ BuildMemoryAllocationHob (PcdGet64 (PcdFdBaseAddress),\r
+ PcdGet32 (PcdFdSize),\r
+ EfiBootServicesData);\r
+\r
Found = TRUE;\r
break;\r
}\r