From 250ef8c76861c756354ed1c67f0a4524e5339369 Mon Sep 17 00:00:00 2001 From: Bastian Koppelmann Date: Tue, 9 Dec 2014 16:04:46 +0000 Subject: [PATCH 1/5] target-tricore: Fix LOOP using wrong register for compare Signed-off-by: Bastian Koppelmann --- target-tricore/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target-tricore/translate.c b/target-tricore/translate.c index 54a48cd694..d2cd64013d 100644 --- a/target-tricore/translate.c +++ b/target-tricore/translate.c @@ -3440,7 +3440,7 @@ static void gen_compute_branch(DisasContext *ctx, uint32_t opc, int r1, break; case OPCM_32_BRR_LOOP: if (MASK_OP_BRR_OP2(ctx->opcode) == OPC2_32_BRR_LOOP) { - gen_loop(ctx, r1, offset * 2); + gen_loop(ctx, r2, offset * 2); } else { /* OPC2_32_BRR_LOOPU */ gen_goto_tb(ctx, 0, ctx->pc + offset * 2); From 7bd0eaec311d188412123a034abb44595deb7dae Mon Sep 17 00:00:00 2001 From: Bastian Koppelmann Date: Fri, 3 Apr 2015 14:29:22 +0200 Subject: [PATCH 2/5] target-tricore: fix SLR_LD_W and SLR_LD_W_POSTINC insn being a 2 byte memory access insted of 4 Signed-off-by: Bastian Koppelmann --- target-tricore/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target-tricore/translate.c b/target-tricore/translate.c index d2cd64013d..663b2a0796 100644 --- a/target-tricore/translate.c +++ b/target-tricore/translate.c @@ -3745,10 +3745,10 @@ static void decode_slr_opc(DisasContext *ctx, int op1) tcg_gen_addi_tl(cpu_gpr_a[r2], cpu_gpr_a[r2], 2); break; case OPC1_16_SLR_LD_W: - tcg_gen_qemu_ld_tl(cpu_gpr_d[r1], cpu_gpr_a[r2], ctx->mem_idx, MO_LESW); + tcg_gen_qemu_ld_tl(cpu_gpr_d[r1], cpu_gpr_a[r2], ctx->mem_idx, MO_LESL); break; case OPC1_16_SLR_LD_W_POSTINC: - tcg_gen_qemu_ld_tl(cpu_gpr_d[r1], cpu_gpr_a[r2], ctx->mem_idx, MO_LESW); + tcg_gen_qemu_ld_tl(cpu_gpr_d[r1], cpu_gpr_a[r2], ctx->mem_idx, MO_LESL); tcg_gen_addi_tl(cpu_gpr_a[r2], cpu_gpr_a[r2], 4); break; } From 4959d6b3662d94a5add5811ba1ff5243116b8987 Mon Sep 17 00:00:00 2001 From: Bastian Koppelmann Date: Tue, 5 May 2015 19:36:55 +0200 Subject: [PATCH 3/5] target-tricore: fix BO_OFF10_SEXT calculating the wrong offset The lower part of the combined offset was sign extended and could lead to wrong results. Signed-off-by: Bastian Koppelmann --- target-tricore/tricore-opcodes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target-tricore/tricore-opcodes.h b/target-tricore/tricore-opcodes.h index d3a9bc158b..2291f75fd9 100644 --- a/target-tricore/tricore-opcodes.h +++ b/target-tricore/tricore-opcodes.h @@ -107,7 +107,7 @@ /* BO Format */ #define MASK_OP_BO_OFF10(op) (MASK_BITS_SHIFT(op, 16, 21) + \ (MASK_BITS_SHIFT(op, 28, 31) << 6)) -#define MASK_OP_BO_OFF10_SEXT(op) (MASK_BITS_SHIFT_SEXT(op, 16, 21) + \ +#define MASK_OP_BO_OFF10_SEXT(op) (MASK_BITS_SHIFT(op, 16, 21) + \ (MASK_BITS_SHIFT_SEXT(op, 28, 31) << 6)) #define MASK_OP_BO_OP2(op) MASK_BITS_SHIFT(op, 22, 27) #define MASK_OP_BO_S2(op) MASK_BITS_SHIFT(op, 12, 15) From bc72f8aaf23fa11833e0e04c10b5c0e1036c2609 Mon Sep 17 00:00:00 2001 From: Bastian Koppelmann Date: Tue, 5 May 2015 19:39:18 +0200 Subject: [PATCH 4/5] target-tricore: fix rslcx restoring the upper context instead of the lower Signed-off-by: Bastian Koppelmann --- target-tricore/op_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target-tricore/op_helper.c b/target-tricore/op_helper.c index 9907e07e22..1dc25c2349 100644 --- a/target-tricore/op_helper.c +++ b/target-tricore/op_helper.c @@ -2581,7 +2581,7 @@ void helper_rslcx(CPUTriCoreState *env) ((env->PCXI & MASK_PCXI_PCXO) << 6); /* {new_PCXI, A[11], A[10], A[11], D[8], D[9], D[10], D[11], A[12], A[13], A[14], A[15], D[12], D[13], D[14], D[15]} = M(EA, 16 * word); */ - restore_context_upper(env, ea, &new_PCXI, &env->gpr_a[11]); + restore_context_lower(env, ea, &env->gpr_a[11], &new_PCXI); /* M(EA, word) = FCX; */ cpu_stl_data(env, ea, env->FCX); /* M(EA, word) = FCX; */ From 3446a11181c6e8263dbd9c13c28986df4317099e Mon Sep 17 00:00:00 2001 From: Bastian Koppelmann Date: Tue, 5 May 2015 19:41:10 +0200 Subject: [PATCH 5/5] target-tricore: fix rfe not restoring the PC Signed-off-by: Bastian Koppelmann --- target-tricore/op_helper.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target-tricore/op_helper.c b/target-tricore/op_helper.c index 1dc25c2349..9919b5b17b 100644 --- a/target-tricore/op_helper.c +++ b/target-tricore/op_helper.c @@ -2458,6 +2458,7 @@ void helper_rfe(CPUTriCoreState *env) if (!cdc_zero(&(env->PSW)) && (env->PSW & MASK_PSW_CDE)) { /* raise MNG trap */ } + env->PC = env->gpr_a[11] & ~0x1; /* ICR.IE = PCXI.PIE; */ env->ICR = (env->ICR & ~MASK_ICR_IE) + ((env->PCXI & MASK_PCXI_PIE) >> 15); /* ICR.CCPN = PCXI.PCPN; */