From d585d89de172bbfaa4a2331c882c46ed186ede2a Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Sep 2021 08:38:04 +0100 Subject: [PATCH] nubus-bridge: embed the NubusBus object directly within nubus-bridge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since nubus-bridge is a container for NubusBus then it should be embedded directly within the bridge device using qbus_create_inplace(). Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier Message-Id: <20210924073808.1041-17-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- hw/m68k/q800.c | 2 +- hw/nubus/mac-nubus-bridge.c | 9 +++++---- hw/nubus/nubus-bridge.c | 3 ++- include/hw/nubus/nubus.h | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c index 9bdea1a362..074acf4fdc 100644 --- a/hw/m68k/q800.c +++ b/hw/m68k/q800.c @@ -398,7 +398,7 @@ static void q800_init(MachineState *machine) sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, NUBUS_SLOT_BASE + MAC_NUBUS_FIRST_SLOT * NUBUS_SLOT_SIZE); - nubus = NUBUS_BRIDGE(dev)->bus; + nubus = &NUBUS_BRIDGE(dev)->bus; /* framebuffer in nubus slot #9 */ diff --git a/hw/nubus/mac-nubus-bridge.c b/hw/nubus/mac-nubus-bridge.c index db8640eed2..a0da5a8b2f 100644 --- a/hw/nubus/mac-nubus-bridge.c +++ b/hw/nubus/mac-nubus-bridge.c @@ -18,19 +18,20 @@ static void mac_nubus_bridge_init(Object *obj) MacNubusBridge *s = MAC_NUBUS_BRIDGE(obj); NubusBridge *nb = NUBUS_BRIDGE(obj); SysBusDevice *sbd = SYS_BUS_DEVICE(obj); + NubusBus *bus = &nb->bus; /* Macintosh only has slots 0x9 to 0xe available */ - nb->bus->slot_available_mask = MAKE_64BIT_MASK(MAC_NUBUS_FIRST_SLOT, - MAC_NUBUS_SLOT_NB); + bus->slot_available_mask = MAKE_64BIT_MASK(MAC_NUBUS_FIRST_SLOT, + MAC_NUBUS_SLOT_NB); /* Aliases for slots 0x9 to 0xe */ memory_region_init_alias(&s->super_slot_alias, obj, "super-slot-alias", - &nb->bus->nubus_mr, + &bus->nubus_mr, MAC_NUBUS_FIRST_SLOT * NUBUS_SUPER_SLOT_SIZE, MAC_NUBUS_SLOT_NB * NUBUS_SUPER_SLOT_SIZE); memory_region_init_alias(&s->slot_alias, obj, "slot-alias", - &nb->bus->nubus_mr, + &bus->nubus_mr, NUBUS_SLOT_BASE + MAC_NUBUS_FIRST_SLOT * NUBUS_SLOT_SIZE, MAC_NUBUS_SLOT_NB * NUBUS_SLOT_SIZE); diff --git a/hw/nubus/nubus-bridge.c b/hw/nubus/nubus-bridge.c index 3b68d4435c..1adda7f5a6 100644 --- a/hw/nubus/nubus-bridge.c +++ b/hw/nubus/nubus-bridge.c @@ -16,8 +16,9 @@ static void nubus_bridge_init(Object *obj) { NubusBridge *s = NUBUS_BRIDGE(obj); + NubusBus *bus = &s->bus; - s->bus = NUBUS_BUS(qbus_create(TYPE_NUBUS_BUS, DEVICE(s), NULL)); + qbus_create_inplace(bus, sizeof(s->bus), TYPE_NUBUS_BUS, DEVICE(s), NULL); } static void nubus_bridge_class_init(ObjectClass *klass, void *data) diff --git a/include/hw/nubus/nubus.h b/include/hw/nubus/nubus.h index 2d00d18150..63c69a7586 100644 --- a/include/hw/nubus/nubus.h +++ b/include/hw/nubus/nubus.h @@ -63,7 +63,7 @@ struct NubusDevice { struct NubusBridge { SysBusDevice parent_obj; - NubusBus *bus; + NubusBus bus; }; #endif