*\r
* Copyright (c) 2011-2015, ARM Limited. All rights reserved.\r
*\r
-* This program and the accompanying materials\r
-* are licensed and made available under the terms and conditions of the BSD License\r
-* which accompanies this distribution. The full text of the license may be found at\r
-* http://opensource.org/licenses/bsd-license.php\r
-*\r
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+* SPDX-License-Identifier: BSD-2-Clause-Patent\r
*\r
**/\r
\r
#include <PiPei.h>\r
\r
+#include <Library/ArmMmuLib.h>\r
#include <Library/ArmPlatformLib.h>\r
#include <Library/DebugLib.h>\r
#include <Library/HobLib.h>\r
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