From patchwork Mon Sep 12 10:01:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 75981 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp767569qgf; Mon, 12 Sep 2016 03:01:35 -0700 (PDT) X-Received: by 10.66.155.7 with SMTP id vs7mr31849276pab.154.1473674495317; Mon, 12 Sep 2016 03:01:35 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id 5si20989463pfn.222.2016.09.12.03.01.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Sep 2016 03:01:35 -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 E19981A1E1D; Mon, 12 Sep 2016 03:01:34 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wm0-x231.google.com (mail-wm0-x231.google.com [IPv6:2a00:1450:400c:c09::231]) (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 11F2A1A1E16 for ; Mon, 12 Sep 2016 03:01:33 -0700 (PDT) Received: by mail-wm0-x231.google.com with SMTP id b187so127045032wme.1 for ; Mon, 12 Sep 2016 03:01:33 -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=SzkDA1VibjvCOaIB5wxpVco3HBileeHHCRuQigumei0=; b=Z6M/+50gGRSo5XkcnPFX63BH3RLxxje/YGJ5mxREMfGRwETW1HhXY366ucCqM4OSMK t0v5SJm2WRAJJDdZ5iviKs+LtNGhLcP7cjr/dhOMlvzUkmKKYF5dL3gUNqlcTe3SBGxL POZ3oi8UPPfPohD7agd1+fFUu9z4aKY5eBSc0= 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=SzkDA1VibjvCOaIB5wxpVco3HBileeHHCRuQigumei0=; b=h7EaU0LuvrWhCPCPNJme3Sev1kLS1KtkyCnwOXQxo+AfxzjQDuV8Xl8veUGp5JdkHM RT2DbEP8osIjEoFvaiuVb0HG3Go0GNZhzQEgKLCv5cFc1iALSSlao9wKtF56t7rY/KxY tboYoqm6OaZY6eqIBe9TmuQxswMIG7Qv7CWX0wfxay33C54f5jgIOVs3/GDLuGKWfAL7 sUKLBLYNMX98gJmnmWBABiB9mJph7y+DVzjXKNMRhtsX7CXeIg/XkQHzgdBaOjAEYe7r oy4XJXHPL5wNQ7mMUghMCh2P55cA2oGU544B6bKti6pi4ZApXxx69nHHzu/2uG1rOFbr o9RA== X-Gm-Message-State: AE9vXwMMw9shgjF3qZqJ56BtfW8sFiq7Xeenvvr7FGxizfiCHg6UPSgt3cPfspU9LpaC5oTE X-Received: by 10.194.59.84 with SMTP id x20mr856485wjq.89.1473674491493; Mon, 12 Sep 2016 03:01:31 -0700 (PDT) Received: from localhost.localdomain ([197.128.106.42]) by smtp.gmail.com with ESMTPSA id ce6sm17092706wjc.27.2016.09.12.03.01.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Sep 2016 03:01:30 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, lersek@redhat.com Date: Mon, 12 Sep 2016 11:01:18 +0100 Message-Id: <1473674479-20207-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1473674479-20207-1-git-send-email-ard.biesheuvel@linaro.org> References: <1473674479-20207-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 2/3] ArmVirtPkg/FdtPciPcdProducerLib: add discovery of PcdPciMmio64Size X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" In preparation of adding IncompatibleDeviceSupportDxe to ArmVirtQemu, in order to lure the PCI code into allocating all 64-bit BARs in the 64-bit region, update FdtPciPcdProducerLib so it sets the PcdPciMmio64Size based on the DT description of the PCIe root complex. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/ArmVirtQemu.dsc | 1 + ArmVirtPkg/ArmVirtQemuKernel.dsc | 1 + ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.c | 31 ++++++++++++-------- ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf | 1 + 4 files changed, 21 insertions(+), 13 deletions(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc index a3beb4654072..fa2b547ac486 100644 --- a/ArmVirtPkg/ArmVirtQemu.dsc +++ b/ArmVirtPkg/ArmVirtQemu.dsc @@ -206,6 +206,7 @@ [PcdsDynamicDefault.common] gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xFFFFFFFFFFFFFFFF gArmTokenSpaceGuid.PcdPciIoTranslation|0x0 + gArmTokenSpaceGuid.PcdPciMmio64Size|0x0 # # Set video resolution for boot options and for text setup. diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc index e0dcf4300338..d80079c45c28 100644 --- a/ArmVirtPkg/ArmVirtQemuKernel.dsc +++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc @@ -202,6 +202,7 @@ [PcdsDynamicDefault.common] gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xFFFFFFFFFFFFFFFF gArmTokenSpaceGuid.PcdPciIoTranslation|0x0 + gArmTokenSpaceGuid.PcdPciMmio64Size|0x0 # # Set video resolution for boot options and for text setup. diff --git a/ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.c b/ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.c index ea27cda7b77c..ea35c6df2546 100644 --- a/ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.c +++ b/ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.c @@ -44,11 +44,12 @@ typedef struct { #define DTB_PCI_HOST_RANGE_TYPEMASK (BIT31 | BIT30 | BIT29 | BIT25 | BIT24) STATIC -RETURN_STATUS -GetPciIoTranslation ( +VOID +GetPciIoTranslationAndMmio64Size ( IN FDT_CLIENT_PROTOCOL *FdtClient, IN INT32 Node, - OUT UINT64 *IoTranslation + OUT UINT64 *IoTranslation, + OUT UINT64 *Mmio64Size ) { UINT32 RecordIdx; @@ -64,24 +65,25 @@ GetPciIoTranslation ( if (EFI_ERROR (Status) || Len == 0 || Len % sizeof (DTB_PCI_HOST_RANGE_RECORD) != 0) { DEBUG ((EFI_D_ERROR, "%a: 'ranges' not found or invalid\n", __FUNCTION__)); - return RETURN_PROTOCOL_ERROR; + return; } for (RecordIdx = 0; RecordIdx < Len / sizeof (DTB_PCI_HOST_RANGE_RECORD); ++RecordIdx) { CONST DTB_PCI_HOST_RANGE_RECORD *Record; - UINT32 Type; Record = (CONST DTB_PCI_HOST_RANGE_RECORD *)Prop + RecordIdx; - Type = SwapBytes32 (Record->Type) & DTB_PCI_HOST_RANGE_TYPEMASK; - if (Type == DTB_PCI_HOST_RANGE_IO) { + switch (SwapBytes32 (Record->Type) & DTB_PCI_HOST_RANGE_TYPEMASK) { + case DTB_PCI_HOST_RANGE_IO: IoBase = SwapBytes64 (Record->ChildBase); *IoTranslation = SwapBytes64 (Record->CpuBase) - IoBase; + break; - return RETURN_SUCCESS; + case DTB_PCI_HOST_RANGE_MMIO64: + *Mmio64Size = SwapBytes64 (Record->Size); + break; } } - return RETURN_NOT_FOUND; } RETURN_STATUS @@ -96,8 +98,8 @@ FdtPciPcdProducerLibConstructor ( UINT32 RegSize; EFI_STATUS Status; INT32 Node; - RETURN_STATUS RetStatus; UINT64 IoTranslation; + UINT64 Mmio64Size; PciExpressBaseAddress = PcdGet64 (PcdPciExpressBaseAddress); if (PciExpressBaseAddress != MAX_UINT64) { @@ -128,9 +130,11 @@ FdtPciPcdProducerLibConstructor ( PcdSetBool (PcdPciDisableBusEnumeration, FALSE); - IoTranslation = 0; - RetStatus = GetPciIoTranslation (FdtClient, Node, &IoTranslation); - if (!RETURN_ERROR (RetStatus)) { + IoTranslation = MAX_UINT64; + Mmio64Size = 0; + GetPciIoTranslationAndMmio64Size (FdtClient, Node, &IoTranslation, + &Mmio64Size); + if (IoTranslation != MAX_UINT64) { PcdSet64 (PcdPciIoTranslation, IoTranslation); } else { // @@ -142,6 +146,7 @@ FdtPciPcdProducerLibConstructor ( "%a: 'pci-host-ecam-generic' device encountered with no I/O range\n", __FUNCTION__)); } + PcdSet64 (PcdPciMmio64Size, Mmio64Size); } } diff --git a/ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf b/ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf index cd138fa1aa6e..d29bcb0a801b 100644 --- a/ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf +++ b/ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf @@ -42,6 +42,7 @@ [Protocols] [Pcd] gArmTokenSpaceGuid.PcdPciIoTranslation ## PRODUCES + gArmTokenSpaceGuid.PcdPciMmio64Size ## PRODUCES gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress ## PRODUCES gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration ## PRODUCES