From patchwork Wed Apr 11 18:56:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 897384 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40LvCj2HYcz9s1l for ; Thu, 12 Apr 2018 05:26:09 +1000 (AEST) Received: from localhost ([::1]:49202 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6LNf-0005Sy-Bv for incoming@patchwork.ozlabs.org; Wed, 11 Apr 2018 15:26:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38016) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6Kw5-00064s-AQ for qemu-devel@nongnu.org; Wed, 11 Apr 2018 14:57:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f6Kw1-0007qq-GR for qemu-devel@nongnu.org; Wed, 11 Apr 2018 14:57:37 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:44925) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f6Kw1-0007pz-5q; Wed, 11 Apr 2018 14:57:33 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue105 [212.227.15.183]) with ESMTPSA (Nemesis) id 0LqU2T-1ebvzw1J1F-00e5vd; Wed, 11 Apr 2018 20:57:17 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Wed, 11 Apr 2018 20:56:42 +0200 Message-Id: <20180411185651.21351-11-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180411185651.21351-1-laurent@vivier.eu> References: <20180411185651.21351-1-laurent@vivier.eu> X-Provags-ID: V03:K1:pCUYlM3sHg/Y69zXS2PBjRm9QP6J18YRPI5mZnY3D47NTm8y/dW SMp/laVZTkC7LhawlTdVZ+K4xY4YW0gOVgqljD4ZPigP49PuBqY60b25t7RhgE7xh/jkd12 TMuNCj/5WC4s1v802X8P1wVdDUFPVOUoBfoQ3A9HIZiJFox1qgtmrkoWlw5gVmGzU4MB35H 8ph7NLiwi5syxlYdq5lMA== X-UI-Out-Filterresults: notjunk:1; V01:K0:VGA5rC7EVlk=:NssLh5KwsHnA2uRkt2NKd3 XbNDka3ardyaqg/8ynAh1O5Ke4Gmzin0TuC/e2ayqrbAKO6bJPDO0Mc3K6FkvXoECW8EiejAf L9lvzUkE0VHXc3K6hyzlPsVphy1pcfxr+6I/JGjaJUqFca2r/2MCUSCFFqnDqlmqSY67m3U1r 8Ra+vyLg/NjUvkdsydXzCFMJdvdRGgv4qU1wFJWLCzyRO1Q7Edzt7Ovsj2QIWV4wXoaBHoCz6 IgOJQ4fXnzV6srFw/gq3LWvphCzVzyccvY6TkeRA8/08Apw/ia1sMiw4cbU0UBl6+mI26+Ivf 7YqDguaK4I4mqA8ssSYJ+R7OcJcxY7PpoLyCRIyAsHoENrBT7H/uedjqyU8754Mc1i1PJj5Ep Zgt1mgnPiGN1KD6A5rwwdOl1VJL6jpiJWj8dGZNYRMqIRz/ATYTkEI5AAQTu2eHS7OjNb2m4D CYrdbwxjmNWPjUlpp0GE2dZve+9faZOJ4Mc+u5QWVsFlbTS8kTH9cY8NEdoqwLsXPc4hAoFCS ILWHjW1Tnqhq2TXaZO+HIU1cOHTfrCtlJiDI4Y0ZLfNe+Ax4N8Q5ezPj3eDWrVCQPutLWSfEb 0+JEfcRIIHIW+mOBXhSI3N/obPNKkBPhitOFnn52ZbOyF8ru/6HW17Aki3pSQ2LFKXr9Y6ADA 34Sdm1h/b87m4HIyQiTj3Bb/E54c4BJUbTtqDV5bYm2K0wdu6XHZPU+Vdqf9PFDdkgnJOp2UB xSJVt/quwFlbSmFWv3wJMCFJH3SmwWLXZuGgIQ== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.72.192.73 Subject: [Qemu-devel] [PATCH for 2.13 v2 10/19] linux-user: move sh4 cpu loop to sh4 directory 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: Peter Maydell , Cornelia Huck , Riku Voipio , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Laurent Vivier , qemu-s390x@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" No code change, only move code from main.c to sh4/cpu_loop.c. Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- Notes: v2: expand tabs linux-user/main.c | 90 ----------------------------------------------- linux-user/sh4/cpu_loop.c | 85 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 90 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index af26a17c46..d7fee3e3db 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -149,87 +149,6 @@ void fork_end(int child) } } -#ifdef TARGET_SH4 -void cpu_loop(CPUSH4State *env) -{ - CPUState *cs = CPU(sh_env_get_cpu(env)); - int trapnr, ret; - target_siginfo_t info; - - while (1) { - bool arch_interrupt = true; - - cpu_exec_start(cs); - trapnr = cpu_exec(cs); - cpu_exec_end(cs); - process_queued_cpu_work(cs); - - switch (trapnr) { - case 0x160: - env->pc += 2; - ret = do_syscall(env, - env->gregs[3], - env->gregs[4], - env->gregs[5], - env->gregs[6], - env->gregs[7], - env->gregs[0], - env->gregs[1], - 0, 0); - if (ret == -TARGET_ERESTARTSYS) { - env->pc -= 2; - } else if (ret != -TARGET_QEMU_ESIGRETURN) { - env->gregs[0] = ret; - } - break; - case EXCP_INTERRUPT: - /* just indicate that signals should be handled asap */ - break; - case EXCP_DEBUG: - { - int sig; - - sig = gdb_handlesig(cs, TARGET_SIGTRAP); - if (sig) { - info.si_signo = sig; - info.si_errno = 0; - info.si_code = TARGET_TRAP_BRKPT; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } else { - arch_interrupt = false; - } - } - break; - case 0xa0: - case 0xc0: - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - info.si_code = TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr = env->tea; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; - case EXCP_ATOMIC: - cpu_exec_step_atomic(cs); - arch_interrupt = false; - break; - default: - printf ("Unhandled trap: 0x%x\n", trapnr); - cpu_dump_state(cs, stderr, fprintf, 0); - exit(EXIT_FAILURE); - } - process_pending_signals (env); - - /* Most of the traps imply an exception or interrupt, which - implies an REI instruction has been executed. Which means - that LDST (aka LOK_ADDR) should be cleared. But there are - a few exceptions for traps internal to QEMU. */ - if (arch_interrupt) { - env->lock_addr = -1; - } - } -} -#endif - #ifdef TARGET_CRIS void cpu_loop(CPUCRISState *env) { @@ -2361,15 +2280,6 @@ int main(int argc, char **argv, char **envp) env->pc = regs->sepc; env->gpr[xSP] = regs->sp; } -#elif defined(TARGET_SH4) - { - int i; - - for(i = 0; i < 16; i++) { - env->gregs[i] = regs->regs[i]; - } - env->pc = regs->pc; - } #elif defined(TARGET_ALPHA) { int i; diff --git a/linux-user/sh4/cpu_loop.c b/linux-user/sh4/cpu_loop.c index b7700a5561..418833ea25 100644 --- a/linux-user/sh4/cpu_loop.c +++ b/linux-user/sh4/cpu_loop.c @@ -21,6 +21,91 @@ #include "qemu.h" #include "cpu_loop-common.h" +void cpu_loop(CPUSH4State *env) +{ + CPUState *cs = CPU(sh_env_get_cpu(env)); + int trapnr, ret; + target_siginfo_t info; + + while (1) { + bool arch_interrupt = true; + + cpu_exec_start(cs); + trapnr = cpu_exec(cs); + cpu_exec_end(cs); + process_queued_cpu_work(cs); + + switch (trapnr) { + case 0x160: + env->pc += 2; + ret = do_syscall(env, + env->gregs[3], + env->gregs[4], + env->gregs[5], + env->gregs[6], + env->gregs[7], + env->gregs[0], + env->gregs[1], + 0, 0); + if (ret == -TARGET_ERESTARTSYS) { + env->pc -= 2; + } else if (ret != -TARGET_QEMU_ESIGRETURN) { + env->gregs[0] = ret; + } + break; + case EXCP_INTERRUPT: + /* just indicate that signals should be handled asap */ + break; + case EXCP_DEBUG: + { + int sig; + + sig = gdb_handlesig(cs, TARGET_SIGTRAP); + if (sig) { + info.si_signo = sig; + info.si_errno = 0; + info.si_code = TARGET_TRAP_BRKPT; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + } else { + arch_interrupt = false; + } + } + break; + case 0xa0: + case 0xc0: + info.si_signo = TARGET_SIGSEGV; + info.si_errno = 0; + info.si_code = TARGET_SEGV_MAPERR; + info._sifields._sigfault._addr = env->tea; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + break; + case EXCP_ATOMIC: + cpu_exec_step_atomic(cs); + arch_interrupt = false; + break; + default: + printf ("Unhandled trap: 0x%x\n", trapnr); + cpu_dump_state(cs, stderr, fprintf, 0); + exit(EXIT_FAILURE); + } + process_pending_signals (env); + + /* Most of the traps imply an exception or interrupt, which + implies an REI instruction has been executed. Which means + that LDST (aka LOK_ADDR) should be cleared. But there are + a few exceptions for traps internal to QEMU. */ + if (arch_interrupt) { + env->lock_addr = -1; + } + } +} + void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) { + int i; + + for(i = 0; i < 16; i++) { + env->gregs[i] = regs->regs[i]; + } + env->pc = regs->pc; }