mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
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:
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
+5
-10
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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. */
|
||||
|
||||
@@ -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"
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
|
||||
+5
-10
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+5
-9
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+5
-9
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
+12
-17
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+5
-9
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
|
||||
+4
-10
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user