From patchwork Wed Apr 6 16:15:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 65205 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1147364lbc; Wed, 6 Apr 2016 09:16:25 -0700 (PDT) X-Received: by 10.98.73.132 with SMTP id r4mr39748413pfi.118.1459959383421; Wed, 06 Apr 2016 09:16:23 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id 18si5506664pfh.24.2016.04.06.09.16.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Apr 2016 09:16:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; 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 198.145.21.10 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 C176F1A1FE2; Wed, 6 Apr 2016 09:15:56 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wm0-x234.google.com (mail-wm0-x234.google.com [IPv6:2a00:1450:400c:c09::234]) (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 9923B1A1FE2 for ; Wed, 6 Apr 2016 09:15:55 -0700 (PDT) Received: by mail-wm0-x234.google.com with SMTP id u206so52747920wme.1 for ; Wed, 06 Apr 2016 09:15:55 -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=9S5CmLDCSKy/SpyTtFh6v0tTMZw5zJRz7echBdzPTc0=; b=W5Lwo4cyXdS7b6XZS0WuONDQOL2BUI47reyS9ctwBt13Y0LK9feaQWP89Ow7x82YxR 4NwJ/mWaiZxVjTn6h0NL9s669+bENZ9aZSz5gn1Uk8tqCant/5w+IEKMiD0jvJXnRLLZ C7I+YEN0tdr5NYNe74z2HA81M1nSqeGF5tFO8= 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=9S5CmLDCSKy/SpyTtFh6v0tTMZw5zJRz7echBdzPTc0=; b=COjpsEzjZvxNB2SE/oXVSkMzkKVA2SoJKBG/zxRWXKZlAnTrwQ8T472TX7HMFoICXL zQ7yTZ/Y/7sZKUYs5PpIrgMcByuF858G682jwja4SGgHktF2n/ZHvc98naIe17hHYT+t y7vCL17MA7dk/hErx+qhYmX6YITS90gYpMeXh5/WMohxUcxNoRDzm+PGhvBIDow7UJXt qS0VhFue5CXb8V7R+2SdeXKgUOcZ5rfNgJg7OQYsXAK4JAQ6E70/0CQ3DRkP7GSbpOcN iDkpHnaAeh0/KmLZChY/sfl7GmPYS1a1FdOca4rFp3vG7R5rsXccjR7cOyCb8yF17dZt F73g== X-Gm-Message-State: AD7BkJI3w0LKyd00vIB//A6kAPYH08FVC8n1tg1+93czOrXV/dxE4CgVsrAXxRNgvuO0du6r X-Received: by 10.28.40.214 with SMTP id o205mr25269976wmo.89.1459959354357; Wed, 06 Apr 2016 09:15:54 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id om6sm3961219wjc.40.2016.04.06.09.15.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Apr 2016 09:15:53 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, lersek@redhat.com Date: Wed, 6 Apr 2016 18:15:14 +0200 Message-Id: <1459959319-19293-17-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459959319-19293-1-git-send-email-ard.biesheuvel@linaro.org> References: <1459959319-19293-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 16/21] ArmVirtPkg/BaseCachingPciExpressLib: construct at first invocation 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" Instead of using a constructor, which may reference a dynamic PCD which is set by the DXE entry point of its user, defer the assignment of the global mPciExpressBaseAddress until the first the library is actually invoked. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/Library/BaseCachingPciExpressLib/BaseCachingPciExpressLib.inf | 1 - ArmVirtPkg/Library/BaseCachingPciExpressLib/PciExpressLib.c | 16 ++++------------ 2 files changed, 4 insertions(+), 13 deletions(-) -- 2.5.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/ArmVirtPkg/Library/BaseCachingPciExpressLib/BaseCachingPciExpressLib.inf b/ArmVirtPkg/Library/BaseCachingPciExpressLib/BaseCachingPciExpressLib.inf index f6a346d49f22..5374f1b9a369 100644 --- a/ArmVirtPkg/Library/BaseCachingPciExpressLib/BaseCachingPciExpressLib.inf +++ b/ArmVirtPkg/Library/BaseCachingPciExpressLib/BaseCachingPciExpressLib.inf @@ -23,7 +23,6 @@ [Defines] MODULE_TYPE = BASE VERSION_STRING = 1.0 LIBRARY_CLASS = PciExpressLib|DXE_DRIVER UEFI_DRIVER UEFI_APPLICATION - CONSTRUCTOR = PciExpressLibInitialize # # VALID_ARCHITECTURES = ARM AARCH64 diff --git a/ArmVirtPkg/Library/BaseCachingPciExpressLib/PciExpressLib.c b/ArmVirtPkg/Library/BaseCachingPciExpressLib/PciExpressLib.c index 6479f53b3714..6135d49a7854 100644 --- a/ArmVirtPkg/Library/BaseCachingPciExpressLib/PciExpressLib.c +++ b/ArmVirtPkg/Library/BaseCachingPciExpressLib/PciExpressLib.c @@ -68,18 +68,7 @@ PciExpressRegisterForRuntimeAccess ( return RETURN_UNSUPPORTED; } -STATIC UINT64 mPciExpressBaseAddress; - -RETURN_STATUS -EFIAPI -PciExpressLibInitialize ( - VOID - ) -{ - mPciExpressBaseAddress = PcdGet64 (PcdPciExpressBaseAddress); - return RETURN_SUCCESS; -} - +STATIC UINT64 mPciExpressBaseAddress = 0xFFFFFFFFFFFFFFFFULL; /** Gets the base address of PCI Express. @@ -92,6 +81,9 @@ GetPciExpressBaseAddress ( VOID ) { + if (mPciExpressBaseAddress == 0xFFFFFFFFFFFFFFFFULL) { + mPciExpressBaseAddress = PcdGet64 (PcdPciExpressBaseAddress); + } return (VOID*)(UINTN) mPciExpressBaseAddress; }