]>
Commit | Line | Data |
---|---|---|
33ac4566 AB |
1 | /** @file\r |
2 | FDT client library for consumers of PCI related dynamic PCDs\r | |
3 | \r | |
4 | Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>\r | |
5 | \r | |
6 | This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #include <Uefi.h>\r | |
17 | \r | |
18 | #include <Library/BaseLib.h>\r | |
19 | #include <Library/DebugLib.h>\r | |
20 | #include <Library/PcdLib.h>\r | |
21 | #include <Library/UefiBootServicesTableLib.h>\r | |
22 | \r | |
23 | #include <Protocol/FdtClient.h>\r | |
24 | \r | |
25 | RETURN_STATUS\r | |
26 | EFIAPI\r | |
27 | FdtPciPcdProducerLibConstructor (\r | |
28 | VOID\r | |
29 | )\r | |
30 | {\r | |
31 | UINT64 PciExpressBaseAddress;\r | |
32 | FDT_CLIENT_PROTOCOL *FdtClient;\r | |
33 | CONST UINT64 *Reg;\r | |
34 | UINT32 RegElemSize, RegSize;\r | |
35 | EFI_STATUS Status;\r | |
36 | \r | |
37 | PciExpressBaseAddress = PcdGet64 (PcdPciExpressBaseAddress);\r | |
38 | if (PciExpressBaseAddress != MAX_UINT64) {\r | |
39 | return EFI_SUCCESS;\r | |
40 | }\r | |
41 | \r | |
42 | Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,\r | |
43 | (VOID **)&FdtClient);\r | |
44 | ASSERT_EFI_ERROR (Status);\r | |
45 | \r | |
46 | Status = FdtClient->FindCompatibleNodeReg (FdtClient,\r | |
47 | "pci-host-ecam-generic", (CONST VOID **)&Reg,\r | |
48 | &RegElemSize, &RegSize);\r | |
49 | \r | |
50 | if (EFI_ERROR (Status)) {\r | |
51 | PciExpressBaseAddress = 0;\r | |
52 | } else {\r | |
53 | ASSERT (RegElemSize == sizeof (UINT64));\r | |
54 | PciExpressBaseAddress = SwapBytes64 (*Reg);\r | |
55 | \r | |
56 | PcdSetBool (PcdPciDisableBusEnumeration, FALSE);\r | |
57 | }\r | |
58 | \r | |
59 | PcdSet64 (PcdPciExpressBaseAddress, PciExpressBaseAddress);\r | |
60 | \r | |
61 | return RETURN_SUCCESS;\r | |
62 | }\r |