[PATCH v2 15/23] q800: move ESCC device to Q800MachineState

Mark Cave-Ayland posted 23 patches 2 years, 8 months ago
Maintainers: Laurent Vivier <laurent@vivier.eu>, Jason Wang <jasowang@redhat.com>
There is a newer version of this series
[PATCH v2 15/23] q800: move ESCC device to Q800MachineState
Posted by Mark Cave-Ayland 2 years, 8 months ago
Also change the instantiation of the ESCC device to use object_initialize_child().

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

diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
index e25f6f1373..ac92daf190 100644
--- a/hw/m68k/q800.c
+++ b/hw/m68k/q800.c
@@ -347,7 +347,9 @@ static void q800_machine_init(MachineState *machine)
 
     /* SCC */
 
-    dev = qdev_new(TYPE_ESCC);
+    object_initialize_child(OBJECT(machine), "escc", &m->escc,
+                            TYPE_ESCC);
+    dev = DEVICE(&m->escc);
     qdev_prop_set_uint32(dev, "disabled", 0);
     qdev_prop_set_uint32(dev, "frequency", MAC_CLOCK);
     qdev_prop_set_uint32(dev, "it_shift", 1);
@@ -357,7 +359,7 @@ static void q800_machine_init(MachineState *machine)
     qdev_prop_set_uint32(dev, "chnBtype", 0);
     qdev_prop_set_uint32(dev, "chnAtype", 0);
     sysbus = SYS_BUS_DEVICE(dev);
-    sysbus_realize_and_unref(sysbus, &error_fatal);
+    sysbus_realize(sysbus, &error_fatal);
 
     /* Logically OR both its IRQs together */
     escc_orgate = DEVICE(object_new(TYPE_OR_IRQ));
diff --git a/include/hw/m68k/q800.h b/include/hw/m68k/q800.h
index 82964cfea1..d03603fe02 100644
--- a/include/hw/m68k/q800.h
+++ b/include/hw/m68k/q800.h
@@ -26,6 +26,7 @@
 #include "hw/m68k/q800-glue.h"
 #include "hw/misc/mac_via.h"
 #include "hw/net/dp8393x.h"
+#include "hw/char/escc.h"
 
 /*
  * The main Q800 machine
@@ -40,6 +41,7 @@ struct Q800MachineState {
     MOS6522Q800VIA1State via1;
     MOS6522Q800VIA2State via2;
     dp8393xState dp8393x;
+    ESCCState escc;
     MemoryRegion macio;
     MemoryRegion macio_alias;
 };
-- 
2.30.2
Re: [PATCH v2 15/23] q800: move ESCC device to Q800MachineState
Posted by Laurent Vivier 2 years, 8 months ago
Le 31/05/2023 à 14:53, Mark Cave-Ayland a écrit :
> Also change the instantiation of the ESCC device to use object_initialize_child().
> 
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>   hw/m68k/q800.c         | 6 ++++--
>   include/hw/m68k/q800.h | 2 ++
>   2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
> index e25f6f1373..ac92daf190 100644
> --- a/hw/m68k/q800.c
> +++ b/hw/m68k/q800.c
> @@ -347,7 +347,9 @@ static void q800_machine_init(MachineState *machine)
>   
>       /* SCC */
>   
> -    dev = qdev_new(TYPE_ESCC);
> +    object_initialize_child(OBJECT(machine), "escc", &m->escc,
> +                            TYPE_ESCC);
> +    dev = DEVICE(&m->escc);
>       qdev_prop_set_uint32(dev, "disabled", 0);
>       qdev_prop_set_uint32(dev, "frequency", MAC_CLOCK);
>       qdev_prop_set_uint32(dev, "it_shift", 1);
> @@ -357,7 +359,7 @@ static void q800_machine_init(MachineState *machine)
>       qdev_prop_set_uint32(dev, "chnBtype", 0);
>       qdev_prop_set_uint32(dev, "chnAtype", 0);
>       sysbus = SYS_BUS_DEVICE(dev);
> -    sysbus_realize_and_unref(sysbus, &error_fatal);
> +    sysbus_realize(sysbus, &error_fatal);
>   
>       /* Logically OR both its IRQs together */
>       escc_orgate = DEVICE(object_new(TYPE_OR_IRQ));
> diff --git a/include/hw/m68k/q800.h b/include/hw/m68k/q800.h
> index 82964cfea1..d03603fe02 100644
> --- a/include/hw/m68k/q800.h
> +++ b/include/hw/m68k/q800.h
> @@ -26,6 +26,7 @@
>   #include "hw/m68k/q800-glue.h"
>   #include "hw/misc/mac_via.h"
>   #include "hw/net/dp8393x.h"
> +#include "hw/char/escc.h"
>   
>   /*
>    * The main Q800 machine
> @@ -40,6 +41,7 @@ struct Q800MachineState {
>       MOS6522Q800VIA1State via1;
>       MOS6522Q800VIA2State via2;
>       dp8393xState dp8393x;
> +    ESCCState escc;
>       MemoryRegion macio;
>       MemoryRegion macio_alias;
>   };

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


Re: [PATCH v2 15/23] q800: move ESCC device to Q800MachineState
Posted by Philippe Mathieu-Daudé 2 years, 8 months ago
On 31/5/23 14:53, Mark Cave-Ayland wrote:
> Also change the instantiation of the ESCC device to use object_initialize_child().
> 
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>   hw/m68k/q800.c         | 6 ++++--
>   include/hw/m68k/q800.h | 2 ++
>   2 files changed, 6 insertions(+), 2 deletions(-)

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