+///\r
+/// Lookup table used to print GCD Memory Space Map\r
+///\r
+GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mGcdMemoryTypeNames[] = {\r
+ "NonExist ", // EfiGcdMemoryTypeNonExistent\r
+ "Reserved ", // EfiGcdMemoryTypeReserved\r
+ "SystemMem", // EfiGcdMemoryTypeSystemMemory\r
+ "MMIO ", // EfiGcdMemoryTypeMemoryMappedIo\r
+ "Unknown " // EfiGcdMemoryTypeMaximum\r
+};\r
+\r
+///\r
+/// Lookup table used to print GCD I/O Space Map\r
+///\r
+GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mGcdIoTypeNames[] = {\r
+ "NonExist", // EfiGcdIoTypeNonExistent\r
+ "Reserved", // EfiGcdIoTypeReserved\r
+ "I/O ", // EfiGcdIoTypeIo\r
+ "Unknown " // EfiGcdIoTypeMaximum \r
+};\r
+\r
+///\r
+/// Lookup table used to print GCD Allocation Types\r
+///\r
+GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mGcdAllocationTypeNames[] = {\r
+ "AnySearchBottomUp ", // EfiGcdAllocateAnySearchBottomUp\r
+ "MaxAddressSearchBottomUp ", // EfiGcdAllocateMaxAddressSearchBottomUp\r
+ "AtAddress ", // EfiGcdAllocateAddress\r
+ "AnySearchTopDown ", // EfiGcdAllocateAnySearchTopDown\r
+ "MaxAddressSearchTopDown ", // EfiGcdAllocateMaxAddressSearchTopDown\r
+ "Unknown " // EfiGcdMaxAllocateType\r
+};\r
+\r
+/**\r
+ Dump the entire contents if the GCD Memory Space Map using DEBUG() macros when\r
+ PcdDebugPrintErrorLevel has the DEBUG_GCD bit set.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CoreDumpGcdMemorySpaceMap (\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN NumberOfDescriptors;\r
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;\r
+ UINTN Index;\r
+ \r
+ Status = CoreGetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);\r
+ ASSERT_EFI_ERROR (Status);\r
+ \r
+ DEBUG ((DEBUG_GCD, "GCDMemType Range Capabilities Attributes \n"));\r
+ DEBUG ((DEBUG_GCD, "========== ================================= ================ ================\n"));\r
+ for (Index = 0; Index < NumberOfDescriptors; Index++) {\r
+ DEBUG ((DEBUG_GCD, "%a %016lx-%016lx %016lx %016lx%c\n", \r
+ mGcdMemoryTypeNames[MIN (MemorySpaceMap[Index].GcdMemoryType, EfiGcdMemoryTypeMaximum)],\r
+ MemorySpaceMap[Index].BaseAddress, \r
+ MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length - 1,\r
+ MemorySpaceMap[Index].Capabilities, \r
+ MemorySpaceMap[Index].Attributes,\r
+ MemorySpaceMap[Index].ImageHandle == NULL ? ' ' : '*'\r
+ ));\r
+ }\r
+ DEBUG ((DEBUG_GCD, "\n"));\r
+ FreePool (MemorySpaceMap);\r
+}\r
+\r
+/**\r
+ Dump the entire contents if the GCD I/O Space Map using DEBUG() macros when \r
+ PcdDebugPrintErrorLevel has the DEBUG_GCD bit set.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CoreDumpGcdIoSpaceMap (\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN NumberOfDescriptors;\r
+ EFI_GCD_IO_SPACE_DESCRIPTOR *IoSpaceMap;\r
+ UINTN Index;\r
+ \r
+ Status = CoreGetIoSpaceMap (&NumberOfDescriptors, &IoSpaceMap);\r
+ ASSERT_EFI_ERROR (Status);\r
+ \r
+ DEBUG ((DEBUG_GCD, "GCDIoType Range \n"));\r
+ DEBUG ((DEBUG_GCD, "========== =================================\n"));\r
+ for (Index = 0; Index < NumberOfDescriptors; Index++) {\r
+ DEBUG ((DEBUG_GCD, "%a %016lx-%016lx%c\n", \r
+ mGcdIoTypeNames[MIN (IoSpaceMap[Index].GcdIoType, EfiGcdIoTypeMaximum)],\r
+ IoSpaceMap[Index].BaseAddress, \r
+ IoSpaceMap[Index].BaseAddress + IoSpaceMap[Index].Length - 1,\r
+ IoSpaceMap[Index].ImageHandle == NULL ? ' ' : '*'\r
+ ));\r
+ }\r
+ DEBUG ((DEBUG_GCD, "\n"));\r
+ FreePool (IoSpaceMap);\r
+}\r
+ \r
+\r