From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KnLMB-0007Oo-8A for qemu-devel@nongnu.org; Tue, 07 Oct 2008 18:48:43 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KnLMA-0007O1-NN for qemu-devel@nongnu.org; Tue, 07 Oct 2008 18:48:42 -0400 Received: from [199.232.76.173] (port=37918 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KnLMA-0007Nu-EJ for qemu-devel@nongnu.org; Tue, 07 Oct 2008 18:48:42 -0400 Received: from savannah.gnu.org ([199.232.41.3]:53335 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KnLMA-00022l-5b for qemu-devel@nongnu.org; Tue, 07 Oct 2008 18:48:42 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KnLM9-0006is-HZ for qemu-devel@nongnu.org; Tue, 07 Oct 2008 22:48:41 +0000 Received: from edgar_igl by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KnLM9-0006io-B0 for qemu-devel@nongnu.org; Tue, 07 Oct 2008 22:48:41 +0000 MIME-Version: 1.0 Errors-To: edgar_igl Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: "Edgar E. Iglesias" Message-Id: Date: Tue, 07 Oct 2008 22:48:41 +0000 Subject: [Qemu-devel] [5445] CRIS: Fix brk 8 and add S-flag emulation. 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 Revision: 5445 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5445 Author: edgar_igl Date: 2008-10-07 22:48:41 +0000 (Tue, 07 Oct 2008) Log Message: ----------- CRIS: Fix brk 8 and add S-flag emulation. * break 8 sets ERP to the current insn. * First shot at S flag single-stepping. * Make it easier to use the local disasm. Modified Paths: -------------- trunk/cpu-exec.c trunk/target-cris/helper.c trunk/target-cris/helper.h trunk/target-cris/op_helper.c trunk/target-cris/translate.c Modified: trunk/cpu-exec.c =================================================================== --- trunk/cpu-exec.c 2008-10-07 21:22:41 UTC (rev 5444) +++ trunk/cpu-exec.c 2008-10-07 22:48:41 UTC (rev 5445) @@ -220,7 +220,7 @@ cs_base = 0; pc = env->pc; #elif defined(TARGET_CRIS) - flags = env->pregs[PR_CCS] & (P_FLAG | U_FLAG | X_FLAG); + flags = env->pregs[PR_CCS] & (S_FLAG | P_FLAG | U_FLAG | X_FLAG); flags |= env->dslot; cs_base = 0; pc = env->pc; Modified: trunk/target-cris/helper.c =================================================================== --- trunk/target-cris/helper.c 2008-10-07 21:22:41 UTC (rev 5444) +++ trunk/target-cris/helper.c 2008-10-07 22:48:41 UTC (rev 5445) @@ -119,7 +119,7 @@ /* These exceptions are genereated by the core itself. ERP should point to the insn following the brk. */ ex_vec = env->trap_vector; - env->pregs[PR_ERP] = env->pc + 2; + env->pregs[PR_ERP] = env->pc; break; case EXCP_NMI: Modified: trunk/target-cris/helper.h =================================================================== --- trunk/target-cris/helper.h 2008-10-07 21:22:41 UTC (rev 5444) +++ trunk/target-cris/helper.h 2008-10-07 22:48:41 UTC (rev 5445) @@ -2,6 +2,7 @@ void TCG_HELPER_PROTO helper_raise_exception(uint32_t index); void TCG_HELPER_PROTO helper_tlb_flush_pid(uint32_t pid); +void TCG_HELPER_PROTO helper_spc_write(uint32_t pid); void TCG_HELPER_PROTO helper_dump(uint32_t a0, uint32_t a1, uint32_t a2); void TCG_HELPER_PROTO helper_rfe(void); void TCG_HELPER_PROTO helper_rfn(void); Modified: trunk/target-cris/op_helper.c =================================================================== --- trunk/target-cris/op_helper.c 2008-10-07 21:22:41 UTC (rev 5444) +++ trunk/target-cris/op_helper.c 2008-10-07 22:48:41 UTC (rev 5445) @@ -97,6 +97,14 @@ #endif } +void helper_spc_write(uint32_t new_spc) +{ +#if !defined(CONFIG_USER_ONLY) + tlb_flush_page(env, env->pregs[PR_SPC]); + tlb_flush_page(env, new_spc); +#endif +} + void helper_dump(uint32_t a0, uint32_t a1, uint32_t a2) { (fprintf(logfile, "%s: a0=%x a1=%x\n", __func__, a0, a1)); Modified: trunk/target-cris/translate.c =================================================================== --- trunk/target-cris/translate.c 2008-10-07 21:22:41 UTC (rev 5444) +++ trunk/target-cris/translate.c 2008-10-07 22:48:41 UTC (rev 5445) @@ -41,7 +41,7 @@ #define DISAS_CRIS 0 #if DISAS_CRIS -#define DIS(x) x +#define DIS(x) if (loglevel & CPU_LOG_TB_IN_ASM) x #else #define DIS(x) #endif @@ -218,6 +218,8 @@ else { if (r == PR_PID) tcg_gen_helper_0_1(helper_tlb_flush_pid, tn); + if (dc->tb_flags & S_FLAG && r == PR_SPC) + tcg_gen_helper_0_1(helper_spc_write, tn); else if (r == PR_CCS) dc->cpustate_changed = 1; tcg_gen_mov_tl(cpu_PR[r], tn); @@ -1377,8 +1379,6 @@ } else imm = ldl_code(dc->pc + 2); - DIS(fprintf (logfile, "imm=%x rd=%d sext=%d ms=%d\n", - imm, rd, s_ext, memsize)); tcg_gen_movi_tl(dst, imm); dc->postinc = 0; } else { @@ -2063,7 +2063,7 @@ /* User space is not allowed to touch these. Silently ignore. */ if (dc->tb_flags & U_FLAG) { - flags &= ~(I_FLAG | U_FLAG); + flags &= ~(S_FLAG | I_FLAG | U_FLAG); } if (flags & X_FLAG) { @@ -2083,6 +2083,9 @@ dc->cpustate_changed = 1; } } + if (flags & S_FLAG) { + dc->cpustate_changed = 1; + } /* Simply decode the flags. */ @@ -2784,9 +2787,6 @@ static unsigned int dec_rfe_etc(DisasContext *dc) { - DIS(fprintf (logfile, "rfe_etc opc=%x pc=0x%x op1=%d op2=%d\n", - dc->opcode, dc->pc, dc->op1, dc->op2)); - cris_cc_mask(dc, 0); if (dc->op2 == 15) /* ignore halt. */ @@ -2795,19 +2795,29 @@ switch (dc->op2 & 7) { case 2: /* rfe. */ + DIS(fprintf(logfile, "rfe\n")); cris_evaluate_flags(dc); tcg_gen_helper_0_0(helper_rfe); dc->is_jmp = DISAS_UPDATE; break; case 5: /* rfn. */ + DIS(fprintf(logfile, "rfn\n")); cris_evaluate_flags(dc); tcg_gen_helper_0_0(helper_rfn); dc->is_jmp = DISAS_UPDATE; break; case 6: + DIS(fprintf(logfile, "break %d\n", dc->op1)); + cris_evaluate_flags (dc); /* break. */ - tcg_gen_movi_tl(env_pc, dc->pc); + if (dc->op1 == 8) { + /* TODO: Find out whats special with brk8. */ + tcg_gen_movi_tl(env_pc, dc->pc); + } + else + tcg_gen_movi_tl(env_pc, dc->pc + 2); + /* Breaks start at 16 in the exception vector. */ t_gen_mov_env_TN(trap_vector, tcg_const_tl(dc->op1 + 16)); @@ -2984,6 +2994,22 @@ } } +#if defined(CONFIG_USER_ONLY) + /* Single-stepping ? */ + if (dc->tb_flags & S_FLAG) { + int l1; + + l1 = gen_new_label(); + tcg_gen_brcondi_tl(TCG_COND_NE, + cpu_PR[PR_SPC], tcg_const_tl(dc->pc), l1); + /* We treat SPC as a break with an odd trap vector. */ + cris_evaluate_flags (dc); + t_gen_mov_env_TN(trap_vector, tcg_const_tl(3)); + tcg_gen_movi_tl(env_pc, dc->pc + insn_len); + t_gen_raise_exception(EXCP_BREAK); + gen_set_label(l1); + } +#endif return insn_len; } @@ -3080,7 +3106,7 @@ dc->cc_size_uptodate = -1; /* Decode TB flags. */ - dc->tb_flags = tb->flags & (P_FLAG | U_FLAG | X_FLAG); + dc->tb_flags = tb->flags & (S_FLAG | P_FLAG | U_FLAG | X_FLAG); dc->delayed_branch = !!(tb->flags & 7); if (dc->delayed_branch) dc->jmp = JMP_INDIRECT; @@ -3108,7 +3134,8 @@ env->regs[10], env->regs[11], env->regs[12], env->regs[13], env->regs[14], env->regs[15]); - + fprintf(logfile, "--------------\n"); + fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start)); } next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; @@ -3139,10 +3166,7 @@ } /* Pretty disas. */ - DIS(fprintf(logfile, "%x ", dc->pc)); - if (search_pc) { - DIS(fprintf(logfile, "%x ", dc->pc)); - } + DIS(fprintf(logfile, "%8.8x:\t", dc->pc)); if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) gen_io_start(); @@ -3241,14 +3265,14 @@ } #ifdef DEBUG_DISAS +#if !DISAS_CRIS if (loglevel & CPU_LOG_TB_IN_ASM) { - fprintf(logfile, "--------------\n"); - fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start)); target_disas(logfile, pc_start, dc->pc - pc_start, 0); fprintf(logfile, "\nisize=%d osize=%zd\n", dc->pc - pc_start, gen_opc_ptr - gen_opc_buf); } #endif +#endif } void gen_intermediate_code (CPUState *env, struct TranslationBlock *tb)