]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c
CryptoPkg: Fix possible build problem with Clang
[mirror_edk2.git] / ArmVirtPkg / Library / FdtPciHostBridgeLib / FdtPciHostBridgeLib.c
index 5b9c887db35df2f5b359df017be5860c6953bc82..496b192d229170d8f11c758d352fb5969d06344b 100644 (file)
@@ -3,20 +3,14 @@
 \r
   Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>\r
 \r
-  This program and the accompanying materials are licensed and made available\r
-  under the terms and conditions of the BSD License which accompanies this\r
-  distribution. The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR\r
-  IMPLIED.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 #include <PiDxe.h>\r
 #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 +76,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 +287,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