From patchwork Fri Mar 15 13:09:01 2024 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: 780487 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp190263wrs; Fri, 15 Mar 2024 06:12:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWhfrpgue/rjDEvuHGxaT2znvZh4By0IzG4Z9qd0G6JLGf6/MgTztlaEzZJULfqluRxJ+xXgvwUPco76epx+HoS X-Google-Smtp-Source: AGHT+IFpFikX6SVsV3Jx166dRkrx/91XVDCguS3b2iRizMdEys4nuYzZd8n3OM+P96XzbuIGEIxi X-Received: by 2002:a05:6808:2f18:b0:3c1:e619:31c9 with SMTP id gu24-20020a0568082f1800b003c1e61931c9mr4595404oib.27.1710508354544; Fri, 15 Mar 2024 06:12:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710508354; cv=none; d=google.com; s=arc-20160816; b=IiiK5I+FdjflUtUprAYVTIlWfi65WEhusEyG6g9F+8ATXfVRlz+nwh1sXqZMBh5imY MMqOeUq3mn2dpBCxL+RT79ttVqDZwBfbuEZqWjFeJbLVI01s0on+pWHvxF9+DR1aLMge Oc9/vE8Doxu47O6XVQuMU0SVf+Yug+NWBmi2u8SapAphfk7h/AqoYtgyDJGGkqUDq5BA rmw4MmFYSL1u6Ea9IkJmmLJVTAYb6kcdx/tCkwIrpYXGrb/hIbMbObrSGgM0MfbLD1+G 8U3WvccA3+t3Rr2hkt+LRWkWnQ5YhaxtY1/viYfTj1v1aZT1NvNGG/8GOp7WWA+DbEgq ahUQ== 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=J25HPqsyrmOQ1iioSn9g7nmBc+Xq8CsuJB3WGvQV87Y=; fh=Ol3tAPX/VLbajEqrc9A2NaG0RWh2tFO21EWtQ1skWSs=; b=ATs25qQr6WgG61+F+8QaQumuR/2spkJGm5Oi1pVc51gxaRlBYRafMhKi6+8JgY5Bhk /SxHX7ZK4cy7QeIFSsF2PFij/ic0k0s4cot8uRtIiGNkT+itFepxwl7/xGd/Au7z0Dww u+hLnqsVMDfnNaBQK7GkGZjqTqSRf05WrVr0BsBk6OFiVbiwHopNtL3qjlnz1eG4nkth 4wn5VGVC5wq8mt5SAz954+WSxsap1ovRfSFnvCRERWmzw8ulaLvL6dwsJBufLfB4+0a6 FU3ADaMbUdpTdXQWjVBGXtleWUWtpr6d2JiJPdYUnRYdkKQ+TiGBWNk/YPdMy2/MHifs DcLA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vi27EO75; 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 y25-20020ab05b99000000b007e000ab8a14si83906uae.63.2024.03.15.06.12.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 06:12:34 -0700 (PDT) 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=Vi27EO75; 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 1rl7L9-0000ko-JW; Fri, 15 Mar 2024 09:11:15 -0400 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 1rl7Kq-0007pM-4r for qemu-devel@nongnu.org; Fri, 15 Mar 2024 09:10:56 -0400 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rl7Kh-0008OW-N5 for qemu-devel@nongnu.org; Fri, 15 Mar 2024 09:10:51 -0400 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2d2505352e6so23328061fa.3 for ; Fri, 15 Mar 2024 06:10:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710508242; x=1711113042; darn=nongnu.org; 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=J25HPqsyrmOQ1iioSn9g7nmBc+Xq8CsuJB3WGvQV87Y=; b=Vi27EO75DlJiqo/Ja2Yu1gvvOfJoqPZMmfBJWXQZ3xQJKEN6K9Z5xtpRzuOOApi9h+ CQJkzAFktpzv/Fl9+xFPFNLFbdnZn9FLP95wbAXYGylB9/NMv+6c4tkbW0DgYPFr4Z4R 2Jql/IoxdTqS9Wu/VRFxLwFBUKVdt3mTzQCQ8dMl88PBUm5XlaTy2NnwwmJ9BZF2QDT6 WvBI4wJiwxcXMvcenhJChApo1Hsy403pKwo06V2fnRnEaMG4jXi/bCFredKo+aqrh5pd rGgITL0wuytDWPo04vs7YUdH7+t77tTkKnbaj6Z3KaADvwE+kWCeB3ACpq0PyT33VEM+ jCgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710508242; x=1711113042; 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=J25HPqsyrmOQ1iioSn9g7nmBc+Xq8CsuJB3WGvQV87Y=; b=hl/8wJX9axlKx3V/lWGGLIgcXUS59Zg39Zkv7XfW8Y8fW6azhdVZZ1yunWBSvQoa9k 27Zhw3GOk8tP9qeK0zQdoVP2SBtZUqhz7r4aYDIGosrrPB4WI7BFqxTIuILSJNFOIHIw dAOoO1+/PgSvksaWfzIh+GRC62bHkZTbv53JnFjmthQKgL3K1UjClKzvf3BrGSUV8YmN qUwT/8Kkn3nZbKRKcDD60+IR5hFL5lmiJdbRNzMxfpKl1h1kt8OD/nBsja5cNgGVnvPZ V3kvUCPoXs0wWJ+thaJFtbZ9boga6G3sG8L0kJxwWasuVA3Trb0h3iTPFTND7ZvNBUoV sbVg== X-Gm-Message-State: AOJu0YwAYoi6MYLeY97i1kh8wKVQKba8P7RpBnURRV7M0vSwWx0/FXpU Q49nZcoVn/RuGa0KByFIpeSAqHotv6Fpf3hmnaOgMknWlAaEYwiDFwX9yfq9t/1oMVL73eQnbhi Y X-Received: by 2002:a05:651c:23a:b0:2d3:3b37:db78 with SMTP id z26-20020a05651c023a00b002d33b37db78mr2967826ljn.16.1710508241796; Fri, 15 Mar 2024 06:10:41 -0700 (PDT) Received: from m1x-phil.lan ([176.176.145.26]) by smtp.gmail.com with ESMTPSA id l23-20020a1709065a9700b00a460040a102sm1670235ejq.124.2024.03.15.06.10.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 15 Mar 2024 06:10:41 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Markus Armbruster Cc: qemu-riscv@nongnu.org, Anton Johansson , qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, =?utf-8?q?Daniel_P_=2E_Berrang?= =?utf-8?q?=C3=A9?= , Paolo Bonzini , Eduardo Habkost , Claudio Fontana , Richard Henderson , Peter Maydell , =?utf-8?q?Alex_Benn=C3=A9e?= , Manos Pitsidianakis , Zhao Liu , qemu-arm@nongnu.org, Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.1 13/21] system: Introduce cpu_typename_by_arch_bit() Date: Fri, 15 Mar 2024 14:09:01 +0100 Message-ID: <20240315130910.15750-14-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240315130910.15750-1-philmd@linaro.org> References: <20240315130910.15750-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::231; envelope-from=philmd@linaro.org; helo=mail-lj1-x231.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Introduce a helper to return the CPU type name given a QemuArchBit. The TYPE_PPC_CPU target have different 32/64-bit definitions so we can not include it yet. Signed-off-by: Philippe Mathieu-Daudé --- --- MAINTAINERS | 1 + include/sysemu/arch_init.h | 2 ++ system/cpu-qom-helpers.c | 58 ++++++++++++++++++++++++++++++++++++++ system/meson.build | 1 + 4 files changed, 62 insertions(+) create mode 100644 system/cpu-qom-helpers.c diff --git a/MAINTAINERS b/MAINTAINERS index ed98814398..af27490243 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -148,6 +148,7 @@ M: Richard Henderson R: Paolo Bonzini S: Maintained F: system/cpus.c +F: system/cpu-qom-helpers.c F: system/watchpoint.c F: cpu-common.c F: cpu-target.c diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h index cf597c40a3..1874f18e67 100644 --- a/include/sysemu/arch_init.h +++ b/include/sysemu/arch_init.h @@ -27,6 +27,8 @@ typedef enum QemuArchBit { QEMU_ARCH_BIT_LAST = QEMU_ARCH_BIT_LOONGARCH } QemuArchBit; +const char *cpu_typename_by_arch_bit(QemuArchBit arch_bit); + enum QemuArchMask { QEMU_ARCH_ALL = -1, QEMU_ARCH_ALPHA = (1 << QEMU_ARCH_BIT_ALPHA), diff --git a/system/cpu-qom-helpers.c b/system/cpu-qom-helpers.c new file mode 100644 index 0000000000..0d402ee3a0 --- /dev/null +++ b/system/cpu-qom-helpers.c @@ -0,0 +1,58 @@ +/* + * Helpers for CPU QOM types + * + * SPDX-FileCopyrightText: 2024 Linaro Ltd. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "sysemu/arch_init.h" + +#include "target/alpha/cpu-qom.h" +#include "target/arm/cpu-qom.h" +#include "target/avr/cpu-qom.h" +#include "target/cris/cpu-qom.h" +#include "target/hexagon/cpu-qom.h" +#include "target/hppa/cpu-qom.h" +#include "target/i386/cpu-qom.h" +#include "target/loongarch/cpu-qom.h" +#include "target/m68k/cpu-qom.h" +#include "target/microblaze/cpu-qom.h" +#include "target/mips/cpu-qom.h" +#include "target/nios2/cpu-qom.h" +#include "target/openrisc/cpu-qom.h" +#include "target/riscv/cpu-qom.h" +#include "target/rx/cpu-qom.h" +#include "target/s390x/cpu-qom.h" +#include "target/sparc/cpu-qom.h" +#include "target/sh4/cpu-qom.h" +#include "target/tricore/cpu-qom.h" +#include "target/xtensa/cpu-qom.h" + +const char *cpu_typename_by_arch_bit(QemuArchBit arch_bit) +{ + static const char *cpu_bit_to_typename[QEMU_ARCH_BIT_LAST + 1] = { + [QEMU_ARCH_BIT_ALPHA] = TYPE_ALPHA_CPU, + [QEMU_ARCH_BIT_ARM] = TYPE_ARM_CPU, + [QEMU_ARCH_BIT_CRIS] = TYPE_CRIS_CPU, + [QEMU_ARCH_BIT_I386] = TYPE_I386_CPU, + [QEMU_ARCH_BIT_M68K] = TYPE_M68K_CPU, + [QEMU_ARCH_BIT_MICROBLAZE] = TYPE_MICROBLAZE_CPU, + [QEMU_ARCH_BIT_MIPS] = TYPE_MIPS_CPU, + /* TODO: TYPE_PPC_CPU */ + [QEMU_ARCH_BIT_S390X] = TYPE_S390_CPU, + [QEMU_ARCH_BIT_SH4] = TYPE_SUPERH_CPU, + [QEMU_ARCH_BIT_SPARC] = TYPE_SPARC_CPU, + [QEMU_ARCH_BIT_XTENSA] = TYPE_XTENSA_CPU, + [QEMU_ARCH_BIT_OPENRISC] = TYPE_OPENRISC_CPU, + [QEMU_ARCH_BIT_TRICORE] = TYPE_TRICORE_CPU, + [QEMU_ARCH_BIT_NIOS2] = TYPE_NIOS2_CPU, + [QEMU_ARCH_BIT_HPPA] = TYPE_HPPA_CPU, + [QEMU_ARCH_BIT_RISCV] = TYPE_RISCV_CPU, + [QEMU_ARCH_BIT_RX] = TYPE_RX_CPU, + [QEMU_ARCH_BIT_AVR] = TYPE_AVR_CPU, + [QEMU_ARCH_BIT_HEXAGON] = TYPE_HEXAGON_CPU, + [QEMU_ARCH_BIT_LOONGARCH] = TYPE_LOONGARCH_CPU, + }; + return cpu_bit_to_typename[arch_bit]; +} diff --git a/system/meson.build b/system/meson.build index 25e2117250..c6ee97e3b2 100644 --- a/system/meson.build +++ b/system/meson.build @@ -10,6 +10,7 @@ system_ss.add(files( 'balloon.c', 'bootdevice.c', 'cpus.c', + 'cpu-qom-helpers.c', 'cpu-throttle.c', 'cpu-timers.c', 'datadir.c',