target: e2k: Fix ct in gdb.

This commit is contained in:
Denis Drakhnia 2020-11-23 13:35:04 +02:00
parent 0f10ca4949
commit e01acef8ad
7 changed files with 25 additions and 19 deletions

View File

@ -45,8 +45,7 @@ void cpu_loop(CPUE2KState *env)
queue_signal(env, info.si_signo, QEMU_SI_KILL, &info);
break;
case E2K_EXCP_SYSCALL: {
int wbs = e2k_state_cr1_wbs_get(env);
int offset = wbs * 2;
int offset = env->wd_base + env->syscall_wbs * 2;
uint64_t *regs = env->wregs;
abi_ulong ret = do_syscall(env,
regs[(0 + offset) % WREGS_SIZE],

View File

@ -264,6 +264,7 @@ typedef struct {
int interrupt_index;
uint32_t is_bp; /* breakpoint flag */
int syscall_wbs; // FIXME: temp for syscall
/* Fields up to this point are cleared by a CPU reset */
struct {} end_reset_fields;

View File

@ -70,7 +70,7 @@ static void pcs_push(CPUE2KState *env, int wbs)
save_br_state(env);
e2k_state_cr1_wpsz_set(env, env->wd_psize / 2);
memcpy(pcsp, env->proc_chain, 32);
memcpy(pcsp, &env->proc_chain[0], 32);
e2k_state_cr1_wbs_set(env, wbs);
e2k_state_pcs_index_set(env, offset + 32);
@ -86,7 +86,7 @@ static void pcs_pop(CPUE2KState *env)
abort();
}
memcpy(&env->proc_chain, pcsp, 32);
memcpy(&env->proc_chain[0], pcsp, 32);
// TODO: restore wbs (after pshtp implemented)
env->wd_psize = e2k_state_cr1_wpsz_get(env) * 2;
@ -166,10 +166,9 @@ void helper_return(CPUE2KState *env)
static inline void do_syscall(CPUE2KState *env, int call_wbs)
{
do_call(env, call_wbs);
helper_raise_exception(env, E2K_EXCP_SYSCALL);
helper_return(env);
env->syscall_wbs = call_wbs;
reset_ctprs(env);
helper_raise_exception(env, E2K_EXCP_SYSCALL);
}
target_ulong helper_call(CPUE2KState *env, uint64_t ctpr,

View File

@ -339,6 +339,7 @@ static inline void do_branch(DisasContext *ctx)
TCGLabel *l0;
if (ctx->ct.type == CT_NONE) {
tcg_gen_movi_tl(e2k_cs.pc, ctx->npc);
return;
}
@ -349,10 +350,14 @@ static inline void do_branch(DisasContext *ctx)
tcg_gen_movi_tl(e2k_cs.pc, ctx->npc);
tcg_gen_exit_tb(NULL, 0);
gen_set_label(l0);
gen_save_npc(ctx->npc);
switch(ctx->ct.type) {
case CT_IBRANCH:
gen_goto_tb(ctx, 0, ctx->pc, ctx->ct.u.target);
// FIXME: does not work with gdb
// gen_goto_tb(ctx, 0, ctx->pc, ctx->ct.u.target);
tcg_gen_movi_tl(e2k_cs.pc, ctx->ct.u.target);
tcg_gen_exit_tb(NULL, 0);
break;
case CT_JUMP: {
TCGLabel *l0 = gen_new_label();
@ -371,13 +376,13 @@ static inline void do_branch(DisasContext *ctx)
gen_goto_ctpr_disp(ctx->ct.u.ctpr);
gen_set_label(l1);
// FIXME: gdb does not see IP change
gen_helper_return(cpu_env);
tcg_gen_lookup_and_goto_ptr();
break;
}
case CT_CALL: {
TCGv_i32 wbs = tcg_const_i32(ctx->ct.wbs);
gen_save_npc(ctx->npc);
gen_helper_call(e2k_cs.pc, cpu_env, ctx->ct.u.ctpr, wbs);
tcg_temp_free_i32(wbs);
tcg_gen_lookup_and_goto_ptr();
@ -402,8 +407,7 @@ static bool e2k_tr_breakpoint_check(DisasContextBase *db, CPUState *cs,
{
DisasContext *dc = container_of(db, DisasContext, base);
tcg_gen_movi_tl(e2k_cs.pc, dc->base.pc_next);
tcg_gen_movi_tl(e2k_cs.npc, dc->npc);
// TODO: suppress on branch to self
gen_helper_debug(cpu_env);
tcg_gen_exit_tb(NULL, 0);
dc->base.is_jmp = DISAS_NORETURN;
@ -465,7 +469,10 @@ static void e2k_tr_tb_stop(DisasContextBase *db, CPUState *cs)
switch(ctx->base.is_jmp) {
case DISAS_NEXT:
case DISAS_TOO_MANY:
gen_goto_tb(ctx, 0, ctx->pc, ctx->npc);
// FIXME: ibranch has some troubles with goto_tb in gdb
// gen_goto_tb(ctx, 0, ctx->pc, ctx->npc);
tcg_gen_movi_tl(e2k_cs.pc, ctx->npc);
tcg_gen_exit_tb(NULL, 0);
break;
case DISAS_NORETURN:
break;
@ -513,8 +520,8 @@ void e2k_tcg_initialize(void) {
char buf[16] = { 0 };
static const struct { TCGv_i32 *ptr; int off; const char *name; } r32[] = {
{ &e2k_cs.woff, offsetof(CPUE2KState, wd_base), "woff" },
{ &e2k_cs.wsize, offsetof(CPUE2KState, wd_size), "wsize" },
{ &e2k_cs.wd_base, offsetof(CPUE2KState, wd_base), "woff" },
{ &e2k_cs.wd_size, offsetof(CPUE2KState, wd_size), "wsize" },
{ &e2k_cs.boff, offsetof(CPUE2KState, boff), "boff" },
{ &e2k_cs.bsize, offsetof(CPUE2KState, bsize), "bsize" },
{ &e2k_cs.bcur, offsetof(CPUE2KState, bcur), "bcur" },

View File

@ -65,8 +65,8 @@ typedef struct CPUE2KStateTCG {
TCGv_i64 wregs[WREGS_SIZE];
TCGv_i64 gregs[GREGS_SIZE];
TCGv_ptr wptr; /* pointer to wregs */
TCGv_i32 woff; /* holds wbs * 2 */
TCGv_i32 wsize; /* holds wsz * 2 */
TCGv_i32 wd_base; /* holds wbs * 2 */
TCGv_i32 wd_size; /* holds wsz * 2 */
TCGv_i32 boff; /* holds rbs * 2 */
TCGv_i32 bsize; /* holds rsz * 2 + 2 */
TCGv_i32 bcur; /* holds rcur * 2 */

View File

@ -367,7 +367,7 @@ static void gen_cs1(DisasContext *dc)
int wsz = GET_FIELD(lts0, 5, 11);
TCGv_i32 t0 = tcg_const_i32(lts0);
tcg_gen_movi_i32(e2k_cs.wsize, wsz * 2);
tcg_gen_movi_i32(e2k_cs.wd_size, wsz * 2);
tcg_temp_free_i32(t0);
}

View File

@ -94,7 +94,7 @@ static inline void gen_wreg_index(TCGv_i32 ret, int reg)
TCGv_i32 t1 = tcg_const_i32(WREGS_SIZE);
/* TODO: exception if overflow window size */
tcg_gen_addi_i32(t0, e2k_cs.woff, reg);
tcg_gen_addi_i32(t0, e2k_cs.wd_base, reg);
tcg_gen_remu_i32(ret, t0, t1);
tcg_temp_free_i32(t1);
@ -151,7 +151,7 @@ static inline void gen_breg_index(TCGv_i32 ret, int reg)
tcg_gen_addi_i32(t0, e2k_cs.bcur, reg);
tcg_gen_remu_i32(t1, t0, e2k_cs.bsize);
tcg_gen_add_i32(t2, t1, e2k_cs.boff);
tcg_gen_add_i32(t3, t2, e2k_cs.woff);
tcg_gen_add_i32(t3, t2, e2k_cs.wd_base);
tcg_gen_remu_i32(ret, t3, t4);
tcg_temp_free_i32(t4);