From nobody Wed Nov 5 18:39:27 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1536306198545153.76845615166587; Fri, 7 Sep 2018 00:43:18 -0700 (PDT) Received: from localhost ([::1]:37176 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fyBQD-00020X-1X for importer@patchew.org; Fri, 07 Sep 2018 03:43:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fyBFV-0007WP-6E for qemu-devel@nongnu.org; Fri, 07 Sep 2018 03:32:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fyBFT-000551-Fh for qemu-devel@nongnu.org; Fri, 07 Sep 2018 03:32:13 -0400 Received: from ozlabs.org ([203.11.71.1]:58415) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fyBFS-00053l-PZ; Fri, 07 Sep 2018 03:32:11 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 4268Jy0f7Lz9sCD; Fri, 7 Sep 2018 17:32:01 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1536305522; bh=2nigEbh6L6iIGzKXe14CwM4nUCrWcYXV4LWvxqpBAP4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XL73KDvPZ4YL8Pauc+E6JNP17WJ6G998Rucpa8vHLyRVuqQL8PWRUArP/eXAk9eXe 92YqXginmbp3FxNxLAANzNGw5OSblIL0k/pOcaYvLAASKBNcAoJwzjJxpFaXA/LchY bP0sEAAj7OJzmPNychFppXgBXJAmatHUr6Bey170= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 7 Sep 2018 17:31:46 +1000 Message-Id: <20180907073155.26200-6-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180907073155.26200-1-david@gibson.dropbear.id.au> References: <20180907073155.26200-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 05/14] macio: add macio bus to help with fw path generation 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: lvivier@redhat.com, mark.cave-ayland@ilande.co.uk, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Mark Cave-Ayland As the in-built IDE controller is attached to the macio bus then we should = also model this the same in QEMU to aid fw path generation. Note that all existing macio devices are moved onto the new macio bus so th= at the qdev tree accurately reflects the real hardware. Signed-off-by: Mark Cave-Ayland Signed-off-by: David Gibson --- hw/misc/macio/macio.c | 37 ++++++++++++++++++++++++++--------- include/hw/misc/macio/macio.h | 10 ++++++++++ 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c index 52aa3775f4..229bfddb90 100644 --- a/hw/misc/macio/macio.c +++ b/hw/misc/macio/macio.c @@ -90,6 +90,15 @@ static void macio_bar_setup(MacIOState *s) macio_escc_legacy_setup(s); } =20 +static void macio_init_child_obj(MacIOState *s, const char *childname, + void *child, size_t childsize, + const char *childtype) +{ + object_initialize_child(OBJECT(s), childname, child, childsize, childt= ype, + &error_abort, NULL); + qdev_set_parent_bus(DEVICE(child), BUS(&s->macio_bus)); +} + static void macio_common_realize(PCIDevice *d, Error **errp) { MacIOState *s =3D MACIO(d); @@ -211,7 +220,7 @@ static void macio_init_ide(MacIOState *s, MACIOIDEState= *ide, size_t ide_size, { gchar *name =3D g_strdup_printf("ide[%i]", index); =20 - sysbus_init_child_obj(OBJECT(s), name, ide, ide_size, TYPE_MACIO_IDE); + macio_init_child_obj(s, name, ide, ide_size, TYPE_MACIO_IDE); memory_region_add_subregion(&s->bar, 0x1f000 + ((index + 1) * 0x1000), &ide->mem); g_free(name); @@ -229,7 +238,7 @@ static void macio_oldworld_init(Object *obj) qdev_prop_allow_set_link_before_realize, 0, NULL); =20 - sysbus_init_child_obj(obj, "cuda", &s->cuda, sizeof(s->cuda), TYPE_CUD= A); + macio_init_child_obj(s, "cuda", &s->cuda, sizeof(s->cuda), TYPE_CUDA); =20 object_initialize(&os->nvram, sizeof(os->nvram), TYPE_MACIO_NVRAM); dev =3D DEVICE(&os->nvram); @@ -340,7 +349,7 @@ static void macio_newworld_realize(PCIDevice *d, Error = **errp) object_property_set_link(OBJECT(&s->pmu), OBJECT(sysbus_dev), "gpi= o", &error_abort); qdev_prop_set_bit(DEVICE(&s->pmu), "has-adb", ns->has_adb); - qdev_set_parent_bus(DEVICE(&s->pmu), sysbus_get_default()); + qdev_set_parent_bus(DEVICE(&s->pmu), BUS(&s->macio_bus)); object_property_add_child(OBJECT(s), "pmu", OBJECT(&s->pmu), NULL); =20 object_property_set_bool(OBJECT(&s->pmu), true, "realized", &err); @@ -356,7 +365,7 @@ static void macio_newworld_realize(PCIDevice *d, Error = **errp) } else { /* CUDA */ object_initialize(&s->cuda, sizeof(s->cuda), TYPE_CUDA); - qdev_set_parent_bus(DEVICE(&s->cuda), sysbus_get_default()); + qdev_set_parent_bus(DEVICE(&s->cuda), BUS(&s->macio_bus)); object_property_add_child(OBJECT(s), "cuda", OBJECT(&s->cuda), NUL= L); qdev_prop_set_uint64(DEVICE(&s->cuda), "timebase-frequency", s->frequency); @@ -385,8 +394,8 @@ static void macio_newworld_init(Object *obj) qdev_prop_allow_set_link_before_realize, 0, NULL); =20 - sysbus_init_child_obj(obj, "gpio", &ns->gpio, sizeof(ns->gpio), - TYPE_MACIO_GPIO); + macio_init_child_obj(s, "gpio", &ns->gpio, sizeof(ns->gpio), + TYPE_MACIO_GPIO); =20 for (i =3D 0; i < 2; i++) { macio_init_ide(s, &ns->ide[i], sizeof(ns->ide[i]), i); @@ -399,10 +408,13 @@ static void macio_instance_init(Object *obj) =20 memory_region_init(&s->bar, obj, "macio", 0x80000); =20 - sysbus_init_child_obj(obj, "dbdma", &s->dbdma, sizeof(s->dbdma), - TYPE_MAC_DBDMA); + qbus_create_inplace(&s->macio_bus, sizeof(s->macio_bus), TYPE_MACIO_BU= S, + DEVICE(obj), "macio.0"); =20 - sysbus_init_child_obj(obj, "escc", &s->escc, sizeof(s->escc), TYPE_ESC= C); + macio_init_child_obj(s, "dbdma", &s->dbdma, sizeof(s->dbdma), + TYPE_MAC_DBDMA); + + macio_init_child_obj(s, "escc", &s->escc, sizeof(s->escc), TYPE_ESCC); } =20 static const VMStateDescription vmstate_macio_oldworld =3D { @@ -470,6 +482,12 @@ static void macio_class_init(ObjectClass *klass, void = *data) dc->user_creatable =3D false; } =20 +static const TypeInfo macio_bus_info =3D { + .name =3D TYPE_MACIO_BUS, + .parent =3D TYPE_BUS, + .instance_size =3D sizeof(MacIOBusState), +}; + static const TypeInfo macio_oldworld_type_info =3D { .name =3D TYPE_OLDWORLD_MACIO, .parent =3D TYPE_MACIO, @@ -501,6 +519,7 @@ static const TypeInfo macio_type_info =3D { =20 static void macio_register_types(void) { + type_register_static(&macio_bus_info); type_register_static(&macio_type_info); type_register_static(&macio_oldworld_type_info); type_register_static(&macio_newworld_type_info); diff --git a/include/hw/misc/macio/macio.h b/include/hw/misc/macio/macio.h index 0c3964ec12..3189973ee6 100644 --- a/include/hw/misc/macio/macio.h +++ b/include/hw/misc/macio/macio.h @@ -34,6 +34,15 @@ #include "hw/ppc/mac_dbdma.h" #include "hw/ppc/openpic.h" =20 +/* MacIO virtual bus */ +#define TYPE_MACIO_BUS "macio-bus" +#define MACIO_BUS(obj) OBJECT_CHECK(MacIOBusState, (obj), TYPE_MACIO_BUS) + +typedef struct MacIOBusState { + /*< private >*/ + BusState parent_obj; +} MacIOBusState; + /* MacIO IDE */ #define TYPE_MACIO_IDE "macio-ide" #define MACIO_IDE(obj) OBJECT_CHECK(MACIOIDEState, (obj), TYPE_MACIO_IDE) @@ -68,6 +77,7 @@ typedef struct MacIOState { PCIDevice parent; /*< public >*/ =20 + MacIOBusState macio_bus; MemoryRegion bar; CUDAState cuda; PMUState pmu; --=20 2.17.1