From patchwork Tue Apr 12 13:47:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 65618 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1930692qge; Tue, 12 Apr 2016 06:47:19 -0700 (PDT) X-Received: by 10.98.86.146 with SMTP id h18mr4751167pfj.9.1460468839462; Tue, 12 Apr 2016 06:47:19 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id wg1si10400993pab.52.2016.04.12.06.47.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Apr 2016 06:47:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 175231A20EE; Tue, 12 Apr 2016 06:47:19 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wm0-x235.google.com (mail-wm0-x235.google.com [IPv6:2a00:1450:400c:c09::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 86E121A20EE for ; Tue, 12 Apr 2016 06:47:17 -0700 (PDT) Received: by mail-wm0-x235.google.com with SMTP id v188so127918995wme.1 for ; Tue, 12 Apr 2016 06:47:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KPh/6xfVLD1xxnZCnWY5I+h4i8xRQ4hon5Yy4bNxz6U=; b=b82AQ218xzD1I2RO5+PpH8BqcA1Ao2O46s8HDIugrg98Yf3bq4zf0LCebFRRNOXXjx 6VK47lcePW3q+YI4PbzA9WQnBRTWetAomx8w+/YaJQbNvo9Ph2zKJbI9fVgIsTmxIxvq V4DXt4KuKuPE5k/niAmMn3JXh0/c+duxwAUYw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KPh/6xfVLD1xxnZCnWY5I+h4i8xRQ4hon5Yy4bNxz6U=; b=QQ/QuCvxq3JK3XmHAD8dTryGOjMelscPh9z1GwGp4d/6zju+OhNAdPUqnF0GtX18HI OBfoH6sRDCTgKxhpMejvE40bQ1Qsv030W1ICyw0isSDIlSVgJQMfryT2uWDCqCPoxmRe UZc7YtL30rUSN7WVWifX3XHvlJMCSy9pvHfClnToQmHIHwrPF3Q1thFdxU3tMuW8BwWw nx4qQB2sYBKZhYX6uQ/H3Bgfi7+5WXuyRCX3Kt5qJxVH3K4FX5PRPNwCGGFc/+P2MAHX SD6PQVNK42ORiTzJyQJ4lM2WagDZrP3vXe8w6C60+/etLixCdRybxaVS/ZWy7RVsbdMm IreQ== X-Gm-Message-State: AD7BkJL1ln4J5qUUmaPI3Gs/W6HBGi3fF4xJufBBgwh8khPEE68psWBomz7QS8lRkFgS9Heh X-Received: by 10.28.27.87 with SMTP id b84mr25540044wmb.7.1460468836084; Tue, 12 Apr 2016 06:47:16 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id w75sm22970685wmw.4.2016.04.12.06.47.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Apr 2016 06:47:15 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, lersek@redhat.com Date: Tue, 12 Apr 2016 15:47:06 +0200 Message-Id: <1460468829-13982-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1460468829-13982-1-git-send-email-ard.biesheuvel@linaro.org> References: <1460468829-13982-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 1/4] ArmVirtPkg: implement FdtPciPcdProducerLib X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" This implements a library FdtPciPcdProducerLib which is intended to be incorporated into modules that consume the PCI related dynamic PCDs PcdPciExpressBaseAddress and PcdPciDisableBusEnumeration, either via NULL library class resolution or via a direct dependency (for other libraries or modules in ArmVirtPkg). This allows us to make them depend on the FDT client protocol, and populate these PCDs based on the presence and the contents of a 'pci-ecam-generic' DT node. This also overloads the meaning of PcdPciExpressBaseAddress, which we will set to MAX_UINT64 to signify that the actual values of these two PCDs have not been assigned yet. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.c | 61 ++++++++++++++++++++ ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf | 47 +++++++++++++++ 2 files changed, 108 insertions(+) -- 2.5.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Laszlo Ersek Reviewed-by: Laszlo Ersek diff --git a/ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.c b/ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.c new file mode 100644 index 000000000000..64a3aa969680 --- /dev/null +++ b/ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.c @@ -0,0 +1,61 @@ +/** @file + FDT client library for consumers of PCI related dynamic PCDs + + Copyright (c) 2016, Linaro Ltd. All rights reserved.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +#include +#include +#include +#include + +#include + +RETURN_STATUS +EFIAPI +FdtPciPcdProducerLibConstructor ( + VOID + ) +{ + UINT64 PciExpressBaseAddress; + FDT_CLIENT_PROTOCOL *FdtClient; + CONST UINT64 *Reg; + UINT32 RegElemSize, RegSize; + EFI_STATUS Status; + + PciExpressBaseAddress = PcdGet64 (PcdPciExpressBaseAddress); + if (PciExpressBaseAddress != MAX_UINT64) { + return EFI_SUCCESS; + } + + Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL, + (VOID **)&FdtClient); + ASSERT_EFI_ERROR (Status); + + Status = FdtClient->FindCompatibleNodeReg (FdtClient, + "pci-host-ecam-generic", (CONST VOID **)&Reg, + &RegElemSize, &RegSize); + + if (EFI_ERROR (Status)) { + PciExpressBaseAddress = 0; + } else { + ASSERT (RegElemSize == sizeof (UINT64)); + PciExpressBaseAddress = SwapBytes64 (*Reg); + } + + PcdSet64 (PcdPciExpressBaseAddress, PciExpressBaseAddress); + PcdSetBool (PcdPciDisableBusEnumeration, FALSE); + + return RETURN_SUCCESS; +} diff --git a/ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf b/ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf new file mode 100644 index 000000000000..546125997ba6 --- /dev/null +++ b/ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf @@ -0,0 +1,47 @@ +#/** @file +# FDT client library for consumers of PCI related dynamic PCDs +# +# Copyright (c) 2016, Linaro Ltd. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# +#**/ + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = FdtPciPcdProducerLib + FILE_GUID = D584275B-BF1E-4DF8-A53D-980F5645C5E7 + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = PciPcdProducerLib|DXE_DRIVER UEFI_DRIVER + CONSTRUCTOR = FdtPciPcdProducerLibConstructor + +[Sources] + FdtPciPcdProducerLib.c + +[Packages] + ArmVirtPkg/ArmVirtPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + BaseLib + DebugLib + PcdLib + UefiBootServicesTableLib + +[Protocols] + gFdtClientProtocolGuid ## CONSUMES + +[Pcd] + gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress ## PRODUCES + gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration ## PRODUCES + +[Depex] + gFdtClientProtocolGuid