qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH-for-6.1 0/3] hw/sparc/sun4m: Introduce Sun4mMachineClass to access sun4m_hwdefs
@ 2021-04-07 17:53 Philippe Mathieu-Daudé
  2021-04-07 17:53 ` [PATCH-for-6.1 1/3] hw/sparc/sun4m: Introduce TYPE_SUN4M_MACHINE and Sun4mMachineClass Philippe Mathieu-Daudé
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-04-07 17:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mark Cave-Ayland, Philippe Mathieu-Daudé, Artyom Tarasenko

Hi Mark,

This series QOM'ify a bit more the sun4m machines.
I need it for a further memory maxsize check.
It is mostly code movement (and the diff-stat is good).

Philippe Mathieu-Daudé (3):
  hw/sparc/sun4m: Introduce TYPE_SUN4M_MACHINE and Sun4mMachineClass
  hw/sparc/sun4m: Factor out sun4m_machine_class_common_init()
  hw/sparc/sun4m: Make sun4m_hwdefs a Sun4mMachineClass field

 hw/sparc/sun4m.c | 178 ++++++++++++++++++-----------------------------
 1 file changed, 69 insertions(+), 109 deletions(-)

-- 
2.26.3



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH-for-6.1 1/3] hw/sparc/sun4m: Introduce TYPE_SUN4M_MACHINE and Sun4mMachineClass
  2021-04-07 17:53 [PATCH-for-6.1 0/3] hw/sparc/sun4m: Introduce Sun4mMachineClass to access sun4m_hwdefs Philippe Mathieu-Daudé
@ 2021-04-07 17:53 ` Philippe Mathieu-Daudé
  2021-04-07 17:53 ` [PATCH-for-6.1 2/3] hw/sparc/sun4m: Factor out sun4m_machine_class_common_init() Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-04-07 17:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mark Cave-Ayland, Philippe Mathieu-Daudé, Artyom Tarasenko

All sun4m machines use a const sun4m_hwdef structure entry.
We want to have the common machine code to access this const
entry. The QOM way is to have it in the MachineClass.

Introduce the Sun4mMachineClass which expands MachineClass.
All sun4m machines inherit the TYPE_SUN4M_MACHINE.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/sparc/sun4m.c | 37 ++++++++++++++++++++++++++++---------
 1 file changed, 28 insertions(+), 9 deletions(-)

diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 1a00816d9a8..543a52a8fc8 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -107,6 +107,16 @@ struct sun4m_hwdef {
     uint8_t nvram_machine_id;
 };
 
+struct Sun4mMachineClass {
+    /*< private >*/
+    MachineClass parent_obj;
+    /*< public >*/
+};
+typedef struct Sun4mMachineClass Sun4mMachineClass;
+
+#define TYPE_SUN4M_MACHINE MACHINE_TYPE_NAME("sun4m-common")
+DECLARE_CLASS_CHECKERS(Sun4mMachineClass, SUN4M_MACHINE, TYPE_SUN4M_MACHINE)
+
 const char *fw_cfg_arch_key_name(uint16_t key)
 {
     static const struct {
@@ -1433,7 +1443,7 @@ static void ss5_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo ss5_type = {
     .name = MACHINE_TYPE_NAME("SS-5"),
-    .parent = TYPE_MACHINE,
+    .parent = TYPE_SUN4M_MACHINE,
     .class_init = ss5_class_init,
 };
 
@@ -1453,7 +1463,7 @@ static void ss10_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo ss10_type = {
     .name = MACHINE_TYPE_NAME("SS-10"),
-    .parent = TYPE_MACHINE,
+    .parent = TYPE_SUN4M_MACHINE,
     .class_init = ss10_class_init,
 };
 
@@ -1473,7 +1483,7 @@ static void ss600mp_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo ss600mp_type = {
     .name = MACHINE_TYPE_NAME("SS-600MP"),
-    .parent = TYPE_MACHINE,
+    .parent = TYPE_SUN4M_MACHINE,
     .class_init = ss600mp_class_init,
 };
 
@@ -1493,7 +1503,7 @@ static void ss20_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo ss20_type = {
     .name = MACHINE_TYPE_NAME("SS-20"),
-    .parent = TYPE_MACHINE,
+    .parent = TYPE_SUN4M_MACHINE,
     .class_init = ss20_class_init,
 };
 
@@ -1512,7 +1522,7 @@ static void voyager_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo voyager_type = {
     .name = MACHINE_TYPE_NAME("Voyager"),
-    .parent = TYPE_MACHINE,
+    .parent = TYPE_SUN4M_MACHINE,
     .class_init = voyager_class_init,
 };
 
@@ -1531,7 +1541,7 @@ static void ss_lx_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo ss_lx_type = {
     .name = MACHINE_TYPE_NAME("LX"),
-    .parent = TYPE_MACHINE,
+    .parent = TYPE_SUN4M_MACHINE,
     .class_init = ss_lx_class_init,
 };
 
@@ -1550,7 +1560,7 @@ static void ss4_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo ss4_type = {
     .name = MACHINE_TYPE_NAME("SS-4"),
-    .parent = TYPE_MACHINE,
+    .parent = TYPE_SUN4M_MACHINE,
     .class_init = ss4_class_init,
 };
 
@@ -1569,7 +1579,7 @@ static void scls_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo scls_type = {
     .name = MACHINE_TYPE_NAME("SPARCClassic"),
-    .parent = TYPE_MACHINE,
+    .parent = TYPE_SUN4M_MACHINE,
     .class_init = scls_class_init,
 };
 
@@ -1588,12 +1598,21 @@ static void sbook_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo sbook_type = {
     .name = MACHINE_TYPE_NAME("SPARCbook"),
-    .parent = TYPE_MACHINE,
+    .parent = TYPE_SUN4M_MACHINE,
     .class_init = sbook_class_init,
 };
 
+static const TypeInfo sun4m_typeinfo = {
+    .name = TYPE_SUN4M_MACHINE,
+    .parent = TYPE_MACHINE,
+    .class_size     = sizeof(Sun4mMachineClass),
+    .abstract       = true,
+};
+
 static void sun4m_register_types(void)
 {
+    type_register_static(&sun4m_typeinfo);
+
     type_register_static(&idreg_info);
     type_register_static(&afx_info);
     type_register_static(&prom_info);
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH-for-6.1 2/3] hw/sparc/sun4m: Factor out sun4m_machine_class_common_init()
  2021-04-07 17:53 [PATCH-for-6.1 0/3] hw/sparc/sun4m: Introduce Sun4mMachineClass to access sun4m_hwdefs Philippe Mathieu-Daudé
  2021-04-07 17:53 ` [PATCH-for-6.1 1/3] hw/sparc/sun4m: Introduce TYPE_SUN4M_MACHINE and Sun4mMachineClass Philippe Mathieu-Daudé
@ 2021-04-07 17:53 ` Philippe Mathieu-Daudé
  2021-04-07 17:53 ` [PATCH-for-6.1 3/3] hw/sparc/sun4m: Make sun4m_hwdefs a Sun4mMachineClass field Philippe Mathieu-Daudé
  2021-05-02 11:20 ` [PATCH-for-6.1 0/3] hw/sparc/sun4m: Introduce Sun4mMachineClass to access sun4m_hwdefs Mark Cave-Ayland
  3 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-04-07 17:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mark Cave-Ayland, Philippe Mathieu-Daudé, Artyom Tarasenko

Some MachineClass fields are common to all sun4m machines.
Factor setting these fields out in a common helper:
sun4m_machine_class_common_init().

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/sparc/sun4m.c | 53 ++++++++++++++++--------------------------------
 1 file changed, 17 insertions(+), 36 deletions(-)

diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 543a52a8fc8..a0d0624e41b 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -1427,18 +1427,23 @@ static void sbook_init(MachineState *machine)
     sun4m_hw_init(&sun4m_hwdefs[8], machine);
 }
 
+static void sun4m_machine_class_common_init(MachineClass *mc)
+{
+    mc->block_default_type = IF_SCSI;
+    mc->default_boot_order = "c";
+    mc->default_display = "tcx";
+    mc->default_ram_id = "sun4m.ram";
+}
+
 static void ss5_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "Sun4m platform, SPARCstation 5";
     mc->init = ss5_init;
-    mc->block_default_type = IF_SCSI;
     mc->is_default = true;
-    mc->default_boot_order = "c";
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("Fujitsu-MB86904");
-    mc->default_display = "tcx";
-    mc->default_ram_id = "sun4m.ram";
+    sun4m_machine_class_common_init(mc);
 }
 
 static const TypeInfo ss5_type = {
@@ -1453,12 +1458,9 @@ static void ss10_class_init(ObjectClass *oc, void *data)
 
     mc->desc = "Sun4m platform, SPARCstation 10";
     mc->init = ss10_init;
-    mc->block_default_type = IF_SCSI;
     mc->max_cpus = 4;
-    mc->default_boot_order = "c";
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-SuperSparc-II");
-    mc->default_display = "tcx";
-    mc->default_ram_id = "sun4m.ram";
+    sun4m_machine_class_common_init(mc);
 }
 
 static const TypeInfo ss10_type = {
@@ -1473,12 +1475,9 @@ static void ss600mp_class_init(ObjectClass *oc, void *data)
 
     mc->desc = "Sun4m platform, SPARCserver 600MP";
     mc->init = ss600mp_init;
-    mc->block_default_type = IF_SCSI;
     mc->max_cpus = 4;
-    mc->default_boot_order = "c";
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-SuperSparc-II");
-    mc->default_display = "tcx";
-    mc->default_ram_id = "sun4m.ram";
+    sun4m_machine_class_common_init(mc);
 }
 
 static const TypeInfo ss600mp_type = {
@@ -1493,12 +1492,9 @@ static void ss20_class_init(ObjectClass *oc, void *data)
 
     mc->desc = "Sun4m platform, SPARCstation 20";
     mc->init = ss20_init;
-    mc->block_default_type = IF_SCSI;
     mc->max_cpus = 4;
-    mc->default_boot_order = "c";
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-SuperSparc-II");
-    mc->default_display = "tcx";
-    mc->default_ram_id = "sun4m.ram";
+    sun4m_machine_class_common_init(mc);
 }
 
 static const TypeInfo ss20_type = {
@@ -1513,11 +1509,8 @@ static void voyager_class_init(ObjectClass *oc, void *data)
 
     mc->desc = "Sun4m platform, SPARCstation Voyager";
     mc->init = vger_init;
-    mc->block_default_type = IF_SCSI;
-    mc->default_boot_order = "c";
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("Fujitsu-MB86904");
-    mc->default_display = "tcx";
-    mc->default_ram_id = "sun4m.ram";
+    sun4m_machine_class_common_init(mc);
 }
 
 static const TypeInfo voyager_type = {
@@ -1532,11 +1525,8 @@ static void ss_lx_class_init(ObjectClass *oc, void *data)
 
     mc->desc = "Sun4m platform, SPARCstation LX";
     mc->init = ss_lx_init;
-    mc->block_default_type = IF_SCSI;
-    mc->default_boot_order = "c";
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-MicroSparc-I");
-    mc->default_display = "tcx";
-    mc->default_ram_id = "sun4m.ram";
+    sun4m_machine_class_common_init(mc);
 }
 
 static const TypeInfo ss_lx_type = {
@@ -1551,11 +1541,8 @@ static void ss4_class_init(ObjectClass *oc, void *data)
 
     mc->desc = "Sun4m platform, SPARCstation 4";
     mc->init = ss4_init;
-    mc->block_default_type = IF_SCSI;
-    mc->default_boot_order = "c";
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("Fujitsu-MB86904");
-    mc->default_display = "tcx";
-    mc->default_ram_id = "sun4m.ram";
+    sun4m_machine_class_common_init(mc);
 }
 
 static const TypeInfo ss4_type = {
@@ -1570,11 +1557,8 @@ static void scls_class_init(ObjectClass *oc, void *data)
 
     mc->desc = "Sun4m platform, SPARCClassic";
     mc->init = scls_init;
-    mc->block_default_type = IF_SCSI;
-    mc->default_boot_order = "c";
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-MicroSparc-I");
-    mc->default_display = "tcx";
-    mc->default_ram_id = "sun4m.ram";
+    sun4m_machine_class_common_init(mc);
 }
 
 static const TypeInfo scls_type = {
@@ -1589,11 +1573,8 @@ static void sbook_class_init(ObjectClass *oc, void *data)
 
     mc->desc = "Sun4m platform, SPARCbook";
     mc->init = sbook_init;
-    mc->block_default_type = IF_SCSI;
-    mc->default_boot_order = "c";
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-MicroSparc-I");
-    mc->default_display = "tcx";
-    mc->default_ram_id = "sun4m.ram";
+    sun4m_machine_class_common_init(mc);
 }
 
 static const TypeInfo sbook_type = {
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH-for-6.1 3/3] hw/sparc/sun4m: Make sun4m_hwdefs a Sun4mMachineClass field
  2021-04-07 17:53 [PATCH-for-6.1 0/3] hw/sparc/sun4m: Introduce Sun4mMachineClass to access sun4m_hwdefs Philippe Mathieu-Daudé
  2021-04-07 17:53 ` [PATCH-for-6.1 1/3] hw/sparc/sun4m: Introduce TYPE_SUN4M_MACHINE and Sun4mMachineClass Philippe Mathieu-Daudé
  2021-04-07 17:53 ` [PATCH-for-6.1 2/3] hw/sparc/sun4m: Factor out sun4m_machine_class_common_init() Philippe Mathieu-Daudé
@ 2021-04-07 17:53 ` Philippe Mathieu-Daudé
  2021-05-02 11:20 ` [PATCH-for-6.1 0/3] hw/sparc/sun4m: Introduce Sun4mMachineClass to access sun4m_hwdefs Mark Cave-Ayland
  3 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-04-07 17:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mark Cave-Ayland, Philippe Mathieu-Daudé, Artyom Tarasenko

Add a reference to sun4m_hwdefs in Sun4mMachineClass.
Set this new field in sun4m_machine_class_common_init(),
our QOM class_init() handler.

Since sun4m_hwdefs is now accessible from the MachineState,
we can simplify sun4m_hw_init() which become our unique
machine class_init().

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/sparc/sun4m.c | 108 +++++++++++++++--------------------------------
 1 file changed, 34 insertions(+), 74 deletions(-)

diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index a0d0624e41b..fab56ab3e56 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -111,6 +111,7 @@ struct Sun4mMachineClass {
     /*< private >*/
     MachineClass parent_obj;
     /*< public >*/
+    const struct sun4m_hwdef *hwdef;
 };
 typedef struct Sun4mMachineClass Sun4mMachineClass;
 
@@ -847,9 +848,9 @@ static void dummy_fdc_tc(void *opaque, int irq, int level)
 {
 }
 
-static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
-                          MachineState *machine)
+static void sun4m_hw_init(MachineState *machine)
 {
+    const struct sun4m_hwdef *hwdef = SUN4M_MACHINE_GET_CLASS(machine)->hwdef;
     DeviceState *slavio_intctl;
     unsigned int i;
     Nvram *nvram;
@@ -1373,77 +1374,28 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = {
     },
 };
 
-/* SPARCstation 5 hardware initialisation */
-static void ss5_init(MachineState *machine)
+static void sun4m_machine_class_common_init(MachineClass *mc,
+                                            const struct sun4m_hwdef *hwdef)
 {
-    sun4m_hw_init(&sun4m_hwdefs[0], machine);
-}
+    Sun4mMachineClass *smc = SUN4M_MACHINE_CLASS(mc);
 
-/* SPARCstation 10 hardware initialisation */
-static void ss10_init(MachineState *machine)
-{
-    sun4m_hw_init(&sun4m_hwdefs[1], machine);
-}
-
-/* SPARCserver 600MP hardware initialisation */
-static void ss600mp_init(MachineState *machine)
-{
-    sun4m_hw_init(&sun4m_hwdefs[2], machine);
-}
-
-/* SPARCstation 20 hardware initialisation */
-static void ss20_init(MachineState *machine)
-{
-    sun4m_hw_init(&sun4m_hwdefs[3], machine);
-}
-
-/* SPARCstation Voyager hardware initialisation */
-static void vger_init(MachineState *machine)
-{
-    sun4m_hw_init(&sun4m_hwdefs[4], machine);
-}
-
-/* SPARCstation LX hardware initialisation */
-static void ss_lx_init(MachineState *machine)
-{
-    sun4m_hw_init(&sun4m_hwdefs[5], machine);
-}
-
-/* SPARCstation 4 hardware initialisation */
-static void ss4_init(MachineState *machine)
-{
-    sun4m_hw_init(&sun4m_hwdefs[6], machine);
-}
-
-/* SPARCClassic hardware initialisation */
-static void scls_init(MachineState *machine)
-{
-    sun4m_hw_init(&sun4m_hwdefs[7], machine);
-}
-
-/* SPARCbook hardware initialisation */
-static void sbook_init(MachineState *machine)
-{
-    sun4m_hw_init(&sun4m_hwdefs[8], machine);
-}
-
-static void sun4m_machine_class_common_init(MachineClass *mc)
-{
+    mc->init = sun4m_hw_init;
     mc->block_default_type = IF_SCSI;
     mc->default_boot_order = "c";
     mc->default_display = "tcx";
     mc->default_ram_id = "sun4m.ram";
+    smc->hwdef = hwdef;
 }
 
+/* SPARCstation 5 hardware initialisation */
 static void ss5_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "Sun4m platform, SPARCstation 5";
-    mc->init = ss5_init;
     mc->is_default = true;
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("Fujitsu-MB86904");
-    sun4m_machine_class_common_init(mc);
+    sun4m_machine_class_common_init(mc, &sun4m_hwdefs[0]);
 }
 
 static const TypeInfo ss5_type = {
@@ -1452,15 +1404,16 @@ static const TypeInfo ss5_type = {
     .class_init = ss5_class_init,
 };
 
+/* SPARCstation 10 hardware initialisation */
+
 static void ss10_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "Sun4m platform, SPARCstation 10";
-    mc->init = ss10_init;
     mc->max_cpus = 4;
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-SuperSparc-II");
-    sun4m_machine_class_common_init(mc);
+    sun4m_machine_class_common_init(mc, &sun4m_hwdefs[1]);
 }
 
 static const TypeInfo ss10_type = {
@@ -1469,15 +1422,16 @@ static const TypeInfo ss10_type = {
     .class_init = ss10_class_init,
 };
 
+/* SPARCserver 600MP hardware initialisation */
+
 static void ss600mp_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "Sun4m platform, SPARCserver 600MP";
-    mc->init = ss600mp_init;
     mc->max_cpus = 4;
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-SuperSparc-II");
-    sun4m_machine_class_common_init(mc);
+    sun4m_machine_class_common_init(mc, &sun4m_hwdefs[2]);
 }
 
 static const TypeInfo ss600mp_type = {
@@ -1486,15 +1440,16 @@ static const TypeInfo ss600mp_type = {
     .class_init = ss600mp_class_init,
 };
 
+/* SPARCstation 20 hardware initialisation */
+
 static void ss20_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "Sun4m platform, SPARCstation 20";
-    mc->init = ss20_init;
     mc->max_cpus = 4;
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-SuperSparc-II");
-    sun4m_machine_class_common_init(mc);
+    sun4m_machine_class_common_init(mc, &sun4m_hwdefs[3]);
 }
 
 static const TypeInfo ss20_type = {
@@ -1503,14 +1458,15 @@ static const TypeInfo ss20_type = {
     .class_init = ss20_class_init,
 };
 
+/* SPARCstation Voyager hardware initialisation */
+
 static void voyager_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "Sun4m platform, SPARCstation Voyager";
-    mc->init = vger_init;
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("Fujitsu-MB86904");
-    sun4m_machine_class_common_init(mc);
+    sun4m_machine_class_common_init(mc, &sun4m_hwdefs[4]);
 }
 
 static const TypeInfo voyager_type = {
@@ -1519,14 +1475,15 @@ static const TypeInfo voyager_type = {
     .class_init = voyager_class_init,
 };
 
+/* SPARCstation LX hardware initialisation */
+
 static void ss_lx_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "Sun4m platform, SPARCstation LX";
-    mc->init = ss_lx_init;
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-MicroSparc-I");
-    sun4m_machine_class_common_init(mc);
+    sun4m_machine_class_common_init(mc, &sun4m_hwdefs[5]);
 }
 
 static const TypeInfo ss_lx_type = {
@@ -1535,14 +1492,15 @@ static const TypeInfo ss_lx_type = {
     .class_init = ss_lx_class_init,
 };
 
+/* SPARCstation 4 hardware initialisation */
+
 static void ss4_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "Sun4m platform, SPARCstation 4";
-    mc->init = ss4_init;
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("Fujitsu-MB86904");
-    sun4m_machine_class_common_init(mc);
+    sun4m_machine_class_common_init(mc, &sun4m_hwdefs[6]);
 }
 
 static const TypeInfo ss4_type = {
@@ -1551,14 +1509,15 @@ static const TypeInfo ss4_type = {
     .class_init = ss4_class_init,
 };
 
+/* SPARCClassic hardware initialisation */
+
 static void scls_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "Sun4m platform, SPARCClassic";
-    mc->init = scls_init;
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-MicroSparc-I");
-    sun4m_machine_class_common_init(mc);
+    sun4m_machine_class_common_init(mc, &sun4m_hwdefs[7]);
 }
 
 static const TypeInfo scls_type = {
@@ -1567,14 +1526,15 @@ static const TypeInfo scls_type = {
     .class_init = scls_class_init,
 };
 
+/* SPARCbook hardware initialisation */
+
 static void sbook_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "Sun4m platform, SPARCbook";
-    mc->init = sbook_init;
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-MicroSparc-I");
-    sun4m_machine_class_common_init(mc);
+    sun4m_machine_class_common_init(mc, &sun4m_hwdefs[8]);
 }
 
 static const TypeInfo sbook_type = {
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH-for-6.1 0/3] hw/sparc/sun4m: Introduce Sun4mMachineClass to access sun4m_hwdefs
  2021-04-07 17:53 [PATCH-for-6.1 0/3] hw/sparc/sun4m: Introduce Sun4mMachineClass to access sun4m_hwdefs Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2021-04-07 17:53 ` [PATCH-for-6.1 3/3] hw/sparc/sun4m: Make sun4m_hwdefs a Sun4mMachineClass field Philippe Mathieu-Daudé
@ 2021-05-02 11:20 ` Mark Cave-Ayland
  2021-05-02 17:40   ` Philippe Mathieu-Daudé
  3 siblings, 1 reply; 6+ messages in thread
From: Mark Cave-Ayland @ 2021-05-02 11:20 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Artyom Tarasenko

On 07/04/2021 18:53, Philippe Mathieu-Daudé wrote:

> Hi Mark,
> 
> This series QOM'ify a bit more the sun4m machines.
> I need it for a further memory maxsize check.
> It is mostly code movement (and the diff-stat is good).
> 
> Philippe Mathieu-Daudé (3):
>    hw/sparc/sun4m: Introduce TYPE_SUN4M_MACHINE and Sun4mMachineClass
>    hw/sparc/sun4m: Factor out sun4m_machine_class_common_init()
>    hw/sparc/sun4m: Make sun4m_hwdefs a Sun4mMachineClass field
> 
>   hw/sparc/sun4m.c | 178 ++++++++++++++++++-----------------------------
>   1 file changed, 69 insertions(+), 109 deletions(-)

Hi Phil,

Possibly it might be worth having an abstract TYPE_SUN4M_MACHINE and then for each 
sun4m machine to have that as a parent type? This would allow you to move 
sun4m_machine_class_common_init() directly into the abstract 
sun4m_machine_class_init() rather than having to call a function from within each 
individual class init function.

No objection to the cleanup though :)


ATB,

Mark.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH-for-6.1 0/3] hw/sparc/sun4m: Introduce Sun4mMachineClass to access sun4m_hwdefs
  2021-05-02 11:20 ` [PATCH-for-6.1 0/3] hw/sparc/sun4m: Introduce Sun4mMachineClass to access sun4m_hwdefs Mark Cave-Ayland
@ 2021-05-02 17:40   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-02 17:40 UTC (permalink / raw)
  To: Mark Cave-Ayland, qemu-devel; +Cc: Artyom Tarasenko

On 5/2/21 1:20 PM, Mark Cave-Ayland wrote:
> On 07/04/2021 18:53, Philippe Mathieu-Daudé wrote:
> 
>> Hi Mark,
>>
>> This series QOM'ify a bit more the sun4m machines.
>> I need it for a further memory maxsize check.
>> It is mostly code movement (and the diff-stat is good).
>>
>> Philippe Mathieu-Daudé (3):
>>    hw/sparc/sun4m: Introduce TYPE_SUN4M_MACHINE and Sun4mMachineClass
>>    hw/sparc/sun4m: Factor out sun4m_machine_class_common_init()
>>    hw/sparc/sun4m: Make sun4m_hwdefs a Sun4mMachineClass field
>>
>>   hw/sparc/sun4m.c | 178 ++++++++++++++++++-----------------------------
>>   1 file changed, 69 insertions(+), 109 deletions(-)
> 
> Hi Phil,
> 
> Possibly it might be worth having an abstract TYPE_SUN4M_MACHINE and
> then for each sun4m machine to have that as a parent type?

This is what this series does...

> This would
> allow you to move sun4m_machine_class_common_init() directly into the
> abstract sun4m_machine_class_init() rather than having to call a
> function from within each individual class init function.

OK, can do that.

Regards,

Phil.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-05-02 17:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07 17:53 [PATCH-for-6.1 0/3] hw/sparc/sun4m: Introduce Sun4mMachineClass to access sun4m_hwdefs Philippe Mathieu-Daudé
2021-04-07 17:53 ` [PATCH-for-6.1 1/3] hw/sparc/sun4m: Introduce TYPE_SUN4M_MACHINE and Sun4mMachineClass Philippe Mathieu-Daudé
2021-04-07 17:53 ` [PATCH-for-6.1 2/3] hw/sparc/sun4m: Factor out sun4m_machine_class_common_init() Philippe Mathieu-Daudé
2021-04-07 17:53 ` [PATCH-for-6.1 3/3] hw/sparc/sun4m: Make sun4m_hwdefs a Sun4mMachineClass field Philippe Mathieu-Daudé
2021-05-02 11:20 ` [PATCH-for-6.1 0/3] hw/sparc/sun4m: Introduce Sun4mMachineClass to access sun4m_hwdefs Mark Cave-Ayland
2021-05-02 17:40   ` Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).