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
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
//\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
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