From patchwork Fri Mar 23 15:22:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 148462 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2723CB6EE6 for ; Sat, 24 Mar 2012 02:51:09 +1100 (EST) Received: from localhost ([::1]:53688 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SB6LZ-0006Fl-J2 for incoming@patchwork.ozlabs.org; Fri, 23 Mar 2012 11:24:09 -0400 Received: from eggs.gnu.org ([208.118.235.92]:39091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SB6KY-0003nm-H3 for qemu-devel@nongnu.org; Fri, 23 Mar 2012 11:23:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SB6KQ-0000QF-T6 for qemu-devel@nongnu.org; Fri, 23 Mar 2012 11:23:06 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:56067) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SB6KQ-0000Pj-HL for qemu-devel@nongnu.org; Fri, 23 Mar 2012 11:22:58 -0400 Received: by pbcuo5 with SMTP id uo5so3135276pbc.4 for ; Fri, 23 Mar 2012 08:22:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=YJvt+HacH30nTlA5IZnho/9f5hlVCXTjM3s9laREZjk=; b=k6OPCOl5SzhiFX4hYMqxlavVvBkhPcFoAHkVxyA4bvFaJMeiYAo0laH416QT1nwx5m o7irBf/2YtlMjRZknbZQkxvaZa+RpX9+iaig11BPqzzoKf2i5g09+UT7J7KDMdasfRlC Mhhz1HbXukQVR5ApQlBgDUeQPt+wIvz3vT0pfOkrMcJvlCEFb47jna9Qljp1sYOUxCmx Edt/04sjpSezk+gdDn90dqVjXLcmlMd2dhpDYk/7LfJpqJaNus9Q/XSTF+cPQ1djMLYr MPx7vOZHmx/6wfdCEzOEfvfz2PmAYQvsZJ+HgPhhi5WcLmDKVFxTlgDt+35B2gTvTcQi s+ug== Received: by 10.68.221.40 with SMTP id qb8mr29900578pbc.154.1332516176669; Fri, 23 Mar 2012 08:22:56 -0700 (PDT) Received: from anchor.twiddle.home.com ([173.160.232.49]) by mx.google.com with ESMTPS id l1sm6020974pbe.54.2012.03.23.08.22.55 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 23 Mar 2012 08:22:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 23 Mar 2012 08:22:38 -0700 Message-Id: <1332516160-17784-8-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1332516160-17784-1-git-send-email-rth@twiddle.net> References: <1332516160-17784-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: blauwirbel@gmail.com Subject: [Qemu-devel] [PATCH 7/9] target-alpha: Move palcode support helpers to sys_helper.c. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Richard Henderson --- Makefile.target | 2 +- target-alpha/helper.h | 10 +++--- target-alpha/op_helper.c | 65 --------------------------------- target-alpha/sys_helper.c | 87 +++++++++++++++++++++++++++++++++++++++++++++ target-alpha/translate.c | 14 ++++---- 5 files changed, 100 insertions(+), 78 deletions(-) create mode 100644 target-alpha/sys_helper.c diff --git a/Makefile.target b/Makefile.target index 256e7b5..254a9fa 100644 --- a/Makefile.target +++ b/Makefile.target @@ -96,7 +96,7 @@ libobj-y += cpu_init.o endif libobj-$(TARGET_SPARC) += int32_helper.o libobj-$(TARGET_SPARC64) += int64_helper.o -libobj-$(TARGET_ALPHA) += int_helper.o fpu_helper.o +libobj-$(TARGET_ALPHA) += int_helper.o fpu_helper.o sys_helper.o libobj-y += disas.o libobj-$(CONFIG_TCI_DIS) += tci-dis.o diff --git a/target-alpha/helper.h b/target-alpha/helper.h index 45e187d..f057ecf 100644 --- a/target-alpha/helper.h +++ b/target-alpha/helper.h @@ -1,7 +1,7 @@ #include "def-helper.h" DEF_HELPER_3(excp, void, env, int, int) -DEF_HELPER_FLAGS_0(load_pcc, TCG_CALL_CONST | TCG_CALL_PURE, i64) +DEF_HELPER_FLAGS_1(load_pcc, TCG_CALL_CONST | TCG_CALL_PURE, i64, env) DEF_HELPER_3(addqv, i64, env, i64, i64) DEF_HELPER_3(addlv, i64, env, i64, i64) @@ -100,7 +100,7 @@ DEF_HELPER_2(ieee_input_cmp, i64, env, i64) DEF_HELPER_2(ieee_input_s, i64, env, i64) #if !defined (CONFIG_USER_ONLY) -DEF_HELPER_1(hw_ret, void, i64) +DEF_HELPER_2(hw_ret, void, env, i64) DEF_HELPER_1(ldl_phys, i64, i64) DEF_HELPER_1(ldq_phys, i64, i64) @@ -111,13 +111,13 @@ DEF_HELPER_2(stq_phys, void, i64, i64) DEF_HELPER_2(stl_c_phys, i64, i64, i64) DEF_HELPER_2(stq_c_phys, i64, i64, i64) -DEF_HELPER_FLAGS_0(tbia, TCG_CALL_CONST, void) -DEF_HELPER_FLAGS_1(tbis, TCG_CALL_CONST, void, i64) +DEF_HELPER_FLAGS_1(tbia, TCG_CALL_CONST, void, env) +DEF_HELPER_FLAGS_2(tbis, TCG_CALL_CONST, void, env, i64) DEF_HELPER_1(halt, void, i64); DEF_HELPER_FLAGS_0(get_time, TCG_CALL_CONST, i64) -DEF_HELPER_FLAGS_1(set_alarm, TCG_CALL_CONST, void, i64) +DEF_HELPER_FLAGS_2(set_alarm, TCG_CALL_CONST, void, env, i64) #endif #include "def-helper.h" diff --git a/target-alpha/op_helper.c b/target-alpha/op_helper.c index c51b535..df1f01c 100644 --- a/target-alpha/op_helper.c +++ b/target-alpha/op_helper.c @@ -25,71 +25,6 @@ #include "sysemu.h" #include "qemu-timer.h" -/*****************************************************************************/ -/* Exceptions processing helpers */ - -uint64_t helper_load_pcc (void) -{ -#ifndef CONFIG_USER_ONLY - /* In system mode we have access to a decent high-resolution clock. - In order to make OS-level time accounting work with the RPCC, - present it with a well-timed clock fixed at 250MHz. */ - return (((uint64_t)env->pcc_ofs << 32) - | (uint32_t)(qemu_get_clock_ns(vm_clock) >> 2)); -#else - /* In user-mode, vm_clock doesn't exist. Just pass through the host cpu - clock ticks. Also, don't bother taking PCC_OFS into account. */ - return (uint32_t)cpu_get_real_ticks(); -#endif -} - -/* PALcode support special instructions */ -#if !defined (CONFIG_USER_ONLY) -void helper_hw_ret (uint64_t a) -{ - env->pc = a & ~3; - env->intr_flag = 0; - env->lock_addr = -1; - if ((a & 1) == 0) { - env->pal_mode = 0; - swap_shadow_regs(env); - } -} - -void helper_tbia(void) -{ - tlb_flush(env, 1); -} - -void helper_tbis(uint64_t p) -{ - tlb_flush_page(env, p); -} - -void helper_halt(uint64_t restart) -{ - if (restart) { - qemu_system_reset_request(); - } else { - qemu_system_shutdown_request(); - } -} - -uint64_t helper_get_time(void) -{ - return qemu_get_clock_ns(rtc_clock); -} - -void helper_set_alarm(uint64_t expire) -{ - if (expire) { - env->alarm_expire = expire; - qemu_mod_timer(env->alarm_timer, expire); - } else { - qemu_del_timer(env->alarm_timer); - } -} -#endif /*****************************************************************************/ /* Softmmu support */ diff --git a/target-alpha/sys_helper.c b/target-alpha/sys_helper.c new file mode 100644 index 0000000..a26bb5c --- /dev/null +++ b/target-alpha/sys_helper.c @@ -0,0 +1,87 @@ +/* + * Helpers for system instructions. + * + * Copyright (c) 2007 Jocelyn Mayer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#include "cpu.h" +#include "helper.h" +#include "sysemu.h" +#include "qemu-timer.h" + + +uint64_t helper_load_pcc(CPUAlphaState *env) +{ +#ifndef CONFIG_USER_ONLY + /* In system mode we have access to a decent high-resolution clock. + In order to make OS-level time accounting work with the RPCC, + present it with a well-timed clock fixed at 250MHz. */ + return (((uint64_t)env->pcc_ofs << 32) + | (uint32_t)(qemu_get_clock_ns(vm_clock) >> 2)); +#else + /* In user-mode, vm_clock doesn't exist. Just pass through the host cpu + clock ticks. Also, don't bother taking PCC_OFS into account. */ + return (uint32_t)cpu_get_real_ticks(); +#endif +} + +/* PALcode support special instructions */ +#if !defined (CONFIG_USER_ONLY) +void helper_hw_ret(CPUAlphaState *env, uint64_t a) +{ + env->pc = a & ~3; + env->intr_flag = 0; + env->lock_addr = -1; + if ((a & 1) == 0) { + env->pal_mode = 0; + swap_shadow_regs(env); + } +} + +void helper_tbia(CPUAlphaState *env) +{ + tlb_flush(env, 1); +} + +void helper_tbis(CPUAlphaState *env, uint64_t p) +{ + tlb_flush_page(env, p); +} + +void helper_halt(uint64_t restart) +{ + if (restart) { + qemu_system_reset_request(); + } else { + qemu_system_shutdown_request(); + } +} + +uint64_t helper_get_time(void) +{ + return qemu_get_clock_ns(rtc_clock); +} + +void helper_set_alarm(CPUAlphaState *env, uint64_t expire) +{ + if (expire) { + env->alarm_expire = expire; + qemu_mod_timer(env->alarm_timer, expire); + } else { + qemu_del_timer(env->alarm_timer); + } +} +#endif /* CONFIG_USER_ONLY */ diff --git a/target-alpha/translate.c b/target-alpha/translate.c index 18e9931..52df02e 100644 --- a/target-alpha/translate.c +++ b/target-alpha/translate.c @@ -1677,12 +1677,12 @@ static ExitStatus gen_mtpr(DisasContext *ctx, int rb, int regno) switch (regno) { case 255: /* TBIA */ - gen_helper_tbia(); + gen_helper_tbia(cpu_env); break; case 254: /* TBIS */ - gen_helper_tbis(tmp); + gen_helper_tbis(cpu_env, tmp); break; case 253: @@ -1698,7 +1698,7 @@ static ExitStatus gen_mtpr(DisasContext *ctx, int rb, int regno) case 251: /* ALARM */ - gen_helper_set_alarm(tmp); + gen_helper_set_alarm(cpu_env, tmp); break; default: @@ -2792,11 +2792,11 @@ static ExitStatus translate_one(DisasContext *ctx, uint32_t insn) if (ra != 31) { if (use_icount) { gen_io_start(); - gen_helper_load_pcc(cpu_ir[ra]); + gen_helper_load_pcc(cpu_ir[ra], cpu_env); gen_io_end(); ret = EXIT_PC_STALE; } else { - gen_helper_load_pcc(cpu_ir[ra]); + gen_helper_load_pcc(cpu_ir[ra], cpu_env); } } break; @@ -3142,10 +3142,10 @@ static ExitStatus translate_one(DisasContext *ctx, uint32_t insn) emulation PALcode, so continue to accept it. */ TCGv tmp = tcg_temp_new(); tcg_gen_ld_i64(tmp, cpu_env, offsetof(CPUAlphaState, exc_addr)); - gen_helper_hw_ret(tmp); + gen_helper_hw_ret(cpu_env, tmp); tcg_temp_free(tmp); } else { - gen_helper_hw_ret(cpu_ir[rb]); + gen_helper_hw_ret(cpu_env, cpu_ir[rb]); } ret = EXIT_PC_UPDATED; break;