From patchwork Fri May 29 12:33:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 49170 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1E519218EC for ; Fri, 29 May 2015 12:34:24 +0000 (UTC) Received: by wifq9 with SMTP id q9sf5822701wif.3 for ; Fri, 29 May 2015 05:34:23 -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=zT97muMlcT65qkVJ2W6HKfAlTO29nUqWFHs42zW4fRA=; b=fXpkRjrlr58UxUMZyawh9xad44L+a8oQjg3GK3FSLAe3DsDt/R3XRWQa//jZcn2+Ad M0rss6/seEEuwqani8aOHGrccDQNdO7o31Wr0uJlRgwykOQpJ5vtTp1SDgrkDSgBKqsW sZvO/bR9Sdh0PE1AXzRnlqnl5AcdWqL3MKNkVrZ0/GlFk5R6HJQPqb1k/3H40SH7kyu+ w1Gy3IdVRhaneHvPtuCCPNkKQ02MqXPpQ5Gz9YVTrmDphWtvjDXE2GBda7TaM8KQSIvh JErWshVbbkB/TXDLrXjLAJevf/WWQTgs32dxCfX1v5kSnIK44D4WHZKED+faexOncPsz NoHA== X-Gm-Message-State: ALoCoQkNvLFvOZC0eTnN+e4Vq6qn6H4/KC4dhUfgjGWhPRGCK+CtuV16b2FcWkDVayV6EhPZtwf7 X-Received: by 10.112.118.162 with SMTP id kn2mr7279262lbb.22.1432902863330; Fri, 29 May 2015 05:34:23 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.34 with SMTP id p2ls135669lap.32.gmail; Fri, 29 May 2015 05:34:23 -0700 (PDT) X-Received: by 10.153.6.36 with SMTP id cr4mr7911037lad.56.1432902863177; Fri, 29 May 2015 05:34:23 -0700 (PDT) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id c10si4555053laa.171.2015.05.29.05.34.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 May 2015 05:34:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by lbcue7 with SMTP id ue7so47479583lbc.0 for ; Fri, 29 May 2015 05:34:22 -0700 (PDT) X-Received: by 10.153.6.36 with SMTP id cr4mr7910996lad.56.1432902862747; Fri, 29 May 2015 05:34:22 -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 hn6csp290852lbb; Fri, 29 May 2015 05:34:21 -0700 (PDT) X-Received: by 10.107.11.26 with SMTP id v26mr9788969ioi.8.1432902859599; Fri, 29 May 2015 05:34:19 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id e5si1436644igz.54.2015.05.29.05.34.18 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 29 May 2015 05:34:19 -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-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YyJUG-000782-Gc; Fri, 29 May 2015 12:34:08 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YyJUF-00077p-IQ for edk2-devel@lists.sourceforge.net; Fri, 29 May 2015 12:34:07 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of linaro.org designates 209.85.212.175 as permitted sender) client-ip=209.85.212.175; envelope-from=ard.biesheuvel@linaro.org; helo=mail-wi0-f175.google.com; Received: from mail-wi0-f175.google.com ([209.85.212.175]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YyJUE-00077U-9j for edk2-devel@lists.sourceforge.net; Fri, 29 May 2015 12:34:07 +0000 Received: by wizo1 with SMTP id o1so21897805wiz.1 for ; Fri, 29 May 2015 05:34:00 -0700 (PDT) X-Received: by 10.194.216.196 with SMTP id os4mr15026103wjc.117.1432902840311; Fri, 29 May 2015 05:34:00 -0700 (PDT) Received: from localhost.localdomain ([109.112.79.182]) by mx.google.com with ESMTPSA id ex5sm2953226wib.2.2015.05.29.05.33.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 May 2015 05:33:59 -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:40 +0200 Message-Id: <1432902820-18721-8-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 -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1YyJUE-00077U-9j Subject: [edk2] [PATCH 7/7] ArmVirtPkg: implement DT-based 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.170 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 Since it is arguably incorrect to infer the GIC revision from CPU ID and GIC feature registers on platforms that describe the GIC in the device tree, this implements the library class ArmGicArchLib tailored for such platforms. The supported GIC revision is retrieved from the dynamic PCD that is set based on the GIC DT node. This means this library can only execute post DXE core, but this is not a problem for any of the virt platforms. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/ArmVirt.dsc.inc | 2 +- ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c | 75 ++++++++++++ ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.inf | 40 ++++++ 3 files changed, 116 insertions(+), 1 deletion(-) diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc index 900d5c3d9dd0..fd20ff39a068 100644 --- a/ArmVirtPkg/ArmVirt.dsc.inc +++ b/ArmVirtPkg/ArmVirt.dsc.inc @@ -71,7 +71,7 @@ ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf DmaLib|ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf - ArmGicArchLib|ArmPkg/Library/ArmGicArchLib/ArmGicArchLib.inf + ArmGicArchLib|ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.inf ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf ArmHvcLib|ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf diff --git a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c new file mode 100644 index 000000000000..732860cadfe6 --- /dev/null +++ b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c @@ -0,0 +1,75 @@ +/** @file + ArmGicArchLib library class implementation for DT based virt platforms + + Copyright (c) 2015, Linaro Ltd. All rights reserved.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +#include +#include +#include +#include + +STATIC ARM_GIC_ARCH_REVISION mGicArchRevision; + +RETURN_STATUS +EFIAPI +ArmVirtGicArchLibConstructor ( + VOID + ) +{ + UINT32 IccSre; + + switch (PcdGet32 (PcdArmGicRevision)) { + + case 3: + // + // The default implementation of ArmGicArchLib is responsible for enabling + // the system register interface on the GICv3 if one is found. So let's do + // the same here. + // + IccSre = ArmGicV3GetControlSystemRegisterEnable (); + if (!(IccSre & ICC_SRE_EL2_SRE)) { + ArmGicV3SetControlSystemRegisterEnable (IccSre | ICC_SRE_EL2_SRE); + IccSre = ArmGicV3GetControlSystemRegisterEnable (); + } + + // + // Unlike the default implementation, there is no fall through to GICv2 + // mode if this GICv3 cannot be driven in native mode due to the fact + // that the System Register interface is unavailable. + // + ASSERT (IccSre & ICC_SRE_EL2_SRE); + + mGicArchRevision = ARM_GIC_ARCH_REVISION_3; + break; + + case 2: + mGicArchRevision = ARM_GIC_ARCH_REVISION_2; + break; + + default: + DEBUG ((EFI_D_ERROR, "%a: No GIC revision specified!\n", __FUNCTION__)); + return RETURN_NOT_FOUND; + } + return RETURN_SUCCESS; +} + +ARM_GIC_ARCH_REVISION +EFIAPI +ArmGicGetSupportedArchRevision ( + VOID + ) +{ + return mGicArchRevision; +} diff --git a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.inf b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.inf new file mode 100644 index 000000000000..c85b2d44d856 --- /dev/null +++ b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.inf @@ -0,0 +1,40 @@ +#/** @file +# +# Component description file for ArmVirtGicArchLib module +# +# Copyright (c) 2015, Linaro Ltd. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +#**/ + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = ArmVirtGicArchLib + FILE_GUID = 87b0dc84-4661-4deb-a789-97977ff636ed + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = ArmGicArchLib|DXE_DRIVER UEFI_DRIVER UEFI_APPLICATION + CONSTRUCTOR = ArmVirtGicArchLibConstructor + +[Sources] + ArmVirtGicArchLib.c + +[LibraryClasses] + PcdLib + DebugLib + ArmGicLib + +[Packages] + MdePkg/MdePkg.dec + ArmPkg/ArmPkg.dec + ArmVirtPkg/ArmVirtPkg.dec + +[Pcd] + gArmVirtTokenSpaceGuid.PcdArmGicRevision