[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH-for-9.1 17/21] target/riscv: Use QMP generic_query_cpu_defini
From: |
Philippe Mathieu-Daudé |
Subject: |
[RFC PATCH-for-9.1 17/21] target/riscv: Use QMP generic_query_cpu_definitions() |
Date: |
Fri, 15 Mar 2024 14:09:05 +0100 |
Expose riscv_cpu_add_definition() and use it as add_definition()
handler, then use the QMP generic_query_cpu_definitions() method.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/riscv/cpu.h | 2 ++
target/riscv/cpu.c | 1 +
target/riscv/riscv-qmp-cmds.c | 11 +++--------
3 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
index 3b1a02b944..15fc287680 100644
--- a/target/riscv/cpu.h
+++ b/target/riscv/cpu.h
@@ -824,4 +824,6 @@ void riscv_cpu_register_gdb_regs_for_features(CPUState *cs);
uint8_t satp_mode_max_from_map(uint32_t map);
const char *satp_mode_str(uint8_t satp_mode, bool is_32_bit);
+void riscv_cpu_add_definition(gpointer data, gpointer user_data);
+
#endif /* RISCV_CPU_H */
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index c160b9216b..2da9364335 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -2341,6 +2341,7 @@ static int64_t riscv_get_arch_id(CPUState *cs)
#include "hw/core/sysemu-cpu-ops.h"
static const struct SysemuCPUOps riscv_sysemu_ops = {
+ .add_definition = riscv_cpu_add_definition,
.get_phys_page_debug = riscv_cpu_get_phys_page_debug,
.write_elf64_note = riscv_cpu_write_elf64_note,
.write_elf32_note = riscv_cpu_write_elf32_note,
diff --git a/target/riscv/riscv-qmp-cmds.c b/target/riscv/riscv-qmp-cmds.c
index d363dc318d..45adc90d3b 100644
--- a/target/riscv/riscv-qmp-cmds.c
+++ b/target/riscv/riscv-qmp-cmds.c
@@ -26,6 +26,7 @@
#include "qapi/error.h"
#include "qapi/qapi-commands-machine-target.h"
+#include "qapi/commands-target-compat.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qobject-input-visitor.h"
@@ -36,7 +37,7 @@
#include "cpu-qom.h"
#include "cpu.h"
-static void riscv_cpu_add_definition(gpointer data, gpointer user_data)
+void riscv_cpu_add_definition(gpointer data, gpointer user_data)
{
ObjectClass *oc = data;
CpuDefinitionInfoList **cpu_list = user_data;
@@ -55,13 +56,7 @@ static void riscv_cpu_add_definition(gpointer data, gpointer
user_data)
CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
{
- CpuDefinitionInfoList *cpu_list = NULL;
- GSList *list = object_class_get_list(TYPE_RISCV_CPU, false);
-
- g_slist_foreach(list, riscv_cpu_add_definition, &cpu_list);
- g_slist_free(list);
-
- return cpu_list;
+ return generic_query_cpu_definitions(errp);
}
static void riscv_check_if_cpu_available(RISCVCPU *cpu, Error **errp)
--
2.41.0
- [PATCH-for-9.1 07/21] target/mips: Make MIPS_CPU common to new MIPS32_CPU / MIPS64_CPU types, (continued)
- [PATCH-for-9.1 07/21] target/mips: Make MIPS_CPU common to new MIPS32_CPU / MIPS64_CPU types, Philippe Mathieu-Daudé, 2024/03/15
- [RFC PATCH-for-9.1 15/21] target/arm: Use QMP generic_query_cpu_definitions(), Philippe Mathieu-Daudé, 2024/03/15
- [PATCH-for-9.1 08/21] target/sparc: Make SPARC_CPU common to new SPARC32_CPU/SPARC64_CPU types, Philippe Mathieu-Daudé, 2024/03/15
- [PATCH-for-9.1 10/21] qapi: Make CpuModel* definitions target agnostic, Philippe Mathieu-Daudé, 2024/03/15
- [PATCH-for-9.1 11/21] qapi: Make CpuDefinitionInfo target agnostic, Philippe Mathieu-Daudé, 2024/03/15
- [PATCH-for-9.1 12/21] system: Introduce QemuArchBit enum, Philippe Mathieu-Daudé, 2024/03/15
- [RFC PATCH-for-9.1 16/21] target/loongarch: Use QMP generic_query_cpu_definitions(), Philippe Mathieu-Daudé, 2024/03/15
- [RFC PATCH-for-9.1 17/21] target/riscv: Use QMP generic_query_cpu_definitions(),
Philippe Mathieu-Daudé <=
- [PATCH-for-9.1 13/21] system: Introduce cpu_typename_by_arch_bit(), Philippe Mathieu-Daudé, 2024/03/15
- [RFC PATCH-for-9.1 14/21] system: Introduce QMP generic_query_cpu_definitions(), Philippe Mathieu-Daudé, 2024/03/15
- [RFC PATCH-for-9.1 18/21] target/i386: Use QMP generic_query_cpu_definitions(), Philippe Mathieu-Daudé, 2024/03/15
- [PATCH-for-9.1 19/21] target/ppc: Factor ppc_add_alias_definitions() out, Philippe Mathieu-Daudé, 2024/03/15
- [RFC PATCH-for-9.1 20/21] target/ppc: Use QMP generic_query_cpu_definitions(), Philippe Mathieu-Daudé, 2024/03/15
- [RFC PATCH-for-9.1 21/21] qapi: Make @query-cpu-definitions target-agnostic, Philippe Mathieu-Daudé, 2024/03/15