From patchwork Wed Nov 12 11:46:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 40659 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 432E2206A5 for ; Wed, 12 Nov 2014 11:46:58 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id gq15sf7637586lab.2 for ; Wed, 12 Nov 2014 03:46:57 -0800 (PST) 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:cc:subject :precedence:reply-to:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=ez4mDJfLypSR7EaVehxtoNyQUaeAIHwGTTkQHMozl34=; b=XQDcIL71EtpAE7VtPcMbRB1bMzCxpw97V84lLw5lhNHqfivh/n9TZxnwPBunQw7sxT 2wJMuqcF+gIt8LHUrBj8vDa2om1HpwT/cADjGInKkzS3lhp92aTMao8ljStmF1vvMDDb YJfdNNjnJx4PRX/YDG96o7r4fBVUHk0tNOzdVf83yBGDxJvBg6FA1m7H/vMzUXH/j9Tl 4oa6X3v0hJchzWL6piTS3dYacW/1kSMlA8ndVew667XBPbZB3UpT0mV1en0FUuULAqCy uFXNL/eQLHMO2TeqGFcDxigNeLYWQdZj8ugzSleuKiHuIxnkKqMZx1NdUqM3LDdpMbDV yCXw== X-Gm-Message-State: ALoCoQlx/J/xDO8lqekemcGG/ueCP7Jw7Rz9psAcPLc8gdJaydoDtNjD65VVqi5SWNfb0ed36wF+ X-Received: by 10.181.27.135 with SMTP id jg7mr6527746wid.5.1415792817171; Wed, 12 Nov 2014 03:46:57 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.4.132 with SMTP id k4ls203985lak.12.gmail; Wed, 12 Nov 2014 03:46:56 -0800 (PST) X-Received: by 10.152.120.133 with SMTP id lc5mr41971070lab.62.1415792816357; Wed, 12 Nov 2014 03:46:56 -0800 (PST) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id p8si32255748laj.1.2014.11.12.03.46.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Nov 2014 03:46:56 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by mail-la0-f53.google.com with SMTP id mc6so11007098lab.26 for ; Wed, 12 Nov 2014 03:46:56 -0800 (PST) X-Received: by 10.112.14.69 with SMTP id n5mr41742642lbc.34.1415792816224; Wed, 12 Nov 2014 03:46:56 -0800 (PST) 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.184.201 with SMTP id ew9csp408700lbc; Wed, 12 Nov 2014 03:46:55 -0800 (PST) X-Received: by 10.50.50.165 with SMTP id d5mr39516250igo.16.1415792814877; Wed, 12 Nov 2014 03:46:54 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id x10si23245674igl.15.2014.11.12.03.46.54 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 12 Nov 2014 03:46:54 -0800 (PST) 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 1XoWNn-0003I8-QZ; Wed, 12 Nov 2014 11:46:43 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XoWNm-0003Hz-Fa for edk2-devel@lists.sourceforge.net; Wed, 12 Nov 2014 11:46:42 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of linaro.org designates 74.125.82.43 as permitted sender) client-ip=74.125.82.43; envelope-from=ard.biesheuvel@linaro.org; helo=mail-wg0-f43.google.com; Received: from mail-wg0-f43.google.com ([74.125.82.43]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1XoWNl-0004SS-EW for edk2-devel@lists.sourceforge.net; Wed, 12 Nov 2014 11:46:42 +0000 Received: by mail-wg0-f43.google.com with SMTP id y10so13887960wgg.30 for ; Wed, 12 Nov 2014 03:46:35 -0800 (PST) X-Received: by 10.180.206.4 with SMTP id lk4mr49565506wic.47.1415792795358; Wed, 12 Nov 2014 03:46:35 -0800 (PST) Received: from ards-macbook-pro.local (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by mx.google.com with ESMTPSA id mw7sm21332358wib.14.2014.11.12.03.46.33 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Nov 2014 03:46:34 -0800 (PST) From: Ard Biesheuvel To: olivier.martin@arm.com, edk2-devel@lists.sourceforge.net Date: Wed, 12 Nov 2014 12:46:32 +0100 Message-Id: <1415792793-8488-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 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: 1XoWNl-0004SS-EW Cc: marc.zyngier@arm.com, kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org Subject: [edk2] [PATCH 1/2] ArmGicLib: cache GIC arch revision in global variable 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.215.53 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 Before extending the GIC arch revision check to support an emulated GICv2 on GICv3 capable hardware in the next patch, add a constructor to ArmGicLib that caches the result of the check so we don't have to go through it on every call into ArmGicLib. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- ArmPkg/Drivers/ArmGic/ArmGicLib.c | 42 +++++++++++++++++++------------------ ArmPkg/Drivers/ArmGic/ArmGicLib.inf | 1 + 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/ArmPkg/Drivers/ArmGic/ArmGicLib.c b/ArmPkg/Drivers/ArmGic/ArmGicLib.c index 1e5924f5a49f..c48b97e3eb4d 100644 --- a/ArmPkg/Drivers/ArmGic/ArmGicLib.c +++ b/ArmPkg/Drivers/ArmGic/ArmGicLib.c @@ -20,6 +20,8 @@ #include "GicV2/ArmGicV2Lib.h" #include "GicV3/ArmGicV3Lib.h" +STATIC ARM_GIC_ARCH_REVISION mGicArchRevision; + UINTN EFIAPI ArmGicGetInterfaceIdentification ( @@ -72,10 +74,7 @@ ArmGicAcknowledgeInterrupt ( ) { UINTN Value; - ARM_GIC_ARCH_REVISION Revision; - - Revision = ArmGicGetSupportedArchRevision (); - if (Revision == ARM_GIC_ARCH_REVISION_2) { + if (mGicArchRevision == ARM_GIC_ARCH_REVISION_2) { Value = ArmGicV2AcknowledgeInterrupt (GicInterruptInterfaceBase); // InterruptId is required for the caller to know if a valid or spurious // interrupt has been read @@ -83,7 +82,7 @@ ArmGicAcknowledgeInterrupt ( if (InterruptId != NULL) { *InterruptId = Value & ARM_GIC_ICCIAR_ACKINTID; } - } else if (Revision == ARM_GIC_ARCH_REVISION_3) { + } else if (mGicArchRevision == ARM_GIC_ARCH_REVISION_3) { Value = ArmGicV3AcknowledgeInterrupt (); } else { ASSERT_EFI_ERROR (EFI_UNSUPPORTED); @@ -102,12 +101,9 @@ ArmGicEndOfInterrupt ( IN UINTN Source ) { - ARM_GIC_ARCH_REVISION Revision; - - Revision = ArmGicGetSupportedArchRevision (); - if (Revision == ARM_GIC_ARCH_REVISION_2) { + if (mGicArchRevision == ARM_GIC_ARCH_REVISION_2) { ArmGicV2EndOfInterrupt (GicInterruptInterfaceBase, Source); - } else if (Revision == ARM_GIC_ARCH_REVISION_3) { + } else if (mGicArchRevision == ARM_GIC_ARCH_REVISION_3) { ArmGicV3EndOfInterrupt (Source); } else { ASSERT_EFI_ERROR (EFI_UNSUPPORTED); @@ -183,12 +179,9 @@ ArmGicEnableInterruptInterface ( IN INTN GicInterruptInterfaceBase ) { - ARM_GIC_ARCH_REVISION Revision; - - Revision = ArmGicGetSupportedArchRevision (); - if (Revision == ARM_GIC_ARCH_REVISION_2) { + if (mGicArchRevision == ARM_GIC_ARCH_REVISION_2) { ArmGicV2EnableInterruptInterface (GicInterruptInterfaceBase); - } else if (Revision == ARM_GIC_ARCH_REVISION_3) { + } else if (mGicArchRevision == ARM_GIC_ARCH_REVISION_3) { ArmGicV3EnableInterruptInterface (); } else { ASSERT_EFI_ERROR (EFI_UNSUPPORTED); @@ -201,14 +194,23 @@ ArmGicDisableInterruptInterface ( IN INTN GicInterruptInterfaceBase ) { - ARM_GIC_ARCH_REVISION Revision; - - Revision = ArmGicGetSupportedArchRevision (); - if (Revision == ARM_GIC_ARCH_REVISION_2) { + if (mGicArchRevision == ARM_GIC_ARCH_REVISION_2) { ArmGicV2DisableInterruptInterface (GicInterruptInterfaceBase); - } else if (Revision == ARM_GIC_ARCH_REVISION_3) { + } else if (mGicArchRevision == ARM_GIC_ARCH_REVISION_3) { ArmGicV3DisableInterruptInterface (); } else { ASSERT_EFI_ERROR (EFI_UNSUPPORTED); } } + + +RETURN_STATUS +EFIAPI +ArmGicLibInitialize ( + VOID + ) +{ + mGicArchRevision = ArmGicGetSupportedArchRevision (); + + return RETURN_SUCCESS; +} diff --git a/ArmPkg/Drivers/ArmGic/ArmGicLib.inf b/ArmPkg/Drivers/ArmGic/ArmGicLib.inf index 81282b9b8299..ceeb95c53e98 100644 --- a/ArmPkg/Drivers/ArmGic/ArmGicLib.inf +++ b/ArmPkg/Drivers/ArmGic/ArmGicLib.inf @@ -18,6 +18,7 @@ MODULE_TYPE = SEC VERSION_STRING = 1.0 LIBRARY_CLASS = ArmGicLib + CONSTRUCTOR = ArmGicLibInitialize [Sources] ArmGicLib.c