| 1 | /* |
| 2 | * QEMU PPC (QMP definitions) |
| 3 | * |
| 4 | * Copyright (c) 2003-2004 Fabrice Bellard |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to deal |
| 8 | * in the Software without restriction, including without limitation the rights |
| 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | * copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in |
| 14 | * all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 | * THE SOFTWARE. |
| 23 | */ |
| 24 | |
| 25 | #include "qemu/osdep.h" |
| 26 | #include "cpu.h" |
| 27 | #include "qemu/ctype.h" |
| 28 | #include "qapi/error.h" |
| 29 | #include "qapi/qapi-commands-machine.h" |
| 30 | #include "cpu-models.h" |
| 31 | #include "cpu-qom.h" |
| 32 | |
| 33 | CpuModelExpansionInfo * |
| 34 | qmp_query_cpu_model_expansion(CpuModelExpansionType type, |
| 35 | CpuModelInfo *model, |
| 36 | Error **errp) |
| 37 | { |
| 38 | error_setg(errp, "CPU model expansion is not supported on this target"); |
| 39 | return NULL; |
| 40 | } |
| 41 | |
| 42 | static void ppc_cpu_defs_entry(gpointer data, gpointer user_data) |
| 43 | { |
| 44 | ObjectClass *oc = data; |
| 45 | CpuDefinitionInfoList **first = user_data; |
| 46 | const char *typename; |
| 47 | CpuDefinitionInfo *info; |
| 48 | |
| 49 | typename = object_class_get_name(oc); |
| 50 | info = g_malloc0(sizeof(*info)); |
| 51 | info->name = cpu_model_from_type(typename); |
| 52 | |
| 53 | QAPI_LIST_PREPEND(*first, info); |
| 54 | } |
| 55 | |
| 56 | CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) |
| 57 | { |
| 58 | CpuDefinitionInfoList *cpu_list = NULL; |
| 59 | GSList *list; |
| 60 | int i; |
| 61 | |
| 62 | list = object_class_get_list(TYPE_POWERPC_CPU, false); |
| 63 | g_slist_foreach(list, ppc_cpu_defs_entry, &cpu_list); |
| 64 | g_slist_free(list); |
| 65 | |
| 66 | for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) { |
| 67 | PowerPCCPUAlias *alias = &ppc_cpu_aliases[i]; |
| 68 | ObjectClass *oc; |
| 69 | CpuDefinitionInfo *info; |
| 70 | |
| 71 | oc = ppc_cpu_class_by_name(alias->model); |
| 72 | if (oc == NULL) { |
| 73 | continue; |
| 74 | } |
| 75 | |
| 76 | info = g_malloc0(sizeof(*info)); |
| 77 | info->name = g_strdup(alias->alias); |
| 78 | info->q_typename = g_strdup(object_class_get_name(oc)); |
| 79 | |
| 80 | QAPI_LIST_PREPEND(cpu_list, info); |
| 81 | } |
| 82 | |
| 83 | return cpu_list; |
| 84 | } |