From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Efmu6-0004tj-OS for qemu-devel@nongnu.org; Fri, 25 Nov 2005 18:22:54 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Efmu3-0004tO-M9 for qemu-devel@nongnu.org; Fri, 25 Nov 2005 18:22:54 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Efmu3-0004tI-Dm for qemu-devel@nongnu.org; Fri, 25 Nov 2005 18:22:51 -0500 Received: from [65.74.133.11] (helo=mail.codesourcery.com) by monty-python.gnu.org with esmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1Efmu2-0004TX-FA for qemu-devel@nongnu.org; Fri, 25 Nov 2005 18:22:51 -0500 From: Paul Brook Date: Fri, 25 Nov 2005 23:22:43 +0000 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_Dz5hDjnuqeVftCw" Message-Id: <200511252322.43616.paul@codesourcery.com> Subject: [Qemu-devel] [patch] Arm CPU halt support 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 --Boundary-00=_Dz5hDjnuqeVftCw Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline The attached patch implements Arm CPU suspend/halt. Paul --Boundary-00=_Dz5hDjnuqeVftCw Content-Type: text/x-diff; charset="us-ascii"; name="patch.qemu_arm_halt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch.qemu_arm_halt" === cpu-exec.c ================================================================== --- cpu-exec.c (revision 1861) +++ cpu-exec.c (local) @@ -274,6 +274,17 @@ return EXCP_HALTED; } } +#elif defined(TARGET_ARM) + if (env1->halted) { + /* An interrupt wakes the CPU even if the I and F CPSR bits are + set. */ + if (env1->interrupt_request + & (CPU_INTERRUPT_FIQ | CPU_INTERRUPT_HARD)) { + env1->halted = 0; + } else { + return EXCP_HALTED; + } + } #endif cpu_single_env = env1; === target-arm/cpu.h ================================================================== --- target-arm/cpu.h (revision 1861) +++ target-arm/cpu.h (local) @@ -90,7 +90,7 @@ int exception_index; int interrupt_request; int user_mode_only; - uint32_t address; + int halted; /* VFP coprocessor state. */ struct { === target-arm/op.c ================================================================== --- target-arm/op.c (revision 1861) +++ target-arm/op.c (local) @@ -878,6 +878,13 @@ cpu_loop_exit(); } +void OPPROTO op_wfi(void) +{ + env->exception_index = EXCP_HLT; + env->halted = 1; + cpu_loop_exit(); +} + /* VFP support. We follow the convention used for VFP instrunctions: Single precition routines have a "s" suffix, double precision a "d" suffix. */ === target-arm/translate.c ================================================================== --- target-arm/translate.c (revision 1861) +++ target-arm/translate.c (local) @@ -496,6 +496,15 @@ if (IS_USER(s)) { return 1; } + if ((insn & 0x0fff0fff) == 0x0e070f90 + || (insn & 0x0fff0fff) == 0x0e070f58) { + /* Wait for interrupt. */ + gen_op_movl_T0_im((long)s->pc); + gen_op_movl_reg_TN[0][15](); + gen_op_wfi(); + s->is_jmp = DISAS_JUMP; + return 0; + } rd = (insn >> 12) & 0xf; if (insn & (1 << 20)) { gen_op_movl_T0_cp15(insn); --Boundary-00=_Dz5hDjnuqeVftCw--