From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DQYtO-0003V0-MF for qemu-devel@nongnu.org; Tue, 26 Apr 2005 18:50:58 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DQYtN-0003Um-76 for qemu-devel@nongnu.org; Tue, 26 Apr 2005 18:50:58 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DQYtN-0003Is-0S for qemu-devel@nongnu.org; Tue, 26 Apr 2005 18:50:57 -0400 Received: from [65.74.133.9] (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 1DQYvm-0007G6-AM for qemu-devel@nongnu.org; Tue, 26 Apr 2005 18:53:26 -0400 From: Paul Brook Date: Tue, 26 Apr 2005 23:49:36 +0100 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_AWsbCIGiSfS85or" Message-Id: <200504262349.36940.paul@codesourcery.com> Subject: [Qemu-devel] [patch] Thumb syscalls 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=_AWsbCIGiSfS85or Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline The attached patch implements syscalls when in thumb mode. Paul --Boundary-00=_AWsbCIGiSfS85or Content-Type: text/x-diff; charset="us-ascii"; name="patch.qemu_thumb_syscall" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch.qemu_thumb_syscall" Index: linux-user/main.c =================================================================== RCS file: /cvsroot/qemu/qemu/linux-user/main.c,v retrieving revision 1.65 diff -u -p -r1.65 main.c --- linux-user/main.c 23 Apr 2005 18:25:40 -0000 1.65 +++ linux-user/main.c 26 Apr 2005 22:47:04 -0000 @@ -359,16 +359,27 @@ void cpu_loop(CPUARMState *env) case EXCP_SWI: { /* system call */ - insn = ldl((void *)(env->regs[15] - 4)); - n = insn & 0xffffff; + if (env->thumb) { + insn = lduw((void *)(env->regs[15] - 2)); + n = insn & 0xff; + } else { + insn = ldl((void *)(env->regs[15] - 4)); + n = insn & 0xffffff; + } + if (n == ARM_NR_cacheflush) { arm_cache_flush(env->regs[0], env->regs[1]); } else if (n == ARM_NR_semihosting || n == ARM_NR_thumb_semihosting) { env->regs[0] = do_arm_semihosting (env); - } else if (n >= ARM_SYSCALL_BASE) { + } else if (n >= ARM_SYSCALL_BASE + || (env->thumb && n == ARM_THUMB_SYSCALL)) { /* linux syscall */ - n -= ARM_SYSCALL_BASE; + if (env->thumb) { + n = env->regs[7]; + } else { + n -= ARM_SYSCALL_BASE; + } env->regs[0] = do_syscall(env, n, env->regs[0], Index: linux-user/arm/syscall.h =================================================================== RCS file: /cvsroot/qemu/qemu/linux-user/arm/syscall.h,v retrieving revision 1.5 diff -u -p -r1.5 syscall.h --- linux-user/arm/syscall.h 23 Apr 2005 18:25:41 -0000 1.5 +++ linux-user/arm/syscall.h 26 Apr 2005 22:47:04 -0000 @@ -26,6 +26,7 @@ struct target_pt_regs { #define ARM_ORIG_r0 uregs[17] #define ARM_SYSCALL_BASE 0x900000 +#define ARM_THUMB_SYSCALL 0 #define ARM_NR_cacheflush (ARM_SYSCALL_BASE + 0xf0000 + 2) --Boundary-00=_AWsbCIGiSfS85or--