From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42343) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMntW-0001ZH-M7 for qemu-devel@nongnu.org; Sun, 09 Mar 2014 20:16:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WMntQ-0005J1-7k for qemu-devel@nongnu.org; Sun, 09 Mar 2014 20:16:38 -0400 Received: from cantor2.suse.de ([195.135.220.15]:42327 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMntP-0005Ir-Uo for qemu-devel@nongnu.org; Sun, 09 Mar 2014 20:16:32 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 10 Mar 2014 01:15:45 +0100 Message-Id: <1394410549-13751-37-git-send-email-afaerber@suse.de> In-Reply-To: <1394410549-13751-1-git-send-email-afaerber@suse.de> References: <1394410549-13751-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH qom-cpu v2 36/40] target-microblaze: Replace DisasContext::env field with MicroBlazeCPU List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, =?UTF-8?q?Andreas=20F=C3=A4rber?= , "Edgar E. Iglesias" This cleans up some mb_env_get_cpu() needed for cpu_abort(). Signed-off-by: Andreas F=C3=A4rber --- target-microblaze/translate.c | 87 +++++++++++++++++++++----------------= ------ 1 file changed, 43 insertions(+), 44 deletions(-) diff --git a/target-microblaze/translate.c b/target-microblaze/translate.= c index 4322f17..782a489 100644 --- a/target-microblaze/translate.c +++ b/target-microblaze/translate.c @@ -56,7 +56,7 @@ static TCGv env_res_val; =20 /* This is the state at translation time. */ typedef struct DisasContext { - CPUMBState *env; + MicroBlazeCPU *cpu; target_ulong pc; =20 /* Decoder. */ @@ -327,8 +327,8 @@ static void dec_pattern(DisasContext *dc) int l1; =20 if ((dc->tb_flags & MSR_EE_FLAG) - && (dc->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK) - && !((dc->env->pvr.regs[2] & PVR2_USE_PCMP_INSTR))) { + && (dc->cpu->env.pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK) + && !((dc->cpu->env.pvr.regs[2] & PVR2_USE_PCMP_INSTR))) { tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP); t_gen_raise_exception(dc, EXCP_HW_EXCP); } @@ -370,7 +370,7 @@ static void dec_pattern(DisasContext *dc) } break; default: - cpu_abort(CPU(mb_env_get_cpu(dc->env)), + cpu_abort(CPU(dc->cpu), "unsupported pattern insn opcode=3D%x\n", dc->opco= de); break; } @@ -441,11 +441,10 @@ static inline void msr_write(DisasContext *dc, TCGv= v) =20 static void dec_msr(DisasContext *dc) { - MicroBlazeCPU *cpu =3D mb_env_get_cpu(dc->env); - CPUState *cs =3D CPU(cpu); + CPUState *cs =3D CPU(dc->cpu); TCGv t0, t1; unsigned int sr, to, rn; - int mem_index =3D cpu_mmu_index(dc->env); + int mem_index =3D cpu_mmu_index(&dc->cpu->env); =20 sr =3D dc->imm & ((1 << 14) - 1); to =3D dc->imm & (1 << 14); @@ -460,7 +459,7 @@ static void dec_msr(DisasContext *dc) LOG_DIS("msr%s r%d imm=3D%x\n", clr ? "clr" : "set", dc->rd, dc->imm); =20 - if (!(dc->env->pvr.regs[2] & PVR2_USE_MSR_INSTR)) { + if (!(dc->cpu->env.pvr.regs[2] & PVR2_USE_MSR_INSTR)) { /* nop??? */ return; } @@ -539,7 +538,7 @@ static void dec_msr(DisasContext *dc) tcg_gen_st_tl(cpu_R[dc->ra], cpu_env, offsetof(CPUMBStat= e, shr)); break; default: - cpu_abort(CPU(mb_env_get_cpu(dc->env)), "unknown mts reg= %x\n", sr); + cpu_abort(CPU(dc->cpu), "unknown mts reg %x\n", sr); break; } } else { @@ -645,8 +644,8 @@ static void dec_mul(DisasContext *dc) unsigned int subcode; =20 if ((dc->tb_flags & MSR_EE_FLAG) - && (dc->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK) - && !(dc->env->pvr.regs[0] & PVR0_USE_HW_MUL_MASK)) { + && (dc->cpu->env.pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK) + && !(dc->cpu->env.pvr.regs[0] & PVR0_USE_HW_MUL_MASK)) { tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP); t_gen_raise_exception(dc, EXCP_HW_EXCP); return; @@ -664,7 +663,7 @@ static void dec_mul(DisasContext *dc) =20 /* mulh, mulhsu and mulhu are not available if C_USE_HW_MUL is < 2. = */ if (subcode >=3D 1 && subcode <=3D 3 - && !((dc->env->pvr.regs[2] & PVR2_USE_MUL64_MASK))) { + && !((dc->cpu->env.pvr.regs[2] & PVR2_USE_MUL64_MASK))) { /* nop??? */ } =20 @@ -686,7 +685,7 @@ static void dec_mul(DisasContext *dc) t_gen_mulu(d[0], cpu_R[dc->rd], cpu_R[dc->ra], cpu_R[dc->rb]= ); break; default: - cpu_abort(CPU(mb_env_get_cpu(dc->env)), "unknown MUL insn %x= \n", subcode); + cpu_abort(CPU(dc->cpu), "unknown MUL insn %x\n", subcode); break; } done: @@ -702,8 +701,8 @@ static void dec_div(DisasContext *dc) u =3D dc->imm & 2;=20 LOG_DIS("div\n"); =20 - if ((dc->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK) - && !((dc->env->pvr.regs[0] & PVR0_USE_DIV_MASK))) { + if ((dc->cpu->env.pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK) + && !((dc->cpu->env.pvr.regs[0] & PVR0_USE_DIV_MASK))) { tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP); t_gen_raise_exception(dc, EXCP_HW_EXCP); } @@ -724,8 +723,8 @@ static void dec_barrel(DisasContext *dc) unsigned int s, t; =20 if ((dc->tb_flags & MSR_EE_FLAG) - && (dc->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK) - && !(dc->env->pvr.regs[0] & PVR0_USE_BARREL_MASK)) { + && (dc->cpu->env.pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK) + && !(dc->cpu->env.pvr.regs[0] & PVR0_USE_BARREL_MASK)) { tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP); t_gen_raise_exception(dc, EXCP_HW_EXCP); return; @@ -754,11 +753,10 @@ static void dec_barrel(DisasContext *dc) =20 static void dec_bit(DisasContext *dc) { - MicroBlazeCPU *cpu =3D mb_env_get_cpu(dc->env); - CPUState *cs =3D CPU(cpu); + CPUState *cs =3D CPU(dc->cpu); TCGv t0; unsigned int op; - int mem_index =3D cpu_mmu_index(dc->env); + int mem_index =3D cpu_mmu_index(&dc->cpu->env); =20 op =3D dc->ir & ((1 << 9) - 1); switch (op) { @@ -823,12 +821,12 @@ static void dec_bit(DisasContext *dc) break; case 0xe0: if ((dc->tb_flags & MSR_EE_FLAG) - && (dc->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK) - && !((dc->env->pvr.regs[2] & PVR2_USE_PCMP_INSTR))) { + && (dc->cpu->env.pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK) + && !((dc->cpu->env.pvr.regs[2] & PVR2_USE_PCMP_INSTR))) = { tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP); t_gen_raise_exception(dc, EXCP_HW_EXCP); } - if (dc->env->pvr.regs[2] & PVR2_USE_PCMP_INSTR) { + if (dc->cpu->env.pvr.regs[2] & PVR2_USE_PCMP_INSTR) { gen_helper_clz(cpu_R[dc->rd], cpu_R[dc->ra]); } break; @@ -937,7 +935,7 @@ static void dec_load(DisasContext *dc) } =20 if (size > 4 && (dc->tb_flags & MSR_EE_FLAG) - && (dc->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK)) { + && (dc->cpu->env.pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK)) { tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP); t_gen_raise_exception(dc, EXCP_HW_EXCP); return; @@ -995,7 +993,7 @@ static void dec_load(DisasContext *dc) } break; default: - cpu_abort(CPU(mb_env_get_cpu(dc->env)), "Invalid reverse= size\n"); + cpu_abort(CPU(dc->cpu), "Invalid reverse size\n"); break; } } @@ -1022,9 +1020,9 @@ static void dec_load(DisasContext *dc) * address and if that succeeds we write into the destination reg. */ v =3D tcg_temp_new(); - tcg_gen_qemu_ld_tl(v, *addr, cpu_mmu_index(dc->env), mop); + tcg_gen_qemu_ld_tl(v, *addr, cpu_mmu_index(&dc->cpu->env), mop); =20 - if ((dc->env->pvr.regs[2] & PVR2_UNALIGNED_EXC_MASK) && size > 1) { + if ((dc->cpu->env.pvr.regs[2] & PVR2_UNALIGNED_EXC_MASK) && size > 1= ) { tcg_gen_movi_tl(cpu_SR[SR_PC], dc->pc); gen_helper_memalign(cpu_env, *addr, tcg_const_tl(dc->rd), tcg_const_tl(0), tcg_const_tl(size - 1)); @@ -1067,7 +1065,7 @@ static void dec_store(DisasContext *dc) } =20 if (size > 4 && (dc->tb_flags & MSR_EE_FLAG) - && (dc->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK)) { + && (dc->cpu->env.pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK)) { tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP); t_gen_raise_exception(dc, EXCP_HW_EXCP); return; @@ -1100,7 +1098,8 @@ static void dec_store(DisasContext *dc) this compare and the following write to be atomic. For user emulation we need to add atomicity between threads. */ tval =3D tcg_temp_new(); - tcg_gen_qemu_ld_tl(tval, swx_addr, cpu_mmu_index(dc->env), MO_TE= UL); + tcg_gen_qemu_ld_tl(tval, swx_addr, cpu_mmu_index(&dc->cpu->env), + MO_TEUL); tcg_gen_brcond_tl(TCG_COND_NE, env_res_val, tval, swx_skip); write_carryi(dc, 0); tcg_temp_free(tval); @@ -1146,14 +1145,14 @@ static void dec_store(DisasContext *dc) } break; default: - cpu_abort(CPU(mb_env_get_cpu(dc->env)), "Invalid reverse= size\n"); + cpu_abort(CPU(dc->cpu), "Invalid reverse size\n"); break; } } - tcg_gen_qemu_st_tl(cpu_R[dc->rd], *addr, cpu_mmu_index(dc->env), mop= ); + tcg_gen_qemu_st_tl(cpu_R[dc->rd], *addr, cpu_mmu_index(&dc->cpu->env= ), mop); =20 /* Verify alignment if needed. */ - if ((dc->env->pvr.regs[2] & PVR2_UNALIGNED_EXC_MASK) && size > 1) { + if ((dc->cpu->env.pvr.regs[2] & PVR2_UNALIGNED_EXC_MASK) && size > 1= ) { tcg_gen_movi_tl(cpu_SR[SR_PC], dc->pc); /* FIXME: if the alignment is wrong, we should restore the value * in memory. One possible way to achieve this is to prob= e @@ -1197,7 +1196,7 @@ static inline void eval_cc(DisasContext *dc, unsign= ed int cc, tcg_gen_setcond_tl(TCG_COND_GT, d, a, b); break; default: - cpu_abort(CPU(mb_env_get_cpu(dc->env)), "Unknown condition c= ode %x.\n", cc); + cpu_abort(CPU(dc->cpu), "Unknown condition code %x.\n", cc); break; } } @@ -1248,7 +1247,7 @@ static void dec_bcc(DisasContext *dc) static void dec_br(DisasContext *dc) { unsigned int dslot, link, abs, mbar; - int mem_index =3D cpu_mmu_index(dc->env); + int mem_index =3D cpu_mmu_index(&dc->cpu->env); =20 dslot =3D dc->ir & (1 << 20); abs =3D dc->ir & (1 << 19); @@ -1380,7 +1379,7 @@ static inline void do_rte(DisasContext *dc) static void dec_rts(DisasContext *dc) { unsigned int b_bit, i_bit, e_bit; - int mem_index =3D cpu_mmu_index(dc->env); + int mem_index =3D cpu_mmu_index(&dc->cpu->env); =20 i_bit =3D dc->ir & (1 << 21); b_bit =3D dc->ir & (1 << 22); @@ -1427,7 +1426,7 @@ static int dec_check_fpuv2(DisasContext *dc) { int r; =20 - r =3D dc->env->pvr.regs[2] & PVR2_USE_FPU2_MASK; + r =3D dc->cpu->env.pvr.regs[2] & PVR2_USE_FPU2_MASK; =20 if (!r && (dc->tb_flags & MSR_EE_FLAG)) { tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_FPU); @@ -1441,8 +1440,8 @@ static void dec_fpu(DisasContext *dc) unsigned int fpu_insn; =20 if ((dc->tb_flags & MSR_EE_FLAG) - && (dc->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK) - && !((dc->env->pvr.regs[2] & PVR2_USE_FPU_MASK))) { + && (dc->cpu->env.pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK) + && !((dc->cpu->env.pvr.regs[2] & PVR2_USE_FPU_MASK))) { tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP); t_gen_raise_exception(dc, EXCP_HW_EXCP); return; @@ -1544,7 +1543,7 @@ static void dec_fpu(DisasContext *dc) static void dec_null(DisasContext *dc) { if ((dc->tb_flags & MSR_EE_FLAG) - && (dc->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK)) { + && (dc->cpu->env.pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK)) { tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP); t_gen_raise_exception(dc, EXCP_HW_EXCP); return; @@ -1556,7 +1555,7 @@ static void dec_null(DisasContext *dc) /* Insns connected to FSL or AXI stream attached devices. */ static void dec_stream(DisasContext *dc) { - int mem_index =3D cpu_mmu_index(dc->env); + int mem_index =3D cpu_mmu_index(&dc->cpu->env); TCGv_i32 t_id, t_ctrl; int ctrl; =20 @@ -1632,8 +1631,8 @@ static inline void decode(DisasContext *dc, uint32_= t ir) dc->nr_nops =3D 0; else { if ((dc->tb_flags & MSR_EE_FLAG) - && (dc->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK) - && (dc->env->pvr.regs[2] & PVR2_OPCODE_0x0_ILL_MASK)) { + && (dc->cpu->env.pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK) + && (dc->cpu->env.pvr.regs[2] & PVR2_OPCODE_0x0_ILL_MASK)) = { tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP); t_gen_raise_exception(dc, EXCP_HW_EXCP); return; @@ -1642,7 +1641,7 @@ static inline void decode(DisasContext *dc, uint32_= t ir) LOG_DIS("nr_nops=3D%d\t", dc->nr_nops); dc->nr_nops++; if (dc->nr_nops > 4) { - cpu_abort(CPU(mb_env_get_cpu(dc->env)), "fetching nop sequen= ce\n"); + cpu_abort(CPU(dc->cpu), "fetching nop sequence\n"); } } /* bit 2 seems to indicate insn type. */ @@ -1696,7 +1695,7 @@ gen_intermediate_code_internal(MicroBlazeCPU *cpu, = TranslationBlock *tb, int max_insns; =20 pc_start =3D tb->pc; - dc->env =3D env; + dc->cpu =3D cpu; dc->tb =3D tb; org_flags =3D dc->synced_flags =3D dc->tb_flags =3D tb->flags; =20 --=20 1.8.4.5