From patchwork Mon Apr 23 15:00:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 134018 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1099520lji; Mon, 23 Apr 2018 08:01:24 -0700 (PDT) X-Google-Smtp-Source: AIpwx49ke8o8QVteJ+/Z3E7Z+PUqhLzyNqNdw7zaQO+vbIkJah8ZsYEVhe8UXjv08mfzMoKnHIWy X-Received: by 10.99.131.72 with SMTP id h69mr16951500pge.378.1524495684409; Mon, 23 Apr 2018 08:01:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524495684; cv=none; d=google.com; s=arc-20160816; b=SnLbjZQY7Fd4aTFxfgb2N5xNb8vf8Tzl88mTht0hxHAGr0k57xwzitv6Ei3ZaF2+Pk 5ALnryADgqSlXpGI3ha0WKk6JBo07bNwdByZNilxBbVPY5XcKvscHlDUt9YwTxud/74s 2ExOnAyRSUiaz15o5mRKsDoyz8OYP6H2ZcTFX9k0RU8KU+jXZv9zRwHDZlGCUjfmLuUv am7RT2bAKcB+GEsLADw2ZKbhXN9bCILuR+Wn1UnjnshM3s6PLFDFabRG9fP/0xk0c2tD azMFi0kF96jzpsOHjfdy94MGsgAU5FbB5cYq62a8Pdsjcwp7M6dtjqQZ1/R7AMjURDEq axzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=XvVSrBCHnDiLhVFIHmDjHUmtb4l17OXbi6S7Av0JUs8=; b=fNc75LG2fcOega9gZ5rW5vRMjGXEf8kwiwrYgMEz/KG6mynOle4/8I+wd7QvyP2QIO kmVu00ixj7UrD3UbcTaqwTaOfgxaSsCDskmkljrX5/22nYEg0bI0ydwsM08YxklNRov5 XmJJV5pbN2fBgOer6meLUqT3MWwPuJnGdi2RZefd4UxkJxs7bEOp/Glk/7MShImHjGdA IMkEIZ7vEJiGIijPf2+QLRmpTdq6rq1wnEkX+BSq5o6LhS+3VORG1kRk4eTv6rPi+PmD zswWN1MClQ8AmgfEZZfgwFa1UTnABUxTDquS2BPdloo9mlEjzF6F426Nx3gawipufXM3 tO7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Ry7Jyznx; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id w9si11569245pfk.14.2018.04.23.08.01.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 08:01:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Ry7Jyznx; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B5C192279CEFC; Mon, 23 Apr 2018 08:01:17 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::242; helo=mail-wr0-x242.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 0D16E2277AF25 for ; Mon, 23 Apr 2018 08:01:15 -0700 (PDT) Received: by mail-wr0-x242.google.com with SMTP id d1-v6so42166227wrj.13 for ; Mon, 23 Apr 2018 08:01:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=b0oFL5YN9HW4BXB99FRl/c5l2gTuiHO5bU/hAjrAAVk=; b=Ry7JyznxUKkxjfPeLBP5Hq1E8ATa5zZiKO7+eWwbhMLHSAvgBMQClGrLWUygYFQWJj w0lgFkKhqvk4LvqaK7KeH0qsULWlN6AYquJJ46Kn9HqMAT9U023wOMaXMX8U2ZbRSfh+ zrpm1Ky+sG1W2gB4ciymzgz1eubQip3hi+lGo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=b0oFL5YN9HW4BXB99FRl/c5l2gTuiHO5bU/hAjrAAVk=; b=Y4rTsaPietyPscTxN3Jwgo680YjwKgJRFY6wtgHfFMTNh6f9UfI9R3vj6c6QlCiuTA ZhyAJVrnHV4EnSBfn67OqbumiQ15TVXNaTamCoLBtHwOAckQcLVJAIu5UiApFiiSBfQb VBNIP97tcfNw2YsRmaEdthoMEHOiHCAyiHNN20Xa7fCjdX7JIEy048plDPlw6/Cpj/1D LoVdWbXnxs+qY9KtXbAq+nhpwYGSgvzuMbrA/dvzzExYjT/wSb5uEdtptR0ApB1j31OU 2IK0Qxm28tTV4I1ZTJdQ4tfdwywLlqCZlLvWwqi7rv3wiLvoFA0BTmHqIecoWYB28YB7 /09w== X-Gm-Message-State: ALQs6tDQN8Y818m0qLu8ruIpaLOK9iHccp9gIFJSktiYdJdYkCXP+FbL RWK5Jll6J1Pe6i4CQm3IE+q0ahy5aPA= X-Received: by 10.28.238.149 with SMTP id j21mr7467749wmi.16.1524495674243; Mon, 23 Apr 2018 08:01:14 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id y101sm8955460wmh.10.2018.04.23.08.01.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 08:01:13 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Mon, 23 Apr 2018 17:00:56 +0200 Message-Id: <20180423150057.13515-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180423150057.13515-1-ard.biesheuvel@linaro.org> References: <20180423150057.13515-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 1/2] ArmPkg: add reenable hook to ArmGenericTimerCounterLib X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: julien.grall@arm.com, lersek@redhat.com, leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" In preparation of selectively reinstating the timer enable quirk for Xen that we removed in commit 411a373ed642 ("ArmPkg/TimerDxe: remove workaround for KVM timer handling"), add a ArmGenericTimerReenableTimer() library function to ArmGenericTimerCounterLib that we will populate for Xen only. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- ArmPkg/Drivers/TimerDxe/TimerDxe.c | 1 + ArmPkg/Include/Library/ArmGenericTimerCounterLib.h | 6 ++++++ ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.c | 8 ++++++++ ArmPkg/Library/ArmGenericTimerVirtCounterLib/ArmGenericTimerVirtCounterLib.c | 8 ++++++++ 4 files changed, 23 insertions(+) -- 2.17.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/ArmPkg/Drivers/TimerDxe/TimerDxe.c b/ArmPkg/Drivers/TimerDxe/TimerDxe.c index bd616d2efc73..478f1bece565 100644 --- a/ArmPkg/Drivers/TimerDxe/TimerDxe.c +++ b/ArmPkg/Drivers/TimerDxe/TimerDxe.c @@ -337,6 +337,7 @@ TimerInterruptHandler ( // Set next compare value ArmGenericTimerSetCompareVal (CompareValue); + ArmGenericTimerReenableTimer (); ArmInstructionSynchronizationBarrier (); } diff --git a/ArmPkg/Include/Library/ArmGenericTimerCounterLib.h b/ArmPkg/Include/Library/ArmGenericTimerCounterLib.h index 805025baa14b..47e28b79c033 100644 --- a/ArmPkg/Include/Library/ArmGenericTimerCounterLib.h +++ b/ArmPkg/Include/Library/ArmGenericTimerCounterLib.h @@ -22,6 +22,12 @@ ArmGenericTimerEnableTimer ( VOID ); +VOID +EFIAPI +ArmGenericTimerReenableTimer ( + VOID + ); + VOID EFIAPI ArmGenericTimerDisableTimer ( diff --git a/ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.c b/ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.c index d04e04fb334d..03519f50e79a 100644 --- a/ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.c +++ b/ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.c @@ -29,6 +29,14 @@ ArmGenericTimerEnableTimer ( ArmWriteCntpCtl (TimerCtrlReg); } +VOID +EFIAPI +ArmGenericTimerReenableTimer ( + VOID + ) +{ +} + VOID EFIAPI ArmGenericTimerDisableTimer ( diff --git a/ArmPkg/Library/ArmGenericTimerVirtCounterLib/ArmGenericTimerVirtCounterLib.c b/ArmPkg/Library/ArmGenericTimerVirtCounterLib/ArmGenericTimerVirtCounterLib.c index c941895a3574..4bb1e1cde538 100644 --- a/ArmPkg/Library/ArmGenericTimerVirtCounterLib/ArmGenericTimerVirtCounterLib.c +++ b/ArmPkg/Library/ArmGenericTimerVirtCounterLib/ArmGenericTimerVirtCounterLib.c @@ -29,6 +29,14 @@ ArmGenericTimerEnableTimer ( ArmWriteCntvCtl (TimerCtrlReg); } +VOID +EFIAPI +ArmGenericTimerReenableTimer ( + VOID + ) +{ +} + VOID EFIAPI ArmGenericTimerDisableTimer ( From patchwork Mon Apr 23 15:00:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 134019 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1099704lji; Mon, 23 Apr 2018 08:01:31 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp6zu1i93Ox3UyiPmCKzD5S9NLPVLj0CLCqPHVPqAj4utRi+M1CjUryZ9i3iIGXYL0vDh3a X-Received: by 10.98.9.27 with SMTP id e27mr246151pfd.93.1524495691225; Mon, 23 Apr 2018 08:01:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524495691; cv=none; d=google.com; s=arc-20160816; b=IJCib4mqUFBhfJFa5yQsL8xYsAaTtsx7WnkFMsp9luwT5rvOH/xP/ZlhZPUi39XDL6 giFP9e5dmjoOjPB5TKFV5gxZfGMTjSCS3bI5DvN+PMxNKoNV6png+T/+8CM1Yo7bpQFv olHdeKxl51YlRsJyxDM9cabqqX5d1kPAutbweTi6Qoza1Qrf7JDTfSkvMcP/CP1VwvmG XTPyyL0NtOmoZCACbM4RTsgMKZITasGpF5Iiq95mBPF6e2oZOnSLZqRzf5Wb8F87ae+W 1eCmdmeFK3FxqiN5csjORrX2bH0DM5Y+1lsoeod8T43X7mpFS+2J5yIp7HZz/TgfPv4i 5vpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=QZ8eWP64Cnh5pqvnN7vZwDmIMB8KlFbzR0DpnyXVBOc=; b=p6SpzDn0F9SoqMDl3pB4r7fOnAsg3iaaPZBGLGRs7Ogt/1A4ftLCXuZX71B1W99roj 1Fo1b1bQm8NXn/Icj26snyn/+S1FahhoVh2QJzSpFwgWVHU67E+l3aP6qLG8PezTJgqY +vygvjmSGYZjwWOop05VRXtKyL7JIx95jE6E3cOkYDraDoFPwn+W51JWqYWgk6hy4Jj6 BJIvmL5SnR+hI9y89SSN0dedz7I22nBkBL4Db+h6OfSZWKmqoIZOTHtnHOkZXlUNstkv JPFN7KgJ5SyGpoFLuDtpmA3buoIePQC6AECjkbf0oKZB8N8Vbu39QRYP+AAsOevSVksE kUUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=PAnR+srS; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id n3-v6si11945517pld.172.2018.04.23.08.01.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 08:01:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=PAnR+srS; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DDF3B228392EA; Mon, 23 Apr 2018 08:01:19 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::243; helo=mail-wr0-x243.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 22ABF2277AF25 for ; Mon, 23 Apr 2018 08:01:18 -0700 (PDT) Received: by mail-wr0-x243.google.com with SMTP id c14-v6so2089447wrd.4 for ; Mon, 23 Apr 2018 08:01:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ub+puy3j8v+0jJyLiAroAUyuWABd2IsKZxuZW79p7J4=; b=PAnR+srSPY6STPH3OVTvfMOz46i49ytOz9jlDiBvMfYWm7qEquFhubjMCZHvGNz2LJ uwVkU+HR1kZBibvFDPxaYKhRH6r6EcWn/mSxeqFeUae928b01EdjoC44xtOPN0uNyiXV cdRzMRwphezofomcrIojPf0HpZFjXrJvgQ1ZI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ub+puy3j8v+0jJyLiAroAUyuWABd2IsKZxuZW79p7J4=; b=OhJE0llAg1IKbiLJSaOKTFX4I7E3C1jquKpwyOqFvD/zH5e9Cwl1YNhpTw4L+VFyY1 w0mpCgyp8fYi8G5oKpUyCVRvyQzFmVPpE6deaf636gseqIivEC4vMIzcWMbL5Afy1B9t Cu2ZSQCeAN2YB3jtxbkvIsfggu821WqmD33pvhns6EX165YCxZUTnRohq/2YRB866+jI 5fLPGJTDIKvKMp7vR0KQ+F5mFWH9QdruuYsRXFin49gZjQEwYgwrBvtJNUVoFXY0pueM nE270h512IbbgE2PIwTd/X1CLBaGsTv32lnJR1BHmvAMe1ASZ3rS5OenwhiQMjDuSYnP x1CQ== X-Gm-Message-State: ALQs6tA+ttI+wm0u1D3AqDrUitBp39M+mTr0kA3iLAjuhHgngmmgRcuo Zhr5p4JVI3/VuOSKwxGGdqyYa2y3TpQ= X-Received: by 2002:adf:a98f:: with SMTP id b15-v6mr16883956wrd.48.1524495676341; Mon, 23 Apr 2018 08:01:16 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id y101sm8955460wmh.10.2018.04.23.08.01.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 08:01:15 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Mon, 23 Apr 2018 17:00:57 +0200 Message-Id: <20180423150057.13515-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180423150057.13515-1-ard.biesheuvel@linaro.org> References: <20180423150057.13515-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 2/2] ArmVirtPkg: reinstate timer unmask quirk for Xen X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: julien.grall@arm.com, lersek@redhat.com, leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Commit 411a373ed642 ("ArmPkg/TimerDxe: remove workaround for KVM timer handling") removed the virtual timer handling quirk that cleared the mask bit in the control register when enabling the timer, under the assumption that only ancient KVM host implementations required it. However, Julien reports that Xen also masks the timer interrupt in the guest view of the timer control register, and therefore needs the same quirk. So let's reinstate it, but using a Xen specific implementation of the timer support library, so that other virt platforms remain unchanged. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/ArmVirtXen.dsc | 1 + ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.c | 146 ++++++++++++++++++++ ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf | 33 +++++ 3 files changed, 180 insertions(+) -- 2.17.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/ArmVirtPkg/ArmVirtXen.dsc b/ArmVirtPkg/ArmVirtXen.dsc index 175b56d10c8f..8878912e6bef 100644 --- a/ArmVirtPkg/ArmVirtXen.dsc +++ b/ArmVirtPkg/ArmVirtXen.dsc @@ -36,6 +36,7 @@ [LibraryClasses] RealTimeClockLib|ArmVirtPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf + ArmGenericTimerCounterLib|ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf diff --git a/ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.c b/ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.c new file mode 100644 index 000000000000..75c28168453e --- /dev/null +++ b/ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.c @@ -0,0 +1,146 @@ +/** @file + + Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
+ Copyright (c) 2014 - 2018, 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 + +VOID +EFIAPI +ArmGenericTimerEnableTimer ( + VOID + ) +{ + UINTN TimerCtrlReg; + + TimerCtrlReg = ArmReadCntvCtl (); + TimerCtrlReg |= ARM_ARCH_TIMER_ENABLE; + ArmWriteCntvCtl (TimerCtrlReg); +} + +VOID +EFIAPI +ArmGenericTimerReenableTimer ( + VOID + ) +{ + UINTN TimerCtrlReg; + + TimerCtrlReg = ArmReadCntvCtl (); + TimerCtrlReg |= ARM_ARCH_TIMER_ENABLE; + + // + // When running under Xen, we need to unmask the interrupt on the timer side + // as Xen will mask it when servicing the interrupt at the hypervisor level + // and delivering the virtual timer interrupt to the guest. Otherwise, the + // interrupt will fire again, trapping into the hypervisor again, etc. etc. + // + TimerCtrlReg &= ~ARM_ARCH_TIMER_IMASK; + ArmWriteCntvCtl (TimerCtrlReg); +} + +VOID +EFIAPI +ArmGenericTimerDisableTimer ( + VOID + ) +{ + UINTN TimerCtrlReg; + + TimerCtrlReg = ArmReadCntvCtl (); + TimerCtrlReg &= ~ARM_ARCH_TIMER_ENABLE; + ArmWriteCntvCtl (TimerCtrlReg); +} + +VOID +EFIAPI +ArmGenericTimerSetTimerFreq ( + IN UINTN FreqInHz + ) +{ + ArmWriteCntFrq (FreqInHz); +} + +UINTN +EFIAPI +ArmGenericTimerGetTimerFreq ( + VOID + ) +{ + return ArmReadCntFrq (); +} + +UINTN +EFIAPI +ArmGenericTimerGetTimerVal ( + VOID + ) +{ + return ArmReadCntvTval (); +} + + +VOID +EFIAPI +ArmGenericTimerSetTimerVal ( + IN UINTN Value + ) +{ + ArmWriteCntvTval (Value); +} + +UINT64 +EFIAPI +ArmGenericTimerGetSystemCount ( + VOID + ) +{ + return ArmReadCntvCt (); +} + +UINTN +EFIAPI +ArmGenericTimerGetTimerCtrlReg ( + VOID + ) +{ + return ArmReadCntvCtl (); +} + +VOID +EFIAPI +ArmGenericTimerSetTimerCtrlReg ( + UINTN Value + ) +{ + ArmWriteCntvCtl (Value); +} + +UINT64 +EFIAPI +ArmGenericTimerGetCompareVal ( + VOID + ) +{ + return ArmReadCntvCval (); +} + +VOID +EFIAPI +ArmGenericTimerSetCompareVal ( + IN UINT64 Value + ) +{ + ArmWriteCntvCval (Value); +} diff --git a/ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf b/ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf new file mode 100644 index 000000000000..bd6ac8039844 --- /dev/null +++ b/ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf @@ -0,0 +1,33 @@ +#/** @file +# Implement ArmGenericTimerCounterLib for Xen using the virtual timer +# +# Copyright (c) 2014 - 2018, 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 = 0x0001001A + BASE_NAME = XenArmGenericTimerVirtCounterLib + FILE_GUID = e3913319-96ac-4ac0-808b-8edb8776a51c + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = ArmGenericTimerCounterLib + +[Sources] + XenArmGenericTimerVirtCounterLib.c + +[Packages] + MdePkg/MdePkg.dec + ArmPkg/ArmPkg.dec + +[LibraryClasses] + ArmLib + BaseLib