target: Simplify how the TARGET_cpu_list() print

The various TARGET_cpu_list() take an fprintf()-like callback and a
FILE * to pass to it.  Their callers (vl.c's main() via list_cpus(),
bsd-user/main.c's main(), linux-user/main.c's main()) all pass
fprintf() and stdout.  Thus, the flexibility provided by the (rather
tiresome) indirection isn't actually used.

Drop the callback, and call qemu_printf() instead.

Calling printf() would also work, but would make the code unsuitable
for monitor context without making it simpler.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190417191805.28198-10-armbru@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
This commit is contained in:
Markus Armbruster 2019-04-17 21:17:57 +02:00
parent b6b71cb5c6
commit 0442428a89
40 changed files with 129 additions and 218 deletions

View File

@ -819,7 +819,7 @@ int main(int argc, char **argv)
if (is_help_option(cpu_model)) {
/* XXX: implement xxx_cpu_list for targets that still miss it */
#if defined(cpu_list)
cpu_list(stdout, &fprintf);
cpu_list();
#endif
exit(1);
}

4
cpus.c
View File

@ -2181,11 +2181,11 @@ int vm_stop_force_state(RunState state)
}
}
void list_cpus(FILE *f, fprintf_function cpu_fprintf, const char *optarg)
void list_cpus(const char *optarg)
{
/* XXX: implement xxx_cpu_list for targets that still miss it */
#if defined(cpu_list)
cpu_list(f, cpu_fprintf);
cpu_list();
#endif
}

View File

@ -9,19 +9,6 @@
#include "qemu/bswap.h"
#include "qemu/queue.h"
#include "qemu/fprintf-fn.h"
/**
* CPUListState:
* @cpu_fprintf: Print function.
* @file: File to print to using @cpu_fprint.
*
* State commonly used for iterating over CPU models.
*/
typedef struct CPUListState {
fprintf_function cpu_fprintf;
FILE *file;
} CPUListState;
/* The CPU list lock nests outside page_(un)lock or mmap_(un)lock */
void qemu_init_cpu_list(void);

View File

@ -1,7 +1,6 @@
#ifndef QEMU_CPUS_H
#define QEMU_CPUS_H
#include "qemu/fprintf-fn.h"
#include "qemu/timer.h"
/* cpus.c */
@ -39,7 +38,7 @@ extern int smp_cores;
extern int smp_threads;
#endif
void list_cpus(FILE *f, fprintf_function cpu_fprintf, const char *optarg);
void list_cpus(const char *optarg);
void qemu_tcg_configure(QemuOpts *opts, Error **errp);

View File

@ -317,7 +317,7 @@ static void handle_arg_cpu(const char *arg)
if (cpu_model == NULL || is_help_option(cpu_model)) {
/* XXX: implement xxx_cpu_list for targets that still miss it */
#if defined(cpu_list)
cpu_list(stdout, &fprintf);
cpu_list();
#endif
exit(EXIT_FAILURE);
}

View File

@ -21,6 +21,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu/qemu-print.h"
#include "cpu.h"
#include "qemu-common.h"
#include "exec/exec-all.h"
@ -74,23 +75,17 @@ static void alpha_cpu_realizefn(DeviceState *dev, Error **errp)
static void alpha_cpu_list_entry(gpointer data, gpointer user_data)
{
ObjectClass *oc = data;
CPUListState *s = user_data;
(*s->cpu_fprintf)(s->file, " %s\n",
object_class_get_name(oc));
qemu_printf(" %s\n", object_class_get_name(oc));
}
void alpha_cpu_list(FILE *f, fprintf_function cpu_fprintf)
void alpha_cpu_list(void)
{
CPUListState s = {
.file = f,
.cpu_fprintf = cpu_fprintf,
};
GSList *list;
list = object_class_get_list_sorted(TYPE_ALPHA_CPU, false);
(*cpu_fprintf)(f, "Available CPUs:\n");
g_slist_foreach(list, alpha_cpu_list_entry, &s);
qemu_printf("Available CPUs:\n");
g_slist_foreach(list, alpha_cpu_list_entry, NULL);
g_slist_free(list);
}

View File

@ -470,7 +470,7 @@ void alpha_translate_init(void);
#define ALPHA_CPU_TYPE_NAME(model) model ALPHA_CPU_TYPE_SUFFIX
#define CPU_RESOLVING_TYPE TYPE_ALPHA_CPU
void alpha_cpu_list(FILE *f, fprintf_function cpu_fprintf);
void alpha_cpu_list(void);
/* you can call this signal handler from your SIGBUS and SIGSEGV
signal handlers to inform the virtual CPU of exceptions. non zero
is returned if the signal was handled by the virtual CPU. */

View File

@ -20,7 +20,6 @@
#include "qemu/osdep.h"
#include "target/arm/idau.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
#include "qapi/visitor.h"
#include "cpu.h"

View File

@ -1936,7 +1936,7 @@ static inline bool access_secure_reg(CPUARMState *env)
(arm_is_secure(_env) && !arm_el_is_aa64((_env), 3)), \
(_val))
void arm_cpu_list(FILE *f, fprintf_function cpu_fprintf);
void arm_cpu_list(void);
uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
uint32_t cur_el, bool secure);

View File

@ -10,6 +10,7 @@
#include "sysemu/sysemu.h"
#include "qemu/bitops.h"
#include "qemu/crc32c.h"
#include "qemu/qemu-print.h"
#include "exec/exec-all.h"
#include "exec/cpu_ldst.h"
#include "arm_ldst.h"
@ -6724,29 +6725,23 @@ static gint arm_cpu_list_compare(gconstpointer a, gconstpointer b)
static void arm_cpu_list_entry(gpointer data, gpointer user_data)
{
ObjectClass *oc = data;
CPUListState *s = user_data;
const char *typename;
char *name;
typename = object_class_get_name(oc);
name = g_strndup(typename, strlen(typename) - strlen("-" TYPE_ARM_CPU));
(*s->cpu_fprintf)(s->file, " %s\n",
name);
qemu_printf(" %s\n", name);
g_free(name);
}
void arm_cpu_list(FILE *f, fprintf_function cpu_fprintf)
void arm_cpu_list(void)
{
CPUListState s = {
.file = f,
.cpu_fprintf = cpu_fprintf,
};
GSList *list;
list = object_class_get_list(TYPE_ARM_CPU, false);
list = g_slist_sort(list, arm_cpu_list_compare);
(*cpu_fprintf)(f, "Available CPUs:\n");
g_slist_foreach(list, arm_cpu_list_entry, &s);
qemu_printf("Available CPUs:\n");
g_slist_foreach(list, arm_cpu_list_entry, NULL);
g_slist_free(list);
}

View File

@ -23,6 +23,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu/qemu-print.h"
#include "cpu.h"
#include "qemu-common.h"
#include "mmu.h"
@ -103,27 +104,22 @@ static gint cris_cpu_list_compare(gconstpointer a, gconstpointer b)
static void cris_cpu_list_entry(gpointer data, gpointer user_data)
{
ObjectClass *oc = data;
CPUListState *s = user_data;
const char *typename = object_class_get_name(oc);
char *name;
name = g_strndup(typename, strlen(typename) - strlen(CRIS_CPU_TYPE_SUFFIX));
(*s->cpu_fprintf)(s->file, " %s\n", name);
qemu_printf(" %s\n", name);
g_free(name);
}
void cris_cpu_list(FILE *f, fprintf_function cpu_fprintf)
void cris_cpu_list(void)
{
CPUListState s = {
.file = f,
.cpu_fprintf = cpu_fprintf,
};
GSList *list;
list = object_class_get_list(TYPE_CRIS_CPU, false);
list = g_slist_sort(list, cris_cpu_list_compare);
(*cpu_fprintf)(f, "Available CPUs:\n");
g_slist_foreach(list, cris_cpu_list_entry, &s);
qemu_printf("Available CPUs:\n");
g_slist_foreach(list, cris_cpu_list_entry, NULL);
g_slist_free(list);
}

View File

@ -308,6 +308,6 @@ static inline void cpu_get_tb_cpu_state(CPUCRISState *env, target_ulong *pc,
}
#define cpu_list cris_cpu_list
void cris_cpu_list(FILE *f, fprintf_function cpu_fprintf);
void cris_cpu_list(void);
#endif

View File

@ -20,6 +20,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu/qemu-print.h"
#include "cpu.h"
#include "qemu-common.h"
#include "exec/exec-all.h"
@ -113,22 +114,17 @@ static void hppa_cpu_realizefn(DeviceState *dev, Error **errp)
static void hppa_cpu_list_entry(gpointer data, gpointer user_data)
{
ObjectClass *oc = data;
CPUListState *s = user_data;
(*s->cpu_fprintf)(s->file, " %s\n", object_class_get_name(oc));
qemu_printf(" %s\n", object_class_get_name(oc));
}
void hppa_cpu_list(FILE *f, fprintf_function cpu_fprintf)
void hppa_cpu_list(void)
{
CPUListState s = {
.file = f,
.cpu_fprintf = cpu_fprintf,
};
GSList *list;
list = object_class_get_list_sorted(TYPE_HPPA_CPU, false);
(*cpu_fprintf)(f, "Available CPUs:\n");
g_slist_foreach(list, hppa_cpu_list_entry, &s);
qemu_printf("Available CPUs:\n");
g_slist_foreach(list, hppa_cpu_list_entry, NULL);
g_slist_free(list);
}

View File

@ -272,7 +272,7 @@ void hppa_translate_init(void);
#define CPU_RESOLVING_TYPE TYPE_HPPA_CPU
void hppa_cpu_list(FILE *f, fprintf_function cpu_fprintf);
void hppa_cpu_list(void);
static inline target_ulong hppa_form_gva_psw(target_ureg psw, uint64_t spc,
target_ureg off)

View File

@ -21,6 +21,7 @@
#include "qemu/units.h"
#include "qemu/cutils.h"
#include "qemu/bitops.h"
#include "qemu/qemu-print.h"
#include "cpu.h"
#include "exec/exec-all.h"
@ -3671,7 +3672,7 @@ static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,
/* Print all cpuid feature names in featureset
*/
static void listflags(FILE *f, fprintf_function print, GList *features)
static void listflags(GList *features)
{
size_t len = 0;
GList *tmp;
@ -3679,13 +3680,13 @@ static void listflags(FILE *f, fprintf_function print, GList *features)
for (tmp = features; tmp; tmp = tmp->next) {
const char *name = tmp->data;
if ((len + strlen(name) + 1) >= 75) {
print(f, "\n");
qemu_printf("\n");
len = 0;
}
print(f, "%s%s", len == 0 ? " " : " ", name);
qemu_printf("%s%s", len == 0 ? " " : " ", name);
len += strlen(name) + 1;
}
print(f, "\n");
qemu_printf("\n");
}
/* Sort alphabetically by type name, respecting X86CPUClass::ordering. */
@ -3721,32 +3722,26 @@ static void x86_cpu_list_entry(gpointer data, gpointer user_data)
{
ObjectClass *oc = data;
X86CPUClass *cc = X86_CPU_CLASS(oc);
CPUListState *s = user_data;
char *name = x86_cpu_class_get_model_name(cc);
const char *desc = cc->model_description;
if (!desc && cc->cpu_def) {
desc = cc->cpu_def->model_id;
}
(*s->cpu_fprintf)(s->file, "x86 %-20s %-48s\n",
name, desc);
qemu_printf("x86 %-20s %-48s\n", name, desc);
g_free(name);
}
/* list available CPU models and flags */
void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf)
void x86_cpu_list(void)
{
int i, j;
CPUListState s = {
.file = f,
.cpu_fprintf = cpu_fprintf,
};
GSList *list;
GList *names = NULL;
(*cpu_fprintf)(f, "Available CPUs:\n");
qemu_printf("Available CPUs:\n");
list = get_sorted_cpu_model_list();
g_slist_foreach(list, x86_cpu_list_entry, &s);
g_slist_foreach(list, x86_cpu_list_entry, NULL);
g_slist_free(list);
names = NULL;
@ -3761,9 +3756,9 @@ void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf)
names = g_list_sort(names, (GCompareFunc)strcmp);
(*cpu_fprintf)(f, "\nRecognized CPUID flags:\n");
listflags(f, cpu_fprintf, names);
(*cpu_fprintf)(f, "\n");
qemu_printf("\nRecognized CPUID flags:\n");
listflags(names);
qemu_printf("\n");
g_list_free(names);
}

View File

@ -1532,7 +1532,7 @@ int x86_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
void x86_cpu_exec_enter(CPUState *cpu);
void x86_cpu_exec_exit(CPUState *cpu);
void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf);
void x86_cpu_list(void);
int cpu_x86_support_mca_broadcast(CPUX86State *env);
int cpu_get_pic_interrupt(CPUX86State *s);

View File

@ -20,6 +20,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu/qemu-print.h"
#include "cpu.h"
#include "qemu-common.h"
@ -34,27 +35,22 @@ static void lm32_cpu_set_pc(CPUState *cs, vaddr value)
static void lm32_cpu_list_entry(gpointer data, gpointer user_data)
{
ObjectClass *oc = data;
CPUListState *s = user_data;
const char *typename = object_class_get_name(oc);
char *name;
name = g_strndup(typename, strlen(typename) - strlen(LM32_CPU_TYPE_SUFFIX));
(*s->cpu_fprintf)(s->file, " %s\n", name);
qemu_printf(" %s\n", name);
g_free(name);
}
void lm32_cpu_list(FILE *f, fprintf_function cpu_fprintf)
void lm32_cpu_list(void)
{
CPUListState s = {
.file = f,
.cpu_fprintf = cpu_fprintf,
};
GSList *list;
list = object_class_get_list_sorted(TYPE_LM32_CPU, false);
(*cpu_fprintf)(f, "Available CPUs:\n");
g_slist_foreach(list, lm32_cpu_list_entry, &s);
qemu_printf("Available CPUs:\n");
g_slist_foreach(list, lm32_cpu_list_entry, NULL);
g_slist_free(list);
}

View File

@ -243,7 +243,7 @@ static inline lm32_wp_t lm32_wp_type(uint32_t dc, int idx)
is returned if the signal was handled by the virtual CPU. */
int cpu_lm32_signal_handler(int host_signum, void *pinfo,
void *puc);
void lm32_cpu_list(FILE *f, fprintf_function cpu_fprintf);
void lm32_cpu_list(void);
void lm32_translate_init(void);
void cpu_lm32_set_phys_msb_ignore(CPULM32State *env, int value);
void QEMU_NORETURN raise_exception(CPULM32State *env, int index);

View File

@ -499,7 +499,7 @@ static inline int m68k_feature(CPUM68KState *env, int feature)
return (env->features & (1u << feature)) != 0;
}
void m68k_cpu_list(FILE *f, fprintf_function cpu_fprintf);
void m68k_cpu_list(void);
void register_m68k_insns (CPUM68KState *env);

View File

@ -22,9 +22,9 @@
#include "cpu.h"
#include "exec/exec-all.h"
#include "exec/gdbstub.h"
#include "exec/helper-proto.h"
#include "fpu/softfloat.h"
#include "qemu/qemu-print.h"
#define SIGNBIT (1u << 31)
@ -49,28 +49,22 @@ static gint m68k_cpu_list_compare(gconstpointer a, gconstpointer b)
static void m68k_cpu_list_entry(gpointer data, gpointer user_data)
{
ObjectClass *c = data;
CPUListState *s = user_data;
const char *typename;
char *name;
typename = object_class_get_name(c);
name = g_strndup(typename, strlen(typename) - strlen("-" TYPE_M68K_CPU));
(*s->cpu_fprintf)(s->file, "%s\n",
name);
qemu_printf("%s\n", name);
g_free(name);
}
void m68k_cpu_list(FILE *f, fprintf_function cpu_fprintf)
void m68k_cpu_list(void)
{
CPUListState s = {
.file = f,
.cpu_fprintf = cpu_fprintf,
};
GSList *list;
list = object_class_get_list(TYPE_M68K_CPU, false);
list = g_slist_sort(list, m68k_cpu_list_compare);
g_slist_foreach(list, m68k_cpu_list_entry, &s);
g_slist_foreach(list, m68k_cpu_list_entry, NULL);
g_slist_free(list);
}

View File

@ -1065,7 +1065,7 @@ static inline MIPSCPU *mips_env_get_cpu(CPUMIPSState *env)
#define ENV_OFFSET offsetof(MIPSCPU, env)
void mips_cpu_list (FILE *f, fprintf_function cpu_fprintf);
void mips_cpu_list(void);
#define cpu_signal_handler cpu_mips_signal_handler
#define cpu_list mips_cpu_list

View File

@ -38,6 +38,7 @@
#include "trace-tcg.h"
#include "exec/translator.h"
#include "exec/log.h"
#include "qemu/qemu-print.h"
#define MIPS_DEBUG_DISAS 0

View File

@ -835,13 +835,12 @@ const mips_def_t mips_defs[] =
};
const int mips_defs_number = ARRAY_SIZE(mips_defs);
void mips_cpu_list (FILE *f, fprintf_function cpu_fprintf)
void mips_cpu_list(void)
{
int i;
for (i = 0; i < ARRAY_SIZE(mips_defs); i++) {
(*cpu_fprintf)(f, "MIPS '%s'\n",
mips_defs[i].name);
qemu_printf("MIPS '%s'\n", mips_defs[i].name);
}
}

View File

@ -19,6 +19,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu/qemu-print.h"
#include "cpu.h"
#include "qemu-common.h"
@ -180,30 +181,24 @@ static gint openrisc_cpu_list_compare(gconstpointer a, gconstpointer b)
static void openrisc_cpu_list_entry(gpointer data, gpointer user_data)
{
ObjectClass *oc = data;
CPUListState *s = user_data;
const char *typename;
char *name;
typename = object_class_get_name(oc);
name = g_strndup(typename,
strlen(typename) - strlen("-" TYPE_OPENRISC_CPU));
(*s->cpu_fprintf)(s->file, " %s\n",
name);
qemu_printf(" %s\n", name);
g_free(name);
}
void cpu_openrisc_list(FILE *f, fprintf_function cpu_fprintf)
void cpu_openrisc_list(void)
{
CPUListState s = {
.file = f,
.cpu_fprintf = cpu_fprintf,
};
GSList *list;
list = object_class_get_list(TYPE_OPENRISC_CPU, false);
list = g_slist_sort(list, openrisc_cpu_list_compare);
(*cpu_fprintf)(f, "Available CPUs:\n");
g_slist_foreach(list, openrisc_cpu_list_entry, &s);
qemu_printf("Available CPUs:\n");
g_slist_foreach(list, openrisc_cpu_list_entry, NULL);
g_slist_free(list);
}

View File

@ -336,7 +336,7 @@ static inline OpenRISCCPU *openrisc_env_get_cpu(CPUOpenRISCState *env)
#define ENV_OFFSET offsetof(OpenRISCCPU, env)
void cpu_openrisc_list(FILE *f, fprintf_function cpu_fprintf);
void cpu_openrisc_list(void);
void openrisc_cpu_do_interrupt(CPUState *cpu);
bool openrisc_cpu_exec_interrupt(CPUState *cpu, int int_req);
void openrisc_cpu_dump_state(CPUState *cpu, FILE *f,

View File

@ -1308,7 +1308,7 @@ void ppc_store_ptcr(CPUPPCState *env, target_ulong value);
#endif /* !defined(CONFIG_USER_ONLY) */
void ppc_store_msr (CPUPPCState *env, target_ulong value);
void ppc_cpu_list (FILE *f, fprintf_function cpu_fprintf);
void ppc_cpu_list(void);
/* Time-base and decrementer management */
#ifndef NO_CPU_IO_DEFS

View File

@ -28,6 +28,7 @@
#include "mmu-hash32.h"
#include "mmu-hash64.h"
#include "qemu/error-report.h"
#include "qemu/qemu-print.h"
#include "qapi/error.h"
#include "qapi/qmp/qnull.h"
#include "qapi/visitor.h"
@ -10215,7 +10216,6 @@ static gint ppc_cpu_list_compare(gconstpointer a, gconstpointer b)
static void ppc_cpu_list_entry(gpointer data, gpointer user_data)
{
ObjectClass *oc = data;
CPUListState *s = user_data;
PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
DeviceClass *family = DEVICE_CLASS(ppc_cpu_get_family_class(pcc));
const char *typename = object_class_get_name(oc);
@ -10228,8 +10228,7 @@ static void ppc_cpu_list_entry(gpointer data, gpointer user_data)
name = g_strndup(typename,
strlen(typename) - strlen(POWERPC_CPU_TYPE_SUFFIX));
(*s->cpu_fprintf)(s->file, "PowerPC %-16s PVR %08x\n",
name, pcc->pvr);
qemu_printf("PowerPC %-16s PVR %08x\n", name, pcc->pvr);
for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) {
PowerPCCPUAlias *alias = &ppc_cpu_aliases[i];
ObjectClass *alias_oc = ppc_cpu_class_by_name(alias->model);
@ -10242,33 +10241,28 @@ static void ppc_cpu_list_entry(gpointer data, gpointer user_data)
* avoid printing the wrong alias here and use "preferred" instead
*/
if (strcmp(alias->alias, family->desc) == 0) {
(*s->cpu_fprintf)(s->file,
"PowerPC %-16s (alias for preferred %s CPU)\n",
alias->alias, family->desc);
qemu_printf("PowerPC %-16s (alias for preferred %s CPU)\n",
alias->alias, family->desc);
} else {
(*s->cpu_fprintf)(s->file, "PowerPC %-16s (alias for %s)\n",
alias->alias, name);
qemu_printf("PowerPC %-16s (alias for %s)\n",
alias->alias, name);
}
}
g_free(name);
}
void ppc_cpu_list(FILE *f, fprintf_function cpu_fprintf)
void ppc_cpu_list(void)
{
CPUListState s = {
.file = f,
.cpu_fprintf = cpu_fprintf,
};
GSList *list;
list = object_class_get_list(TYPE_POWERPC_CPU, false);
list = g_slist_sort(list, ppc_cpu_list_compare);
g_slist_foreach(list, ppc_cpu_list_entry, &s);
g_slist_foreach(list, ppc_cpu_list_entry, NULL);
g_slist_free(list);
#ifdef CONFIG_KVM
cpu_fprintf(f, "\n");
cpu_fprintf(f, "PowerPC %-16s\n", "host");
qemu_printf("\n");
qemu_printf("PowerPC %-16s\n", "host");
#endif
}

View File

@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/qemu-print.h"
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"
@ -383,11 +384,6 @@ char *riscv_isa_string(RISCVCPU *cpu)
return isa_str;
}
typedef struct RISCVCPUListState {
fprintf_function cpu_fprintf;
FILE *file;
} RISCVCPUListState;
static gint riscv_cpu_list_compare(gconstpointer a, gconstpointer b)
{
ObjectClass *class_a = (ObjectClass *)a;
@ -401,24 +397,19 @@ static gint riscv_cpu_list_compare(gconstpointer a, gconstpointer b)
static void riscv_cpu_list_entry(gpointer data, gpointer user_data)
{
RISCVCPUListState *s = user_data;
const char *typename = object_class_get_name(OBJECT_CLASS(data));
int len = strlen(typename) - strlen(RISCV_CPU_TYPE_SUFFIX);
(*s->cpu_fprintf)(s->file, "%.*s\n", len, typename);
qemu_printf("%.*s\n", len, typename);
}
void riscv_cpu_list(FILE *f, fprintf_function cpu_fprintf)
void riscv_cpu_list(void)
{
RISCVCPUListState s = {
.cpu_fprintf = cpu_fprintf,
.file = f,
};
GSList *list;
list = object_class_get_list(TYPE_RISCV_CPU, false);
list = g_slist_sort(list, riscv_cpu_list_compare);
g_slist_foreach(list, riscv_cpu_list_entry, &s);
g_slist_foreach(list, riscv_cpu_list_entry, NULL);
g_slist_free(list);
}

View File

@ -264,7 +264,7 @@ void riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
int riscv_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size,
int rw, int mmu_idx);
char *riscv_isa_string(RISCVCPU *cpu);
void riscv_cpu_list(FILE *f, fprintf_function cpu_fprintf);
void riscv_cpu_list(void);
#define cpu_signal_handler riscv_cpu_signal_handler
#define cpu_list riscv_cpu_list

View File

@ -753,7 +753,7 @@ static inline uint8_t s390_cpu_get_state(S390CPU *cpu)
/* cpu_models.c */
void s390_cpu_list(FILE *f, fprintf_function cpu_fprintf);
void s390_cpu_list(void);
#define cpu_list s390_cpu_list
void s390_set_qemu_cpu_model(uint16_t type, uint8_t gen, uint8_t ec_ga,
const S390FeatInit feat_init);

View File

@ -18,6 +18,7 @@
#include "qapi/error.h"
#include "qapi/visitor.h"
#include "qemu/error-report.h"
#include "qemu/qemu-print.h"
#include "qapi/qmp/qerror.h"
#include "qapi/qobject-input-visitor.h"
#include "qapi/qmp/qdict.h"
@ -308,7 +309,6 @@ const S390CPUDef *s390_find_cpu_def(uint16_t type, uint8_t gen, uint8_t ec_ga,
static void s390_print_cpu_model_list_entry(gpointer data, gpointer user_data)
{
CPUListState *s = user_data;
const S390CPUClass *scc = S390_CPU_CLASS((ObjectClass *)data);
char *name = g_strdup(object_class_get_name((ObjectClass *)data));
const char *details = "";
@ -321,8 +321,7 @@ static void s390_print_cpu_model_list_entry(gpointer data, gpointer user_data)
/* strip off the -s390x-cpu */
g_strrstr(name, "-" TYPE_S390_CPU)[0] = 0;
(*s->cpu_fprintf)(s->file, "s390 %-15s %-35s %s\n", name, scc->desc,
details);
qemu_printf("s390 %-15s %-35s %s\n", name, scc->desc, details);
g_free(name);
}
@ -360,33 +359,29 @@ static gint s390_cpu_list_compare(gconstpointer a, gconstpointer b)
return cc_a->is_static ? -1 : 1;
}
void s390_cpu_list(FILE *f, fprintf_function print)
void s390_cpu_list(void)
{
CPUListState s = {
.file = f,
.cpu_fprintf = print,
};
S390FeatGroup group;
S390Feat feat;
GSList *list;
list = object_class_get_list(TYPE_S390_CPU, false);
list = g_slist_sort(list, s390_cpu_list_compare);
g_slist_foreach(list, s390_print_cpu_model_list_entry, &s);
g_slist_foreach(list, s390_print_cpu_model_list_entry, NULL);
g_slist_free(list);
(*print)(f, "\nRecognized feature flags:\n");
qemu_printf("\nRecognized feature flags:\n");
for (feat = 0; feat < S390_FEAT_MAX; feat++) {
const S390FeatDef *def = s390_feat_def(feat);
(*print)(f, "%-20s %-50s\n", def->name, def->desc);
qemu_printf("%-20s %-50s\n", def->name, def->desc);
}
(*print)(f, "\nRecognized feature groups:\n");
qemu_printf("\nRecognized feature groups:\n");
for (group = 0; group < S390_FEAT_GROUP_MAX; group++) {
const S390FeatGroupDef *def = s390_feat_group_def(group);
(*print)(f, "%-20s %-50s\n", def->name, def->desc);
qemu_printf("%-20s %-50s\n", def->name, def->desc);
}
}

View File

@ -21,6 +21,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu/qemu-print.h"
#include "cpu.h"
#include "qemu-common.h"
#include "migration/vmstate.h"
@ -79,30 +80,20 @@ static void superh_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)
info->print_insn = print_insn_sh;
}
typedef struct SuperHCPUListState {
fprintf_function cpu_fprintf;
FILE *file;
} SuperHCPUListState;
static void superh_cpu_list_entry(gpointer data, gpointer user_data)
{
SuperHCPUListState *s = user_data;
const char *typename = object_class_get_name(OBJECT_CLASS(data));
int len = strlen(typename) - strlen(SUPERH_CPU_TYPE_SUFFIX);
(*s->cpu_fprintf)(s->file, "%.*s\n", len, typename);
qemu_printf("%.*s\n", len, typename);
}
void sh4_cpu_list(FILE *f, fprintf_function cpu_fprintf)
void sh4_cpu_list(void)
{
SuperHCPUListState s = {
.cpu_fprintf = cpu_fprintf,
.file = f,
};
GSList *list;
list = object_class_get_list_sorted(TYPE_SUPERH_CPU, false);
g_slist_foreach(list, superh_cpu_list_entry, &s);
g_slist_foreach(list, superh_cpu_list_entry, NULL);
g_slist_free(list);
}

View File

@ -247,7 +247,7 @@ int cpu_sh4_signal_handler(int host_signum, void *pinfo,
int superh_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, int rw,
int mmu_idx);
void sh4_cpu_list(FILE *f, fprintf_function cpu_fprintf);
void sh4_cpu_list(void);
#if !defined(CONFIG_USER_ONLY)
void cpu_sh4_invalidate_tlb(CPUSH4State *s);
uint32_t cpu_sh4_read_mmaped_itlb_addr(CPUSH4State *s,

View File

@ -20,7 +20,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "cpu.h"
#include "qemu/error-report.h"
#include "qemu/qemu-print.h"
#include "exec/exec-all.h"
#include "hw/qdev-properties.h"
#include "qapi/visitor.h"
@ -556,47 +556,44 @@ static const char * const feature_name[] = {
"gl",
};
static void print_features(FILE *f, fprintf_function cpu_fprintf,
uint32_t features, const char *prefix)
static void print_features(uint32_t features, const char *prefix)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(feature_name); i++) {
if (feature_name[i] && (features & (1 << i))) {
if (prefix) {
(*cpu_fprintf)(f, "%s", prefix);
qemu_printf("%s", prefix);
}
(*cpu_fprintf)(f, "%s ", feature_name[i]);
qemu_printf("%s ", feature_name[i]);
}
}
}
void sparc_cpu_list(FILE *f, fprintf_function cpu_fprintf)
void sparc_cpu_list(void)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(sparc_defs); i++) {
(*cpu_fprintf)(f, "Sparc %16s IU " TARGET_FMT_lx
" FPU %08x MMU %08x NWINS %d ",
sparc_defs[i].name,
sparc_defs[i].iu_version,
sparc_defs[i].fpu_version,
sparc_defs[i].mmu_version,
sparc_defs[i].nwindows);
print_features(f, cpu_fprintf, CPU_DEFAULT_FEATURES &
~sparc_defs[i].features, "-");
print_features(f, cpu_fprintf, ~CPU_DEFAULT_FEATURES &
sparc_defs[i].features, "+");
(*cpu_fprintf)(f, "\n");
qemu_printf("Sparc %16s IU " TARGET_FMT_lx
" FPU %08x MMU %08x NWINS %d ",
sparc_defs[i].name,
sparc_defs[i].iu_version,
sparc_defs[i].fpu_version,
sparc_defs[i].mmu_version,
sparc_defs[i].nwindows);
print_features(CPU_DEFAULT_FEATURES & ~sparc_defs[i].features, "-");
print_features(~CPU_DEFAULT_FEATURES & sparc_defs[i].features, "+");
qemu_printf("\n");
}
(*cpu_fprintf)(f, "Default CPU feature flags (use '-' to remove): ");
print_features(f, cpu_fprintf, CPU_DEFAULT_FEATURES, NULL);
(*cpu_fprintf)(f, "\n");
(*cpu_fprintf)(f, "Available CPU feature flags (use '+' to add): ");
print_features(f, cpu_fprintf, ~CPU_DEFAULT_FEATURES, NULL);
(*cpu_fprintf)(f, "\n");
(*cpu_fprintf)(f, "Numerical features (use '=' to set): iu_version "
"fpu_version mmu_version nwindows\n");
qemu_printf("Default CPU feature flags (use '-' to remove): ");
print_features(CPU_DEFAULT_FEATURES, NULL);
qemu_printf("\n");
qemu_printf("Available CPU feature flags (use '+' to add): ");
print_features(~CPU_DEFAULT_FEATURES, NULL);
qemu_printf("\n");
qemu_printf("Numerical features (use '=' to set): iu_version "
"fpu_version mmu_version nwindows\n");
}
static void cpu_print_cc(FILE *f, fprintf_function cpu_fprintf,

View File

@ -578,7 +578,7 @@ void cpu_raise_exception_ra(CPUSPARCState *, int, uintptr_t) QEMU_NORETURN;
#ifndef NO_CPU_IO_DEFS
/* cpu_init.c */
void cpu_sparc_set_id(CPUSPARCState *env, unsigned int cpu);
void sparc_cpu_list(FILE *f, fprintf_function cpu_fprintf);
void sparc_cpu_list(void);
/* mmu_helper.c */
int sparc_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, int rw,
int mmu_idx);

View File

@ -375,7 +375,7 @@ void fpu_set_state(CPUTriCoreState *env);
#define MMU_USER_IDX 2
void tricore_cpu_list(FILE *f, fprintf_function cpu_fprintf);
void tricore_cpu_list(void);
#define cpu_signal_handler cpu_tricore_signal_handler
#define cpu_list tricore_cpu_list

View File

@ -20,6 +20,7 @@
#include "cpu.h"
#include "exec/exec-all.h"
#include "fpu/softfloat.h"
#include "qemu/qemu-print.h"
enum {
TLBRET_DIRTY = -4,
@ -82,28 +83,22 @@ int cpu_tricore_handle_mmu_fault(CPUState *cs, target_ulong address,
static void tricore_cpu_list_entry(gpointer data, gpointer user_data)
{
ObjectClass *oc = data;
CPUListState *s = user_data;
const char *typename;
char *name;
typename = object_class_get_name(oc);
name = g_strndup(typename, strlen(typename) - strlen("-" TYPE_TRICORE_CPU));
(*s->cpu_fprintf)(s->file, " %s\n",
name);
qemu_printf(" %s\n", name);
g_free(name);
}
void tricore_cpu_list(FILE *f, fprintf_function cpu_fprintf)
void tricore_cpu_list(void)
{
CPUListState s = {
.file = f,
.cpu_fprintf = cpu_fprintf,
};
GSList *list;
list = object_class_get_list_sorted(TYPE_TRICORE_CPU, false);
(*cpu_fprintf)(f, "Available CPUs:\n");
g_slist_foreach(list, tricore_cpu_list_entry, &s);
qemu_printf("Available CPUs:\n");
g_slist_foreach(list, tricore_cpu_list_entry, NULL);
g_slist_free(list);
}

View File

@ -600,7 +600,7 @@ void xtensa_irq_init(CPUXtensaState *env);
qemu_irq *xtensa_get_extints(CPUXtensaState *env);
qemu_irq xtensa_get_runstall(CPUXtensaState *env);
int cpu_xtensa_signal_handler(int host_signum, void *pinfo, void *puc);
void xtensa_cpu_list(FILE *f, fprintf_function cpu_fprintf);
void xtensa_cpu_list(void);
void xtensa_sync_window_from_phys(CPUXtensaState *env);
void xtensa_sync_phys_from_window(CPUXtensaState *env);
void xtensa_rotate_window(CPUXtensaState *env, uint32_t delta);

View File

@ -31,6 +31,7 @@
#include "exec/gdbstub.h"
#include "exec/helper-proto.h"
#include "qemu/error-report.h"
#include "qemu/qemu-print.h"
#include "qemu/host-utils.h"
static struct XtensaConfigList *xtensa_cores;
@ -228,12 +229,12 @@ void xtensa_breakpoint_handler(CPUState *cs)
}
}
void xtensa_cpu_list(FILE *f, fprintf_function cpu_fprintf)
void xtensa_cpu_list(void)
{
XtensaConfigList *core = xtensa_cores;
cpu_fprintf(f, "Available CPUs:\n");
qemu_printf("Available CPUs:\n");
for (; core; core = core->next) {
cpu_fprintf(f, " %s\n", core->config->name);
qemu_printf(" %s\n", core->config->name);
}
}

2
vl.c
View File

@ -4051,7 +4051,7 @@ int main(int argc, char **argv, char **envp)
}
if (cpu_model && is_help_option(cpu_model)) {
list_cpus(stdout, &fprintf, cpu_model);
list_cpus(cpu_model);
exit(0);
}