@@ -18,7 +18,7 @@ DEF_HELPER_1(rfdi, void, env)
DEF_HELPER_1(rfmci, void, env)
#if defined(TARGET_PPC64)
DEF_HELPER_2(scv, noreturn, env, i32)
-DEF_HELPER_2(pminsn, void, env, i32)
+DEF_HELPER_2(PMINSN, void, env, i32)
DEF_HELPER_1(rfid, void, env)
DEF_HELPER_1(rfscv, void, env)
DEF_HELPER_1(hrfid, void, env)
@@ -459,7 +459,7 @@ void helper_scv(CPUPPCState *env, uint32_t lev)
}
}
-void helper_pminsn(CPUPPCState *env, uint32_t insn)
+void helper_PMINSN(CPUPPCState *env, uint32_t insn)
{
CPUState *cs = env_cpu(env);
@@ -104,102 +104,33 @@ static bool trans_MSGSYNC(DisasContext *ctx, arg_MSGSYNC *a)
return true;
}
-static bool do_doze(DisasContext *ctx, arg_DOZE *a)
-{
- REQUIRE_64BIT(ctx);
-
-#if defined(CONFIG_USER_ONLY)
- gen_priv_opc(ctx);
-#else
- TCGv_i32 t;
-
- REQUIRE_HV(ctx);
- translator_io_start(&ctx->base);
- t = tcg_constant_i32(PPC_PM_DOZE);
- gen_helper_pminsn(tcg_env, t);
- /* Stop translation, as the CPU is supposed to sleep from now */
- gen_exception_nip(ctx, EXCP_HLT, ctx->base.pc_next);
-#endif /* defined(CONFIG_USER_ONLY) */
- return true;
-}
-TRANS_FLAGS2(PM_ISA206, DOZE, do_doze);
-
-static bool do_nap(DisasContext *ctx, arg_NAP *a)
+/*
+ * Helper to handle DOZE, NAP, SLEEP, RVWINKLE & STOP. Since none of them use
+ * any arguments just use a placeholder arg_SLEEP.
+ */
+static bool do_sleep(DisasContext *ctx, arg_SLEEP *a, powerpc_pm_insn_t type)
{
REQUIRE_64BIT(ctx);
#if defined(CONFIG_USER_ONLY)
gen_priv_opc(ctx);
-#else
+#elif defined(TARGET_PPC64)
TCGv_i32 t;
REQUIRE_HV(ctx);
translator_io_start(&ctx->base);
- t = tcg_constant_i32(PPC_PM_NAP);
- gen_helper_pminsn(tcg_env, t);
+ t = tcg_constant_i32(type);
+ gen_helper_PMINSN(tcg_env, t);
/* Stop translation, as the CPU is supposed to sleep from now */
gen_exception_nip(ctx, EXCP_HLT, ctx->base.pc_next);
-#endif /* defined(CONFIG_USER_ONLY) */
- return true;
-}
-TRANS_FLAGS2(PM_ISA206, NAP, do_nap);
-
-static bool do_sleep(DisasContext *ctx, arg_SLEEP *a)
-{
- REQUIRE_64BIT(ctx);
-
-#if defined(CONFIG_USER_ONLY)
- gen_priv_opc(ctx);
#else
- TCGv_i32 t;
-
- REQUIRE_HV(ctx);
- translator_io_start(&ctx->base);
- t = tcg_constant_i32(PPC_PM_SLEEP);
- gen_helper_pminsn(tcg_env, t);
- /* Stop translation, as the CPU is supposed to sleep from now */
- gen_exception_nip(ctx, EXCP_HLT, ctx->base.pc_next);
-#endif /* defined(CONFIG_USER_ONLY) */
- return true;
-}
-TRANS_FLAGS2(PM_ISA206, SLEEP, do_sleep);
-
-static bool do_rvwinkle(DisasContext *ctx, arg_RVWINKLE *a)
-{
- REQUIRE_64BIT(ctx);
-
-#if defined(CONFIG_USER_ONLY)
- gen_priv_opc(ctx);
-#else
- TCGv_i32 t;
-
- REQUIRE_HV(ctx);
- translator_io_start(&ctx->base);
- t = tcg_constant_i32(PPC_PM_RVWINKLE);
- gen_helper_pminsn(tcg_env, t);
- /* Stop translation, as the CPU is supposed to sleep from now */
- gen_exception_nip(ctx, EXCP_HLT, ctx->base.pc_next);
-#endif /* defined(CONFIG_USER_ONLY) */
+ qemu_build_not_reached();
+#endif
return true;
}
-TRANS_FLAGS2(PM_ISA206, RVWINKLE, do_rvwinkle);
-
-static bool do_stop(DisasContext *ctx, arg_STOP *a)
-{
- REQUIRE_64BIT(ctx);
-#if defined(CONFIG_USER_ONLY)
- gen_priv_opc(ctx);
-#else
- TCGv_i32 t;
-
- REQUIRE_HV(ctx);
- translator_io_start(&ctx->base);
- t = tcg_constant_i32(PPC_PM_STOP);
- gen_helper_pminsn(tcg_env, t);
- /* Stop translation, as the CPU is supposed to sleep from now */
- gen_exception_nip(ctx, EXCP_HLT, ctx->base.pc_next);
-#endif /* defined(CONFIG_USER_ONLY) */
- return true;
-}
-TRANS_FLAGS2(ISA300, STOP, do_stop);
+TRANS_FLAGS2(PM_ISA206, DOZE, do_sleep, PPC_PM_DOZE);
+TRANS_FLAGS2(PM_ISA206, NAP, do_sleep, PPC_PM_NAP);
+TRANS_FLAGS2(PM_ISA206, SLEEP, do_sleep, PPC_PM_SLEEP);
+TRANS_FLAGS2(PM_ISA206, RVWINKLE, do_sleep, PPC_PM_RVWINKLE);
+TRANS_FLAGS2(ISA300, STOP, do_sleep, PPC_PM_STOP);