From patchwork Fri Apr 8 09:45:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 65377 Delivered-To: patch@linaro.org Received: by 10.112.43.237 with SMTP id z13csp569374lbl; Fri, 8 Apr 2016 02:46:08 -0700 (PDT) X-Received: by 10.50.20.104 with SMTP id m8mr2513981ige.43.1460108754659; Fri, 08 Apr 2016 02:45:54 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id y7si2453669igl.5.2016.04.08.02.45.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Apr 2016 02:45:54 -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 963451A1FD0; Fri, 8 Apr 2016 02:45:41 -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 9F5F71A1FD0 for ; Fri, 8 Apr 2016 02:45:39 -0700 (PDT) Received: by mail-wm0-x231.google.com with SMTP id l6so57639174wml.1 for ; Fri, 08 Apr 2016 02:45:39 -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=YUpdqqz6OnPMNY8u53UpnmMixufe/K83Sl+WESCMG94=; b=iFT6Ba0wWC5doZOJVYTeji9dNQh2fPufxX2+JmSioEEHkd+2L+78P9hPuSLgYavpUd 9KjrebBNFH2M6+ZEY0rp2q2riJkXTmR3u09C8dqIzdlSkdYrVEmuOOVj8JQjLnDuVKvR 07SKGZ0cDNG5yCV32vfBJyA175D6Fk2eCDdSM= 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=YUpdqqz6OnPMNY8u53UpnmMixufe/K83Sl+WESCMG94=; b=W8WcyYi0+sli8s2JrY8sYnMLnVa7VzNq+KKDy8RJ77CpS+QMdik0mOdDI5/VO1IJpa IqdfFbqn5YxHvlItX18xpv7Le31UuFAgt1KSGqeM4rGy8TFU+LNttDvDXS9qOBjSlnRc 2J36jYTQ7bLgQ0cfvl52IBT/jyaNkBperTeTXRkSaIzcIojNKbI1WWo7yxfBIBkI3C6Y 98+PAQ+Rd5ATur3+NQQeZtD7lFfM8QfLC8b6KSGKSf36waOBKXbEfFqKfWkwJx0xYThq 7X5c82EcqLFtlA+sJbSgKKcg9e54WZ1WyhVFAMOBCJdWSAc+43IJKikWgFFxuiUzWDzO QsgQ== X-Gm-Message-State: AD7BkJImUN5AxM7G0N5RwinnelKZ0S9jL1FIVVqQ+A0trCmHn6eD/yDgC0uf7Uz1kPM0SU3h X-Received: by 10.194.84.2 with SMTP id u2mr8296042wjy.61.1460108738231; Fri, 08 Apr 2016 02:45:38 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id s10sm9710681wjp.3.2016.04.08.02.45.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Apr 2016 02:45:37 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, lersek@redhat.com Date: Fri, 8 Apr 2016 11:45:00 +0200 Message-Id: <1460108711-12122-14-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1460108711-12122-1-git-send-email-ard.biesheuvel@linaro.org> References: <1460108711-12122-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 13/24] 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..0ce6d118483b 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 = MAX_UINT64; /** Gets the base address of PCI Express. @@ -92,6 +81,9 @@ GetPciExpressBaseAddress ( VOID ) { + if (mPciExpressBaseAddress == MAX_UINT64) { + mPciExpressBaseAddress = PcdGet64 (PcdPciExpressBaseAddress); + } return (VOID*)(UINTN) mPciExpressBaseAddress; }