mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-17 23:22:12 -06: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:
parent
b6b71cb5c6
commit
0442428a89
40 changed files with 129 additions and 218 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue