hw/core: Use a callback for target specific query-cpus-fast information
For being able to create a universal QEMU binary one day, core files like machine-qmp-cmds.c must not contain any "#ifdef TARGET_..." parts. Thus let's provide the target specific function via a function pointer in CPUClass instead, as a first step towards making this file target independent. Message-Id: <20230424160434.331175-2-thuth@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
parent
c70bb9a771
commit
5503da4a0c
@ -28,18 +28,6 @@
|
|||||||
#include "sysemu/runstate.h"
|
#include "sysemu/runstate.h"
|
||||||
#include "sysemu/sysemu.h"
|
#include "sysemu/sysemu.h"
|
||||||
|
|
||||||
static void cpustate_to_cpuinfo_s390(CpuInfoS390 *info, const CPUState *cpu)
|
|
||||||
{
|
|
||||||
#ifdef TARGET_S390X
|
|
||||||
S390CPU *s390_cpu = S390_CPU(cpu);
|
|
||||||
CPUS390XState *env = &s390_cpu->env;
|
|
||||||
|
|
||||||
info->cpu_state = env->cpu_state;
|
|
||||||
#else
|
|
||||||
abort();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fast means: we NEVER interrupt vCPU threads to retrieve
|
* fast means: we NEVER interrupt vCPU threads to retrieve
|
||||||
* information from KVM.
|
* information from KVM.
|
||||||
@ -68,8 +56,8 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
value->target = target;
|
value->target = target;
|
||||||
if (target == SYS_EMU_TARGET_S390X) {
|
if (cpu->cc->query_cpu_fast) {
|
||||||
cpustate_to_cpuinfo_s390(&value->u.s390x, cpu);
|
cpu->cc->query_cpu_fast(cpu, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
QAPI_LIST_APPEND(tail, value);
|
QAPI_LIST_APPEND(tail, value);
|
||||||
|
@ -106,6 +106,9 @@ struct SysemuCPUOps;
|
|||||||
* @has_work: Callback for checking if there is work to do.
|
* @has_work: Callback for checking if there is work to do.
|
||||||
* @memory_rw_debug: Callback for GDB memory access.
|
* @memory_rw_debug: Callback for GDB memory access.
|
||||||
* @dump_state: Callback for dumping state.
|
* @dump_state: Callback for dumping state.
|
||||||
|
* @query_cpu_fast:
|
||||||
|
* Fill in target specific information for the "query-cpus-fast"
|
||||||
|
* QAPI call.
|
||||||
* @get_arch_id: Callback for getting architecture-dependent CPU ID.
|
* @get_arch_id: Callback for getting architecture-dependent CPU ID.
|
||||||
* @set_pc: Callback for setting the Program Counter register. This
|
* @set_pc: Callback for setting the Program Counter register. This
|
||||||
* should have the semantics used by the target architecture when
|
* should have the semantics used by the target architecture when
|
||||||
@ -151,6 +154,7 @@ struct CPUClass {
|
|||||||
int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
|
int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
|
||||||
uint8_t *buf, int len, bool is_write);
|
uint8_t *buf, int len, bool is_write);
|
||||||
void (*dump_state)(CPUState *cpu, FILE *, int flags);
|
void (*dump_state)(CPUState *cpu, FILE *, int flags);
|
||||||
|
void (*query_cpu_fast)(CPUState *cpu, CpuInfoFast *value);
|
||||||
int64_t (*get_arch_id)(CPUState *cpu);
|
int64_t (*get_arch_id)(CPUState *cpu);
|
||||||
void (*set_pc)(CPUState *cpu, vaddr value);
|
void (*set_pc)(CPUState *cpu, vaddr value);
|
||||||
vaddr (*get_pc)(CPUState *cpu);
|
vaddr (*get_pc)(CPUState *cpu);
|
||||||
|
@ -41,6 +41,7 @@ typedef struct CompatProperty CompatProperty;
|
|||||||
typedef struct ConfidentialGuestSupport ConfidentialGuestSupport;
|
typedef struct ConfidentialGuestSupport ConfidentialGuestSupport;
|
||||||
typedef struct CPUAddressSpace CPUAddressSpace;
|
typedef struct CPUAddressSpace CPUAddressSpace;
|
||||||
typedef struct CPUArchState CPUArchState;
|
typedef struct CPUArchState CPUArchState;
|
||||||
|
typedef struct CpuInfoFast CpuInfoFast;
|
||||||
typedef struct CPUJumpCache CPUJumpCache;
|
typedef struct CPUJumpCache CPUJumpCache;
|
||||||
typedef struct CPUState CPUState;
|
typedef struct CPUState CPUState;
|
||||||
typedef struct CPUTLBEntryFull CPUTLBEntryFull;
|
typedef struct CPUTLBEntryFull CPUTLBEntryFull;
|
||||||
|
@ -140,6 +140,13 @@ static bool s390_cpu_has_work(CPUState *cs)
|
|||||||
return s390_cpu_has_int(cpu);
|
return s390_cpu_has_int(cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void s390_query_cpu_fast(CPUState *cpu, CpuInfoFast *value)
|
||||||
|
{
|
||||||
|
S390CPU *s390_cpu = S390_CPU(cpu);
|
||||||
|
|
||||||
|
value->u.s390x.cpu_state = s390_cpu->env.cpu_state;
|
||||||
|
}
|
||||||
|
|
||||||
/* S390CPUClass::reset() */
|
/* S390CPUClass::reset() */
|
||||||
static void s390_cpu_reset(CPUState *s, cpu_reset_type type)
|
static void s390_cpu_reset(CPUState *s, cpu_reset_type type)
|
||||||
{
|
{
|
||||||
@ -332,6 +339,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)
|
|||||||
cc->class_by_name = s390_cpu_class_by_name,
|
cc->class_by_name = s390_cpu_class_by_name,
|
||||||
cc->has_work = s390_cpu_has_work;
|
cc->has_work = s390_cpu_has_work;
|
||||||
cc->dump_state = s390_cpu_dump_state;
|
cc->dump_state = s390_cpu_dump_state;
|
||||||
|
cc->query_cpu_fast = s390_query_cpu_fast;
|
||||||
cc->set_pc = s390_cpu_set_pc;
|
cc->set_pc = s390_cpu_set_pc;
|
||||||
cc->get_pc = s390_cpu_get_pc;
|
cc->get_pc = s390_cpu_get_pc;
|
||||||
cc->gdb_read_register = s390_cpu_gdb_read_register;
|
cc->gdb_read_register = s390_cpu_gdb_read_register;
|
||||||
|
Loading…
Reference in New Issue
Block a user