]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: PI1.4 DxeCore GetMemoryMap() update
authorLiming Gao <liming.gao@intel.com>
Wed, 29 Apr 2015 05:11:21 +0000 (05:11 +0000)
committerlgao4 <lgao4@Edk2>
Wed, 29 Apr 2015 05:11:21 +0000 (05:11 +0000)
PI1.4: Updates DxeCore to add all EfiGcdMemoryTypeReserved memory
into UEFI memory map.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17253 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/Dxe/Mem/Page.c

index 830b19700aae8750f90da71b1f51da68db224b30..abfb0b9c7461a15e4ac5a2aae95b5088d66640ac 100644 (file)
@@ -1530,7 +1530,7 @@ CoreGetMemoryMap (
   EFI_STATUS                        Status;\r
   UINTN                             Size;\r
   UINTN                             BufferSize;\r
-  UINTN                             NumberOfRuntimePersistentEntries;\r
+  UINTN                             NumberOfEntries;\r
   LIST_ENTRY                        *Link;\r
   MEMORY_MAP                        *Entry;\r
   EFI_GCD_MAP_ENTRY                 *GcdMapEntry;\r
@@ -1547,21 +1547,17 @@ CoreGetMemoryMap (
   CoreAcquireGcdMemoryLock ();\r
 \r
   //\r
-  // Count the number of Reserved and MMIO entries that are marked for runtime use\r
+  // Count the number of Reserved and runtime MMIO entries\r
   // And, count the number of Persistent entries.\r
   //\r
-  NumberOfRuntimePersistentEntries = 0;\r
+  NumberOfEntries = 0;\r
   for (Link = mGcdMemorySpaceMap.ForwardLink; Link != &mGcdMemorySpaceMap; Link = Link->ForwardLink) {\r
     GcdMapEntry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);\r
-    if ((GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeReserved) ||\r
-        (GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo)) {\r
-      if ((GcdMapEntry->Attributes & EFI_MEMORY_RUNTIME) == EFI_MEMORY_RUNTIME) {\r
-        NumberOfRuntimePersistentEntries ++;\r
-      }\r
-    }\r
-    \r
-    if (GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypePersistentMemory) {\r
-      NumberOfRuntimePersistentEntries ++;\r
+    if ((GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypePersistentMemory) || \r
+        (GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeReserved) ||\r
+        ((GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo) &&\r
+        ((GcdMapEntry->Attributes & EFI_MEMORY_RUNTIME) == EFI_MEMORY_RUNTIME))) {\r
+      NumberOfEntries ++;\r
     }\r
   }\r
 \r
@@ -1587,7 +1583,7 @@ CoreGetMemoryMap (
   //\r
   // Compute the buffer size needed to fit the entire map\r
   //\r
-  BufferSize = Size * NumberOfRuntimePersistentEntries;\r
+  BufferSize = Size * NumberOfEntries;\r
   for (Link = gMemoryMap.ForwardLink; Link != &gMemoryMap; Link = Link->ForwardLink) {\r
     BufferSize += Size;\r
   }\r
@@ -1652,33 +1648,31 @@ CoreGetMemoryMap (
   for (Link = mGcdMemorySpaceMap.ForwardLink; Link != &mGcdMemorySpaceMap; Link = Link->ForwardLink) {\r
     GcdMapEntry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);\r
     if ((GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeReserved) ||\r
-        (GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo)) {\r
-      if ((GcdMapEntry->Attributes & EFI_MEMORY_RUNTIME) == EFI_MEMORY_RUNTIME) {\r
-        // \r
-        // Create EFI_MEMORY_DESCRIPTOR for every Reserved and MMIO GCD entries\r
-        // that are marked for runtime use\r
-        //\r
-        MemoryMap->PhysicalStart = GcdMapEntry->BaseAddress;\r
-        MemoryMap->VirtualStart  = 0;\r
-        MemoryMap->NumberOfPages = RShiftU64 ((GcdMapEntry->EndAddress - GcdMapEntry->BaseAddress + 1), EFI_PAGE_SHIFT);\r
-        MemoryMap->Attribute     = GcdMapEntry->Attributes & ~EFI_MEMORY_PORT_IO;\r
-\r
-        if (GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeReserved) {\r
-          MemoryMap->Type = EfiReservedMemoryType;\r
-        } else if (GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo) {\r
-          if ((GcdMapEntry->Attributes & EFI_MEMORY_PORT_IO) == EFI_MEMORY_PORT_IO) {\r
-            MemoryMap->Type = EfiMemoryMappedIOPortSpace;\r
-          } else {\r
-            MemoryMap->Type = EfiMemoryMappedIO;\r
-          }\r
+        ((GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo) &&\r
+        ((GcdMapEntry->Attributes & EFI_MEMORY_RUNTIME) == EFI_MEMORY_RUNTIME))) {\r
+      // \r
+      // Create EFI_MEMORY_DESCRIPTOR for every Reserved and runtime MMIO GCD entries\r
+      //\r
+      MemoryMap->PhysicalStart = GcdMapEntry->BaseAddress;\r
+      MemoryMap->VirtualStart  = 0;\r
+      MemoryMap->NumberOfPages = RShiftU64 ((GcdMapEntry->EndAddress - GcdMapEntry->BaseAddress + 1), EFI_PAGE_SHIFT);\r
+      MemoryMap->Attribute     = GcdMapEntry->Attributes & ~EFI_MEMORY_PORT_IO;\r
+\r
+      if (GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeReserved) {\r
+        MemoryMap->Type = EfiReservedMemoryType;\r
+      } else if (GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo) {\r
+        if ((GcdMapEntry->Attributes & EFI_MEMORY_PORT_IO) == EFI_MEMORY_PORT_IO) {\r
+          MemoryMap->Type = EfiMemoryMappedIOPortSpace;\r
+        } else {\r
+          MemoryMap->Type = EfiMemoryMappedIO;\r
         }\r
-\r
-        //\r
-        // Check to see if the new Memory Map Descriptor can be merged with an \r
-        // existing descriptor if they are adjacent and have the same attributes\r
-        //\r
-        MemoryMap = MergeMemoryMapDescriptor (MemoryMapStart, MemoryMap, Size);\r
       }\r
+\r
+      //\r
+      // Check to see if the new Memory Map Descriptor can be merged with an \r
+      // existing descriptor if they are adjacent and have the same attributes\r
+      //\r
+      MemoryMap = MergeMemoryMapDescriptor (MemoryMapStart, MemoryMap, Size);\r
     }\r
     \r
     if (GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypePersistentMemory) {\r