From patchwork Wed Apr 7 22:42:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 49672 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2BC07B7D0F for ; Thu, 8 Apr 2010 09:19:49 +1000 (EST) Received: from localhost ([127.0.0.1]:55146 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NzeOV-0003s7-V2 for incoming@patchwork.ozlabs.org; Wed, 07 Apr 2010 19:10:47 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nze3i-0005Q0-Bm for qemu-devel@nongnu.org; Wed, 07 Apr 2010 18:49:18 -0400 Received: from [140.186.70.92] (port=37914 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nze3U-0005Is-0i for qemu-devel@nongnu.org; Wed, 07 Apr 2010 18:49:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nze3Q-0003hv-C3 for qemu-devel@nongnu.org; Wed, 07 Apr 2010 18:49:03 -0400 Received: from are.twiddle.net ([75.149.56.221]:44529) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nze3Q-0003hN-4q for qemu-devel@nongnu.org; Wed, 07 Apr 2010 18:49:00 -0400 Received: by are.twiddle.net (Postfix, from userid 5000) id 7F45CDE2; Wed, 7 Apr 2010 15:48:56 -0700 (PDT) Message-Id: <71f0403498e3107af0d749484b2710d1cefd1ace.1270680209.git.rth@twiddle.net> In-Reply-To: References: From: Richard Henderson Date: Wed, 7 Apr 2010 15:42:54 -0700 To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: aurelien@aurel32.net Subject: [Qemu-devel] [PATCH 13/13] target-alpha: Implement RPCC. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org A minimal implementation that more or less corresponds to the user-level version used by target-i386. More hoops will want to be jumped through when alpha gets system-level emulation. Signed-off-by: Richard Henderson --- qemu-timer.h | 13 +++++++++++++ target-alpha/cpu.h | 1 - target-alpha/op_helper.c | 5 +++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/qemu-timer.h b/qemu-timer.h index d2e15f4..6e2d2e1 100644 --- a/qemu-timer.h +++ b/qemu-timer.h @@ -209,6 +209,19 @@ static inline int64_t cpu_get_real_ticks(void) return (int64_t)(count * cyc_per_count); } +#elif defined(__alpha__) + +static inline int64_t cpu_get_real_ticks(void) +{ + uint64_t cc; + uint32_t cur, ofs; + + asm volatile("rpcc %0" : "=r"(cc)); + cur = cc; + ofs = cc >> 32; + return cur - ofs; +} + #else /* The host CPU doesn't have an easily accessible cycle counter. Just return a monotonically increasing value. This will be diff --git a/target-alpha/cpu.h b/target-alpha/cpu.h index dae23e2..c2f6a50 100644 --- a/target-alpha/cpu.h +++ b/target-alpha/cpu.h @@ -355,7 +355,6 @@ struct CPUAlphaState { uint64_t ir[31]; float64 fir[31]; uint64_t pc; - uint32_t pcc[2]; uint64_t ipr[IPR_LAST]; uint64_t ps; uint64_t unique; diff --git a/target-alpha/op_helper.c b/target-alpha/op_helper.c index bfc095c..ff5ae26 100644 --- a/target-alpha/op_helper.c +++ b/target-alpha/op_helper.c @@ -21,6 +21,7 @@ #include "host-utils.h" #include "softfloat.h" #include "helper.h" +#include "qemu-timer.h" /*****************************************************************************/ /* Exceptions processing helpers */ @@ -33,8 +34,8 @@ void QEMU_NORETURN helper_excp (int excp, int error) uint64_t helper_load_pcc (void) { - /* XXX: TODO */ - return 0; + /* ??? This isn't a timer for which we have any rate info. */ + return (uint32_t)cpu_get_real_ticks(); } uint64_t helper_load_fpcr (void)