From patchwork Fri May 31 13:43:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 165534 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp787160ili; Fri, 31 May 2019 06:57:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqw0luq9LJaG3Y6M09ERuzhhOXNT7IZZl+ONOuwZp3uo1QtR+7j5muIYUVq22lDbErVoL9pu X-Received: by 2002:aed:2961:: with SMTP id s88mr9222121qtd.120.1559311033924; Fri, 31 May 2019 06:57:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559311033; cv=none; d=google.com; s=arc-20160816; b=t3xU1bSqy5A+f2VzR7jvNs0tonsUlxyJSVfy3Z0C9z0UGizpAm7NHk/gVBq0jajKyj E2mweVbCTgDvKgXG7zFVHXRDyXoqtW8T2nrhB/iITnJM9Bf+0RHxANPQpW9nSPmZWpqi 5dSJW/jWJam1jlPkBcI6+mcYeHLgoD0x/AYGEl0aAnt9LN9tLqd3mwh3exQUSLVHRths mJNBcSOE9HpmCGbhyaNNWLR5E6Lvthk4y+oek/cvjSy2ISmxLNTkku7a2Qan+xdW7vPh n2ZdglWME1YJ9/Ym8+ZDxFgipGuF9xF+7FHRE6eR6fvTGUD2fn6pTOHenXvL3TdyM68r jKAQ== 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:dkim-signature; bh=gyvqL6c4/oaHwFa3XHYMgL2lVq/nblv9jYZvWQQxxMs=; b=q+aTpqsL+mIfZ+EqdGciYt1gopruxYRbJ6LGaockBLScSpp2TLQl/1a8UpLv9EUCMI 8R8ZWmy1wsXB4YdV/IdaHIGTBu7lhAbX/uacCUztSsMuIRCseUM80vi7wDLYjD6I0TWz g1g2SUUNeZV37II/pTYwEEjVECa2zT9hQ4GTNXIHoOAvZ0oNatQ+uKqqI4C7LbR3Qwhr +6fucveslOWK7zCC+zeuRvs/vYgOrOClmT8tn/w1tVYgO+aC39vnKN5Vlyf5zMKIOEKZ mRl6pgQwBJ/v70/D5PtAw3cVOYJ90oHDRI6O60d03yadT2d24s+7OpHoZ1PEHAHF1M27 ahwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KAa4Nw2A; 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=fail (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 e65si2820133qkf.138.2019.05.31.06.57.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 31 May 2019 06:57:13 -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=fail header.i=@linaro.org header.s=google header.b=KAa4Nw2A; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:43976 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWi1x-0000qr-Dx for patch@linaro.org; Fri, 31 May 2019 09:57:13 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWhor-0007Vf-3C for qemu-devel@nongnu.org; Fri, 31 May 2019 09:43:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hWhop-0000QN-Ln for qemu-devel@nongnu.org; Fri, 31 May 2019 09:43:41 -0400 Received: from mail-ot1-x341.google.com ([2607:f8b0:4864:20::341]:42161) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hWhop-0000PJ-FF for qemu-devel@nongnu.org; Fri, 31 May 2019 09:43:39 -0400 Received: by mail-ot1-x341.google.com with SMTP id i2so8224755otr.9 for ; Fri, 31 May 2019 06:43:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gyvqL6c4/oaHwFa3XHYMgL2lVq/nblv9jYZvWQQxxMs=; b=KAa4Nw2AriMhrKHg3Q/NJriL9L9fpRqjo11Qni7wcBSo0/Z84ulhexsjd2QiF9rEgO 92lnJN0VaFBunOu4snm75LsvJLB/yOKC4JzEaM+CXmuw1hxenrTImEknBTAIvbvz3D85 kkRi91Q3D5tdKanE1SIWFv4isE85Itoury2ZTtiCv/N0e7CGDRRpBvza2wP3or8IS3xT /w+3XQO15y/OYe9t36M8U2zpvTJnR0JgnUfPDfG2k0i/6zkqlBMaXOC/+53QaARMauI3 uYNt4/nG9YlcCch94rlDo36eXSjSRS/VSu7XKTHqfyZJIm7QQwTKjHoXiC3CXZB5DdWk MIJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gyvqL6c4/oaHwFa3XHYMgL2lVq/nblv9jYZvWQQxxMs=; b=J5pjBk74cSn2v5+LCNkAJWUcGxbERq3QE/pdkFIsymK/ZmIs4WFYpLF6Pet8dQ8jY2 O2/yK+sEqzEj7HyxMtdxWmIxiBi3tj6Cy76r3v8SKYvts6uGy3yKdfNapEKns9vPKTHP 7Y9nkG/4VPXeyiuucFcbe+cApKa8t0NkF6l/fVyg1bv/8yuUedx9lA3gWFjzyfpCCVbf hPgl2VPK7h+YU8wLrNnTEbxDwwosHe51YDubD3ha+PinSTEmiswtA6Kx+1h694eVM9Av uIaf/lyoBczf6gJWPwdJNWivA69587ke6ad9GvwlhCx2YknzP8ImdEUwA+WztS7aJ2Ax JvDg== X-Gm-Message-State: APjAAAW8Y5GWsGh5eV01s+EDDpvWF9KmI/CYmfk7BGWno9ZC7DkHa1Qb S7G83DF8gq3jS13lszPQkwmlRULuRE6H2Q== X-Received: by 2002:a9d:480a:: with SMTP id c10mr1836044otf.10.1559310218531; Fri, 31 May 2019 06:43:38 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id r23sm2391176otg.49.2019.05.31.06.43.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 May 2019 06:43:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 31 May 2019 08:43:05 -0500 Message-Id: <20190531134315.4109-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190531134315.4109-1-richard.henderson@linaro.org> References: <20190531134315.4109-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::341 Subject: [Qemu-devel] [PATCH v16 13/23] target/rx: Fix cpu types and names X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: philmd@redhat.com, ysato@users.sourceforge.jp Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- 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.17.1 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 void rxcpu_register_types(void) +static const TypeInfo rx62n_rx_cpu_info = { + .name = RX_CPU_TYPE_NAME("rx62n"), + .parent = TYPE_RX_CPU, +}; + +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];