From patchwork Mon Apr 30 09:10:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 906608 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=208.118.235.17; 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 [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40ZK9n1Y75z9s0W for ; Mon, 30 Apr 2018 19:34:05 +1000 (AEST) Received: from localhost ([::1]:58660 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fD5C7-00005D-33 for incoming@patchwork.ozlabs.org; Mon, 30 Apr 2018 05:34:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fD4qa-0006qU-21 for qemu-devel@nongnu.org; Mon, 30 Apr 2018 05:11:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fD4qU-0006fs-HH for qemu-devel@nongnu.org; Mon, 30 Apr 2018 05:11:47 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:37907) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fD4qU-0006dn-0h; Mon, 30 Apr 2018 05:11:42 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.183]) with ESMTPSA (Nemesis) id 0MV4iD-1esO7941q1-00YSqf; Mon, 30 Apr 2018 11:11:19 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Mon, 30 Apr 2018 11:10:27 +0200 Message-Id: <20180430091037.13878-33-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180430091037.13878-1-laurent@vivier.eu> References: <20180430091037.13878-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:yn/T5dm/jFJmUbdpz/YT6HVYZry1y5lM8Jgi/uAbKoRJOhhl5Xw 1CSX9NayKIYbtUrn1LX8hIpJ65mSFnEo2rRaPxl2v+43NC/Dq4V4wSSCfqfG4ZQWIN6yYwf VNusqCWtmj2vwVu2jcdSEkST09f/HBIK9U5OmKtWpB+CkmGH/68WsQcOrTfM6c1OgsgVFAs ZcEtiQir9/IcO0EfCqIUw== X-UI-Out-Filterresults: notjunk:1; V01:K0:tvg7hZtDpBA=:pvJgmcUD0/NVFdaAHkYMaD PXnvnXKk02QitmayRNTIlWtpmiQDL568MYhaqQ3CQjkq8YuzfieDGHWGO4Mqyy/rCZq6a188l ICjqhWKyZSRb0G9CUpL/pKhcY8qmcIYtUJzEgAZrkcyOt3FotnEfzhvD9XABwVKBd9LHLu1cx xqJILmua7/mcUsslYQIFgZCPewHEajtO/icgLrntRxF0dUmkGT9+6xoh+fkULkj6+MvpQ1L1S JPjXxjizJP1etiDH/lWXjuIEY87kZAqbfZxn9LU1vu8lJmdiWtF4ok0AJbUFTUJgWsR+rs+5Y lUp2ZQDRZhwFLqV06OK5Yn2U/6Jzz/Q7rA3xFIrOdSjRxh5KGSDsDRlac1aE/6QMN8OyDUp/2 DBwXBh4fcRd1/GIaQn+NDnclGmYQeh8QP9l1YVECrtvibJWvwzHGBq5rErV0ROIeL2kjeEiI/ C7cFipkQFv4fbsrbhgcP8gqMLb/qm7+1MZ3U7Vb9Udim+d27ejlUuVbYezWKOt4XAECdoIuzz Y8njGz21p0p1e2B/Q6OklTHxW9NpFbz5zS0jW5HSKxGT/43IC1edBst0qDLMBfAAd57IHwFyw Bihb+n/w729cOviHSxNd5Ssa3hfMTaMqDNOn119q9p6tfWULy42dXixZuX9FLYyFN9eOOLPJj e+Zy2JkKBtkQOaqYvogljqCnZpJAz7+5HmvPmOWMs6KtE7Pd1IboVI8O4Q7OFDeCL3P6uSCBA R82pSAt9e2o6Jk+c X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.17.13 Subject: [Qemu-devel] [PULL 32/42] 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: qemu-s390x@nongnu.org, Riku Voipio , Laurent Vivier , Cornelia Huck 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é Message-Id: <20180411185651.21351-11-laurent@vivier.eu> --- 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; }