@@ -19,10 +19,10 @@ typedef struct SysemuCPUOps {
/**
* @has_work: Callback for checking if there is work to do.
*
- * This function should be idempotent (i.e. not change state) as
+ * This function is idempotent (i.e. not change state) as
* it will likely be queried multiple times before a CPU resumes.
*/
- bool (*has_work)(CPUState *cpu); /* MANDATORY NON-NULL */
+ bool (*has_work)(const CPUState *cpu); /* MANDATORY NON-NULL */
/**
* @get_memory_mapping: Callback for obtaining the memory mappings.
*/
@@ -77,7 +77,7 @@ static void alpha_restore_state_to_opc(CPUState *cs,
}
#ifndef CONFIG_USER_ONLY
-static bool alpha_cpu_has_work(CPUState *cs)
+static bool alpha_cpu_has_work(const CPUState *cs)
{
/* Here we are checking to see if the CPU should wake up from HALT.
We will have gotten into this state only for WTINT from PALmode. */
@@ -141,9 +141,9 @@ int arm_cpu_mmu_index(CPUState *cs, bool ifetch)
* CPU_INTERRUPT_*NMI anyway. So we might as well accept NMI here
* unconditionally.
*/
-static bool arm_cpu_has_work(CPUState *cs)
+static bool arm_cpu_has_work(const CPUState *cs)
{
- ARMCPU *cpu = ARM_CPU(cs);
+ const ARMCPU *cpu = ARM_CPU(cs);
/*
* Only another PSCI call can wake the CPU up in which case the
@@ -23,6 +23,7 @@
#include "qemu/qemu-print.h"
#include "exec/translation-block.h"
#include "system/address-spaces.h"
+#include "hw/core/cpu.h"
#include "cpu.h"
#include "disas/dis-asm.h"
#include "tcg/debug-assert.h"
@@ -43,7 +44,7 @@ static vaddr avr_cpu_get_pc(CPUState *cs)
return cpu->env.pc_w * 2;
}
-static bool avr_cpu_has_work(CPUState *cs)
+static bool avr_cpu_has_work(const CPUState *cs)
{
return cpu_test_interrupt(cs, CPU_INTERRUPT_HARD | CPU_INTERRUPT_RESET)
&& cpu_interrupts_enabled(cpu_env(cs));
@@ -364,9 +364,9 @@ bool hexagon_thread_is_enabled(const CPUHexagonState *env)
return E_bit;
}
-static bool hexagon_cpu_has_work(CPUState *cs)
+static bool hexagon_cpu_has_work(const CPUState *cs)
{
- CPUHexagonState *env = cpu_env(cs);
+ const CPUHexagonState *env = cpu_env(cs);
return hexagon_thread_is_enabled(env) &&
(cs->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_SWI
@@ -134,7 +134,7 @@ static void hppa_restore_state_to_opc(CPUState *cs,
}
#ifndef CONFIG_USER_ONLY
-static bool hppa_cpu_has_work(CPUState *cs)
+static bool hppa_cpu_has_work(const CPUState *cs)
{
return cpu_test_interrupt(cs, CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI);
}
@@ -10638,7 +10638,7 @@ int x86_cpu_pending_interrupt(const CPUState *cs, int interrupt_request)
return 0;
}
-static bool x86_cpu_has_work(CPUState *cs)
+static bool x86_cpu_has_work(const CPUState *cs)
{
return x86_cpu_pending_interrupt(cs, cs->interrupt_request) != 0;
}
@@ -110,7 +110,7 @@ bool cpu_loongarch_hw_interrupts_pending(const CPULoongArchState *env)
#endif
#ifndef CONFIG_USER_ONLY
-static bool loongarch_cpu_has_work(CPUState *cs)
+static bool loongarch_cpu_has_work(const CPUState *cs)
{
bool has_work = false;
@@ -76,7 +76,7 @@ static void m68k_restore_state_to_opc(CPUState *cs,
}
#ifndef CONFIG_USER_ONLY
-static bool m68k_cpu_has_work(CPUState *cs)
+static bool m68k_cpu_has_work(const CPUState *cs)
{
return cpu_test_interrupt(cs, CPU_INTERRUPT_HARD);
}
@@ -127,7 +127,7 @@ static void mb_restore_state_to_opc(CPUState *cs,
}
#ifndef CONFIG_USER_ONLY
-static bool mb_cpu_has_work(CPUState *cs)
+static bool mb_cpu_has_work(const CPUState *cs)
{
return cpu_test_interrupt(cs, CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI);
}
@@ -134,9 +134,9 @@ static vaddr mips_cpu_get_pc(CPUState *cs)
}
#if !defined(CONFIG_USER_ONLY)
-static bool mips_cpu_has_work(CPUState *cs)
+static bool mips_cpu_has_work(const CPUState *cs)
{
- CPUMIPSState *env = cpu_env(cs);
+ const CPUMIPSState *env = cpu_env(cs);
bool has_work = false;
/*
@@ -76,7 +76,7 @@ static void openrisc_restore_state_to_opc(CPUState *cs,
}
#ifndef CONFIG_USER_ONLY
-static bool openrisc_cpu_has_work(CPUState *cs)
+static bool openrisc_cpu_has_work(const CPUState *cs)
{
return cpu_test_interrupt(cs, CPU_INTERRUPT_HARD | CPU_INTERRUPT_TIMER);
}
@@ -7222,7 +7222,7 @@ static int ppc_cpu_mmu_index(CPUState *cs, bool ifetch)
#endif /* CONFIG_TCG */
#ifndef CONFIG_USER_ONLY
-static bool ppc_cpu_has_work(CPUState *cs)
+static bool ppc_cpu_has_work(const CPUState *cs)
{
return cpu_test_interrupt(cs, CPU_INTERRUPT_HARD);
}
@@ -953,10 +953,9 @@ int riscv_cpu_vsirq_pending(const CPURISCVState *env)
(irqs | irqs_f_vs), env->hviprio);
}
-static bool riscv_cpu_has_work(CPUState *cs)
+static bool riscv_cpu_has_work(const CPUState *cs)
{
- RISCVCPU *cpu = RISCV_CPU(cs);
- CPURISCVState *env = &cpu->env;
+ const CPURISCVState *env = cpu_env(cs);
/*
* Definition of the WFI instruction requires it to ignore the privilege
* mode and delegation registers, but respect individual enables
@@ -73,7 +73,7 @@ static void rx_restore_state_to_opc(CPUState *cs,
cpu->env.pc = data[0];
}
-static bool rx_cpu_has_work(CPUState *cs)
+static bool rx_cpu_has_work(const CPUState *cs)
{
return cpu_test_interrupt(cs, CPU_INTERRUPT_HARD | CPU_INTERRUPT_FIR);
}
@@ -39,9 +39,9 @@
#include "system/tcg.h"
#include "hw/core/sysemu-cpu-ops.h"
-static bool s390_cpu_has_work(CPUState *cs)
+static bool s390_cpu_has_work(const CPUState *cs)
{
- S390CPU *cpu = S390_CPU(cs);
+ const S390CPU *cpu = S390_CPU(cs);
/* STOPPED cpus can never wake up */
if (s390_cpu_get_state(cpu) != S390_CPU_STATE_LOAD &&
@@ -107,7 +107,7 @@ static bool superh_io_recompile_replay_branch(CPUState *cs,
return false;
}
-static bool superh_cpu_has_work(CPUState *cs)
+static bool superh_cpu_has_work(const CPUState *cs)
{
return cpu_test_interrupt(cs, CPU_INTERRUPT_HARD);
}
@@ -783,7 +783,7 @@ static void sparc_restore_state_to_opc(CPUState *cs,
}
#ifndef CONFIG_USER_ONLY
-static bool sparc_cpu_has_work(CPUState *cs)
+static bool sparc_cpu_has_work(const CPUState *cs)
{
return cpu_test_interrupt(cs, CPU_INTERRUPT_HARD) &&
cpu_interrupts_enabled(cpu_env(cs));
@@ -111,7 +111,7 @@ static void tricore_cpu_reset_hold(Object *obj, ResetType type)
cpu_state_reset(cpu_env(cs));
}
-static bool tricore_cpu_has_work(CPUState *cs)
+static bool tricore_cpu_has_work(const CPUState *cs)
{
/* Interrupts are not implemented */
return true;
@@ -140,9 +140,9 @@ static void xtensa_restore_state_to_opc(CPUState *cs,
}
#ifndef CONFIG_USER_ONLY
-static bool xtensa_cpu_has_work(CPUState *cs)
+static bool xtensa_cpu_has_work(const CPUState *cs)
{
- CPUXtensaState *env = cpu_env(cs);
+ const CPUXtensaState *env = cpu_env(cs);
return !env->runstall && env->pending_irq_level;
}
All functions called by target has_work() handler take a const @cpu argument. We can now fulfill the comment added in commit c2804566f6 ("target/arm: do not clear halting reason in has_work helper"), qualifying the handler const to denote its idempotency. Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> --- include/hw/core/sysemu-cpu-ops.h | 4 ++-- target/alpha/cpu.c | 2 +- target/arm/cpu.c | 4 ++-- target/avr/cpu.c | 3 ++- target/hexagon/cpu.c | 4 ++-- target/hppa/cpu.c | 2 +- target/i386/cpu.c | 2 +- target/loongarch/cpu.c | 2 +- target/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 4 ++-- target/or1k/cpu.c | 2 +- target/ppc/cpu_init.c | 2 +- target/riscv/cpu.c | 5 ++--- target/rx/cpu.c | 2 +- target/s390x/cpu-system.c | 4 ++-- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/tricore/cpu.c | 2 +- target/xtensa/cpu.c | 4 ++-- 20 files changed, 28 insertions(+), 28 deletions(-)