From nobody Thu Nov 13 18:05:18 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581794444529751.5094716146939; Sat, 15 Feb 2020 11:20:44 -0800 (PST) Received: from localhost ([::1]:53820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j32za-0000kB-T9 for importer@patchew.org; Sat, 15 Feb 2020 14:20:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35311) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j32uz-0008SL-HJ for qemu-devel@nongnu.org; Sat, 15 Feb 2020 14:15:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j32uy-0004I2-0G for qemu-devel@nongnu.org; Sat, 15 Feb 2020 14:15:57 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:55350) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j32ux-0004HY-Pp; Sat, 15 Feb 2020 14:15:55 -0500 Received: by mail-wm1-x342.google.com with SMTP id q9so13334240wmj.5; Sat, 15 Feb 2020 11:15:55 -0800 (PST) Received: from localhost.localdomain (78.red-88-21-202.staticip.rima-tde.net. [88.21.202.78]) by smtp.gmail.com with ESMTPSA id o9sm9678605wrw.20.2020.02.15.11.15.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 11:15:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pPEcldfHD5OEhzQuYmprGj9+p4+mZQlzGRO9gMQy3Os=; b=Q0ty9M794wYXqt0r4fzM7ztljMLs0XYTnqx4DlSdbTis3II3KidV3mdY3rShtB7neK WojctAnkCKARVuk8/qg1yc4vjmm9QRMaTN9BaSyIjJ01Ag+ata4ZWpzTz+dSYAay2KNp PG3ZAWvjGQOPV2Z5w58iSL/XjkT4JfkUX0XoMuTh0K4jxTlAAcEHgjJBuNoauJqdpil8 xYgZJJwNNPaSStBdnimzfLGsRNl/sjgc6fjLKbQyOV7r7C7K6sJm+jC+oyWoQFIXj/uh ZJk6WzsqTYi6fRSy2XDeOUhEq734PBmZNkMm6pnfHr4PzQ12CQn3uJL/7c0kWmuRrJkQ jMgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=pPEcldfHD5OEhzQuYmprGj9+p4+mZQlzGRO9gMQy3Os=; b=kVvBTFug8kL29fFHasHY8YG6qzQrH5USa//4wutn8xyyfsp6k4Em1LmZ6ptV17akM5 ktZPQIQFCgTsULcl8DWNq3KphC23uGt8NRN4RxrSQhS/bA42BtWv5l0YAxiHtw+nfXUX Z1KZUr6G4SGGp235cj3onxHpyjCO58+Y3zsEhi9rS2NkVNAmKB58hbH++YjMPPlyXnQF rYSw4W8Hx7KKaSsigdpPZ9erk/E/lO+Wxnkr3Ecmz/beJyIg7SawgxbBDNvTBWXtX6ZV qNJUnvU2vRQHlOY1xLER5Md07G9L1muHzuelrkbrGnAdp2quJAv1+YF8iyWIL17ECt6u rl4A== X-Gm-Message-State: APjAAAUFwBBQ/AAK+udUNoBDRPmpOPtjfN1wXtW/s6mCOUqme4I88m++ Gw6sDL8e4uePHGVigyhHcukXYJyI25Y= X-Google-Smtp-Source: APXvYqxg9d31T70kpIR2Xg4ZvH6WqXCTwv81la7HabTi0PVFuaizbqvaCQgbJ2c41DKp+nL9sKtGOg== X-Received: by 2002:a1c:7317:: with SMTP id d23mr12301275wmb.165.1581794154640; Sat, 15 Feb 2020 11:15:54 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 06/12] hw/arm/bcm2836: QOM'ify more by adding class_init() to each SoC type Date: Sat, 15 Feb 2020 20:15:37 +0100 Message-Id: <20200215191543.3235-7-f4bug@amsat.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200215191543.3235-1-f4bug@amsat.org> References: <20200215191543.3235-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 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 , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Andrew Baumann , qemu-arm@nongnu.org, Igor Mammedov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Remove usage of TypeInfo::class_data. Instead fill the fields in the corresponding class_init(). Cc: Igor Mammedov Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/arm/bcm2836.c | 109 ++++++++++++++++++++++------------------------- 1 file changed, 51 insertions(+), 58 deletions(-) diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c index 24109fef1d..683d04d6ea 100644 --- a/hw/arm/bcm2836.c +++ b/hw/arm/bcm2836.c @@ -16,57 +16,30 @@ #include "hw/arm/raspi_platform.h" #include "hw/sysbus.h" =20 -typedef struct BCM283XInfo BCM283XInfo; - typedef struct BCM283XClass { /*< private >*/ DeviceClass parent_class; /*< public >*/ - const BCM283XInfo *info; -} BCM283XClass; - -struct BCM283XInfo { - const char *name; const char *cpu_type; hwaddr peri_base; /* Peripheral base address seen by the CPU */ hwaddr ctrl_base; /* Interrupt controller and mailboxes etc. */ int clusterid; -}; +} BCM283XClass; =20 #define BCM283X_CLASS(klass) \ OBJECT_CLASS_CHECK(BCM283XClass, (klass), TYPE_BCM283X) #define BCM283X_GET_CLASS(obj) \ OBJECT_GET_CLASS(BCM283XClass, (obj), TYPE_BCM283X) =20 -static const BCM283XInfo bcm283x_socs[] =3D { - { - .name =3D TYPE_BCM2836, - .cpu_type =3D ARM_CPU_TYPE_NAME("cortex-a7"), - .peri_base =3D 0x3f000000, - .ctrl_base =3D 0x40000000, - .clusterid =3D 0xf, - }, -#ifdef TARGET_AARCH64 - { - .name =3D TYPE_BCM2837, - .cpu_type =3D ARM_CPU_TYPE_NAME("cortex-a53"), - .peri_base =3D 0x3f000000, - .ctrl_base =3D 0x40000000, - .clusterid =3D 0x0, - }, -#endif -}; - static void bcm2836_init(Object *obj) { BCM283XState *s =3D BCM283X(obj); BCM283XClass *bc =3D BCM283X_GET_CLASS(obj); - const BCM283XInfo *info =3D bc->info; int n; =20 for (n =3D 0; n < BCM283X_NCPUS; n++) { object_initialize_child(obj, "cpu[*]", &s->cpu[n].core, - sizeof(s->cpu[n].core), info->cpu_type, + sizeof(s->cpu[n].core), bc->cpu_type, &error_abort, NULL); } =20 @@ -85,7 +58,6 @@ static void bcm2836_realize(DeviceState *dev, Error **err= p) { BCM283XState *s =3D BCM283X(dev); BCM283XClass *bc =3D BCM283X_GET_CLASS(dev); - const BCM283XInfo *info =3D bc->info; Object *obj; Error *err =3D NULL; int n; @@ -119,7 +91,7 @@ static void bcm2836_realize(DeviceState *dev, Error **er= rp) } =20 sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->peripherals), 0, - info->peri_base, 1); + bc->peri_base, 1); =20 /* bcm2836 interrupt controller (and mailboxes, etc.) */ object_property_set_bool(OBJECT(&s->control), true, "realized", &err); @@ -128,7 +100,7 @@ static void bcm2836_realize(DeviceState *dev, Error **e= rrp) return; } =20 - sysbus_mmio_map(SYS_BUS_DEVICE(&s->control), 0, info->ctrl_base); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->control), 0, bc->ctrl_base); =20 sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 0, qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-irq", 0)); @@ -137,11 +109,11 @@ static void bcm2836_realize(DeviceState *dev, Error *= *errp) =20 for (n =3D 0; n < BCM283X_NCPUS; n++) { /* TODO: this should be converted to a property of ARM_CPU */ - s->cpu[n].core.mp_affinity =3D (info->clusterid << 8) | n; + s->cpu[n].core.mp_affinity =3D (bc->clusterid << 8) | n; =20 /* set periphbase/CBAR value for CPU-local registers */ object_property_set_int(OBJECT(&s->cpu[n].core), - info->peri_base, + bc->peri_base, "reset-cbar", &err); if (err) { error_propagate(errp, err); @@ -190,38 +162,59 @@ static Property bcm2836_props[] =3D { static void bcm283x_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); - BCM283XClass *bc =3D BCM283X_CLASS(oc); =20 - bc->info =3D data; - dc->realize =3D bcm2836_realize; - device_class_set_props(dc, bcm2836_props); /* Reason: Must be wired up in code (see raspi_init() function) */ dc->user_creatable =3D false; } =20 -static const TypeInfo bcm283x_type_info =3D { - .name =3D TYPE_BCM283X, - .parent =3D TYPE_DEVICE, - .instance_size =3D sizeof(BCM283XState), - .instance_init =3D bcm2836_init, - .class_size =3D sizeof(BCM283XClass), - .abstract =3D true, +static void bcm2836_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(oc); + BCM283XClass *bc =3D BCM283X_CLASS(oc); + + bc->cpu_type =3D ARM_CPU_TYPE_NAME("cortex-a7"); + bc->peri_base =3D 0x3f000000; + bc->ctrl_base =3D 0x40000000; + bc->clusterid =3D 0xf; + dc->realize =3D bcm2836_realize; + device_class_set_props(dc, bcm2836_props); }; =20 -static void bcm2836_register_types(void) +#ifdef TARGET_AARCH64 +static void bcm2837_class_init(ObjectClass *oc, void *data) { - int i; + DeviceClass *dc =3D DEVICE_CLASS(oc); + BCM283XClass *bc =3D BCM283X_CLASS(oc); =20 - type_register_static(&bcm283x_type_info); - for (i =3D 0; i < ARRAY_SIZE(bcm283x_socs); i++) { - TypeInfo ti =3D { - .name =3D bcm283x_socs[i].name, - .parent =3D TYPE_BCM283X, - .class_init =3D bcm283x_class_init, - .class_data =3D (void *) &bcm283x_socs[i], - }; - type_register(&ti); + bc->cpu_type =3D ARM_CPU_TYPE_NAME("cortex-a53"); + bc->peri_base =3D 0x3f000000; + bc->ctrl_base =3D 0x40000000; + bc->clusterid =3D 0x0; + dc->realize =3D bcm2836_realize; + device_class_set_props(dc, bcm2836_props); +}; +#endif + +static const TypeInfo bcm283x_types[] =3D { + { + .name =3D TYPE_BCM2836, + .parent =3D TYPE_BCM283X, + .class_init =3D bcm2836_class_init, +#ifdef TARGET_AARCH64 + }, { + .name =3D TYPE_BCM2837, + .parent =3D TYPE_BCM283X, + .class_init =3D bcm2837_class_init, +#endif + }, { + .name =3D TYPE_BCM283X, + .parent =3D TYPE_DEVICE, + .instance_size =3D sizeof(BCM283XState), + .instance_init =3D bcm2836_init, + .class_size =3D sizeof(BCM283XClass), + .class_init =3D bcm283x_class_init, + .abstract =3D true, } -} +}; =20 -type_init(bcm2836_register_types) +DEFINE_TYPES(bcm283x_types) --=20 2.21.1