Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KV7TH-00049x-Rd for qemu-devel@nongnu.org; Mon, 18 Aug 2008 12:20:43 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KV7TH-00049R-4U for qemu-devel@nongnu.org; Mon, 18 Aug 2008 12:20:43 -0400 Received: from [199.232.76.173] (port=45863 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KV7TG-00049D-T7 for qemu-devel@nongnu.org; Mon, 18 Aug 2008 12:20:42 -0400 Received: from vsmtp02.dti.ne.jp ([202.216.231.137]:40612) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KV7TG-0006hn-Ak for qemu-devel@nongnu.org; Mon, 18 Aug 2008 12:20:42 -0400 Received: from [192.168.1.21] (PPPa1666.e11.eacc.dti.ne.jp [124.255.92.149]) by vsmtp02.dti.ne.jp (3.11v) with ESMTP AUTH id m7IGKesW007347 for ; Tue, 19 Aug 2008 01:20:41 +0900 (JST) Message-ID: <48A9A15B.4070003@juno.dti.ne.jp> Date: Tue, 19 Aug 2008 01:20:43 +0900 From: Shin-ichiro KAWASAKI MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 1/5] [sh4] sleep instruction Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This patch adds sleep instruction. diff -ruwN a/target-sh4/cpu.h b/target-sh4/cpu.h --- a/target-sh4/cpu.h 2008-07-02 05:01:19.000000000 +0900 +++ b/target-sh4/cpu.h 2008-08-18 21:08:54.000000000 +0900 @@ -117,6 +117,7 @@ CPU_COMMON tlb_t utlb[UTLB_SIZE]; /* unified translation table */ tlb_t itlb[ITLB_SIZE]; /* instruction translation table */ void *intc_handle; + int intr_at_halt; /* SR_BL ignored during sleep */ } CPUSH4State; CPUSH4State *cpu_sh4_init(const char *cpu_model); diff -ruwN a/target-sh4/exec.h b/target-sh4/exec.h --- a/target-sh4/exec.h 2008-05-10 03:45:55.000000000 +0900 +++ b/target-sh4/exec.h 2008-08-18 21:00:35.000000000 +0900 @@ -41,6 +41,7 @@ return 0; if (env->interrupt_request & CPU_INTERRUPT_HARD) { env->halted = 0; + env->intr_at_halt = 1; return 0; } return EXCP_HALTED; diff -ruwN a/target-sh4/helper.c b/target-sh4/helper.c --- a/target-sh4/helper.c 2008-05-10 03:45:55.000000000 +0900 +++ b/target-sh4/helper.c 2008-08-18 21:00:35.000000000 +0900 @@ -87,9 +87,10 @@ if (do_exp && env->exception_index != 0x1e0) { env->exception_index = 0x000; /* masked exception -> reset */ } - if (do_irq) { + if (do_irq && !env->intr_at_halt) { return; /* masked */ } + env->intr_at_halt = 0; } if (do_irq) { diff -ruwN a/target-sh4/op.c b/target-sh4/op.c --- a/target-sh4/op.c 2008-07-16 21:13:52.000000000 +0900 +++ b/target-sh4/op.c 2008-08-18 21:00:35.000000000 +0900 @@ -1091,6 +1091,13 @@ cpu_loop_exit(); } +void OPPROTO op_sleep(void) +{ + env->halted = 1; + env->exception_index = EXCP_HLT; + cpu_loop_exit(); +} + /* Load and store */ #define MEMSUFFIX _raw #include "op_mem.c" diff -ruwN a/target-sh4/translate.c b/target-sh4/translate.c --- a/target-sh4/translate.c 2008-08-18 05:21:51.000000000 +0900 +++ b/target-sh4/translate.c 2008-08-18 21:00:35.000000000 +0900 @@ -298,7 +298,12 @@ case 0x0009: /* nop */ return; case 0x001b: /* sleep */ - assert(0); /* XXXXX */ + if (ctx->memidx) { + gen_op_sleep(); + } else { + gen_op_raise_illegal_instruction(); + ctx->bstate = BS_EXCP; + } return; }