[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/71] cpu: Add generic cpu_list()
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 06/71] cpu: Add generic cpu_list() |
Date: |
Fri, 5 Jan 2024 16:41:59 +0100 |
From: Gavin Shan <gshan@redhat.com>
Add generic cpu_list() to replace the individual target's implementation
in the subsequent commits. Currently, there are 3 targets with no cpu_list()
implementation: microblaze and nios2. With this applied, those two targets
switch to the generic cpu_list().
[gshan@gshan q]$ ./build/qemu-system-microblaze -cpu ?
Available CPUs:
microblaze-cpu
[gshan@gshan q]$ ./build/qemu-system-nios2 -cpu ?
Available CPUs:
nios2-cpu
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Gavin Shan <gshan@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231114235628.534334-7-gshan@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
bsd-user/main.c | 5 +----
cpu-target.c | 29 ++++++++++++++++++++++++++---
2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/bsd-user/main.c b/bsd-user/main.c
index e6014f517e..4de226d211 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -378,10 +378,7 @@ int main(int argc, char **argv)
} else if (!strcmp(r, "cpu")) {
cpu_model = argv[optind++];
if (is_help_option(cpu_model)) {
- /* XXX: implement xxx_cpu_list for targets that still miss it
*/
-#if defined(cpu_list)
- cpu_list();
-#endif
+ list_cpus();
exit(1);
}
} else if (!strcmp(r, "B")) {
diff --git a/cpu-target.c b/cpu-target.c
index 6f4afc1dbc..5eecd7ea2d 100644
--- a/cpu-target.c
+++ b/cpu-target.c
@@ -24,6 +24,7 @@
#include "hw/qdev-core.h"
#include "hw/qdev-properties.h"
#include "qemu/error-report.h"
+#include "qemu/qemu-print.h"
#include "migration/vmstate.h"
#ifdef CONFIG_USER_ONLY
#include "qemu.h"
@@ -283,12 +284,34 @@ const char *parse_cpu_option(const char *cpu_option)
return cpu_type;
}
+#ifndef cpu_list
+static void cpu_list_entry(gpointer data, gpointer user_data)
+{
+ CPUClass *cc = CPU_CLASS(OBJECT_CLASS(data));
+ const char *typename = object_class_get_name(OBJECT_CLASS(data));
+ g_autofree char *model = cpu_model_from_type(typename);
+
+ if (cc->deprecation_note) {
+ qemu_printf(" %s (deprecated)\n", model);
+ } else {
+ qemu_printf(" %s\n", model);
+ }
+}
+
+static void cpu_list(void)
+{
+ GSList *list;
+
+ list = object_class_get_list_sorted(TYPE_CPU, false);
+ qemu_printf("Available CPUs:\n");
+ g_slist_foreach(list, cpu_list_entry, NULL);
+ g_slist_free(list);
+}
+#endif
+
void list_cpus(void)
{
- /* XXX: implement xxx_cpu_list for targets that still miss it */
-#if defined(cpu_list)
cpu_list();
-#endif
}
#if defined(CONFIG_USER_ONLY)
--
2.41.0
- [PULL 00/71] HW core patches for 2024-01-05, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 01/71] meson: Allow building binary with no target-specific files in hw/, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 02/71] target/alpha: Remove fallback to ev67 cpu class, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 03/71] target/hppa: Remove object_class_is_abstract(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 04/71] cpu: Call object_class_dynamic_cast() once in cpu_class_by_name(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 05/71] cpu: Add helper cpu_model_from_type(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 06/71] cpu: Add generic cpu_list(),
Philippe Mathieu-Daudé <=
- [PULL 07/71] target/alpha: Use generic cpu_list(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 08/71] target/arm: Use generic cpu_list(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 09/71] target/avr: Use generic cpu_list(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 10/71] target/cris: Use generic cpu_list(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 11/71] target/hexagon: Use generic cpu_list(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 12/71] target/hppa: Use generic cpu_list(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 13/71] target/loongarch: Use generic cpu_list(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 14/71] target/m68k: Use generic cpu_list(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 15/71] target/mips: Use generic cpu_list(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 16/71] target/openrisc: Use generic cpu_list(), Philippe Mathieu-Daudé, 2024/01/05