From patchwork Fri May 29 12:33:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 49169 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 58024218EC for ; Fri, 29 May 2015 12:34:21 +0000 (UTC) Received: by laat2 with SMTP id t2sf20127214laa.2 for ; Fri, 29 May 2015 05:34:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=pupXtYHo3JLJhZquqJ8cBPR2OPSQ6jVq7//8ABDnDF0=; b=Pj8bkL0vv6O1MZAJf3xoGyYorkUw9toNCTITYsdr4V9bCXxcOUcqrtYFii60PYE2bm gznK+nDwsGdYW+Zr88bHulVx1Zd1/UnHWxJQNQ23pPlfHtCbyT+cTaeG4xV8r/Qyu8fc SsHrZ1UjGff8nxn6cGYix8OQBV8H5cr136AgGmI/ympjVVAFy8qvjU++Sl5Cqne8xqmN AQn+8hGUELirsbcz0REzMkY8XXV/lcKY7IpvrbfxaYTAHmXwq4r6AJk6RCHcByoD5ntE DOfQ92LY7D3maijRWMrfv/GDXXYZ6N+8xWsfWMTDQKH/Y1oOTnvPBgkAkHKFgVd7MoXc Cyfg== X-Gm-Message-State: ALoCoQlJhDfSyJO66bj0jR0M9bkAnP7A/LuOEnsKN8THVUo9JKw7tZAa5pPtzV/rJ2xQ7fOj5qpl X-Received: by 10.180.105.226 with SMTP id gp2mr2758921wib.1.1432902860095; Fri, 29 May 2015 05:34:20 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.22.10 with SMTP id z10ls338318lae.24.gmail; Fri, 29 May 2015 05:34:19 -0700 (PDT) X-Received: by 10.112.145.132 with SMTP id su4mr7535079lbb.85.1432902859925; Fri, 29 May 2015 05:34:19 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id k5si4583338lbd.83.2015.05.29.05.34.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 May 2015 05:34:19 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by lbbuc2 with SMTP id uc2so47528954lbb.2 for ; Fri, 29 May 2015 05:34:19 -0700 (PDT) X-Received: by 10.112.29.36 with SMTP id g4mr7923296lbh.56.1432902859337; Fri, 29 May 2015 05:34:19 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp290813lbb; Fri, 29 May 2015 05:34:18 -0700 (PDT) X-Received: by 10.43.152.204 with SMTP id kx12mr14436809icc.51.1432902855483; Fri, 29 May 2015 05:34:15 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id fm15si4708782icb.6.2015.05.29.05.34.14 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 29 May 2015 05:34:15 -0700 (PDT) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YyJUB-0000Iu-S1; Fri, 29 May 2015 12:34:03 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YyJUB-0000Io-2n for edk2-devel@lists.sourceforge.net; Fri, 29 May 2015 12:34:03 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of linaro.org designates 209.85.212.181 as permitted sender) client-ip=209.85.212.181; envelope-from=ard.biesheuvel@linaro.org; helo=mail-wi0-f181.google.com; Received: from mail-wi0-f181.google.com ([209.85.212.181]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YyJUA-0007mF-7R for edk2-devel@lists.sourceforge.net; Fri, 29 May 2015 12:34:03 +0000 Received: by wifw1 with SMTP id w1so21969275wif.0 for ; Fri, 29 May 2015 05:33:56 -0700 (PDT) X-Received: by 10.194.95.41 with SMTP id dh9mr15078100wjb.55.1432902836260; Fri, 29 May 2015 05:33:56 -0700 (PDT) Received: from localhost.localdomain ([109.112.79.182]) by mx.google.com with ESMTPSA id ex5sm2953226wib.2.2015.05.29.05.33.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 May 2015 05:33:55 -0700 (PDT) From: Ard Biesheuvel To: lersek@redhat.com, olivier.martin@arm.com, leif.lindholm@linaro.org, edk2-devel@lists.sourceforge.net Date: Fri, 29 May 2015 14:33:38 +0200 Message-Id: <1432902820-18721-6-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1432902820-18721-1-git-send-email-ard.biesheuvel@linaro.org> References: <1432902820-18721-1-git-send-email-ard.biesheuvel@linaro.org> X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1YyJUA-0007mF-7R Subject: [edk2] [PATCH 5/7] ArmPkg: cache detected revision in ArmGicArchLib X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Instead of inferring the GIC revision from the CPU id registers and the presence/availability of the system register interface upon each invocation, move the logic to a constructor and cache the result. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- ArmPkg/Library/ArmGicArchLib/AArch64/ArmGicArchLib.c | 23 ++++++++++-- ArmPkg/Library/ArmGicArchLib/Arm/ArmGicArchLib.c | 23 ++++++++++-- ArmPkg/Library/ArmGicArchLib/ArmGicArchLib.inf | 3 +- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/ArmPkg/Library/ArmGicArchLib/AArch64/ArmGicArchLib.c b/ArmPkg/Library/ArmGicArchLib/AArch64/ArmGicArchLib.c index 0e0fa3b9f33e..9853c7ba8566 100644 --- a/ArmPkg/Library/ArmGicArchLib/AArch64/ArmGicArchLib.c +++ b/ArmPkg/Library/ArmGicArchLib/AArch64/ArmGicArchLib.c @@ -15,9 +15,11 @@ #include #include -ARM_GIC_ARCH_REVISION +STATIC ARM_GIC_ARCH_REVISION mGicArchRevision; + +RETURN_STATUS EFIAPI -ArmGicGetSupportedArchRevision ( +ArmGicArchLibInitialize ( VOID ) { @@ -43,9 +45,22 @@ ArmGicGetSupportedArchRevision ( IccSre = ArmGicV3GetControlSystemRegisterEnable (); } if (IccSre & ICC_SRE_EL2_SRE) { - return ARM_GIC_ARCH_REVISION_3; + mGicArchRevision = ARM_GIC_ARCH_REVISION_3; + goto Done; } } - return ARM_GIC_ARCH_REVISION_2; + mGicArchRevision = ARM_GIC_ARCH_REVISION_2; + +Done: + return RETURN_SUCCESS; +} + +ARM_GIC_ARCH_REVISION +EFIAPI +ArmGicGetSupportedArchRevision ( + VOID + ) +{ + return mGicArchRevision; } diff --git a/ArmPkg/Library/ArmGicArchLib/Arm/ArmGicArchLib.c b/ArmPkg/Library/ArmGicArchLib/Arm/ArmGicArchLib.c index f256de704631..f8822a224580 100644 --- a/ArmPkg/Library/ArmGicArchLib/Arm/ArmGicArchLib.c +++ b/ArmPkg/Library/ArmGicArchLib/Arm/ArmGicArchLib.c @@ -15,9 +15,11 @@ #include #include -ARM_GIC_ARCH_REVISION +STATIC ARM_GIC_ARCH_REVISION mGicArchRevision; + +RETURN_STATUS EFIAPI -ArmGicGetSupportedArchRevision ( +ArmGicArchLibInitialize ( VOID ) { @@ -43,9 +45,22 @@ ArmGicGetSupportedArchRevision ( IccSre = ArmGicV3GetControlSystemRegisterEnable (); } if (IccSre & ICC_SRE_EL2_SRE) { - return ARM_GIC_ARCH_REVISION_3; + mGicArchRevision = ARM_GIC_ARCH_REVISION_3; + goto Done; } } - return ARM_GIC_ARCH_REVISION_2; + mGicArchRevision = ARM_GIC_ARCH_REVISION_2; + +Done: + return RETURN_SUCCESS; +} + +ARM_GIC_ARCH_REVISION +EFIAPI +ArmGicGetSupportedArchRevision ( + VOID + ) +{ + return mGicArchRevision; } diff --git a/ArmPkg/Library/ArmGicArchLib/ArmGicArchLib.inf b/ArmPkg/Library/ArmGicArchLib/ArmGicArchLib.inf index d71b2adc3027..7dbcb08f50d6 100644 --- a/ArmPkg/Library/ArmGicArchLib/ArmGicArchLib.inf +++ b/ArmPkg/Library/ArmGicArchLib/ArmGicArchLib.inf @@ -17,7 +17,8 @@ FILE_GUID = cd67f41a-26e9-4482-90c9-a9aff803382a MODULE_TYPE = BASE VERSION_STRING = 1.0 - LIBRARY_CLASS = ArmGicArchLib + LIBRARY_CLASS = ArmGicArchLib|DXE_DRIVER UEFI_DRIVER UEFI_APPLICATION + CONSTRUCTOR = ArmGicArchLibInitialize [Sources.ARM] Arm/ArmGicArchLib.c