From patchwork Mon Aug 25 19:19:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 35930 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C44EC20565 for ; Mon, 25 Aug 2014 19:20:23 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id va2sf66002521obc.3 for ; Mon, 25 Aug 2014 12:20: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 :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=Ka9ib27ZFzTMAC7rRxhuFiF3fx/0XCdzHqqmwbbysok=; b=GEi291tHhHS9zYpKBOlvLeklIfcXDG1JDGIg1SW/4DXQH2qfYzzGgVaBicb4kkMuEu NWYfbJgPsooweSP+h3sTz1Jgphp6IMwJQrq26ehniL0vHMDpTBeyfFHqISYhgSOcWCy+ 3mzapatbRpwgM8/hDyQGoOhIHW212i/Ujai7+kKCN6Gt9M/UH7adBqRAYZwHS5YDl7OW BPrFe4fuuZHPVcslVvgFt27NEB+yP9G6dDM7zXRVgZXTo+1tCKpDlndrj4LBATv7a9HE L5LhC7w9eQgDJzkcm553DHiXMVIzZjj/IUt4SHMQEru2X4yV+B4hwne05cIAd0NV6MNi PNVw== X-Gm-Message-State: ALoCoQk/hmYvukYzAAeLaO3uq2VJ12ibE2NjqdJiwRs9a26YZXXGlMgWJnTgI/AuTogne8fAR8oI X-Received: by 10.182.171.67 with SMTP id as3mr14489498obc.34.1408994423359; Mon, 25 Aug 2014 12:20:23 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.51.51 with SMTP id t48ls2159554qga.67.gmail; Mon, 25 Aug 2014 12:20:23 -0700 (PDT) X-Received: by 10.220.251.200 with SMTP id mt8mr8526211vcb.24.1408994423243; Mon, 25 Aug 2014 12:20:23 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id w7si485738vcn.49.2014.08.25.12.20.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Aug 2014 12:20:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id hy4so15812205vcb.13 for ; Mon, 25 Aug 2014 12:20:23 -0700 (PDT) X-Received: by 10.220.81.132 with SMTP id x4mr20260812vck.0.1408994423120; Mon, 25 Aug 2014 12:20:23 -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.221.45.67 with SMTP id uj3csp141509vcb; Mon, 25 Aug 2014 12:20:22 -0700 (PDT) X-Received: by 10.42.96.132 with SMTP id j4mr25418579icn.16.1408994422544; Mon, 25 Aug 2014 12:20:22 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id ky3si894432igb.17.2014.08.25.12.20.22 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 25 Aug 2014 12:20:22 -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 1XLzoM-0006Oo-St; Mon, 25 Aug 2014 19:20:14 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XLzoL-0006Oe-RO for edk2-devel@lists.sourceforge.net; Mon, 25 Aug 2014 19:20:13 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of linaro.org designates 74.125.82.48 as permitted sender) client-ip=74.125.82.48; envelope-from=ard.biesheuvel@linaro.org; helo=mail-wg0-f48.google.com; Received: from mail-wg0-f48.google.com ([74.125.82.48]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1XLzoK-0006V7-TL for edk2-devel@lists.sourceforge.net; Mon, 25 Aug 2014 19:20:13 +0000 Received: by mail-wg0-f48.google.com with SMTP id x13so13480132wgg.19 for ; Mon, 25 Aug 2014 12:20:06 -0700 (PDT) X-Received: by 10.194.87.102 with SMTP id w6mr24579547wjz.24.1408994406661; Mon, 25 Aug 2014 12:20:06 -0700 (PDT) Received: from ards-macbook-pro.local ([193.77.13.198]) by mx.google.com with ESMTPSA id b3sm3476891wiw.22.2014.08.25.12.19.59 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Aug 2014 12:20:05 -0700 (PDT) From: Ard Biesheuvel To: lersek@redhat.com, olivier.martin@arm.com, edk2-devel@lists.sourceforge.net, peter.maydell@linaro.org, christoffer.dall@linaro.org, drjones@redhat.com, ilias.biris@linaro.org, leif.lindholm@linaro.org Date: Mon, 25 Aug 2014 21:19:21 +0200 Message-Id: <1408994367-11143-5-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1408994367-11143-1-git-send-email-ard.biesheuvel@linaro.org> References: <1408994367-11143-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: 1XLzoK-0006V7-TL Subject: [edk2] [PATCH 04/10] ArmPkg: allow dynamically discovered virtual timer interrupt 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.220.182 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 To support booting on virtual machines whose interrupt routing is discovered from the device tree, allow the interrupt numbers to be redeclared as PcdsDynamic by the platform .dsc --- ArmPkg/ArmPkg.dec | 2 ++ ArmPkg/Drivers/TimerDxe/TimerDxe.c | 6 +++++- ArmPkg/Library/ArmLib/AArch64/AArch64ArchTimer.c | 16 ++++++++-------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec index 1d896892dafc..9229c07df53c 100644 --- a/ArmPkg/ArmPkg.dec +++ b/ArmPkg/ArmPkg.dec @@ -136,6 +136,8 @@ # Maximum file size for TFTP servers that do not support 'tsize' extension gArmTokenSpaceGuid.PcdMaxTftpFileSize|0x01000000|UINT32|0x00000000 + +[PcdsFixedAtBuild.common,PcdsDynamic.common] # # ARM Architectural Timer # diff --git a/ArmPkg/Drivers/TimerDxe/TimerDxe.c b/ArmPkg/Drivers/TimerDxe/TimerDxe.c index be346bf89c51..670c4431e5a1 100644 --- a/ArmPkg/Drivers/TimerDxe/TimerDxe.c +++ b/ArmPkg/Drivers/TimerDxe/TimerDxe.c @@ -36,6 +36,8 @@ EFI_EVENT EfiExitBootServicesEvent = (EFI_EVENT)NULL; // The current period of the timer interrupt UINT64 mTimerPeriod = 0; +UINTN mArmArchTimerTimerFreq = 0; + // Cached copy of the Hardware Interrupt protocol instance EFI_HARDWARE_INTERRUPT_PROTOCOL *gInterrupt = NULL; @@ -144,7 +146,7 @@ TimerDriverSetTimerPeriod ( // Convert TimerPeriod to micro sec units TimerTicks = DivU64x32 (TimerPeriod, 10); - TimerTicks = MultU64x32 (TimerTicks, (PcdGet32(PcdArmArchTimerFreqInHz)/1000000)); + TimerTicks = MultU64x32 (TimerTicks, mArmArchTimerTimerFreq); ArmArchTimerSetTimerVal((UINTN)TimerTicks); @@ -343,6 +345,8 @@ TimerInitialize ( Status = TimerDriverSetTimerPeriod (&gTimer, 0); ASSERT_EFI_ERROR (Status); + mArmArchTimerTimerFreq = ArmArchTimerGetTimerFreq() / 1000000; + // Install secure and Non-secure interrupt handlers // Note: Because it is not possible to determine the security state of the // CPU dynamically, we just install interrupt handler for both sec and non-sec diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64ArchTimer.c b/ArmPkg/Library/ArmLib/AArch64/AArch64ArchTimer.c index 232d745b3d06..6487dcc441e4 100644 --- a/ArmPkg/Library/ArmLib/AArch64/AArch64ArchTimer.c +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64ArchTimer.c @@ -175,7 +175,7 @@ ArmArchTimerEnableTimer ( { UINTN TimerCtrlReg; - if (PcdGetBool(PcdArmArchTimerUseVirtual) == TRUE) { + if (FixedPcdGetBool(PcdArmArchTimerUseVirtual) == TRUE) { ArmArchTimerReadReg (CntvCtl, (VOID *)&TimerCtrlReg); /* FIXME: We need to clear IMASK when under KVM because KVM sets it. Unclear if this is a bug ... */ TimerCtrlReg |= ARM_ARCH_TIMER_ENABLE; @@ -196,7 +196,7 @@ ArmArchTimerDisableTimer ( { UINTN TimerCtrlReg; - if (PcdGetBool(PcdArmArchTimerUseVirtual) == TRUE) { + if (FixedPcdGetBool(PcdArmArchTimerUseVirtual) == TRUE) { ArmArchTimerReadReg (CntvCtl, (VOID *)&TimerCtrlReg); TimerCtrlReg &= ~ARM_ARCH_TIMER_ENABLE; ArmArchTimerWriteReg (CntvCtl, (VOID *)&TimerCtrlReg); @@ -234,7 +234,7 @@ ArmArchTimerGetTimerVal ( ) { UINTN ArchTimerVal; - if (PcdGetBool(PcdArmArchTimerUseVirtual) == TRUE) { + if (FixedPcdGetBool(PcdArmArchTimerUseVirtual) == TRUE) { ArmArchTimerReadReg (CntvTval, (VOID *)&ArchTimerVal); } else { ArmArchTimerReadReg (CntpTval, (VOID *)&ArchTimerVal); @@ -250,7 +250,7 @@ ArmArchTimerSetTimerVal ( IN UINTN Val ) { - if (PcdGetBool(PcdArmArchTimerUseVirtual) == TRUE) { + if (FixedPcdGetBool(PcdArmArchTimerUseVirtual) == TRUE) { ArmArchTimerWriteReg (CntvTval, (VOID *)&Val); } else { ArmArchTimerWriteReg (CntpTval, (VOID *)&Val); @@ -264,7 +264,7 @@ ArmArchTimerGetSystemCount ( ) { UINT64 SystemCount; - if (PcdGetBool(PcdArmArchTimerUseVirtual) == TRUE) { + if (FixedPcdGetBool(PcdArmArchTimerUseVirtual) == TRUE) { ArmArchTimerReadReg (CntvCt, (VOID *)&SystemCount); } else { ArmArchTimerReadReg (CntPct, (VOID *)&SystemCount); @@ -281,7 +281,7 @@ ArmArchTimerGetTimerCtrlReg ( { UINTN Val; - if (PcdGetBool(PcdArmArchTimerUseVirtual) == TRUE) { + if (FixedPcdGetBool(PcdArmArchTimerUseVirtual) == TRUE) { ArmArchTimerReadReg (CntvCtl, (VOID *)&Val); } else { ArmArchTimerReadReg (CntpCtl, (VOID *)&Val); @@ -296,7 +296,7 @@ ArmArchTimerSetTimerCtrlReg ( UINTN Val ) { - if (PcdGetBool(PcdArmArchTimerUseVirtual) == TRUE) { + if (FixedPcdGetBool(PcdArmArchTimerUseVirtual) == TRUE) { ArmArchTimerWriteReg (CntvCtl, (VOID *)&Val); } else { ArmArchTimerWriteReg (CntpCtl, (VOID *)&Val); @@ -309,7 +309,7 @@ ArmArchTimerSetCompareVal ( IN UINT64 Val ) { - if (PcdGetBool(PcdArmArchTimerUseVirtual) == TRUE) { + if (FixedPcdGetBool(PcdArmArchTimerUseVirtual) == TRUE) { ArmArchTimerWriteReg (CntvCval, (VOID *)&Val); } else { ArmArchTimerWriteReg (CntpCval, (VOID *)&Val);