2 FDT client library for consumers of PCI related dynamic PCDs
4 Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #include <Library/BaseLib.h>
19 #include <Library/DebugLib.h>
20 #include <Library/PcdLib.h>
21 #include <Library/UefiBootServicesTableLib.h>
23 #include <Protocol/FdtClient.h>
27 FdtPciPcdProducerLibConstructor (
31 UINT64 PciExpressBaseAddress
;
32 FDT_CLIENT_PROTOCOL
*FdtClient
;
34 UINT32 RegElemSize
, RegSize
;
37 PciExpressBaseAddress
= PcdGet64 (PcdPciExpressBaseAddress
);
38 if (PciExpressBaseAddress
!= MAX_UINT64
) {
42 Status
= gBS
->LocateProtocol (&gFdtClientProtocolGuid
, NULL
,
44 ASSERT_EFI_ERROR (Status
);
46 Status
= FdtClient
->FindCompatibleNodeReg (FdtClient
,
47 "pci-host-ecam-generic", (CONST VOID
**)&Reg
,
48 &RegElemSize
, &RegSize
);
50 if (EFI_ERROR (Status
)) {
51 PciExpressBaseAddress
= 0;
53 ASSERT (RegElemSize
== sizeof (UINT64
));
54 PciExpressBaseAddress
= SwapBytes64 (*Reg
);
56 PcdSetBool (PcdPciDisableBusEnumeration
, FALSE
);
59 PcdSet64 (PcdPciExpressBaseAddress
, PciExpressBaseAddress
);
61 return RETURN_SUCCESS
;