Skip to content

Commit

Permalink
target/sparc: implement asr17 feature for smp
Browse files Browse the repository at this point in the history
This allows the guest program to know its cpu id.

Co-developed-by: Frederic Konrad <konrad.frederic@yahoo.fr>
Signed-off-by: Clément Chigot <chigot@adacore.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240131085047.18458-6-chigot@adacore.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
  • Loading branch information
Helflym authored and philmd committed Feb 15, 2024
1 parent 0fa5cd4 commit c92948f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
16 changes: 16 additions & 0 deletions target/sparc/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,20 @@ void helper_power_down(CPUSPARCState *env)
env->npc = env->pc + 4;
cpu_loop_exit(cs);
}

target_ulong helper_rdasr17(CPUSPARCState *env)
{
CPUState *cs = env_cpu(env);
target_ulong val;

/*
* TODO: There are many more fields to be filled,
* some of which are writable.
*/
val = env->def.nwindows - 1; /* [4:0] NWIN */
val |= 1 << 8; /* [8] V8 */
val |= (cs->cpu_index) << 28; /* [31:28] INDEX */

return val;
}
#endif
1 change: 1 addition & 0 deletions target/sparc/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
DEF_HELPER_1(rett, void, env)
DEF_HELPER_2(wrpsr, void, env, tl)
DEF_HELPER_1(rdpsr, tl, env)
DEF_HELPER_1(rdasr17, tl, env)
DEF_HELPER_1(power_down, void, env)
#else
DEF_HELPER_FLAGS_2(wrpil, TCG_CALL_NO_RWG, void, env, tl)
Expand Down
13 changes: 3 additions & 10 deletions target/sparc/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#ifdef TARGET_SPARC64
# define gen_helper_rdpsr(D, E) qemu_build_not_reached()
# define gen_helper_rdasr17(D, E) qemu_build_not_reached()
# define gen_helper_rett(E) qemu_build_not_reached()
# define gen_helper_power_down(E) qemu_build_not_reached()
# define gen_helper_wrpsr(E, S) qemu_build_not_reached()
Expand Down Expand Up @@ -2382,16 +2383,8 @@ static bool trans_RDY(DisasContext *dc, arg_RDY *a)

static TCGv do_rd_leon3_config(DisasContext *dc, TCGv dst)
{
uint32_t val;

/*
* TODO: There are many more fields to be filled,
* some of which are writable.
*/
val = dc->def->nwindows - 1; /* [4:0] NWIN */
val |= 1 << 8; /* [8] V8 */

return tcg_constant_tl(val);
gen_helper_rdasr17(dst, tcg_env);
return dst;
}

TRANS(RDASR17, ASR17, do_rd_special, true, a->rd, do_rd_leon3_config)
Expand Down

0 comments on commit c92948f

Please sign in to comment.