Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KVRF4-00017z-OJ for qemu-devel@nongnu.org; Tue, 19 Aug 2008 09:27:22 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KVRF1-000176-Jr for qemu-devel@nongnu.org; Tue, 19 Aug 2008 09:27:22 -0400 Received: from [199.232.76.173] (port=59321 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KVRF1-000173-Gt for qemu-devel@nongnu.org; Tue, 19 Aug 2008 09:27:19 -0400 Received: from wf-out-1314.google.com ([209.85.200.170]:41818) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KVRF1-0003JS-AK for qemu-devel@nongnu.org; Tue, 19 Aug 2008 09:27:19 -0400 Received: by wf-out-1314.google.com with SMTP id 27so3725275wfd.4 for ; Tue, 19 Aug 2008 06:27:15 -0700 (PDT) Message-ID: <3e1533500808190627m9d16672k8d6b06fb22ebfdb0@mail.gmail.com> Date: Tue, 19 Aug 2008 14:27:15 +0100 From: "Luis Pureza" Sender: pureza@gmail.com MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: [Qemu-devel] Sparc32: Mask writes to the WIM register 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 The following patch, for Sparc32, correctly masks the WIM register, so that bits relative to non-existent windows remain cleared. This fixes a problem I was having with RTEMS. Cheers, Luis Pureza --- a/target-sparc/op_helper.c +++ b/target-sparc/op_helper.c @@ -2289,6 +2289,16 @@ target_ulong helper_rdpsr(void) return GET_PSR(env); } +void helper_wrwim(target_ulong new_wim) +{ + if (env->nwindows == 32) { + env->wim = new_wim; + } else { + env->wim = new_wim & ((1 << env->nwindows) - 1); + } +} + #else /* XXX: use another pointer for %iN registers to avoid slow wrapping handling ? */ --- a/target-sparc/translate.c +++ b/target-sparc/translate.c @@ -3487,9 +3487,9 @@ static void disas_sparc_insn(DisasContext * dc) goto illegal_insn; } #else tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_tmp0); - tcg_gen_st_i32(cpu_tmp32, cpu_env, - offsetof(CPUSPARCState, wim)); + tcg_gen_helper_0_1(helper_wrwim, cpu_tmp32); #endif } break;