]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Gcd/Gcd.c
MdeModulePkg/Gcd: Suppress incorrect compiler/analyzer warnings
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Gcd / Gcd.c
index 77586a9ac8f3adcb85d6e868fef3d7f6bdb0025f..e17e98230b79beb063c5a00cbe38c251e86e9fc3 100644 (file)
@@ -3,7 +3,7 @@
   The GCD services are used to manage the memory and I/O regions that\r
   are accessible to the CPU that is executing the DXE core.\r
 \r
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\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
@@ -16,6 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "DxeMain.h"\r
 #include "Gcd.h"\r
+#include "Mem/HeapGuard.h"\r
 \r
 #define MINIMUM_INITIAL_MEMORY_SIZE 0x10000\r
 \r
@@ -40,7 +41,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #define PRESENT_MEMORY_ATTRIBUTES     (EFI_RESOURCE_ATTRIBUTE_PRESENT)\r
 \r
-#define INVALID_CPU_ARCH_ATTRIBUTES   0xffffffff\r
+#define EXCLUSIVE_MEMORY_ATTRIBUTES   (EFI_MEMORY_UC | EFI_MEMORY_WC | \\r
+                                       EFI_MEMORY_WT | EFI_MEMORY_WB | \\r
+                                       EFI_MEMORY_WP | EFI_MEMORY_UCE)\r
+\r
+#define NONEXCLUSIVE_MEMORY_ATTRIBUTES (EFI_MEMORY_XP | EFI_MEMORY_RP | \\r
+                                        EFI_MEMORY_RO)\r
 \r
 //\r
 // Module Variables\r
@@ -108,7 +114,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mGcdMemoryTypeNames[] = {
   "Reserved ",  // EfiGcdMemoryTypeReserved\r
   "SystemMem",  // EfiGcdMemoryTypeSystemMemory\r
   "MMIO     ",  // EfiGcdMemoryTypeMemoryMappedIo\r
-  "PersisMem",  // EfiGcdMemoryTypePersistentMemory\r
+  "PersisMem",  // EfiGcdMemoryTypePersistent\r
   "MoreRelia",  // EfiGcdMemoryTypeMoreReliable\r
   "Unknown  "   // EfiGcdMemoryTypeMaximum\r
 };\r
@@ -384,12 +390,21 @@ CoreAllocateGcdMapEntry (
   IN OUT EFI_GCD_MAP_ENTRY  **BottomEntry\r
   )\r
 {\r
+  //\r
+  // Set to mOnGuarding to TRUE before memory allocation. This will make sure\r
+  // that the entry memory is not "guarded" by HeapGuard. Otherwise it might\r
+  // cause problem when it's freed (if HeapGuard is enabled).\r
+  //\r
+  mOnGuarding = TRUE;\r
   *TopEntry = AllocateZeroPool (sizeof (EFI_GCD_MAP_ENTRY));\r
+  mOnGuarding = FALSE;\r
   if (*TopEntry == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
+  mOnGuarding = TRUE;\r
   *BottomEntry = AllocateZeroPool (sizeof (EFI_GCD_MAP_ENTRY));\r
+  mOnGuarding = FALSE;\r
   if (*BottomEntry == NULL) {\r
     CoreFreePool (*TopEntry);\r
     return EFI_OUT_OF_RESOURCES;\r
@@ -654,28 +669,25 @@ ConverToCpuArchAttributes (
   UINT64 Attributes\r
   )\r
 {\r
-  if ( (Attributes & EFI_MEMORY_UC) == EFI_MEMORY_UC) {\r
-    return EFI_MEMORY_UC;\r
-  }\r
-\r
-  if ( (Attributes & EFI_MEMORY_WC ) == EFI_MEMORY_WC) {\r
-    return EFI_MEMORY_WC;\r
-  }\r
+  UINT64      CpuArchAttributes;\r
 \r
-  if ( (Attributes & EFI_MEMORY_WT ) == EFI_MEMORY_WT) {\r
-    return EFI_MEMORY_WT;\r
-  }\r
-\r
-  if ( (Attributes & EFI_MEMORY_WB) == EFI_MEMORY_WB) {\r
-    return EFI_MEMORY_WB;\r
-  }\r
-\r
-  if ( (Attributes & EFI_MEMORY_WP) == EFI_MEMORY_WP) {\r
-    return EFI_MEMORY_WP;\r
-  }\r
-\r
-  return INVALID_CPU_ARCH_ATTRIBUTES;\r
+  CpuArchAttributes = Attributes & NONEXCLUSIVE_MEMORY_ATTRIBUTES;\r
 \r
+  if ( (Attributes & EFI_MEMORY_UC) == EFI_MEMORY_UC) {\r
+    CpuArchAttributes |= EFI_MEMORY_UC;\r
+  } else if ( (Attributes & EFI_MEMORY_WC ) == EFI_MEMORY_WC) {\r
+    CpuArchAttributes |= EFI_MEMORY_WC;\r
+  } else if ( (Attributes & EFI_MEMORY_WT ) == EFI_MEMORY_WT) {\r
+    CpuArchAttributes |= EFI_MEMORY_WT;\r
+  } else if ( (Attributes & EFI_MEMORY_WB) == EFI_MEMORY_WB) {\r
+    CpuArchAttributes |= EFI_MEMORY_WB;\r
+  } else if ( (Attributes & EFI_MEMORY_UCE) == EFI_MEMORY_UCE) {\r
+    CpuArchAttributes |= EFI_MEMORY_UCE;\r
+  } else if ( (Attributes & EFI_MEMORY_WP) == EFI_MEMORY_WP) {\r
+    CpuArchAttributes |= EFI_MEMORY_WP;\r
+  }\r
+\r
+  return CpuArchAttributes;\r
 }\r
 \r
 \r
@@ -854,12 +866,30 @@ CoreConvertSpace (
   }\r
   ASSERT (TopEntry != NULL && BottomEntry != NULL);\r
 \r
+  //\r
+  // Initialize CpuArchAttributes to suppress incorrect compiler/analyzer warnings.\r
+  //\r
+  CpuArchAttributes = 0;\r
   if (Operation == GCD_SET_ATTRIBUTES_MEMORY_OPERATION) {\r
     //\r
     // Call CPU Arch Protocol to attempt to set attributes on the range\r
     //\r
     CpuArchAttributes = ConverToCpuArchAttributes (Attributes);\r
-    if (CpuArchAttributes != INVALID_CPU_ARCH_ATTRIBUTES) {\r
+    //\r
+    // CPU arch attributes include page attributes and cache attributes. \r
+    // Only page attributes supports to be cleared, but not cache attributes.\r
+    // Caller is expected to use GetMemorySpaceDescriptor() to get the current\r
+    // attributes, AND/OR attributes, and then calls SetMemorySpaceAttributes()\r
+    // to set the new attributes.\r
+    // So 0 CPU arch attributes should not happen as memory should always have\r
+    // a cache attribute (no matter UC or WB, etc). \r
+    //\r
+    // Here, 0 CPU arch attributes will be filtered to be compatible with the\r
+    // case that caller just calls SetMemorySpaceAttributes() with none CPU\r
+    // arch attributes (for example, RUNTIME) as the purpose of the case is not\r
+    // to clear CPU arch attributes.\r
+    //\r
+    if (CpuArchAttributes != 0) {\r
       if (gCpu == NULL) {\r
         Status = EFI_NOT_AVAILABLE_YET;\r
       } else {\r
@@ -922,6 +952,13 @@ CoreConvertSpace (
     // Set attributes operation\r
     //\r
     case GCD_SET_ATTRIBUTES_MEMORY_OPERATION:\r
+      if (CpuArchAttributes == 0) {\r
+        //\r
+        // Keep original CPU arch attributes when caller just calls\r
+        // SetMemorySpaceAttributes() with none CPU arch attributes (for example, RUNTIME).\r
+        //\r
+        Attributes |= (Entry->Attributes & (EXCLUSIVE_MEMORY_ATTRIBUTES | NONEXCLUSIVE_MEMORY_ATTRIBUTES));\r
+      }\r
       Entry->Attributes = Attributes;\r
       break;\r
     //\r
@@ -1337,7 +1374,11 @@ CoreAllocateMemorySpace (
   IN     EFI_HANDLE             DeviceHandle OPTIONAL\r
   )\r
 {\r
-  DEBUG ((DEBUG_GCD, "GCD:AllocateMemorySpace(Base=%016lx,Length=%016lx)\n", *BaseAddress, Length));\r
+  if (BaseAddress != NULL) {\r
+    DEBUG ((DEBUG_GCD, "GCD:AllocateMemorySpace(Base=%016lx,Length=%016lx)\n", *BaseAddress, Length));\r
+  } else {\r
+    DEBUG ((DEBUG_GCD, "GCD:AllocateMemorySpace(Base=<NULL>,Length=%016lx)\n", Length));\r
+  }\r
   DEBUG ((DEBUG_GCD, "  GcdAllocateType = %a\n", mGcdAllocationTypeNames[MIN (GcdAllocateType, EfiGcdMaxAllocateType)]));\r
   DEBUG ((DEBUG_GCD, "  GcdMemoryType   = %a\n", mGcdMemoryTypeNames[MIN (GcdMemoryType, EfiGcdMemoryTypeMaximum)]));\r
   DEBUG ((DEBUG_GCD, "  Alignment       = %016lx\n", LShiftU64 (1, Alignment)));\r
@@ -1624,7 +1665,7 @@ CoreSetMemorySpaceCapabilities (
 \r
   Status = CoreConvertSpace (GCD_SET_CAPABILITIES_MEMORY_OPERATION, (EFI_GCD_MEMORY_TYPE) 0, (EFI_GCD_IO_TYPE) 0, BaseAddress, Length, Capabilities, 0);\r
   if (!EFI_ERROR(Status)) {\r
-    CoreUpdateMemoryAttributes(BaseAddress, RShiftU64(Length, EFI_PAGE_SHIFT), Capabilities);\r
+    CoreUpdateMemoryAttributes(BaseAddress, RShiftU64(Length, EFI_PAGE_SHIFT), Capabilities & (~EFI_MEMORY_RUNTIME));\r
   }\r
 \r
   return Status;\r
@@ -1761,7 +1802,11 @@ CoreAllocateIoSpace (
   IN     EFI_HANDLE             DeviceHandle OPTIONAL\r
   )\r
 {\r
-  DEBUG ((DEBUG_GCD, "GCD:AllocateIoSpace(Base=%016lx,Length=%016lx)\n", *BaseAddress, Length));\r
+  if (BaseAddress != NULL) {\r
+    DEBUG ((DEBUG_GCD, "GCD:AllocateIoSpace(Base=%016lx,Length=%016lx)\n", *BaseAddress, Length));\r
+  } else {\r
+    DEBUG ((DEBUG_GCD, "GCD:AllocateIoSpace(Base=<NULL>,Length=%016lx)\n", Length));\r
+  }\r
   DEBUG ((DEBUG_GCD, "  GcdAllocateType = %a\n", mGcdAllocationTypeNames[MIN (GcdAllocateType, EfiGcdMaxAllocateType)]));\r
   DEBUG ((DEBUG_GCD, "  GcdIoType       = %a\n", mGcdIoTypeNames[MIN (GcdIoType, EfiGcdIoTypeMaximum)]));\r
   DEBUG ((DEBUG_GCD, "  Alignment       = %016lx\n", LShiftU64 (1, Alignment)));\r
@@ -2003,6 +2048,30 @@ CoreConvertResourceDescriptorHobAttributesToCapabilities (
   return Capabilities;\r
 }\r
 \r
+/**\r
+  Calculate total memory bin size neeeded.\r
+\r
+  @return The total memory bin size neeeded.\r
+\r
+**/\r
+UINT64\r
+CalculateTotalMemoryBinSizeNeeded (\r
+  VOID\r
+  )\r
+{\r
+  UINTN     Index;\r
+  UINT64    TotalSize;\r
+\r
+  //\r
+  // Loop through each memory type in the order specified by the gMemoryTypeInformation[] array\r
+  //\r
+  TotalSize = 0;\r
+  for (Index = 0; gMemoryTypeInformation[Index].Type != EfiMaxMemoryType; Index++) {\r
+    TotalSize += LShiftU64 (gMemoryTypeInformation[Index].NumberOfPages, EFI_PAGE_SHIFT);\r
+  }\r
+\r
+  return TotalSize;\r
+}\r
 \r
 /**\r
   External function. Initializes memory services based on the memory\r
@@ -2037,14 +2106,12 @@ CoreInitializeMemoryServices (
   UINT64                             Length;\r
   UINT64                             Attributes;\r
   UINT64                             Capabilities;\r
-  EFI_PHYSICAL_ADDRESS               MaxMemoryBaseAddress;\r
-  UINT64                             MaxMemoryLength;\r
-  UINT64                             MaxMemoryAttributes;\r
   EFI_PHYSICAL_ADDRESS               TestedMemoryBaseAddress;\r
   UINT64                             TestedMemoryLength;\r
   EFI_PHYSICAL_ADDRESS               HighAddress;\r
   EFI_HOB_GUID_TYPE                  *GuidHob;\r
-  UINT32                              ReservedCodePageNumber;\r
+  UINT32                             ReservedCodePageNumber;\r
+  UINT64                             MinimalMemorySizeNeeded;\r
 \r
   //\r
   // Point at the first HOB.  This must be the PHIT HOB.\r
@@ -2066,9 +2133,6 @@ CoreInitializeMemoryServices (
   BaseAddress           = 0;\r
   Length                = 0;\r
   Attributes            = 0;\r
-  MaxMemoryBaseAddress  = 0;\r
-  MaxMemoryLength       = 0;\r
-  MaxMemoryAttributes   = 0;\r
 \r
   //\r
   // Cache the PHIT HOB for later use\r
@@ -2097,10 +2161,14 @@ CoreInitializeMemoryServices (
     }\r
   }\r
 \r
+  //\r
+  // Include the total memory bin size needed to make sure memory bin could be allocated successfully.\r
+  //\r
+  MinimalMemorySizeNeeded = MINIMUM_INITIAL_MEMORY_SIZE + CalculateTotalMemoryBinSizeNeeded ();\r
+\r
   //\r
   // Find the Resource Descriptor HOB that contains PHIT range EfiFreeMemoryBottom..EfiFreeMemoryTop\r
   //\r
-  Length = 0;\r
   Found  = FALSE;\r
   for (Hob.Raw = *HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {\r
     //\r
@@ -2138,19 +2206,19 @@ CoreInitializeMemoryServices (
     Found = TRUE;\r
 \r
     //\r
-    // Compute range between PHIT EfiFreeMemoryTop and the end of the Resource Descriptor HOB\r
+    // Compute range between PHIT EfiMemoryTop and the end of the Resource Descriptor HOB\r
     //\r
     Attributes  = PhitResourceHob->ResourceAttribute;\r
     BaseAddress = PageAlignAddress (PhitHob->EfiMemoryTop);\r
     Length      = PageAlignLength  (ResourceHob->PhysicalStart + ResourceHob->ResourceLength - BaseAddress);\r
-    if (Length < MINIMUM_INITIAL_MEMORY_SIZE) {\r
+    if (Length < MinimalMemorySizeNeeded) {\r
       //\r
       // If that range is not large enough to intialize the DXE Core, then \r
       // Compute range between PHIT EfiFreeMemoryBottom and PHIT EfiFreeMemoryTop\r
       //\r
       BaseAddress = PageAlignAddress (PhitHob->EfiFreeMemoryBottom);\r
       Length      = PageAlignLength  (PhitHob->EfiFreeMemoryTop - BaseAddress);\r
-      if (Length < MINIMUM_INITIAL_MEMORY_SIZE) {\r
+      if (Length < MinimalMemorySizeNeeded) {\r
         //\r
         // If that range is not large enough to intialize the DXE Core, then \r
         // Compute range between the start of the Resource Descriptor HOB and the start of the HOB List\r
@@ -2168,81 +2236,79 @@ CoreInitializeMemoryServices (
   ASSERT (Found);\r
 \r
   //\r
-  // Search all the resource descriptor HOBs from the highest possible addresses down for a memory\r
-  // region that is big enough to initialize the DXE core.  Always skip the PHIT Resource HOB.\r
-  // The max address must be within the physically addressible range for the processor.\r
+  // Take the range in the resource descriptor HOB for the memory region described\r
+  // by the PHIT as higher priority if it is big enough. It can make the memory bin\r
+  // allocated to be at the same memory region with PHIT that has more better compatibility\r
+  // to avoid memory fragmentation for some code practices assume and allocate <4G ACPI memory.\r
   //\r
-  HighAddress = MAX_ADDRESS;\r
-  for (Hob.Raw = *HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {\r
+  if (Length < MinimalMemorySizeNeeded) {\r
     //\r
-    // Skip the Resource Descriptor HOB that contains the PHIT\r
-    //\r
-    if (Hob.ResourceDescriptor == PhitResourceHob) {\r
-      continue;\r
-    }\r
+    // Search all the resource descriptor HOBs from the highest possible addresses down for a memory\r
+    // region that is big enough to initialize the DXE core.  Always skip the PHIT Resource HOB.\r
+    // The max address must be within the physically addressible range for the processor.\r
     //\r
-    // Skip all HOBs except Resource Descriptor HOBs\r
-    //\r
-    if (GET_HOB_TYPE (Hob) != EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {\r
-      continue;\r
-    }\r
+    HighAddress = MAX_ADDRESS;\r
+    for (Hob.Raw = *HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {\r
+      //\r
+      // Skip the Resource Descriptor HOB that contains the PHIT\r
+      //\r
+      if (Hob.ResourceDescriptor == PhitResourceHob) {\r
+        continue;\r
+      }\r
+      //\r
+      // Skip all HOBs except Resource Descriptor HOBs\r
+      //\r
+      if (GET_HOB_TYPE (Hob) != EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {\r
+        continue;\r
+      }\r
 \r
-    //\r
-    // Skip Resource Descriptor HOBs that do not describe tested system memory below MAX_ADDRESS\r
-    //\r
-    ResourceHob = Hob.ResourceDescriptor;\r
-    if (ResourceHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY) {\r
-      continue;\r
-    }\r
-    if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) != TESTED_MEMORY_ATTRIBUTES) {\r
-      continue;\r
-    }\r
-    if ((ResourceHob->PhysicalStart + ResourceHob->ResourceLength) > (EFI_PHYSICAL_ADDRESS)MAX_ADDRESS) {\r
-      continue;\r
-    }\r
-    \r
-    //\r
-    // Skip Resource Descriptor HOBs that are below a previously found Resource Descriptor HOB\r
-    //\r
-    if (HighAddress != (EFI_PHYSICAL_ADDRESS)MAX_ADDRESS && ResourceHob->PhysicalStart <= HighAddress) {\r
-      continue;\r
-    }\r
+      //\r
+      // Skip Resource Descriptor HOBs that do not describe tested system memory below MAX_ADDRESS\r
+      //\r
+      ResourceHob = Hob.ResourceDescriptor;\r
+      if (ResourceHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY) {\r
+        continue;\r
+      }\r
+      if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) != TESTED_MEMORY_ATTRIBUTES) {\r
+        continue;\r
+      }\r
+      if ((ResourceHob->PhysicalStart + ResourceHob->ResourceLength) > (EFI_PHYSICAL_ADDRESS)MAX_ADDRESS) {\r
+        continue;\r
+      }\r
 \r
-    //\r
-    // Skip Resource Descriptor HOBs that are not large enough to initilize the DXE Core\r
-    //\r
-    TestedMemoryBaseAddress = PageAlignAddress (ResourceHob->PhysicalStart);\r
-    TestedMemoryLength      = PageAlignLength  (ResourceHob->PhysicalStart + ResourceHob->ResourceLength - TestedMemoryBaseAddress);\r
-    if (TestedMemoryLength < MINIMUM_INITIAL_MEMORY_SIZE) {\r
-      continue;\r
+      //\r
+      // Skip Resource Descriptor HOBs that are below a previously found Resource Descriptor HOB\r
+      //\r
+      if (HighAddress != (EFI_PHYSICAL_ADDRESS)MAX_ADDRESS && ResourceHob->PhysicalStart <= HighAddress) {\r
+        continue;\r
+      }\r
+\r
+      //\r
+      // Skip Resource Descriptor HOBs that are not large enough to initilize the DXE Core\r
+      //\r
+      TestedMemoryBaseAddress = PageAlignAddress (ResourceHob->PhysicalStart);\r
+      TestedMemoryLength      = PageAlignLength  (ResourceHob->PhysicalStart + ResourceHob->ResourceLength - TestedMemoryBaseAddress);\r
+      if (TestedMemoryLength < MinimalMemorySizeNeeded) {\r
+        continue;\r
+      }\r
+\r
+      //\r
+      // Save the range described by the Resource Descriptor that is large enough to initilize the DXE Core\r
+      //\r
+      BaseAddress = TestedMemoryBaseAddress;\r
+      Length      = TestedMemoryLength;\r
+      Attributes  = ResourceHob->ResourceAttribute; \r
+      HighAddress = ResourceHob->PhysicalStart;\r
     }\r
-    \r
-    //\r
-    // Save the Resource Descriptor HOB context that is large enough to initilize the DXE Core\r
-    //\r
-    MaxMemoryBaseAddress = TestedMemoryBaseAddress;\r
-    MaxMemoryLength      = TestedMemoryLength;\r
-    MaxMemoryAttributes  = ResourceHob->ResourceAttribute; \r
-    HighAddress          = ResourceHob->PhysicalStart;\r
   }\r
 \r
-  //\r
-  // If Length is not large enough to initialize the DXE Core or a Resource \r
-  // Descriptor HOB was found above the PHIT HOB that is large enough to initialize \r
-  // the DXE Core, then use the range described by the Resource Descriptor \r
-  // HOB that was found above the PHIT HOB.\r
-  //\r
-  if ((Length < MINIMUM_INITIAL_MEMORY_SIZE) ||\r
-      (MaxMemoryBaseAddress > BaseAddress && MaxMemoryLength >= MINIMUM_INITIAL_MEMORY_SIZE)) {\r
-    BaseAddress = MaxMemoryBaseAddress;\r
-    Length      = MaxMemoryLength;\r
-    Attributes  = MaxMemoryAttributes;\r
-  }\r
+  DEBUG ((EFI_D_INFO, "CoreInitializeMemoryServices:\n"));\r
+  DEBUG ((EFI_D_INFO, "  BaseAddress - 0x%lx Length - 0x%lx MinimalMemorySizeNeeded - 0x%lx\n", BaseAddress, Length, MinimalMemorySizeNeeded));\r
 \r
   //\r
   // If no memory regions are found that are big enough to initialize the DXE core, then ASSERT().\r
   //\r
-  ASSERT (Length >= MINIMUM_INITIAL_MEMORY_SIZE);\r
+  ASSERT (Length >= MinimalMemorySizeNeeded);\r
 \r
   //\r
   // Convert the Resource HOB Attributes to an EFI Memory Capabilities mask\r
@@ -2378,7 +2444,7 @@ CoreInitializeGcdServices (
           GcdMemoryType = EfiGcdMemoryTypeReserved;\r
         }\r
         if ((ResourceHob->ResourceAttribute & EFI_RESOURCE_ATTRIBUTE_PERSISTENT) == EFI_RESOURCE_ATTRIBUTE_PERSISTENT) {\r
-          GcdMemoryType = EfiGcdMemoryTypePersistentMemory;\r
+          GcdMemoryType = EfiGcdMemoryTypePersistent;\r
         }\r
         break;\r
       case EFI_RESOURCE_MEMORY_MAPPED_IO:\r