[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH-for-9.1 19/21] target/ppc: Factor ppc_add_alias_definitions() out
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH-for-9.1 19/21] target/ppc: Factor ppc_add_alias_definitions() out |
Date: |
Fri, 15 Mar 2024 14:09:07 +0100 |
Factor ppc_add_alias_definitions() out of qmp_query_cpu_definitions()
to clearly see the generic pattern used in all targets.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/ppc/cpu-models.h | 4 ++++
target/ppc/ppc-qmp-cmds.c | 26 +++++++++++++++-----------
2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/target/ppc/cpu-models.h b/target/ppc/cpu-models.h
index 0229ef3a9a..89a5e232b7 100644
--- a/target/ppc/cpu-models.h
+++ b/target/ppc/cpu-models.h
@@ -21,6 +21,8 @@
#ifndef TARGET_PPC_CPU_MODELS_H
#define TARGET_PPC_CPU_MODELS_H
+#include "qapi/qapi-types-machine.h"
+
/**
* PowerPCCPUAlias:
* @alias: The alias name.
@@ -480,4 +482,6 @@ enum {
POWERPC_SVR_8641D = 0x80900121,
};
+void ppc_add_alias_definitions(CpuDefinitionInfoList **cpu_list);
+
#endif
diff --git a/target/ppc/ppc-qmp-cmds.c b/target/ppc/ppc-qmp-cmds.c
index a25d86a8d1..528cc3e4af 100644
--- a/target/ppc/ppc-qmp-cmds.c
+++ b/target/ppc/ppc-qmp-cmds.c
@@ -189,17 +189,9 @@ static void ppc_cpu_defs_entry(gpointer data, gpointer
user_data)
QAPI_LIST_PREPEND(*first, info);
}
-CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
+void ppc_add_alias_definitions(CpuDefinitionInfoList **cpu_list)
{
- CpuDefinitionInfoList *cpu_list = NULL;
- GSList *list;
- int i;
-
- list = object_class_get_list(TYPE_POWERPC_CPU, false);
- g_slist_foreach(list, ppc_cpu_defs_entry, &cpu_list);
- g_slist_free(list);
-
- for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) {
+ for (unsigned i = 0; ppc_cpu_aliases[i].alias != NULL; i++) {
PowerPCCPUAlias *alias = &ppc_cpu_aliases[i];
ObjectClass *oc;
CpuDefinitionInfo *info;
@@ -213,8 +205,20 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error
**errp)
info->name = g_strdup(alias->alias);
info->q_typename = g_strdup(object_class_get_name(oc));
- QAPI_LIST_PREPEND(cpu_list, info);
+ QAPI_LIST_PREPEND(*cpu_list, info);
}
+}
+
+CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
+{
+ CpuDefinitionInfoList *cpu_list = NULL;
+ GSList *list;
+
+ list = object_class_get_list(TYPE_POWERPC_CPU, false);
+ g_slist_foreach(list, ppc_cpu_defs_entry, &cpu_list);
+ g_slist_free(list);
+
+ ppc_add_alias_definitions(&cpu_list);
return cpu_list;
}
--
2.41.0
- Re: [PATCH-for-9.1 10/21] qapi: Make CpuModel* definitions target agnostic, (continued)
- [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é, 2024/03/15
- [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é <=
- [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
- Re: [RFC PATCH-for-9.1 00/21] qapi: Make @query-cpu-definitions command target-agnostic, Markus Armbruster, 2024/03/26
- Re: [RFC PATCH-for-9.1 00/21] qapi: Make @query-cpu-definitions command target-agnostic, Markus Armbruster, 2024/03/26