diff mbox series

[v3,19/23] q800: move mac-nubus-bridge device to Q800MachineState

Message ID 20230604131450.428797-20-mark.cave-ayland@ilande.co.uk (mailing list archive)
State New, archived
Headers show
Series q800: add support for booting MacOS Classic - part 1 | expand

Commit Message

Mark Cave-Ayland June 4, 2023, 1:14 p.m. UTC
Also change the instantiation of the mac-nubus-bridge device to use
object_initialize_child() and map the Nubus address space using
memory_region_add_subregion() instead of sysbus_mmio_map().

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/m68k/q800.c         | 21 ++++++++++++++-------
 include/hw/m68k/q800.h |  2 ++
 2 files changed, 16 insertions(+), 7 deletions(-)

Comments

Laurent Vivier June 4, 2023, 4:29 p.m. UTC | #1
Le 04/06/2023 à 15:14, Mark Cave-Ayland a écrit :
> Also change the instantiation of the mac-nubus-bridge device to use
> object_initialize_child() and map the Nubus address space using
> memory_region_add_subregion() instead of sysbus_mmio_map().
> 
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>   hw/m68k/q800.c         | 21 ++++++++++++++-------
>   include/hw/m68k/q800.h |  2 ++
>   2 files changed, 16 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
> index d6e19ff18c..14879310ca 100644
> --- a/hw/m68k/q800.c
> +++ b/hw/m68k/q800.c
> @@ -415,14 +415,21 @@ static void q800_machine_init(MachineState *machine)
>   
>       /* NuBus */
>   
> -    dev = qdev_new(TYPE_MAC_NUBUS_BRIDGE);
> -    qdev_prop_set_uint32(dev, "slot-available-mask",
> +    object_initialize_child(OBJECT(machine), "mac-nubus-bridge",
> +                            &m->mac_nubus_bridge,
> +                            TYPE_MAC_NUBUS_BRIDGE);
> +    sysbus = SYS_BUS_DEVICE(&m->mac_nubus_bridge);
> +    dev = DEVICE(&m->mac_nubus_bridge);
> +    qdev_prop_set_uint32(DEVICE(&m->mac_nubus_bridge), "slot-available-mask",
>                            Q800_NUBUS_SLOTS_AVAILABLE);
> -    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
> -    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0,
> -                    MAC_NUBUS_FIRST_SLOT * NUBUS_SUPER_SLOT_SIZE);
> -    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, NUBUS_SLOT_BASE +
> -                    MAC_NUBUS_FIRST_SLOT * NUBUS_SLOT_SIZE);
> +    sysbus_realize(sysbus, &error_fatal);
> +    memory_region_add_subregion(get_system_memory(),
> +                                MAC_NUBUS_FIRST_SLOT * NUBUS_SUPER_SLOT_SIZE,
> +                                sysbus_mmio_get_region(sysbus, 0));
> +    memory_region_add_subregion(get_system_memory(),
> +                                NUBUS_SLOT_BASE +
> +                                MAC_NUBUS_FIRST_SLOT * NUBUS_SLOT_SIZE,
> +                                sysbus_mmio_get_region(sysbus, 1));

Why it's not done in PATCH 10?

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Mark Cave-Ayland June 5, 2023, 5:43 a.m. UTC | #2
On 04/06/2023 17:29, Laurent Vivier wrote:

> Le 04/06/2023 à 15:14, Mark Cave-Ayland a écrit :
>> Also change the instantiation of the mac-nubus-bridge device to use
>> object_initialize_child() and map the Nubus address space using
>> memory_region_add_subregion() instead of sysbus_mmio_map().
>>
>> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>> ---
>>   hw/m68k/q800.c         | 21 ++++++++++++++-------
>>   include/hw/m68k/q800.h |  2 ++
>>   2 files changed, 16 insertions(+), 7 deletions(-)
>>
>> diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
>> index d6e19ff18c..14879310ca 100644
>> --- a/hw/m68k/q800.c
>> +++ b/hw/m68k/q800.c
>> @@ -415,14 +415,21 @@ static void q800_machine_init(MachineState *machine)
>>       /* NuBus */
>> -    dev = qdev_new(TYPE_MAC_NUBUS_BRIDGE);
>> -    qdev_prop_set_uint32(dev, "slot-available-mask",
>> +    object_initialize_child(OBJECT(machine), "mac-nubus-bridge",
>> +                            &m->mac_nubus_bridge,
>> +                            TYPE_MAC_NUBUS_BRIDGE);
>> +    sysbus = SYS_BUS_DEVICE(&m->mac_nubus_bridge);
>> +    dev = DEVICE(&m->mac_nubus_bridge);
>> +    qdev_prop_set_uint32(DEVICE(&m->mac_nubus_bridge), "slot-available-mask",
>>                            Q800_NUBUS_SLOTS_AVAILABLE);
>> -    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
>> -    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0,
>> -                    MAC_NUBUS_FIRST_SLOT * NUBUS_SUPER_SLOT_SIZE);
>> -    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, NUBUS_SLOT_BASE +
>> -                    MAC_NUBUS_FIRST_SLOT * NUBUS_SLOT_SIZE);
>> +    sysbus_realize(sysbus, &error_fatal);
>> +    memory_region_add_subregion(get_system_memory(),
>> +                                MAC_NUBUS_FIRST_SLOT * NUBUS_SUPER_SLOT_SIZE,
>> +                                sysbus_mmio_get_region(sysbus, 0));
>> +    memory_region_add_subregion(get_system_memory(),
>> +                                NUBUS_SLOT_BASE +
>> +                                MAC_NUBUS_FIRST_SLOT * NUBUS_SLOT_SIZE,
>> +                                sysbus_mmio_get_region(sysbus, 1));
> 
> Why it's not done in PATCH 10?

Patch 10 is concerned with devices mapped into the macio aliased memory space, 
whereas the mac-nubus-bridge device is mapped into the system memory address space 
(I'm not a fan of sysbus_mmio_map() because the "system memory space" isn't often 
well-defined: I much prefer to make the mapping explicit).

> Reviewed-by: Laurent Vivier <laurent@vivier.eu>

Thanks!


ATB,

Mark.
Philippe Mathieu-Daudé June 5, 2023, 12:47 p.m. UTC | #3
On 4/6/23 15:14, Mark Cave-Ayland wrote:
> Also change the instantiation of the mac-nubus-bridge device to use
> object_initialize_child() and map the Nubus address space using
> memory_region_add_subregion() instead of sysbus_mmio_map().
> 
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>   hw/m68k/q800.c         | 21 ++++++++++++++-------
>   include/hw/m68k/q800.h |  2 ++
>   2 files changed, 16 insertions(+), 7 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
diff mbox series

Patch

diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
index d6e19ff18c..14879310ca 100644
--- a/hw/m68k/q800.c
+++ b/hw/m68k/q800.c
@@ -415,14 +415,21 @@  static void q800_machine_init(MachineState *machine)
 
     /* NuBus */
 
-    dev = qdev_new(TYPE_MAC_NUBUS_BRIDGE);
-    qdev_prop_set_uint32(dev, "slot-available-mask",
+    object_initialize_child(OBJECT(machine), "mac-nubus-bridge",
+                            &m->mac_nubus_bridge,
+                            TYPE_MAC_NUBUS_BRIDGE);
+    sysbus = SYS_BUS_DEVICE(&m->mac_nubus_bridge);
+    dev = DEVICE(&m->mac_nubus_bridge);
+    qdev_prop_set_uint32(DEVICE(&m->mac_nubus_bridge), "slot-available-mask",
                          Q800_NUBUS_SLOTS_AVAILABLE);
-    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
-    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0,
-                    MAC_NUBUS_FIRST_SLOT * NUBUS_SUPER_SLOT_SIZE);
-    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, NUBUS_SLOT_BASE +
-                    MAC_NUBUS_FIRST_SLOT * NUBUS_SLOT_SIZE);
+    sysbus_realize(sysbus, &error_fatal);
+    memory_region_add_subregion(get_system_memory(),
+                                MAC_NUBUS_FIRST_SLOT * NUBUS_SUPER_SLOT_SIZE,
+                                sysbus_mmio_get_region(sysbus, 0));
+    memory_region_add_subregion(get_system_memory(),
+                                NUBUS_SLOT_BASE +
+                                MAC_NUBUS_FIRST_SLOT * NUBUS_SLOT_SIZE,
+                                sysbus_mmio_get_region(sysbus, 1));
     qdev_connect_gpio_out(dev, 9,
                           qdev_get_gpio_in_named(DEVICE(&m->via2), "nubus-irq",
                           VIA2_NUBUS_IRQ_INTVIDEO));
diff --git a/include/hw/m68k/q800.h b/include/hw/m68k/q800.h
index 06e095ae29..8f2c572a81 100644
--- a/include/hw/m68k/q800.h
+++ b/include/hw/m68k/q800.h
@@ -34,6 +34,7 @@ 
 #include "hw/or-irq.h"
 #include "hw/scsi/esp.h"
 #include "hw/block/swim.h"
+#include "hw/nubus/mac-nubus-bridge.h"
 
 /*
  * The main Q800 machine
@@ -52,6 +53,7 @@  struct Q800MachineState {
     OrIRQState escc_orgate;
     SysBusESPState esp;
     Swim swim;
+    MacNubusBridge mac_nubus_bridge;
     MemoryRegion macio;
     MemoryRegion macio_alias;
 };