From patchwork Fri Jun 7 09:11:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yoshinori Sato X-Patchwork-Id: 166095 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp398211ili; Fri, 7 Jun 2019 02:29:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGrAIJWD0DGh1rKooBRMSyrMV3R1x1clHBewdTI9/axR/ejdnqpJyUZj2TCoiAsG9FjRV8 X-Received: by 2002:a05:620a:13d1:: with SMTP id g17mr43328100qkl.121.1559899757441; Fri, 07 Jun 2019 02:29:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559899757; cv=none; d=google.com; s=arc-20160816; b=CPCrZ2Iyk0CF5+1CZCavYOiT6DtP+8pGWkMnrzu0/rtDHtYynlx30nwQ7OKc24jkyD 9KqXlPgZCe0ndbGKyKXU8Z44LLRRFXWFCnofKa4b36rZAvpqRScU1/P/Z43Lcc/OqbW0 7bOp7/pmr5gJcI5qnmmb7O+idrZaxWePpc9iYkMR8UxZElV+v7m/pjQ6/u5K8DM8WccU PVjeuGIrbkjRXAARYhKQuWKsLZrxsNQeX3FuaPvN9zretcqoClWwwjfHnQggAS4/mi2P mFe00h42y+iu2Jc/4EeL5qkzXHSAia4/He7fllcdkwx+7KY/+DmlPkM00cBwJJOxwvlO bMPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from; bh=Oabu6CouOtU+d1WLJK3DndPmSla5lQ2sU7BlCGC7sgk=; b=LzM+Yy6lc/tI0m6lCIPo2eRrON8kFzKlj5JObw7sbSs2u/ttZOhxXhoA5aiGemmw3J R5eQdhwx66pcY6FrcKvVxPpnrXdp28KhseX6/u2NG6kglpgnPgjAk92whNJ3geLkas0P OUASkZaQaToe1obtdTvUALA6gEaBgQ8XqWWA7lAO505CFZJ0+13o0pJhjgcTMy/iK6An RzBnZ1GvKHhJHKKfwaA0a9ESttj5nLXPG3Cj2dDBZ0OAQMPF7RvmuF3XOSIZSwiO19S0 JteAJLaWGZsxenO09W4FG6Z+dAoCXK60PJrIxclH3+DAsI5E+5dbN2/uzNVLfNHIYaR9 AP7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.47 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.47]) by mx.google.com with ESMTPS id y13si852745qkf.6.2019.06.07.02.29.17 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Jun 2019 02:29:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.47 as permitted sender) client-ip=209.51.188.47; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.47 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:47482 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBBV-0006Xg-2W for patch@linaro.org; Fri, 07 Jun 2019 05:29:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41383) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAuR-0000no-Mn for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:11:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAuO-0002qP-2y for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:11:39 -0400 Received: from mail03.asahi-net.or.jp ([202.224.55.15]:41364) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hZAuN-0002Zn-MI for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:11:35 -0400 Received: from h61-195-96-97.vps.ablenet.jp (h61-195-96-97.ablenetvps.ne.jp [61.195.96.97]) (Authenticated sender: PQ4Y-STU) by mail03.asahi-net.or.jp (Postfix) with ESMTPA id 5057E49ADB; Fri, 7 Jun 2019 18:11:29 +0900 (JST) Received: from yo-satoh-debian.localdomain (ZM005235.ppp.dion.ne.jp [222.8.5.235]) by h61-195-96-97.vps.ablenet.jp (Postfix) with ESMTPSA id E294E240085; Fri, 7 Jun 2019 18:11:28 +0900 (JST) From: Yoshinori Sato To: qemu-devel@nongnu.org Date: Fri, 7 Jun 2019 18:11:05 +0900 Message-Id: <20190607091116.49044-14-ysato@users.sourceforge.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190607091116.49044-1-ysato@users.sourceforge.jp> References: <20190607091116.49044-1-ysato@users.sourceforge.jp> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 202.224.55.15 Subject: [Qemu-devel] [PATCH v17 13/24] target/rx: Fix cpu types and names X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Richard Henderson , Yoshinori Sato , philmd@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson There was confusion here about abstract classes and naming cpus. We had registered a concrete class named "-rxcpu". This was put into the default cpu fields, and matched, so basic tests worked. However, no value for -cpu could ever match in rx_cpu_class_by_name. Rename the base class to "rx-cpu" and make it abstract. This matches what we do for most other targets. Create a new concrete cpu with the name "rx62n-rx-cpu". Signed-off-by: Richard Henderson Signed-off-by: Yoshinori Sato --- target/rx/cpu.h | 12 ++++++------ hw/rx/rx-virt.c | 2 +- hw/rx/rx62n.c | 2 +- target/rx/cpu.c | 43 ++++++++++++++++++++++++++----------------- 4 files changed, 34 insertions(+), 25 deletions(-) -- 2.11.0 Reviewed-by: Philippe Mathieu-Daudé diff --git a/target/rx/cpu.h b/target/rx/cpu.h index 8c1a4e448d..a0b6975963 100644 --- a/target/rx/cpu.h +++ b/target/rx/cpu.h @@ -24,14 +24,14 @@ #include "hw/registerfields.h" #include "qom/cpu.h" -#define TYPE_RXCPU "rxcpu" +#define TYPE_RX_CPU "rx-cpu" #define RXCPU_CLASS(klass) \ - OBJECT_CLASS_CHECK(RXCPUClass, (klass), TYPE_RXCPU) + OBJECT_CLASS_CHECK(RXCPUClass, (klass), TYPE_RX_CPU) #define RXCPU(obj) \ - OBJECT_CHECK(RXCPU, (obj), TYPE_RXCPU) + OBJECT_CHECK(RXCPU, (obj), TYPE_RX_CPU) #define RXCPU_GET_CLASS(obj) \ - OBJECT_GET_CLASS(RXCPUClass, (obj), TYPE_RXCPU) + OBJECT_GET_CLASS(RXCPUClass, (obj), TYPE_RX_CPU) /* * RXCPUClass: @@ -164,9 +164,9 @@ static inline RXCPU *rx_env_get_cpu(CPURXState *env) #define ENV_OFFSET offsetof(RXCPU, env) -#define RX_CPU_TYPE_SUFFIX "-" TYPE_RXCPU +#define RX_CPU_TYPE_SUFFIX "-" TYPE_RX_CPU #define RX_CPU_TYPE_NAME(model) model RX_CPU_TYPE_SUFFIX -#define CPU_RESOLVING_TYPE TYPE_RXCPU +#define CPU_RESOLVING_TYPE TYPE_RX_CPU extern const char rx_crname[][6]; diff --git a/hw/rx/rx-virt.c b/hw/rx/rx-virt.c index 3deb7cb335..72a2989fcf 100644 --- a/hw/rx/rx-virt.c +++ b/hw/rx/rx-virt.c @@ -88,7 +88,7 @@ static void rxvirt_class_init(ObjectClass *oc, void *data) mc->desc = "RX QEMU Virtual Target"; mc->init = rxvirt_init; mc->is_default = 1; - mc->default_cpu_type = TYPE_RXCPU; + mc->default_cpu_type = RX_CPU_TYPE_NAME("rx62n"); } static const TypeInfo rxvirt_type = { diff --git a/hw/rx/rx62n.c b/hw/rx/rx62n.c index c6660b75b4..3a8fe7b0bf 100644 --- a/hw/rx/rx62n.c +++ b/hw/rx/rx62n.c @@ -195,7 +195,7 @@ static void rx62n_realize(DeviceState *dev, Error **errp) } object_initialize_child(OBJECT(s), "cpu", &s->cpu, - sizeof(RXCPU), TYPE_RXCPU, + sizeof(RXCPU), RX_CPU_TYPE_NAME("rx62n"), errp, NULL); object_property_set_bool(OBJECT(&s->cpu), true, "realized", errp); diff --git a/target/rx/cpu.c b/target/rx/cpu.c index 3268077d08..41fe1de4bb 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -74,13 +74,14 @@ static void rx_cpu_list_entry(gpointer data, gpointer user_data) const char *typename = object_class_get_name(OBJECT_CLASS(data)); int len = strlen(typename) - strlen(RX_CPU_TYPE_SUFFIX); - qemu_printf("%.*s\n", len, typename); + qemu_printf(" %.*s\n", len, typename); } void rx_cpu_list(void) { - GSList *list; - list = object_class_get_list_sorted(TYPE_RXCPU, false); + GSList *list = object_class_get_list_sorted(TYPE_RX_CPU, false); + + qemu_printf("Available CPUs:\n"); g_slist_foreach(list, rx_cpu_list_entry, NULL); g_slist_free(list); } @@ -88,15 +89,17 @@ void rx_cpu_list(void) static ObjectClass *rx_cpu_class_by_name(const char *cpu_model) { ObjectClass *oc; - char *typename = NULL; + char *typename; - typename = g_strdup_printf(RX_CPU_TYPE_NAME("")); + typename = g_strdup_printf(RX_CPU_TYPE_NAME("%s"), cpu_model); oc = object_class_by_name(typename); - if (oc != NULL && object_class_is_abstract(oc)) { - oc = NULL; - } - g_free(typename); + + if (oc == NULL || + object_class_is_abstract(oc) || + !object_class_dynamic_cast(oc, TYPE_RX_CPU)) { + return NULL; + } return oc; } @@ -166,7 +169,7 @@ static void rx_cpu_init(Object *obj) qdev_init_gpio_in(DEVICE(cpu), rx_cpu_set_irq, 2); } -static void rxcpu_class_init(ObjectClass *klass, void *data) +static void rx_cpu_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); CPUClass *cc = CPU_CLASS(klass); @@ -195,22 +198,28 @@ static void rxcpu_class_init(ObjectClass *klass, void *data) cc->gdb_num_core_regs = 26; } -static const TypeInfo rxcpu_info = { - .name = TYPE_RXCPU, +static const TypeInfo rx_cpu_info = { + .name = TYPE_RX_CPU, .parent = TYPE_CPU, .instance_size = sizeof(RXCPU), .instance_init = rx_cpu_init, - .abstract = false, + .abstract = true, .class_size = sizeof(RXCPUClass), - .class_init = rxcpu_class_init, + .class_init = rx_cpu_class_init, +}; + +static const TypeInfo rx62n_rx_cpu_info = { + .name = RX_CPU_TYPE_NAME("rx62n"), + .parent = TYPE_RX_CPU, }; -static void rxcpu_register_types(void) +static void rx_cpu_register_types(void) { - type_register_static(&rxcpu_info); + type_register_static(&rx_cpu_info); + type_register_static(&rx62n_rx_cpu_info); } -type_init(rxcpu_register_types) +type_init(rx_cpu_register_types) static uint32_t extable[32];