From patchwork Thu Feb 5 10:28:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 44424 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 95F2021521 for ; Thu, 5 Feb 2015 10:29:38 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id n3sf5731938wiv.0 for ; Thu, 05 Feb 2015 02:29:37 -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: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=+nQR9hKHJWiBAsgIHUb4NUbZlXH663gquovm/eU5Zc4=; b=bPAuU0HXAoQgYNkcZ0cO/WC20pGWJkblg6pr7BDKtEDWkCAwTOp6DsioPMWnZpuIJv aGz/XnGPVrzRnCbpDelMvBJDURRVfcczfqrypXKYMvUw7b9n1B/zjRMUEYHf9p5JjZht 0/1CBVt3TLfUxfa75ic1wHvKW/QtvSzb3BjYWqTfCsgTzt+aihCNa4h0Fv12ZLIG564F KNJHeERKQCg3yEAAAQaKKvkHaPyN7wUbYZPURHcij6Rj7qFb9WAXbOpOI0giTSJmPkdS BMXcKayaREiDPwQWUHduuipDl7ScoA0vM8Sr371LckA3KOco+KOmYw5zt0uX95KA0yBA 2Zfw== X-Gm-Message-State: ALoCoQkdOOrMU93xDOvfG2Uht1Bg9uSPup8c0w91KNRvXPTCwGd9X7cdefY/tDu/nfKNfck6HDlo X-Received: by 10.180.182.47 with SMTP id eb15mr964203wic.5.1423132177944; Thu, 05 Feb 2015 02:29:37 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.9 with SMTP id p9ls130325lag.86.gmail; Thu, 05 Feb 2015 02:29:37 -0800 (PST) X-Received: by 10.152.185.72 with SMTP id fa8mr2498622lac.73.1423132177740; Thu, 05 Feb 2015 02:29:37 -0800 (PST) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id gf1si3532918lbc.139.2015.02.05.02.29.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Feb 2015 02:29:37 -0800 (PST) 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 mail-lb0-f170.google.com with SMTP id w7so6245627lbi.1 for ; Thu, 05 Feb 2015 02:29:37 -0800 (PST) X-Received: by 10.112.173.202 with SMTP id bm10mr2649055lbc.24.1423132177488; Thu, 05 Feb 2015 02:29:37 -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.35.133 with SMTP id h5csp1049543lbj; Thu, 5 Feb 2015 02:29:36 -0800 (PST) X-Received: by 10.107.19.38 with SMTP id b38mr3233388ioj.35.1423132171960; Thu, 05 Feb 2015 02:29:31 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id n91si1663821ioi.107.2015.02.05.02.29.31 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 05 Feb 2015 02:29:31 -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-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YJJgZ-0000tQ-U9; Thu, 05 Feb 2015 10:29:23 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YJJgY-0000tD-2b for edk2-devel@lists.sourceforge.net; Thu, 05 Feb 2015 10:29:22 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of linaro.org designates 74.125.82.51 as permitted sender) client-ip=74.125.82.51; envelope-from=ard.biesheuvel@linaro.org; helo=mail-wg0-f51.google.com; Received: from mail-wg0-f51.google.com ([74.125.82.51]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YJJgW-0000dS-Nx for edk2-devel@lists.sourceforge.net; Thu, 05 Feb 2015 10:29:22 +0000 Received: by mail-wg0-f51.google.com with SMTP id k14so6697975wgh.10 for ; Thu, 05 Feb 2015 02:29:14 -0800 (PST) X-Received: by 10.180.79.65 with SMTP id h1mr13514092wix.59.1423132154817; Thu, 05 Feb 2015 02:29:14 -0800 (PST) Received: from ards-macbook-pro.local (205.28.43.5.rev.vodafone.pt. [5.43.28.205]) by mx.google.com with ESMTPSA id x6sm6706609wjf.24.2015.02.05.02.29.12 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Feb 2015 02:29:14 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.sourceforge.net, lersek@redhat.com, olivier.martin@arm.com, roy.franz@linaro.org, leif.lindholm@linaro.org Date: Thu, 5 Feb 2015 10:28:56 +0000 Message-Id: <1423132136-19349-5-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1423132136-19349-1-git-send-email-ard.biesheuvel@linaro.org> References: <1423132136-19349-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: 1YJJgW-0000dS-Nx Subject: [edk2] [PATCH 4/4] ArmVirtualizationPkg: 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 This implements the library class ArmGicArchLib tailored for device tree based virt platforms. The recorded dynamic PCD is used to set the supported GIC version, which means this library can only execute post DXE core, but this is not a problem for the virt platforms. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- .../ArmVirtualizationPkg/ArmVirtualization.dsc.inc | 2 +- .../Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c | 77 ++++++++++++++++++++++ .../ArmVirtGicArchLib/ArmVirtGicArchLib.inf | 40 +++++++++++ 3 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c create mode 100644 ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.inf diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc index c72591ff48b7..345270f2eb19 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc +++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc @@ -68,7 +68,7 @@ ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf DmaLib|ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf - ArmGicArchLib|ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf + ArmGicArchLib|ArmPlatformPkg/ArmVirtualizationPkg/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/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c b/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c new file mode 100644 index 000000000000..45f5aec92bce --- /dev/null +++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c @@ -0,0 +1,77 @@ +/** @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 + +#include + +STATIC ARM_GIC_ARCH_REVISION mArmGicSupportedArchRevision; + +RETURN_STATUS +EFIAPI +ArmVirtGicArchLibConstructor ( + VOID + ) +{ + UINT32 Val; + + 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. + // + Val = ArmGicV3GetControlSystemRegisterEnable (); + if ((Val & ICC_SRE_EL2_SRE) == 0) { + ArmGicV3SetControlSystemRegisterEnable (Val | ICC_SRE_EL2_SRE); + Val = 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 (Val & ICC_SRE_EL2_SRE); + + mArmGicSupportedArchRevision = ARM_GIC_ARCH_REVISION_3; + break; + + case 2: + mArmGicSupportedArchRevision = 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 mArmGicSupportedArchRevision; +} diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.inf b/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.inf new file mode 100644 index 000000000000..ce682722ef1b --- /dev/null +++ b/ArmPlatformPkg/ArmVirtualizationPkg/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 DXE_RUNTIME_DRIVER UEFI_APPLICATION + CONSTRUCTOR = ArmVirtGicArchLibConstructor + +[Sources] + ArmVirtGicArchLib.c + +[LibraryClasses] + PcdLib + DebugLib + ArmGicLib + +[Packages] + MdePkg/MdePkg.dec + ArmPkg/ArmPkg.dec + ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec + +[Pcd] + gArmVirtualizationTokenSpaceGuid.PcdArmGicRevision