1 /*
2  * QEMU LoongArch CPU (monitor definitions)
3  *
4  * SPDX-FileCopyrightText: 2021 Loongson Technology Corporation Limited
5  *
6  * SPDX-License-Identifier: GPL-2.0-or-later
7  */
8 
9 #include "qemu/osdep.h"
10 #include "qapi/qapi-commands-machine-target.h"
11 #include "cpu.h"
12 
13 static void loongarch_cpu_add_definition(gpointer data, gpointer user_data)
14 {
15     ObjectClass *oc = data;
16     CpuDefinitionInfoList **cpu_list = user_data;
17     CpuDefinitionInfo *info = g_new0(CpuDefinitionInfo, 1);
18     const char *typename = object_class_get_name(oc);
19 
20     info->name = g_strndup(typename,
21                            strlen(typename) - strlen("-" TYPE_LOONGARCH_CPU));
22     info->q_typename = g_strdup(typename);
23 
24     QAPI_LIST_PREPEND(*cpu_list, info);
25 }
26 
27 CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
28 {
29     CpuDefinitionInfoList *cpu_list = NULL;
30     GSList *list;
31 
32     list = object_class_get_list(TYPE_LOONGARCH_CPU, false);
33     g_slist_foreach(list, loongarch_cpu_add_definition, &cpu_list);
34     g_slist_free(list);
35 
36     return cpu_list;
37 }
38