From patchwork Tue Dec 20 11:03:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 635442 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2857525pvb; Tue, 20 Dec 2022 03:31:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf6XWFLY11F+fowsNgAxt01k5p4gVQDbF18sifes6k/2WKU1JUMJ5xeZb0w8QG06CVzIMZKa X-Received: by 2002:a0c:fbd1:0:b0:4c7:61a9:ab5c with SMTP id n17-20020a0cfbd1000000b004c761a9ab5cmr59831999qvp.25.1671535876296; Tue, 20 Dec 2022 03:31:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671535876; cv=none; d=google.com; s=arc-20160816; b=VMnfr80mkDbNJE0NWNjGVwKzM2MbqHQ10Ta7afcYU10wckOJTISitJ8jQRAOjXO5wQ Wx/9fp2ya1PaNi27lnWsHR74Ir46BDsV9NTcLv3vUZxVKMdlUeFNOPr3a+SyH3lMvPer JeiP1xjnNFRRHC8U3gb0xJBpCiZ9tr1tNMklDJaHtT5DmORVnr62NrXwJ8OBq77LN/7j 9tC4UbO6bvi9qdDQiLZQMG5XN7wKec1+lN27Kymc9xtPnMJWoiNwoW6vbv1fe2ya8gbQ LGGGlmA11US/wwodlb7UPbDxgGoFwURoADFwekioDvnbhLPp3kZPHSl4MQvIL6OAbu70 nQTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Tc4icU5uIZDb6KV/spc5EMSSVzOZKwdCLgvhFKNLqtU=; b=sQSGTHE49i1DjDLXj81HtEuwpR8BcZ3O7yNIqFSGW8MZ3chSysG+enfoPuzKr8YnJa OoVWXL9cueZWyIy1OmOinZun3G3ZXG0tuLsXmi06OFXwjHpvwU7UoWlCQpQuflNdoPej XIj61aziEabYfLYpr6Zh6uaCKicHSGBBj56WwCvyVqrWnnrFFzY/5hjMV+hNam/Mx9Ho m1Xx7EwnQWVwxaJSuPWprMFvjcRzoSOe4BkATKcOus6lFTesgGLVUm5+ib0ZosqxpDD7 MsytC6k2a9qnaVz3265VHwDzqx7vqqEqgr1hS7l+DNpv0tflFJRIeGXz1gCnqVVQSy1s SsZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nXfZ+zjH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a12-20020a056214062c00b004c68f2d9e73si5010661qvx.471.2022.12.20.03.31.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Dec 2022 03:31:16 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nXfZ+zjH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7aQ6-0000zr-Il; Tue, 20 Dec 2022 06:04:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p7aPV-0000o2-E7 for qemu-devel@nongnu.org; Tue, 20 Dec 2022 06:03:52 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p7aPS-0002MZ-6A for qemu-devel@nongnu.org; Tue, 20 Dec 2022 06:03:49 -0500 Received: by mail-wm1-x32f.google.com with SMTP id ay40so8412308wmb.2 for ; Tue, 20 Dec 2022 03:03:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Tc4icU5uIZDb6KV/spc5EMSSVzOZKwdCLgvhFKNLqtU=; b=nXfZ+zjHuCw0iulHIaB9nXsY3wJAN3AaP6ZCsTQpOal3ZcenlArGCoadjO9G5KYbUZ E718kX60ONJN0LMV23b/eTrfsXMTPkZ231Dv4O4zaWjd/uTG177zkm4ThNmHkL3wQb3i AhTo538LACrCueH5AlMFYfDdAuQ1UF16DAECWUHPHqcoNyJGn+E1bC/5sEhq3MInU8Hh mBqjAF8/bPbUpgOFYNsyWy/kglvwbmo+X5/6UejhpcITLeTS4JEjofW5BgG1EnIBNMS3 7WPDMJsVWiLNqVbNtglGXSRzEzdxaFrUzMHEBUCIwWqxABaWnbg21tjBalqnRDfXHzgz GfHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Tc4icU5uIZDb6KV/spc5EMSSVzOZKwdCLgvhFKNLqtU=; b=rxii/FxrN5pZ2PUN1vfFEurhrg6OHp7KsoT+s6ItgTrzOFvShlePg7WWNdwJoXbdW6 DlrOFWuz6YkNi94B2lVDlipx7Mk1djy2haCPxZShAMszV+iuhyStJiq90ItXyJ1RxM01 zlSHTidxHQt6tXfjm0wuhsD/Xa9q9Yw1YmA34NDNzOkSGR9ZkeH0UNYE5ZmYzxj00NA4 ZtbzEPlAJMKBrzrUbQHWh/AfbEbWw+bx9p5/9g8y6Z7p2N/qOfU/TXz9yXphzRdKOsIq 9guprAeN6dt9XLPEs2Di/n1E/BFvk9fChXF946ezMruykHyMJ61NDvhiOC8yQqviuV2/ Y7jg== X-Gm-Message-State: ANoB5plDmw/sXKetYpx2ptL6Ic7/qHUedfSrCLBI2nQ/LE4jQe+oP9sD zGOGs3KOAJ9/3FK9chMZmtUZ3CMH6IPinIaKvtc= X-Received: by 2002:a05:600c:3d0d:b0:3cf:e95b:fe71 with SMTP id bh13-20020a05600c3d0d00b003cfe95bfe71mr33553980wmb.9.1671534224364; Tue, 20 Dec 2022 03:03:44 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id l20-20020a05600c2cd400b003c70191f267sm22535267wmc.39.2022.12.20.03.03.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 20 Dec 2022 03:03:43 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Xiaojuan Yang , Daniel Henrique Barboza , =?utf-8?q?Philippe_Mathieu?= =?utf-8?q?-Daud=C3=A9?= , Greg Kurz , =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-ppc@nongnu.org, Peter Maydell , Aurelien Jarno , Song Gao , Jiaxun Yang , David Gibson , Huacai Chen , Aleksandar Rikalo , qemu-arm@nongnu.org, Markus Armbruster , Richard Henderson Subject: [PATCH v2 5/5] target/ppc: Restrict 'qapi-commands-machine.h' to system emulation Date: Tue, 20 Dec 2022 12:03:10 +0100 Message-Id: <20221220110310.8656-6-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221220110310.8656-1-philmd@linaro.org> References: <20221220110310.8656-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Since commit a0e61807a3 ("qapi: Remove QMP events and commands from user-mode builds") we don't generate the "qapi-commands-machine.h" header in a user-emulation-only build. Move the QMP functions from cpu_init.c (which is always compiled) to monitor.c (which is only compiled when system-emulation is selected). Note ppc_cpu_class_by_name() is used by both file units, so we expose its prototype in "cpu-qom.h". Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/ppc/cpu-qom.h | 2 ++ target/ppc/cpu_init.c | 48 +---------------------------------------- target/ppc/monitor.c | 50 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 52 insertions(+), 48 deletions(-) diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h index 89ff88f28c..6431c520c8 100644 --- a/target/ppc/cpu-qom.h +++ b/target/ppc/cpu-qom.h @@ -31,6 +31,8 @@ OBJECT_DECLARE_CPU_TYPE(PowerPCCPU, PowerPCCPUClass, POWERPC_CPU) +ObjectClass *ppc_cpu_class_by_name(const char *name); + typedef struct CPUArchState CPUPPCState; typedef struct ppc_tb_t ppc_tb_t; typedef struct ppc_dcr_t ppc_dcr_t; diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index cbf0081374..7858cc4c6c 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -40,7 +40,6 @@ #include "qemu/cutils.h" #include "disas/capstone.h" #include "fpu/softfloat.h" -#include "qapi/qapi-commands-machine-target.h" #include "helper_regs.h" #include "internal.h" @@ -6816,7 +6815,7 @@ static const char *ppc_cpu_lookup_alias(const char *alias) return NULL; } -static ObjectClass *ppc_cpu_class_by_name(const char *name) +ObjectClass *ppc_cpu_class_by_name(const char *name) { char *cpu_model, *typename; ObjectClass *oc; @@ -6956,51 +6955,6 @@ void ppc_cpu_list(void) #endif } -static void ppc_cpu_defs_entry(gpointer data, gpointer user_data) -{ - ObjectClass *oc = data; - CpuDefinitionInfoList **first = user_data; - const char *typename; - CpuDefinitionInfo *info; - - typename = object_class_get_name(oc); - info = g_malloc0(sizeof(*info)); - info->name = g_strndup(typename, - strlen(typename) - strlen(POWERPC_CPU_TYPE_SUFFIX)); - - QAPI_LIST_PREPEND(*first, info); -} - -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) -{ - 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++) { - PowerPCCPUAlias *alias = &ppc_cpu_aliases[i]; - ObjectClass *oc; - CpuDefinitionInfo *info; - - oc = ppc_cpu_class_by_name(alias->model); - if (oc == NULL) { - continue; - } - - info = g_malloc0(sizeof(*info)); - info->name = g_strdup(alias->alias); - info->q_typename = g_strdup(object_class_get_name(oc)); - - QAPI_LIST_PREPEND(cpu_list, info); - } - - return cpu_list; -} - static void ppc_cpu_set_pc(CPUState *cs, vaddr value) { PowerPCCPU *cpu = POWERPC_CPU(cs); diff --git a/target/ppc/monitor.c b/target/ppc/monitor.c index 8250b1304e..36e5b5eff8 100644 --- a/target/ppc/monitor.c +++ b/target/ppc/monitor.c @@ -1,5 +1,5 @@ /* - * QEMU monitor + * QEMU PPC (monitor definitions) * * Copyright (c) 2003-2004 Fabrice Bellard * @@ -28,6 +28,9 @@ #include "qemu/ctype.h" #include "monitor/hmp-target.h" #include "monitor/hmp.h" +#include "qapi/qapi-commands-machine-target.h" +#include "cpu-models.h" +#include "cpu-qom.h" static target_long monitor_get_ccr(Monitor *mon, const struct MonitorDef *md, int val) @@ -172,3 +175,48 @@ int target_get_monitor_def(CPUState *cs, const char *name, uint64_t *pval) return -EINVAL; } + +static void ppc_cpu_defs_entry(gpointer data, gpointer user_data) +{ + ObjectClass *oc = data; + CpuDefinitionInfoList **first = user_data; + const char *typename; + CpuDefinitionInfo *info; + + typename = object_class_get_name(oc); + info = g_malloc0(sizeof(*info)); + info->name = g_strndup(typename, + strlen(typename) - strlen(POWERPC_CPU_TYPE_SUFFIX)); + + QAPI_LIST_PREPEND(*first, info); +} + +CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) +{ + 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++) { + PowerPCCPUAlias *alias = &ppc_cpu_aliases[i]; + ObjectClass *oc; + CpuDefinitionInfo *info; + + oc = ppc_cpu_class_by_name(alias->model); + if (oc == NULL) { + continue; + } + + info = g_malloc0(sizeof(*info)); + info->name = g_strdup(alias->alias); + info->q_typename = g_strdup(object_class_get_name(oc)); + + QAPI_LIST_PREPEND(cpu_list, info); + } + + return cpu_list; +}