--- /dev/null
+/** @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
+ This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this 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 IMPLIED.\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
+RETURN_STATUS\r
+EFIAPI\r
+FdtPciPcdProducerLibConstructor (\r
+ VOID\r
+ )\r
+{\r
+ UINT64 PciExpressBaseAddress;\r
+ FDT_CLIENT_PROTOCOL *FdtClient;\r
+ CONST UINT64 *Reg;\r
+ UINT32 RegElemSize, RegSize;\r
+ EFI_STATUS Status;\r
+\r
+ PciExpressBaseAddress = PcdGet64 (PcdPciExpressBaseAddress);\r
+ if (PciExpressBaseAddress != MAX_UINT64) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,\r
+ (VOID **)&FdtClient);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = FdtClient->FindCompatibleNodeReg (FdtClient,\r
+ "pci-host-ecam-generic", (CONST VOID **)&Reg,\r
+ &RegElemSize, &RegSize);\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ PciExpressBaseAddress = 0;\r
+ } else {\r
+ ASSERT (RegElemSize == sizeof (UINT64));\r
+ PciExpressBaseAddress = SwapBytes64 (*Reg);\r
+\r
+ PcdSetBool (PcdPciDisableBusEnumeration, FALSE);\r
+ }\r
+\r
+ PcdSet64 (PcdPciExpressBaseAddress, PciExpressBaseAddress);\r
+\r
+ return RETURN_SUCCESS;\r
+}\r
--- /dev/null
+#/** @file\r
+# FDT client library for consumers of PCI related dynamic PCDs\r
+#\r
+# Copyright (c) 2016, Linaro Ltd. All rights reserved.\r
+#\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this 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 IMPLIED.\r
+#\r
+#**/\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = FdtPciPcdProducerLib\r
+ FILE_GUID = D584275B-BF1E-4DF8-A53D-980F5645C5E7\r
+ MODULE_TYPE = BASE\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = PciPcdProducerLib|DXE_DRIVER UEFI_DRIVER\r
+ CONSTRUCTOR = FdtPciPcdProducerLibConstructor\r
+\r
+[Sources]\r
+ FdtPciPcdProducerLib.c\r
+\r
+[Packages]\r
+ ArmVirtPkg/ArmVirtPkg.dec\r
+ MdeModulePkg/MdeModulePkg.dec\r
+ MdePkg/MdePkg.dec\r
+\r
+[LibraryClasses]\r
+ BaseLib\r
+ DebugLib\r
+ PcdLib\r
+ UefiBootServicesTableLib\r
+\r
+[Protocols]\r
+ gFdtClientProtocolGuid ## CONSUMES\r
+\r
+[Pcd]\r
+ gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress ## PRODUCES\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration ## PRODUCES\r
+\r
+[Depex]\r
+ gFdtClientProtocolGuid\r