]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c
Maintainers.txt: Move ShellBin maintainers to EDK II Releases section
[mirror_edk2.git] / ArmPlatformPkg / MemoryInitPei / MemoryInitPeiLib.c
index 75e6631d7f30152ce4458fa4d94ad8c53254fcc8..89a40d4f32cfd3391a748e0f9b5638e7c9794636 100644 (file)
@@ -2,13 +2,7 @@
 *\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
@@ -89,7 +83,6 @@ MemoryPeim (
   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
@@ -130,7 +123,8 @@ MemoryPeim (
   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
@@ -146,12 +140,10 @@ MemoryPeim (
         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
@@ -160,9 +152,9 @@ MemoryPeim (
             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
@@ -178,6 +170,12 @@ MemoryPeim (
                                         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