From patchwork Sat Mar 24 16:51:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 148524 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 E28AEB6EE6 for ; Sun, 25 Mar 2012 04:28:04 +1100 (EST) Received: from localhost ([::1]:46681 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SBUDJ-0000RU-93 for incoming@patchwork.ozlabs.org; Sat, 24 Mar 2012 12:53:13 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SBUBi-0004ej-SY for qemu-devel@nongnu.org; Sat, 24 Mar 2012 12:51:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SBUBf-00056J-UH for qemu-devel@nongnu.org; Sat, 24 Mar 2012 12:51:34 -0400 Received: from mail-iy0-f173.google.com ([209.85.210.173]:54133) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SBUBf-00054g-Ky for qemu-devel@nongnu.org; Sat, 24 Mar 2012 12:51:31 -0400 Received: by mail-iy0-f173.google.com with SMTP id j26so7261753iaf.4 for ; Sat, 24 Mar 2012 09:51:30 -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=2PZ/rKJq7jJNRRgBAlHOemXmw0chzi5DkXEyMRpl23I=; b=i650j6wg1a9lTT2O/iz+t9YHgYd3L+L51/Irv7Jtd6h5hC0RCpAsPqQ8ExswjHRvoX RavS7GdKEG5ywiYWNdyp6cwEF3wfAYGQ7iDx/sQXfHqjVSuxXMhGKuMkDst2pady4cIt e+8V1amM1d8iiiZ7pThhS1XLaNjzWiwlntEeW6QW9UQEd9ykM0sJR/ieFnFi76TS6JPR MdE19+tkaIB1M6PO7E74xtgTrmIb3DHbhd6eYqQeVmt2/DyXtamJLcvzpJ8qjkSCVjjt h1Te2oFIemw7ijQ4sA8OoZ7QhC39Jw4kzkjAfB79keLRf4J94fzKvsz5Ruu+dulrsSSX 0sKQ== Received: by 10.68.200.9 with SMTP id jo9mr39158436pbc.19.1332607890618; Sat, 24 Mar 2012 09:51:30 -0700 (PDT) Received: from pebble.twiddle.home ([173.160.232.49]) by mx.google.com with ESMTPS id q8sm8412101pbi.1.2012.03.24.09.51.29 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 24 Mar 2012 09:51:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 24 Mar 2012 09:51:12 -0700 Message-Id: <1332607875-18895-8-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1332607875-18895-1-git-send-email-rth@twiddle.net> References: <1332607875-18895-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.210.173 Cc: blauwirbel@gmail.com Subject: [Qemu-devel] [PATCH 07/10] 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..40ca49c --- /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 */ +#ifndef 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 551237c..cc87320 100644 --- a/target-alpha/translate.c +++ b/target-alpha/translate.c @@ -1678,12 +1678,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: @@ -1699,7 +1699,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: @@ -2793,11 +2793,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; @@ -3143,10 +3143,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;