]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.c
ArmVirtPkg/FdtPciPcdProducerLib: Relocate PciPcdProducerLib to OvmfPkg
[mirror_edk2.git] / ArmVirtPkg / Library / FdtPciPcdProducerLib / FdtPciPcdProducerLib.c
diff --git a/ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.c b/ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.c
deleted file mode 100644 (file)
index 2520101..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-/** @file\r
-  FDT client library for consumers of PCI related dynamic PCDs\r
-\r
-  Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>\r
-\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include <Uefi.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-\r
-#include <Protocol/FdtClient.h>\r
-\r
-//\r
-// We expect the "ranges" property of "pci-host-ecam-generic" to consist of\r
-// records like this.\r
-//\r
-#pragma pack (1)\r
-typedef struct {\r
-  UINT32 Type;\r
-  UINT64 ChildBase;\r
-  UINT64 CpuBase;\r
-  UINT64 Size;\r
-} DTB_PCI_HOST_RANGE_RECORD;\r
-#pragma pack ()\r
-\r
-#define DTB_PCI_HOST_RANGE_RELOCATABLE  BIT31\r
-#define DTB_PCI_HOST_RANGE_PREFETCHABLE BIT30\r
-#define DTB_PCI_HOST_RANGE_ALIASED      BIT29\r
-#define DTB_PCI_HOST_RANGE_MMIO32       BIT25\r
-#define DTB_PCI_HOST_RANGE_MMIO64       (BIT25 | BIT24)\r
-#define DTB_PCI_HOST_RANGE_IO           BIT24\r
-#define DTB_PCI_HOST_RANGE_TYPEMASK     (BIT31 | BIT30 | BIT29 | BIT25 | BIT24)\r
-\r
-STATIC\r
-RETURN_STATUS\r
-GetPciIoTranslation (\r
-  IN  FDT_CLIENT_PROTOCOL *FdtClient,\r
-  IN  INT32               Node,\r
-  OUT UINT64              *IoTranslation\r
-  )\r
-{\r
-  UINT32        RecordIdx;\r
-  CONST VOID    *Prop;\r
-  UINT32        Len;\r
-  EFI_STATUS    Status;\r
-  UINT64        IoBase;\r
-\r
-  //\r
-  // Iterate over "ranges".\r
-  //\r
-  Status = FdtClient->GetNodeProperty (FdtClient, Node, "ranges", &Prop, &Len);\r
-  if (EFI_ERROR (Status) || Len == 0 ||\r
-      Len % sizeof (DTB_PCI_HOST_RANGE_RECORD) != 0) {\r
-    DEBUG ((EFI_D_ERROR, "%a: 'ranges' not found or invalid\n", __FUNCTION__));\r
-    return RETURN_PROTOCOL_ERROR;\r
-  }\r
-\r
-  for (RecordIdx = 0; RecordIdx < Len / sizeof (DTB_PCI_HOST_RANGE_RECORD);\r
-       ++RecordIdx) {\r
-    CONST DTB_PCI_HOST_RANGE_RECORD *Record;\r
-    UINT32                          Type;\r
-\r
-    Record = (CONST DTB_PCI_HOST_RANGE_RECORD *)Prop + RecordIdx;\r
-    Type = SwapBytes32 (Record->Type) & DTB_PCI_HOST_RANGE_TYPEMASK;\r
-    if (Type == DTB_PCI_HOST_RANGE_IO) {\r
-      IoBase = SwapBytes64 (Record->ChildBase);\r
-      *IoTranslation = SwapBytes64 (Record->CpuBase) - IoBase;\r
-\r
-      return RETURN_SUCCESS;\r
-    }\r
-  }\r
-  return RETURN_NOT_FOUND;\r
-}\r
-\r
-RETURN_STATUS\r
-EFIAPI\r
-FdtPciPcdProducerLibConstructor (\r
-  VOID\r
-  )\r
-{\r
-  UINT64              PciExpressBaseAddress;\r
-  FDT_CLIENT_PROTOCOL *FdtClient;\r
-  CONST UINT64        *Reg;\r
-  UINT32              RegSize;\r
-  EFI_STATUS          Status;\r
-  INT32               Node;\r
-  RETURN_STATUS       RetStatus;\r
-  UINT64              IoTranslation;\r
-  RETURN_STATUS       PcdStatus;\r
-\r
-  PciExpressBaseAddress = PcdGet64 (PcdPciExpressBaseAddress);\r
-  if (PciExpressBaseAddress != MAX_UINT64) {\r
-    //\r
-    // Assume that the fact that PciExpressBaseAddress has been changed from\r
-    // its default value of MAX_UINT64 implies that this code has been\r
-    // executed already, in the context of another module. That means we can\r
-    // assume that PcdPciIoTranslation has been discovered from the DT node\r
-    // as well.\r
-    //\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,\r
-                  (VOID **)&FdtClient);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  PciExpressBaseAddress = 0;\r
-  Status = FdtClient->FindCompatibleNode (FdtClient, "pci-host-ecam-generic",\r
-                        &Node);\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    Status = FdtClient->GetNodeProperty (FdtClient, Node, "reg",\r
-                          (CONST VOID **)&Reg, &RegSize);\r
-\r
-    if (!EFI_ERROR (Status) && RegSize == 2 * sizeof (UINT64)) {\r
-      PciExpressBaseAddress = SwapBytes64 (*Reg);\r
-\r
-      PcdStatus = PcdSetBoolS (PcdPciDisableBusEnumeration, FALSE);\r
-      ASSERT_RETURN_ERROR (PcdStatus);\r
-\r
-      IoTranslation = 0;\r
-      RetStatus = GetPciIoTranslation (FdtClient, Node, &IoTranslation);\r
-      if (!RETURN_ERROR (RetStatus)) {\r
-          PcdStatus = PcdSet64S (PcdPciIoTranslation, IoTranslation);\r
-          ASSERT_RETURN_ERROR (PcdStatus);\r
-      } else {\r
-        //\r
-        // Support for I/O BARs is not mandatory, and so it does not make sense\r
-        // to abort in the general case. So leave it up to the actual driver to\r
-        // complain about this if it wants to, and just issue a warning here.\r
-        //\r
-        DEBUG ((EFI_D_WARN,\r
-          "%a: 'pci-host-ecam-generic' device encountered with no I/O range\n",\r
-          __FUNCTION__));\r
-      }\r
-    }\r
-  }\r
-\r
-  PcdStatus = PcdSet64S (PcdPciExpressBaseAddress, PciExpressBaseAddress);\r
-  ASSERT_RETURN_ERROR (PcdStatus);\r
-\r
-  return RETURN_SUCCESS;\r
-}\r