From patchwork Tue Oct 25 19:03:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 9395247 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7E48D60233 for ; Tue, 25 Oct 2016 19:18:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF5712973F for ; Tue, 25 Oct 2016 19:18:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D280A29743; Tue, 25 Oct 2016 19:18:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 71BEC2973F for ; Tue, 25 Oct 2016 19:18:41 +0000 (UTC) Received: from localhost ([::1]:57684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bz7FA-00011C-Kf for patchwork-qemu-devel@patchwork.kernel.org; Tue, 25 Oct 2016 15:18:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46668) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bz714-0006EJ-PB for qemu-devel@nongnu.org; Tue, 25 Oct 2016 15:04:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bz711-00084j-Kw for qemu-devel@nongnu.org; Tue, 25 Oct 2016 15:04:06 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:52538) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bz711-00084E-BW for qemu-devel@nongnu.org; Tue, 25 Oct 2016 15:04:03 -0400 Received: from Quad.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue101) with ESMTPSA (Nemesis) id 0MTgfY-1cPXrO2Fg8-00QRSR; Tue, 25 Oct 2016 21:03:38 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Tue, 25 Oct 2016 21:03:13 +0200 Message-Id: <1477422199-11208-18-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477422199-11208-1-git-send-email-laurent@vivier.eu> References: <1477422199-11208-1-git-send-email-laurent@vivier.eu> X-Provags-ID: V03:K0:pI3PjSPmDjRBIZjFf/NbJx24X/6g80XbB4hie+sVepD4RLnqQNi HwEUMIi3UHjfsSIswaYP9d2tS4+SRJDe3IThDV/lFJYHCUklJBX8fFbJ1die+3nxxNT7yYo STkaCiMkSiWR4hoWvyR7VErn3yyjrEf48uZWy/bgMIpAVRmXdooWtNVpoOBI6AYGjiYngvh e5VYyOMr2F+xw+eMcc9rA== X-UI-Out-Filterresults: notjunk:1; V01:K0:bUrbUrVrceo=:Dlab0xtGt3CS+5nBkdTQmQ T9xfXxNjyCwCmKlbF37vHb9tT9HM5TZgWlUkbc7jN7OYSVp0WO0i/AN4wtebgy50o2YIgkFly oHOh7NGs081Gz6VUuLwEqgFm07KhFsHMJVOGk0dF9kUgH1xNNYaetIP17xqsljY9jvS6SGdBF HqcEaJAFDfBE5EAIu379hmfhjxpQb4EdYETqu78zMcnq+fxvTY5vTdpD62YNwwSm0L+4wvDYE HpsrA199AppNYHS5+ESWUjiEsw5bnIOD4ZR7+COpvMFbyVlorQoy1oKeN9uBJk0f+AYxBcV4Z 7EaCKz6SwK2v+cWazkJyEwT35avheoFT1jumkZSwFbxoZ+dyqIYNjEfVSeQDmPDgVno9NuPsr arDgdDryMkwrYy9It0njxEQqF5Mtd3lfL4P6D+h1/njGhzHDW+mgCkG3shNv9nE73MUi3FxEP N+NaOv13Ky8g2Ov8J4YI0VbsoEBMeSia0B0dJKZYEp0KWvvNTA9E/xi729fvUgb/oopdSUkB3 P308n5MFMkcINvOBZCQV3JzbNa+oVuJVNredM1AVruvhT4tZEU5IRBD5Dj/eTT54iq/K+CIFq ahPj+xQYfHOHAxXBMijtfjEiB95O/X1nuyyH+UzW9zxzK/DnN4CGGkIj3+b3LZLfHtcVSzUus d2WwYgxrqEsZ4P6mnvd3mcpn17Mw4BYkLq70ceTYq1+XVypmGxrILwvgZfX81WulI/r8= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.10 Subject: [Qemu-devel] [PULL 17/23] target-m68k: Some fixes to SR and flags management X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , gerg@uclinux.org, schwab@linux-m68k.org, agraf@suse.de, Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Richard Henderson Signed-off-by: Richard Henderson Signed-off-by: Laurent Vivier --- target-m68k/cpu.h | 3 ++- target-m68k/helper.c | 17 +++++++++++++++-- target-m68k/op_helper.c | 5 +++-- target-m68k/translate.c | 2 +- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/target-m68k/cpu.h b/target-m68k/cpu.h index 2f08a2c..c0de978 100644 --- a/target-m68k/cpu.h +++ b/target-m68k/cpu.h @@ -158,7 +158,8 @@ M68kCPU *cpu_m68k_init(const char *cpu_model); is returned if the signal was handled by the virtual CPU. */ int cpu_m68k_signal_handler(int host_signum, void *pinfo, void *puc); -uint32_t cpu_m68k_flush_flags(CPUM68KState *env, int op); +uint32_t cpu_m68k_get_ccr(CPUM68KState *env); +void cpu_m68k_set_ccr(CPUM68KState *env, uint32_t); /* Instead of computing the condition codes after each m68k instruction, diff --git a/target-m68k/helper.c b/target-m68k/helper.c index d9ea830..1a54e66 100644 --- a/target-m68k/helper.c +++ b/target-m68k/helper.c @@ -132,7 +132,7 @@ void m68k_cpu_init_gdb(M68kCPU *cpu) /* TODO: Add [E]MAC registers. */ } -uint32_t cpu_m68k_flush_flags(CPUM68KState *env, int op) +static uint32_t cpu_m68k_flush_flags(CPUM68KState *env, int op) { int flags; uint32_t src; @@ -272,6 +272,18 @@ set_x: return flags; } +uint32_t cpu_m68k_get_ccr(CPUM68KState *env) +{ + return cpu_m68k_flush_flags(env, env->cc_op) | env->cc_x * CCF_X; +} + +void cpu_m68k_set_ccr(CPUM68KState *env, uint32_t val) +{ + env->cc_op = CC_OP_FLAGS; + env->cc_dest = val & 0xf; + env->cc_x = (val & CCF_X ? 1 : 0); +} + void HELPER(movec)(CPUM68KState *env, uint32_t reg, uint32_t val) { M68kCPU *cpu = m68k_env_get_cpu(env); @@ -466,7 +478,8 @@ uint32_t HELPER(addx_cc)(CPUM68KState *env, uint32_t op1, uint32_t op2) void HELPER(set_sr)(CPUM68KState *env, uint32_t val) { - env->sr = val & 0xffff; + env->sr = val & 0xffe0; + cpu_m68k_set_ccr(env, val); m68k_switch_sp(env); } diff --git a/target-m68k/op_helper.c b/target-m68k/op_helper.c index e41ae46..af36177 100644 --- a/target-m68k/op_helper.c +++ b/target-m68k/op_helper.c @@ -63,9 +63,9 @@ static void do_rte(CPUM68KState *env) fmt = cpu_ldl_kernel(env, sp); env->pc = cpu_ldl_kernel(env, sp + 4); sp |= (fmt >> 28) & 3; - env->sr = fmt & 0xffff; env->aregs[7] = sp + 8; - m68k_switch_sp(env); + + helper_set_sr(env, fmt); } static void do_interrupt_all(CPUM68KState *env, int is_hw) @@ -112,6 +112,7 @@ static void do_interrupt_all(CPUM68KState *env, int is_hw) fmt |= 0x40000000; fmt |= vector << 16; fmt |= env->sr; + fmt |= cpu_m68k_get_ccr(env); env->sr |= SR_S; if (is_hw) { diff --git a/target-m68k/translate.c b/target-m68k/translate.c index cecd12c..73f9e9f 100644 --- a/target-m68k/translate.c +++ b/target-m68k/translate.c @@ -3145,7 +3145,7 @@ void m68k_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, i, u.l.upper, u.l.lower, *(double *)&u.d); } cpu_fprintf (f, "PC = %08x ", env->pc); - sr = env->sr | cpu_m68k_flush_flags(env, env->cc_op) | env->cc_x * CCF_X; + sr = env->sr | cpu_m68k_get_ccr(env); cpu_fprintf(f, "SR = %04x %c%c%c%c%c ", sr, (sr & CCF_X) ? 'X' : '-', (sr & CCF_N) ? 'N' : '-', (sr & CCF_Z) ? 'Z' : '-', (sr & CCF_V) ? 'V' : '-', (sr & CCF_C) ? 'C' : '-');