]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c
ArmVirtPkg/FdtPciHostBridgeLib: map ECAM and I/O spaces in GCD memory map
[mirror_edk2.git] / ArmVirtPkg / Library / FdtPciHostBridgeLib / FdtPciHostBridgeLib.c
index bb3742386c63cf78667c27436102b019f13ffeff..ebfa14a349f4aad62c25e18ee888211a9432ccd7 100644 (file)
@@ -17,6 +17,7 @@
 #include <Library/PciHostBridgeLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/DevicePathLib.h>\r
+#include <Library/DxeServicesTableLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
@@ -82,6 +83,33 @@ typedef struct {
 #define DTB_PCI_HOST_RANGE_IO           BIT24\r
 #define DTB_PCI_HOST_RANGE_TYPEMASK     (BIT31 | BIT30 | BIT29 | BIT25 | BIT24)\r
 \r
+STATIC\r
+EFI_STATUS\r
+MapGcdMmioSpace (\r
+  IN    UINT64    Base,\r
+  IN    UINT64    Size\r
+  )\r
+{\r
+  EFI_STATUS    Status;\r
+\r
+  Status = gDS->AddMemorySpace (EfiGcdMemoryTypeMemoryMappedIo, Base, Size,\r
+                  EFI_MEMORY_UC);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((DEBUG_ERROR,\r
+      "%a: failed to add GCD memory space for region [0x%Lx+0x%Lx)\n",\r
+      __FUNCTION__, Base, Size));\r
+    return Status;\r
+  }\r
+\r
+  Status = gDS->SetMemorySpaceAttributes (Base, Size, EFI_MEMORY_UC);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((DEBUG_ERROR,\r
+      "%a: failed to set memory space attributes for region [0x%Lx+0x%Lx)\n",\r
+      __FUNCTION__, Base, Size));\r
+  }\r
+  return Status;\r
+}\r
+\r
 STATIC\r
 EFI_STATUS\r
 ProcessPciHost (\r
@@ -266,7 +294,23 @@ ProcessPciHost (
     "Io[0x%Lx+0x%Lx)@0x%Lx Mem32[0x%Lx+0x%Lx)@0x0 Mem64[0x%Lx+0x%Lx)@0x0\n",\r
     __FUNCTION__, ConfigBase, ConfigSize, *BusMin, *BusMax, *IoBase, *IoSize,\r
     IoTranslation, *Mmio32Base, *Mmio32Size, *Mmio64Base, *Mmio64Size));\r
-  return EFI_SUCCESS;\r
+\r
+  // Map the ECAM space in the GCD memory map\r
+  Status = MapGcdMmioSpace (ConfigBase, ConfigSize);\r
+  ASSERT_EFI_ERROR (Status);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Map the MMIO window that provides I/O access - the PCI host bridge code\r
+  // is not aware of this translation and so it will only map the I/O view\r
+  // in the GCD I/O map.\r
+  //\r
+  Status = MapGcdMmioSpace (*IoBase + IoTranslation, *IoSize);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
 }\r
 \r
 STATIC PCI_ROOT_BRIDGE mRootBridge;\r
@@ -317,7 +361,7 @@ PciHostBridgeGetRootBridges (
                                       EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;\r
   mRootBridge.Attributes            = mRootBridge.Supports;\r
 \r
-  mRootBridge.DmaAbove4G            = FALSE;\r
+  mRootBridge.DmaAbove4G            = TRUE;\r
   mRootBridge.NoExtendedConfigSpace = FALSE;\r
   mRootBridge.ResourceAssigned      = FALSE;\r
 \r