hw/sparc/sun4m: Introduce Sun4mMachineClass to access sun4m_hwdefs
v3 cover hw/sparc/sun4m: Introduce Sun4mMachineClass to access sun4m_hwdefs
Missing review: 6
Hi Mark,
This series QOM'ify the sun4m machines.
I need it for a further memory maxsize check. It is mostly code movement (and the diff-stat is good).
Since v2:
- use static const variable for hwdef (Richard)
- added Richard's R-b tag
Since v1:
- Full rewrite after Mark review
Philippe Mathieu-Daudé (6):
hw/sparc/sun4m: Have sun4m machines inherit new TYPE_SUN4M_MACHINE hw/sparc/sun4m: Introduce Sun4mMachineClass hw/sparc/sun4m: Factor out sun4m_machine_class_init() hw/sparc/sun4m: Register machine types in sun4m_machine_types[] hw/sparc/sun4m: Fix code style for checkpatch.pl hw/sparc/sun4m: Move each sun4m_hwdef definition in its class_init
hw/sparc/sun4m.c | 459 +++++++++++++++++++---------------------------- 1 file changed, 186 insertions(+), 273 deletions(-)
Signature · 1 line
2.26.3
PATCH v3 1/6 hw/sparc/sun4m: Have sun4m machines inherit new TYPE_SUN4M_MACHINE
Introduce the TYPE_SUN4M_MACHINE and have all sun4m machines inherit it.
--- hw/sparc/sun4m.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
hw/sparc/sun4m.c +21 -9
@@ -107,6 +107,8 @@ struct sun4m_hwdef {uint8_t nvram_machine_id; }; +#define TYPE_SUN4M_MACHINE MACHINE_TYPE_NAME("sun4m-common") +const char *fw_cfg_arch_key_name (uint16_t key) { static const struct {
@@ -1433,7 +1435,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 +1455,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 +1475,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 +1495,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 +1514,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 +1533,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 +1552,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 +1571,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,10 +1590,20 @@ 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_machine_types[] = { + { + .name =TYPE_SUN4M_MACHINE , + .parent =TYPE_MACHINE , + .abstract = true, + } +}; + +DEFINE_TYPES (sun4m_machine_types) + static void sun4m_register_types(void) {type_register_static (&idreg_info);
Signature · 1 line
2.26.3
PATCH v3 2/6 hw/sparc/sun4m: Introduce Sun4mMachineClass
In reply to Philippe Mathieu-DaudéInstead of passing the sun4m_hwdef structure viamachine_init(), store it into the MachineClass.
--- hw/sparc/sun4m.c | 50 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 11 deletions(-)
hw/sparc/sun4m.c +39 -11
@@ -107,7 +107,16 @@ struct sun4m_hwdef {uint8_t nvram_machine_id; }; +struct Sun4mMachineClass { +/*< private >*/ +MachineClass parent_obj; +/*< public >*/ +const struct sun4m_hwdef *hwdef; +}; +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) {
@@ -839,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;
@@ -1368,60 +1377,61 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = {/* SPARCstation 5 hardware initialisation */ static void ss5_init (MachineState *machine) { -sun4m_hw_init (&sun4m_hwdefs[0 ], machine); +sun4m_hw_init (machine); }/* SPARCstation 10 hardware initialisation */ static void ss10_init (MachineState *machine) { -sun4m_hw_init (&sun4m_hwdefs[1 ], machine); +sun4m_hw_init (machine); }/* SPARCserver 600MP hardware initialisation */ static void ss600mp_init (MachineState *machine) { -sun4m_hw_init (&sun4m_hwdefs[2 ], machine); +sun4m_hw_init (machine); }/* SPARCstation 20 hardware initialisation */ static void ss20_init (MachineState *machine) { -sun4m_hw_init (&sun4m_hwdefs[3 ], machine); +sun4m_hw_init (machine); }/* SPARCstation Voyager hardware initialisation */ static void vger_init (MachineState *machine) { -sun4m_hw_init (&sun4m_hwdefs[4 ], machine); +sun4m_hw_init (machine); }/* SPARCstation LX hardware initialisation */ static void ss_lx_init (MachineState *machine) { -sun4m_hw_init (&sun4m_hwdefs[5 ], machine); +sun4m_hw_init (machine); }/* SPARCstation 4 hardware initialisation */ static void ss4_init (MachineState *machine) { -sun4m_hw_init (&sun4m_hwdefs[6 ], machine); +sun4m_hw_init (machine); }/* SPARCClassic hardware initialisation */ static void scls_init (MachineState *machine) { -sun4m_hw_init (&sun4m_hwdefs[7 ], machine); +sun4m_hw_init (machine); }/* SPARCbook hardware initialisation */ static void sbook_init (MachineState *machine) { -sun4m_hw_init (&sun4m_hwdefs[8 ], machine); +sun4m_hw_init (machine); }static void ss5_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); mc->desc ="Sun4m platform, SPARCstation 5" ; mc->init = ss5_init;
@@ -1431,6 +1441,7 @@ static void ss5_class_init(ObjectClass *oc, void *data) mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("Fujitsu-MB86904" ); mc->default_display ="tcx" ; mc->default_ram_id ="sun4m.ram" ; + smc->hwdef = &sun4m_hwdefs[0 ]; }static const TypeInfo ss5_type = {
@@ -1442,6 +1453,7 @@ static const TypeInfo ss5_type = {static void ss10_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); mc->desc ="Sun4m platform, SPARCstation 10" ; mc->init = ss10_init;
@@ -1451,6 +1463,7 @@ static void ss10_class_init(ObjectClass *oc, void *data) mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("TI-SuperSparc-II" ); mc->default_display ="tcx" ; mc->default_ram_id ="sun4m.ram" ; + smc->hwdef = &sun4m_hwdefs[1 ]; }static const TypeInfo ss10_type = {
@@ -1462,6 +1475,7 @@ static const TypeInfo ss10_type = {static void ss600mp_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); mc->desc ="Sun4m platform, SPARCserver 600MP" ; mc->init = ss600mp_init;
@@ -1471,6 +1485,7 @@ static void ss600mp_class_init(ObjectClass *oc, void *data) mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("TI-SuperSparc-II" ); mc->default_display ="tcx" ; mc->default_ram_id ="sun4m.ram" ; + smc->hwdef = &sun4m_hwdefs[2 ]; }static const TypeInfo ss600mp_type = {
@@ -1482,6 +1497,7 @@ static const TypeInfo ss600mp_type = {static void ss20_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); mc->desc ="Sun4m platform, SPARCstation 20" ; mc->init = ss20_init;
@@ -1491,6 +1507,7 @@ static void ss20_class_init(ObjectClass *oc, void *data) mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("TI-SuperSparc-II" ); mc->default_display ="tcx" ; mc->default_ram_id ="sun4m.ram" ; + smc->hwdef = &sun4m_hwdefs[3 ]; }static const TypeInfo ss20_type = {
@@ -1502,6 +1519,7 @@ static const TypeInfo ss20_type = {static void voyager_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); mc->desc ="Sun4m platform, SPARCstation Voyager" ; mc->init = vger_init;
@@ -1510,6 +1528,7 @@ static void voyager_class_init(ObjectClass *oc, void *data) mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("Fujitsu-MB86904" ); mc->default_display ="tcx" ; mc->default_ram_id ="sun4m.ram" ; + smc->hwdef = &sun4m_hwdefs[4 ]; }static const TypeInfo voyager_type = {
@@ -1521,6 +1540,7 @@ static const TypeInfo voyager_type = {static void ss_lx_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); mc->desc ="Sun4m platform, SPARCstation LX" ; mc->init = ss_lx_init;
@@ -1529,6 +1549,7 @@ static void ss_lx_class_init(ObjectClass *oc, void *data) mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("TI-MicroSparc-I" ); mc->default_display ="tcx" ; mc->default_ram_id ="sun4m.ram" ; + smc->hwdef = &sun4m_hwdefs[5 ]; }static const TypeInfo ss_lx_type = {
@@ -1540,6 +1561,7 @@ static const TypeInfo ss_lx_type = {static void ss4_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); mc->desc ="Sun4m platform, SPARCstation 4" ; mc->init = ss4_init;
@@ -1548,6 +1570,7 @@ static void ss4_class_init(ObjectClass *oc, void *data) mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("Fujitsu-MB86904" ); mc->default_display ="tcx" ; mc->default_ram_id ="sun4m.ram" ; + smc->hwdef = &sun4m_hwdefs[6 ]; }static const TypeInfo ss4_type = {
@@ -1559,6 +1582,7 @@ static const TypeInfo ss4_type = {static void scls_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); mc->desc ="Sun4m platform, SPARCClassic" ; mc->init = scls_init;
@@ -1567,6 +1591,7 @@ static void scls_class_init(ObjectClass *oc, void *data) mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("TI-MicroSparc-I" ); mc->default_display ="tcx" ; mc->default_ram_id ="sun4m.ram" ; + smc->hwdef = &sun4m_hwdefs[7 ]; }static const TypeInfo scls_type = {
@@ -1578,6 +1603,7 @@ static const TypeInfo scls_type = {static void sbook_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); mc->desc ="Sun4m platform, SPARCbook" ; mc->init = sbook_init;
@@ -1586,6 +1612,7 @@ static void sbook_class_init(ObjectClass *oc, void *data) mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("TI-MicroSparc-I" ); mc->default_display ="tcx" ; mc->default_ram_id ="sun4m.ram" ; + smc->hwdef = &sun4m_hwdefs[8 ]; }static const TypeInfo sbook_type = {
@@ -1598,6 +1625,7 @@ static const TypeInfo sun4m_machine_types[] = { { .name = TYPE_SUN4M_MACHINE, .parent = TYPE_MACHINE, + .class_size = sizeof(Sun4mMachineClass), .abstract = true, } };
Signature · 1 line
2.26.3
PATCH v3 3/6 hw/sparc/sun4m: Factor out sun4m_machine_class_init()
In reply to Philippe Mathieu-DaudéFactor out the class_init code common to all machines to sun4m_machine_class_init().
--- hw/sparc/sun4m.c | 103 ++++------------------------------------------- 1 file changed, 8 insertions(+), 95 deletions(-)
hw/sparc/sun4m.c +8 -95
@@ -1374,58 +1374,15 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { }, }; -/* SPARCstation 5 hardware initialisation */ -static void ss5_init (MachineState *machine) +static void sun4m_machine_class_init (ObjectClass *oc,void *data) { -sun4m_hw_init (machine); -} +MachineClass *mc =MACHINE_CLASS (oc); -/* SPARCstation 10 hardware initialisation */ -static void ss10_init (MachineState *machine) -{ -sun4m_hw_init (machine); -} - -/* SPARCserver 600MP hardware initialisation */ -static void ss600mp_init (MachineState *machine) -{ -sun4m_hw_init (machine); -} - -/* SPARCstation 20 hardware initialisation */ -static void ss20_init (MachineState *machine) -{ -sun4m_hw_init (machine); -} - -/* SPARCstation Voyager hardware initialisation */ -static void vger_init (MachineState *machine) -{ -sun4m_hw_init (machine); -} - -/* SPARCstation LX hardware initialisation */ -static void ss_lx_init (MachineState *machine) -{ -sun4m_hw_init (machine); -} - -/* SPARCstation 4 hardware initialisation */ -static void ss4_init (MachineState *machine) -{ -sun4m_hw_init (machine); -} - -/* SPARCClassic hardware initialisation */ -static void scls_init (MachineState *machine) -{ -sun4m_hw_init (machine); -} - -/* SPARCbook hardware initialisation */ -static void sbook_init (MachineState *machine) -{ -sun4m_hw_init (machine); + 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" ; }static void ss5_class_init (ObjectClass *oc,void *data)
@@ -1434,13 +1391,8 @@ static void ss5_class_init(ObjectClass *oc, void *data)Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); 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" ; smc->hwdef = &sun4m_hwdefs[0 ]; }
@@ -1456,13 +1408,8 @@ static void ss10_class_init(ObjectClass *oc, void *data)Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); 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" ; smc->hwdef = &sun4m_hwdefs[1 ]; }
@@ -1478,13 +1425,8 @@ static void ss600mp_class_init(ObjectClass *oc, void *data)Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); 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" ; smc->hwdef = &sun4m_hwdefs[2 ]; }
@@ -1500,13 +1442,8 @@ static void ss20_class_init(ObjectClass *oc, void *data)Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); 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" ; smc->hwdef = &sun4m_hwdefs[3 ]; }
@@ -1522,12 +1459,7 @@ static void voyager_class_init(ObjectClass *oc, void *data)Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); 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" ; smc->hwdef = &sun4m_hwdefs[4 ]; }
@@ -1543,12 +1475,7 @@ static void ss_lx_class_init(ObjectClass *oc, void *data)Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); 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" ; smc->hwdef = &sun4m_hwdefs[5 ]; }
@@ -1564,12 +1491,7 @@ static void ss4_class_init(ObjectClass *oc, void *data)Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); 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" ; smc->hwdef = &sun4m_hwdefs[6 ]; }
@@ -1585,12 +1507,7 @@ static void scls_class_init(ObjectClass *oc, void *data)Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); 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" ; smc->hwdef = &sun4m_hwdefs[7 ]; }
@@ -1606,12 +1523,7 @@ static void sbook_class_init(ObjectClass *oc, void *data)Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); 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" ; smc->hwdef = &sun4m_hwdefs[8 ]; }
@@ -1626,6 +1538,7 @@ static const TypeInfo sun4m_machine_types[] = { .name = TYPE_SUN4M_MACHINE, .parent = TYPE_MACHINE, .class_size = sizeof(Sun4mMachineClass), + .class_init = sun4m_machine_class_init, .abstract = true, } };
Signature · 1 line
2.26.3
PATCH v3 4/6 hw/sparc/sun4m: Register machine types in sun4m_machine_types[]
In reply to Philippe Mathieu-Daudé--- hw/sparc/sun4m.c | 100 +++++++++++++++++------------------------------ 1 file changed, 36 insertions(+), 64 deletions(-)
hw/sparc/sun4m.c +36 -64
@@ -1396,12 +1396,6 @@ static void ss5_class_init(ObjectClass *oc, void *data) smc->hwdef = &sun4m_hwdefs[0 ]; } -static const TypeInfo ss5_type = { - .name =MACHINE_TYPE_NAME ("SS-5" ), - .parent =TYPE_SUN4M_MACHINE , - .class_init = ss5_class_init, -}; -static void ss10_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -1413,12 +1407,6 @@ static void ss10_class_init(ObjectClass *oc, void *data) smc->hwdef = &sun4m_hwdefs[1 ]; } -static const TypeInfo ss10_type = { - .name =MACHINE_TYPE_NAME ("SS-10" ), - .parent =TYPE_SUN4M_MACHINE , - .class_init = ss10_class_init, -}; -static void ss600mp_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -1430,12 +1418,6 @@ static void ss600mp_class_init(ObjectClass *oc, void *data) smc->hwdef = &sun4m_hwdefs[2 ]; } -static const TypeInfo ss600mp_type = { - .name =MACHINE_TYPE_NAME ("SS-600MP" ), - .parent =TYPE_SUN4M_MACHINE , - .class_init = ss600mp_class_init, -}; -static void ss20_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -1447,12 +1429,6 @@ static void ss20_class_init(ObjectClass *oc, void *data) smc->hwdef = &sun4m_hwdefs[3 ]; } -static const TypeInfo ss20_type = { - .name =MACHINE_TYPE_NAME ("SS-20" ), - .parent =TYPE_SUN4M_MACHINE , - .class_init = ss20_class_init, -}; -static void voyager_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -1463,12 +1439,6 @@ static void voyager_class_init(ObjectClass *oc, void *data) smc->hwdef = &sun4m_hwdefs[4 ]; } -static const TypeInfo voyager_type = { - .name =MACHINE_TYPE_NAME ("Voyager" ), - .parent =TYPE_SUN4M_MACHINE , - .class_init = voyager_class_init, -}; -static void ss_lx_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -1479,12 +1449,6 @@ static void ss_lx_class_init(ObjectClass *oc, void *data) smc->hwdef = &sun4m_hwdefs[5 ]; } -static const TypeInfo ss_lx_type = { - .name =MACHINE_TYPE_NAME ("LX" ), - .parent =TYPE_SUN4M_MACHINE , - .class_init = ss_lx_class_init, -}; -static void ss4_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -1495,12 +1459,6 @@ static void ss4_class_init(ObjectClass *oc, void *data) smc->hwdef = &sun4m_hwdefs[6 ]; } -static const TypeInfo ss4_type = { - .name =MACHINE_TYPE_NAME ("SS-4" ), - .parent =TYPE_SUN4M_MACHINE , - .class_init = ss4_class_init, -}; -static void scls_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -1511,12 +1469,6 @@ static void scls_class_init(ObjectClass *oc, void *data) smc->hwdef = &sun4m_hwdefs[7 ]; } -static const TypeInfo scls_type = { - .name =MACHINE_TYPE_NAME ("SPARCClassic" ), - .parent =TYPE_SUN4M_MACHINE , - .class_init = scls_class_init, -}; -static void sbook_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -1527,14 +1479,44 @@ static void sbook_class_init(ObjectClass *oc, void *data) smc->hwdef = &sun4m_hwdefs[8 ]; } -static const TypeInfo sbook_type = { - .name =MACHINE_TYPE_NAME ("SPARCbook" ), - .parent =TYPE_SUN4M_MACHINE , - .class_init = sbook_class_init, -}; -static const TypeInfo sun4m_machine_types[] = { { + .name =MACHINE_TYPE_NAME ("SS-5" ), + .parent =TYPE_SUN4M_MACHINE , + .class_init = ss5_class_init, + }, { + .name =MACHINE_TYPE_NAME ("SS-10" ), + .parent =TYPE_SUN4M_MACHINE , + .class_init = ss10_class_init, + }, { + .name =MACHINE_TYPE_NAME ("SS-600MP" ), + .parent =TYPE_SUN4M_MACHINE , + .class_init = ss600mp_class_init, + }, { + .name =MACHINE_TYPE_NAME ("SS-20" ), + .parent =TYPE_SUN4M_MACHINE , + .class_init = ss20_class_init, + }, { + .name =MACHINE_TYPE_NAME ("Voyager" ), + .parent =TYPE_SUN4M_MACHINE , + .class_init = voyager_class_init, + }, { + .name =MACHINE_TYPE_NAME ("LX" ), + .parent =TYPE_SUN4M_MACHINE , + .class_init = ss_lx_class_init, + }, { + .name =MACHINE_TYPE_NAME ("SS-4" ), + .parent =TYPE_SUN4M_MACHINE , + .class_init = ss4_class_init, + }, { + .name =MACHINE_TYPE_NAME ("SPARCClassic" ), + .parent =TYPE_SUN4M_MACHINE , + .class_init = scls_class_init, + }, { + .name =MACHINE_TYPE_NAME ("SPARCbook" ), + .parent =TYPE_SUN4M_MACHINE , + .class_init = sbook_class_init, + }, { .name =TYPE_SUN4M_MACHINE , .parent =TYPE_MACHINE , .class_size =sizeof (Sun4mMachineClass),
@@ -1551,16 +1533,6 @@ static void sun4m_register_types(void)type_register_static (&afx_info);type_register_static (&prom_info);type_register_static (&ram_info); - -type_register_static (&ss5_type); -type_register_static (&ss10_type); -type_register_static (&ss600mp_type); -type_register_static (&ss20_type); -type_register_static (&voyager_type); -type_register_static (&ss_lx_type); -type_register_static (&ss4_type); -type_register_static (&scls_type); -type_register_static (&sbook_type); }type_init (sun4m_register_types)
Signature · 1 line
2.26.3
PATCH v3 5/6 hw/sparc/sun4m: Fix code style for checkpatch.pl
In reply to Philippe Mathieu-DaudéWe are going to move this code, fix its style first.
--- hw/sparc/sun4m.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
hw/sparc/sun4m.c +9 -9
@@ -1181,11 +1181,11 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .dma_base = 0xef0400000ULL, .esp_base = 0xef0800000ULL, .le_base = 0xef0c00000ULL, - .apc_base = 0xefa000000ULL, // XXX should not exist + .apc_base = 0xefa000000ULL, /* XXX should not exist */ .aux1_base = 0xff1800000ULL, .aux2_base = 0xff1a01000ULL, .ecc_base = 0xf00000000ULL, - .ecc_version = 0x10000000, // version 0, implementation 1 + .ecc_version = 0x10000000, /* version 0, implementation 1 */ .nvram_machine_id = 0x72, .machine_id = ss10_id, .iommu_version = 0x03000000,
@@ -1204,11 +1204,11 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .dma_base = 0xef0081000ULL, .esp_base = 0xef0080000ULL, .le_base = 0xef0060000ULL, - .apc_base = 0xefa000000ULL, // XXX should not exist + .apc_base = 0xefa000000ULL, /* XXX should not exist */ .aux1_base = 0xff1800000ULL, - .aux2_base = 0xff1a01000ULL, // XXX should not exist + .aux2_base = 0xff1a01000ULL, /* XXX should not exist */ .ecc_base = 0xf00000000ULL, - .ecc_version = 0x00000000, // version 0, implementation 0 + .ecc_version = 0x00000000, /* version 0, implementation 0 */ .nvram_machine_id = 0x71, .machine_id = ss600mp_id, .iommu_version = 0x01000000,
@@ -1230,7 +1230,7 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .esp_base = 0xef0800000ULL, .le_base = 0xef0c00000ULL, .bpp_base = 0xef4800000ULL, - .apc_base = 0xefa000000ULL, // XXX should not exist + .apc_base = 0xefa000000ULL, /* XXX should not exist */ .aux1_base = 0xff1800000ULL, .aux2_base = 0xff1a01000ULL, .dbri_base = 0xee0000000ULL,
@@ -1249,7 +1249,7 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { } }, .ecc_base = 0xf00000000ULL, - .ecc_version = 0x20000000, // version 0, implementation 2 + .ecc_version = 0x20000000, /* version 0, implementation 2 */ .nvram_machine_id = 0x72, .machine_id = ss20_id, .iommu_version = 0x13000000,
@@ -1270,7 +1270,7 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .dma_base = 0x78400000, .esp_base = 0x78800000, .le_base = 0x78c00000, - .apc_base = 0x71300000, // pmc + .apc_base = 0x71300000, /* pmc */ .aux1_base = 0x71900000, .aux2_base = 0x71910000, .nvram_machine_id = 0x80,
@@ -1352,7 +1352,7 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = {/* SPARCbook */ { .iommu_base = 0x10000000, - .tcx_base = 0x50000000, // XXX + .tcx_base = 0x50000000, /* XXX */ .slavio_base = 0x70000000, .ms_kb_base = 0x71000000, .serial_base = 0x71100000,
Signature · 1 line
2.26.3
PATCH v3 6/6 hw/sparc/sun4m: Move each sun4m_hwdef definition in its class_init
In reply to Philippe Mathieu-DaudéRemove the sun4m_hwdefs[] array by moving assigning the structure fields directly in each machine class_init() function.
--- hw/sparc/sun4m.c | 248 ++++++++++++++++++++++------------------------- 1 file changed, 118 insertions(+), 130 deletions(-)
hw/sparc/sun4m.c +118 -130
@@ -1138,9 +1138,22 @@ enum { ss600mp_id, }; -static const struct sun4m_hwdef sun4m_hwdefs[] = { -/* SS-5 */ - { +static void sun4m_machine_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + + 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" ; +} + +static void ss5_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); +Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); +static const struct sun4m_hwdef ss5_hwdef = { .iommu_base =0x10000000 , .iommu_pad_base =0x10004000 , .iommu_pad_len =0x0fffb000 ,
@@ -1165,9 +1178,19 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .machine_id = ss5_id, .iommu_version = 0x05000000, .max_mem = 0x10000000, - }, -/* SS-10 */ - { + }; + + mc->desc ="Sun4m platform, SPARCstation 5" ; + mc->is_default = true; + mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("Fujitsu-MB86904" ); + smc->hwdef = &ss5_hwdef; +} + +static void ss10_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); +Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); +static const struct sun4m_hwdef ss10_hwdef = { .iommu_base =0xfe0000000ULL , .tcx_base =0xe20000000ULL , .slavio_base =0xff0000000ULL ,
@@ -1190,9 +1213,19 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .machine_id = ss10_id, .iommu_version = 0x03000000, .max_mem = 0xf00000000ULL, - }, -/* SS-600MP */ - { + }; + + mc->desc ="Sun4m platform, SPARCstation 10" ; + mc->max_cpus =4 ; + mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("TI-SuperSparc-II" ); + smc->hwdef = &ss10_hwdef; +} + +static void ss600mp_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); +Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); +static const struct sun4m_hwdef ss600mp_hwdef = { .iommu_base =0xfe0000000ULL , .tcx_base =0xe20000000ULL , .slavio_base =0xff0000000ULL ,
@@ -1213,9 +1246,19 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .machine_id = ss600mp_id, .iommu_version = 0x01000000, .max_mem = 0xf00000000ULL, - }, -/* SS-20 */ - { + }; + + mc->desc ="Sun4m platform, SPARCserver 600MP" ; + mc->max_cpus =4 ; + mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("TI-SuperSparc-II" ); + smc->hwdef = &ss600mp_hwdef; +} + +static void ss20_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); +Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); +static const struct sun4m_hwdef ss20_hwdef = { .iommu_base =0xfe0000000ULL , .tcx_base =0xe20000000ULL , .slavio_base =0xff0000000ULL ,
@@ -1254,9 +1297,19 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .machine_id = ss20_id, .iommu_version = 0x13000000, .max_mem = 0xf00000000ULL, - }, -/* Voyager */ - { + }; + + mc->desc ="Sun4m platform, SPARCstation 20" ; + mc->max_cpus =4 ; + mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("TI-SuperSparc-II" ); + smc->hwdef = &ss20_hwdef; +} + +static void voyager_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); +Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); +static const struct sun4m_hwdef voyager_hwdef = { .iommu_base =0x10000000 , .tcx_base =0x50000000 , .slavio_base =0x70000000 ,
@@ -1277,9 +1330,18 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .machine_id = vger_id, .iommu_version = 0x05000000, .max_mem = 0x10000000, - }, -/* LX */ - { + }; + + mc->desc ="Sun4m platform, SPARCstation Voyager" ; + mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("Fujitsu-MB86904" ); + smc->hwdef = &voyager_hwdef; +} + +static void ss_lx_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); +Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); +static const struct sun4m_hwdef ss_lx_hwdef = { .iommu_base =0x10000000 , .iommu_pad_base =0x10004000 , .iommu_pad_len =0x0fffb000 ,
@@ -1301,9 +1363,18 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .machine_id = lx_id, .iommu_version = 0x04000000, .max_mem = 0x10000000, - }, -/* SS-4 */ - { + }; + + mc->desc ="Sun4m platform, SPARCstation LX" ; + mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("TI-MicroSparc-I" ); + smc->hwdef = &ss_lx_hwdef; +} + +static void ss4_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); +Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); +static const struct sun4m_hwdef ss4_hwdef = { .iommu_base =0x10000000 , .tcx_base =0x50000000 , .cs_base =0x6c000000 ,
@@ -1325,9 +1396,18 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .machine_id = ss4_id, .iommu_version = 0x05000000, .max_mem = 0x10000000, - }, -/* SPARCClassic */ - { + }; + + mc->desc ="Sun4m platform, SPARCstation 4" ; + mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("Fujitsu-MB86904" ); + smc->hwdef = &ss4_hwdef; +} + +static void scls_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); +Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); +static const struct sun4m_hwdef scls_hwdef = { .iommu_base =0x10000000 , .tcx_base =0x50000000 , .slavio_base =0x70000000 ,
@@ -1348,9 +1428,18 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .machine_id = scls_id, .iommu_version = 0x05000000, .max_mem = 0x10000000, - }, -/* SPARCbook */ - { + }; + + mc->desc ="Sun4m platform, SPARCClassic" ; + mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("TI-MicroSparc-I" ); + smc->hwdef = &scls_hwdef; +} + +static void sbook_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); +Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); +static const struct sun4m_hwdef sbook_hwdef = { .iommu_base =0x10000000 , .tcx_base =0x50000000 ,/* XXX */ .slavio_base =0x70000000 ,
@@ -1371,112 +1460,11 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .machine_id = sbook_id, .iommu_version = 0x05000000, .max_mem = 0x10000000, - }, -}; - -static void sun4m_machine_class_init (ObjectClass *oc,void *data) -{ -MachineClass *mc =MACHINE_CLASS (oc); - - 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" ; -} - -static void ss5_class_init (ObjectClass *oc,void *data) -{ -MachineClass *mc =MACHINE_CLASS (oc); -Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); - - mc->desc ="Sun4m platform, SPARCstation 5" ; - mc->is_default = true; - mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("Fujitsu-MB86904" ); - smc->hwdef = &sun4m_hwdefs[0 ]; -} - -static void ss10_class_init (ObjectClass *oc,void *data) -{ -MachineClass *mc =MACHINE_CLASS (oc); -Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); - - mc->desc ="Sun4m platform, SPARCstation 10" ; - mc->max_cpus =4 ; - mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("TI-SuperSparc-II" ); - smc->hwdef = &sun4m_hwdefs[1 ]; -} - -static void ss600mp_class_init (ObjectClass *oc,void *data) -{ -MachineClass *mc =MACHINE_CLASS (oc); -Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); - - mc->desc ="Sun4m platform, SPARCserver 600MP" ; - mc->max_cpus =4 ; - mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("TI-SuperSparc-II" ); - smc->hwdef = &sun4m_hwdefs[2 ]; -} - -static void ss20_class_init (ObjectClass *oc,void *data) -{ -MachineClass *mc =MACHINE_CLASS (oc); -Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); - - mc->desc ="Sun4m platform, SPARCstation 20" ; - mc->max_cpus =4 ; - mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("TI-SuperSparc-II" ); - smc->hwdef = &sun4m_hwdefs[3 ]; -} - -static void voyager_class_init (ObjectClass *oc,void *data) -{ -MachineClass *mc =MACHINE_CLASS (oc); -Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); - - mc->desc ="Sun4m platform, SPARCstation Voyager" ; - mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("Fujitsu-MB86904" ); - smc->hwdef = &sun4m_hwdefs[4 ]; -} - -static void ss_lx_class_init (ObjectClass *oc,void *data) -{ -MachineClass *mc =MACHINE_CLASS (oc); -Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); - - mc->desc ="Sun4m platform, SPARCstation LX" ; - mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("TI-MicroSparc-I" ); - smc->hwdef = &sun4m_hwdefs[5 ]; -} - -static void ss4_class_init (ObjectClass *oc,void *data) -{ -MachineClass *mc =MACHINE_CLASS (oc); -Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); - - mc->desc ="Sun4m platform, SPARCstation 4" ; - mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("Fujitsu-MB86904" ); - smc->hwdef = &sun4m_hwdefs[6 ]; -} - -static void scls_class_init (ObjectClass *oc,void *data) -{ -MachineClass *mc =MACHINE_CLASS (oc); -Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); - - mc->desc ="Sun4m platform, SPARCClassic" ; - mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("TI-MicroSparc-I" ); - smc->hwdef = &sun4m_hwdefs[7 ]; -} - -static void sbook_class_init (ObjectClass *oc,void *data) -{ -MachineClass *mc =MACHINE_CLASS (oc); -Sun4mMachineClass *smc =SUN4M_MACHINE_CLASS (mc); + }; mc->desc ="Sun4m platform, SPARCbook" ; mc->default_cpu_type =SPARC_CPU_TYPE_NAME ("TI-MicroSparc-I" ); - smc->hwdef = &sun4m_hwdefs[8 ]; + smc->hwdef = &sbook_hwdef; }static const TypeInfo sun4m_machine_types[] = {
Signature · 1 line
2.26.3
Re: [PATCH v3 6/6] hw/sparc/sun4m: Move each sun4m_hwdef definition in its class_init
Quoted 8 lines · Philippe Mathieu-Daudé
Remove the sun4m_hwdefs[] array by moving assigning the structure fields directly in each machine
class_init()function.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- hw/sparc/sun4m.c | 248 ++++++++++++++++++++++------------------------- 1 file changed, 118 insertions(+), 130 deletions(-)
r~
Quoted 23 lines · Philippe Mathieu-Daudé
Missing review: 6
Hi Mark,
This series QOM'ify the sun4m machines.
I need it for a further memory maxsize check. It is mostly code movement (and the diff-stat is good).Since v2:
- use static const variable for hwdef (Richard)
- added Richard's R-b tagSince v1:
- Full rewrite after Mark reviewPhilippe Mathieu-Daudé (6):
hw/sparc/sun4m: Have sun4m machines inherit newTYPE_SUN4M_MACHINEhw/sparc/sun4m: Introduce Sun4mMachineClass hw/sparc/sun4m: Factor outsun4m_machine_class_init()hw/sparc/sun4m: Register machine types in sun4m_machine_types[] hw/sparc/sun4m: Fix code style for checkpatch.pl hw/sparc/sun4m: Move eachsun4m_hwdefdefinition in itsclass_init
Quoted 2 lines
hw/sparc/sun4m.c | 459 +++++++++++++++++++---------------------------- 1 file changed, 186 insertions(+), 273 deletions(-)
Looks good to me:
I've also queued this to my qemu-sparc branch.
ATB,
Mark.