diff mbox

[RFC,2/4] target-ppc: derive all PPC machine classes to have PPCMachineClass as their superclass

Message ID 1460042594-8056-3-git-send-email-mark.cave-ayland@ilande.co.uk
State New
Headers show

Commit Message

Mark Cave-Ayland April 7, 2016, 3:23 p.m. UTC
Using a new DEFINE_PPC_MACHINE macro, make sure that all PPC machines now derive from
the new PPCMachineClass.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/ppc/e500plat.c      |    7 +++++--
 hw/ppc/mac_newworld.c  |   17 +++--------------
 hw/ppc/mac_oldworld.c  |    6 ++++--
 hw/ppc/mpc8544ds.c     |    7 +++++--
 hw/ppc/ppc405_boards.c |   28 ++++++----------------------
 hw/ppc/ppc440_bamboo.c |    6 ++++--
 hw/ppc/prep.c          |    6 ++++--
 hw/ppc/spapr.c         |    2 +-
 hw/ppc/virtex_ml507.c  |    6 ++++--
 include/hw/ppc/ppc.h   |   21 ++++++++++++++++++++-
 10 files changed, 56 insertions(+), 50 deletions(-)

Comments

David Gibson April 15, 2016, 5:17 a.m. UTC | #1
On Thu, Apr 07, 2016 at 04:23:12PM +0100, Mark Cave-Ayland wrote:
> Using a new DEFINE_PPC_MACHINE macro, make sure that all PPC machines now derive from
> the new PPCMachineClass.

> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>

Hmm.. I'm a little bit dubious about this, since the timebase sync
will be pretty much the *only* thing in common between ppc machine
times, and even that's only by convention, not anything fundamental to
the ISA.  (And I want to discourage the misconception - all too common
in x86 land - that platform details are largely determined by ISA).

I might be convinced, but I'd like to also consider the option of just
making the timebase sync stuff a bunch of helpers that each machine
type can use.

> ---
>  hw/ppc/e500plat.c      |    7 +++++--
>  hw/ppc/mac_newworld.c  |   17 +++--------------
>  hw/ppc/mac_oldworld.c  |    6 ++++--
>  hw/ppc/mpc8544ds.c     |    7 +++++--
>  hw/ppc/ppc405_boards.c |   28 ++++++----------------------
>  hw/ppc/ppc440_bamboo.c |    6 ++++--
>  hw/ppc/prep.c          |    6 ++++--
>  hw/ppc/spapr.c         |    2 +-
>  hw/ppc/virtex_ml507.c  |    6 ++++--
>  include/hw/ppc/ppc.h   |   21 ++++++++++++++++++++-
>  10 files changed, 56 insertions(+), 50 deletions(-)
> 
> diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c
> index b00565c..6e4cf05 100644
> --- a/hw/ppc/e500plat.c
> +++ b/hw/ppc/e500plat.c
> @@ -15,6 +15,7 @@
>  #include "hw/boards.h"
>  #include "sysemu/device_tree.h"
>  #include "hw/pci/pci.h"
> +#include "hw/ppc/ppc.h"
>  #include "hw/ppc/openpic.h"
>  #include "kvm_ppc.h"
>  
> @@ -57,12 +58,14 @@ static void e500plat_init(MachineState *machine)
>      ppce500_init(machine, &params);
>  }
>  
> -static void e500plat_machine_init(MachineClass *mc)
> +static void e500plat_machine_init(PPCMachineClass *pmc)
>  {
> +    MachineClass *mc = MACHINE_CLASS(pmc);
> +
>      mc->desc = "generic paravirt e500 platform";
>      mc->init = e500plat_init;
>      mc->max_cpus = 32;
>      mc->has_dynamic_sysbus = true;
>  }
>  
> -DEFINE_MACHINE("ppce500", e500plat_machine_init)
> +DEFINE_PPC_MACHINE("ppce500", e500plat_machine_init)
> diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
> index 32e88b3..40c050d 100644
> --- a/hw/ppc/mac_newworld.c
> +++ b/hw/ppc/mac_newworld.c
> @@ -510,9 +510,9 @@ static int core99_kvm_type(const char *arg)
>      return 2;
>  }
>  
> -static void core99_machine_class_init(ObjectClass *oc, void *data)
> +static void core99_machine_init(PPCMachineClass *pmc)
>  {
> -    MachineClass *mc = MACHINE_CLASS(oc);
> +    MachineClass *mc = MACHINE_CLASS(pmc);
>  
>      mc->desc = "Mac99 based PowerMAC";
>      mc->init = ppc_core99_init;
> @@ -521,15 +521,4 @@ static void core99_machine_class_init(ObjectClass *oc, void *data)
>      mc->kvm_type = core99_kvm_type;
>  }
>  
> -static const TypeInfo core99_machine_info = {
> -    .name          = MACHINE_TYPE_NAME("mac99"),
> -    .parent        = TYPE_MACHINE,
> -    .class_init    = core99_machine_class_init,
> -};
> -
> -static void mac_machine_register_types(void)
> -{
> -    type_register_static(&core99_machine_info);
> -}
> -
> -type_init(mac_machine_register_types)
> +DEFINE_PPC_MACHINE("mac99", core99_machine_init)
> diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
> index a9bb1c2..334768a 100644
> --- a/hw/ppc/mac_oldworld.c
> +++ b/hw/ppc/mac_oldworld.c
> @@ -363,8 +363,10 @@ static int heathrow_kvm_type(const char *arg)
>      return 2;
>  }
>  
> -static void heathrow_machine_init(MachineClass *mc)
> +static void heathrow_machine_init(PPCMachineClass *pmc)
>  {
> +    MachineClass *mc = MACHINE_CLASS(pmc);
> +
>      mc->desc = "Heathrow based PowerMAC";
>      mc->init = ppc_heathrow_init;
>      mc->max_cpus = MAX_CPUS;
> @@ -376,4 +378,4 @@ static void heathrow_machine_init(MachineClass *mc)
>      mc->kvm_type = heathrow_kvm_type;
>  }
>  
> -DEFINE_MACHINE("g3beige", heathrow_machine_init)
> +DEFINE_PPC_MACHINE("g3beige", heathrow_machine_init)
> diff --git a/hw/ppc/mpc8544ds.c b/hw/ppc/mpc8544ds.c
> index 27b8289..09af3b1 100644
> --- a/hw/ppc/mpc8544ds.c
> +++ b/hw/ppc/mpc8544ds.c
> @@ -14,6 +14,7 @@
>  #include "e500.h"
>  #include "hw/boards.h"
>  #include "sysemu/device_tree.h"
> +#include "hw/ppc/ppc.h"
>  #include "hw/ppc/openpic.h"
>  #include "qemu/error-report.h"
>  
> @@ -50,11 +51,13 @@ static void mpc8544ds_init(MachineState *machine)
>  }
>  
>  
> -static void ppce500_machine_init(MachineClass *mc)
> +static void ppce500_machine_init(PPCMachineClass *pmc)
>  {
> +    MachineClass *mc = MACHINE_CLASS(pmc);
> +
>      mc->desc = "mpc8544ds";
>      mc->init = mpc8544ds_init;
>      mc->max_cpus = 15;
>  }
>  
> -DEFINE_MACHINE("mpc8544ds", ppce500_machine_init)
> +DEFINE_PPC_MACHINE("mpc8544ds", ppce500_machine_init)
> diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c
> index 4b2f07a..05d9578 100644
> --- a/hw/ppc/ppc405_boards.c
> +++ b/hw/ppc/ppc405_boards.c
> @@ -373,19 +373,15 @@ static void ref405ep_init(MachineState *machine)
>  #endif
>  }
>  
> -static void ref405ep_class_init(ObjectClass *oc, void *data)
> +static void ref405ep_machine_init(PPCMachineClass *pmc)
>  {
> -    MachineClass *mc = MACHINE_CLASS(oc);
> +    MachineClass *mc = MACHINE_CLASS(pmc);
>  
>      mc->desc = "ref405ep";
>      mc->init = ref405ep_init;
>  }
>  
> -static const TypeInfo ref405ep_type = {
> -    .name = MACHINE_TYPE_NAME("ref405ep"),
> -    .parent = TYPE_MACHINE,
> -    .class_init = ref405ep_class_init,
> -};
> +DEFINE_PPC_MACHINE("ref405ep", ref405ep_machine_init)
>  
>  /*****************************************************************************/
>  /* AMCC Taihu evaluation board */
> @@ -641,24 +637,12 @@ static void taihu_405ep_init(MachineState *machine)
>  #endif
>  }
>  
> -static void taihu_class_init(ObjectClass *oc, void *data)
> +static void taihu_machine_init(PPCMachineClass *pmc)
>  {
> -    MachineClass *mc = MACHINE_CLASS(oc);
> +    MachineClass *mc = MACHINE_CLASS(pmc);
>  
>      mc->desc = "taihu";
>      mc->init = taihu_405ep_init;
>  }
>  
> -static const TypeInfo taihu_type = {
> -    .name = MACHINE_TYPE_NAME("taihu"),
> -    .parent = TYPE_MACHINE,
> -    .class_init = taihu_class_init,
> -};
> -
> -static void ppc405_machine_init(void)
> -{
> -    type_register_static(&ref405ep_type);
> -    type_register_static(&taihu_type);
> -}
> -
> -type_init(ppc405_machine_init)
> +DEFINE_PPC_MACHINE("taihu", taihu_machine_init)
> diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c
> index 5c535b1..1aa6011 100644
> --- a/hw/ppc/ppc440_bamboo.c
> +++ b/hw/ppc/ppc440_bamboo.c
> @@ -291,10 +291,12 @@ static void bamboo_init(MachineState *machine)
>      }
>  }
>  
> -static void bamboo_machine_init(MachineClass *mc)
> +static void bamboo_machine_init(PPCMachineClass *pmc)
>  {
> +    MachineClass *mc = MACHINE_CLASS(pmc);
> +
>      mc->desc = "bamboo";
>      mc->init = bamboo_init;
>  }
>  
> -DEFINE_MACHINE("bamboo", bamboo_machine_init)
> +DEFINE_PPC_MACHINE("bamboo", bamboo_machine_init)
> diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
> index 3ffb85e..70c671e 100644
> --- a/hw/ppc/prep.c
> +++ b/hw/ppc/prep.c
> @@ -668,12 +668,14 @@ static void ppc_prep_init(MachineState *machine)
>                           graphic_width, graphic_height, graphic_depth);
>  }
>  
> -static void prep_machine_init(MachineClass *mc)
> +static void prep_machine_init(PPCMachineClass *pmc)
>  {
> +    MachineClass *mc = MACHINE_CLASS(pmc);
> +
>      mc->desc = "PowerPC PREP platform";
>      mc->init = ppc_prep_init;
>      mc->max_cpus = MAX_CPUS;
>      mc->default_boot_order = "cad";
>  }
>  
> -DEFINE_MACHINE("prep", prep_machine_init)
> +DEFINE_PPC_MACHINE("prep", prep_machine_init)
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index e7be21e..71f0821 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -2296,7 +2296,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
>  
>  static const TypeInfo spapr_machine_info = {
>      .name          = TYPE_SPAPR_MACHINE,
> -    .parent        = TYPE_MACHINE,
> +    .parent        = TYPE_PPC_MACHINE,
>      .abstract      = true,
>      .instance_size = sizeof(sPAPRMachineState),
>      .instance_init = spapr_machine_initfn,
> diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
> index b807a08..865328a 100644
> --- a/hw/ppc/virtex_ml507.c
> +++ b/hw/ppc/virtex_ml507.c
> @@ -299,10 +299,12 @@ static void virtex_init(MachineState *machine)
>      env->load_info = &boot_info;
>  }
>  
> -static void virtex_machine_init(MachineClass *mc)
> +static void virtex_machine_init(PPCMachineClass *pmc)
>  {
> +    MachineClass *mc = MACHINE_CLASS(pmc);
> +
>      mc->desc = "Xilinx Virtex ML507 reference design";
>      mc->init = virtex_init;
>  }
>  
> -DEFINE_MACHINE("virtex-ml507", virtex_machine_init)
> +DEFINE_PPC_MACHINE("virtex-ml507", virtex_machine_init)
> diff --git a/include/hw/ppc/ppc.h b/include/hw/ppc/ppc.h
> index f1be147..dd085e9 100644
> --- a/include/hw/ppc/ppc.h
> +++ b/include/hw/ppc/ppc.h
> @@ -16,7 +16,26 @@ struct PPCMachineClass {
>  #define TYPE_PPC_MACHINE "generic-ppc-machine"
>  #define PPC_MACHINE(obj) \
>      OBJECT_CHECK(PPCMachineState, (obj), TYPE_PPC_MACHINE)
> -
> +#define PPC_MACHINE_CLASS(klass) \
> +    OBJECT_CLASS_CHECK(PPCMachineClass, (klass), TYPE_PPC_MACHINE)
> +
> +#define DEFINE_PPC_MACHINE(namestr, machine_initfn) \
> +    static void machine_initfn##_class_init(ObjectClass *oc, void *data) \
> +    { \
> +        PPCMachineClass *mc = PPC_MACHINE_CLASS(oc); \
> +        machine_initfn(mc); \
> +    } \
> +    static const TypeInfo machine_initfn##_typeinfo = { \
> +        .name       = MACHINE_TYPE_NAME(namestr), \
> +        .parent     = TYPE_PPC_MACHINE, \
> +        .class_init = machine_initfn##_class_init, \
> +    }; \
> +    static void machine_initfn##_register_types(void) \
> +    { \
> +        type_register_static(&machine_initfn##_typeinfo); \
> +    } \
> +    type_init(machine_initfn##_register_types)
> +    
>  void ppc_set_irq(PowerPCCPU *cpu, int n_IRQ, int level);
>  
>  /* PowerPC hardware exceptions management helpers */
diff mbox

Patch

diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c
index b00565c..6e4cf05 100644
--- a/hw/ppc/e500plat.c
+++ b/hw/ppc/e500plat.c
@@ -15,6 +15,7 @@ 
 #include "hw/boards.h"
 #include "sysemu/device_tree.h"
 #include "hw/pci/pci.h"
+#include "hw/ppc/ppc.h"
 #include "hw/ppc/openpic.h"
 #include "kvm_ppc.h"
 
@@ -57,12 +58,14 @@  static void e500plat_init(MachineState *machine)
     ppce500_init(machine, &params);
 }
 
-static void e500plat_machine_init(MachineClass *mc)
+static void e500plat_machine_init(PPCMachineClass *pmc)
 {
+    MachineClass *mc = MACHINE_CLASS(pmc);
+
     mc->desc = "generic paravirt e500 platform";
     mc->init = e500plat_init;
     mc->max_cpus = 32;
     mc->has_dynamic_sysbus = true;
 }
 
-DEFINE_MACHINE("ppce500", e500plat_machine_init)
+DEFINE_PPC_MACHINE("ppce500", e500plat_machine_init)
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index 32e88b3..40c050d 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -510,9 +510,9 @@  static int core99_kvm_type(const char *arg)
     return 2;
 }
 
-static void core99_machine_class_init(ObjectClass *oc, void *data)
+static void core99_machine_init(PPCMachineClass *pmc)
 {
-    MachineClass *mc = MACHINE_CLASS(oc);
+    MachineClass *mc = MACHINE_CLASS(pmc);
 
     mc->desc = "Mac99 based PowerMAC";
     mc->init = ppc_core99_init;
@@ -521,15 +521,4 @@  static void core99_machine_class_init(ObjectClass *oc, void *data)
     mc->kvm_type = core99_kvm_type;
 }
 
-static const TypeInfo core99_machine_info = {
-    .name          = MACHINE_TYPE_NAME("mac99"),
-    .parent        = TYPE_MACHINE,
-    .class_init    = core99_machine_class_init,
-};
-
-static void mac_machine_register_types(void)
-{
-    type_register_static(&core99_machine_info);
-}
-
-type_init(mac_machine_register_types)
+DEFINE_PPC_MACHINE("mac99", core99_machine_init)
diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
index a9bb1c2..334768a 100644
--- a/hw/ppc/mac_oldworld.c
+++ b/hw/ppc/mac_oldworld.c
@@ -363,8 +363,10 @@  static int heathrow_kvm_type(const char *arg)
     return 2;
 }
 
-static void heathrow_machine_init(MachineClass *mc)
+static void heathrow_machine_init(PPCMachineClass *pmc)
 {
+    MachineClass *mc = MACHINE_CLASS(pmc);
+
     mc->desc = "Heathrow based PowerMAC";
     mc->init = ppc_heathrow_init;
     mc->max_cpus = MAX_CPUS;
@@ -376,4 +378,4 @@  static void heathrow_machine_init(MachineClass *mc)
     mc->kvm_type = heathrow_kvm_type;
 }
 
-DEFINE_MACHINE("g3beige", heathrow_machine_init)
+DEFINE_PPC_MACHINE("g3beige", heathrow_machine_init)
diff --git a/hw/ppc/mpc8544ds.c b/hw/ppc/mpc8544ds.c
index 27b8289..09af3b1 100644
--- a/hw/ppc/mpc8544ds.c
+++ b/hw/ppc/mpc8544ds.c
@@ -14,6 +14,7 @@ 
 #include "e500.h"
 #include "hw/boards.h"
 #include "sysemu/device_tree.h"
+#include "hw/ppc/ppc.h"
 #include "hw/ppc/openpic.h"
 #include "qemu/error-report.h"
 
@@ -50,11 +51,13 @@  static void mpc8544ds_init(MachineState *machine)
 }
 
 
-static void ppce500_machine_init(MachineClass *mc)
+static void ppce500_machine_init(PPCMachineClass *pmc)
 {
+    MachineClass *mc = MACHINE_CLASS(pmc);
+
     mc->desc = "mpc8544ds";
     mc->init = mpc8544ds_init;
     mc->max_cpus = 15;
 }
 
-DEFINE_MACHINE("mpc8544ds", ppce500_machine_init)
+DEFINE_PPC_MACHINE("mpc8544ds", ppce500_machine_init)
diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c
index 4b2f07a..05d9578 100644
--- a/hw/ppc/ppc405_boards.c
+++ b/hw/ppc/ppc405_boards.c
@@ -373,19 +373,15 @@  static void ref405ep_init(MachineState *machine)
 #endif
 }
 
-static void ref405ep_class_init(ObjectClass *oc, void *data)
+static void ref405ep_machine_init(PPCMachineClass *pmc)
 {
-    MachineClass *mc = MACHINE_CLASS(oc);
+    MachineClass *mc = MACHINE_CLASS(pmc);
 
     mc->desc = "ref405ep";
     mc->init = ref405ep_init;
 }
 
-static const TypeInfo ref405ep_type = {
-    .name = MACHINE_TYPE_NAME("ref405ep"),
-    .parent = TYPE_MACHINE,
-    .class_init = ref405ep_class_init,
-};
+DEFINE_PPC_MACHINE("ref405ep", ref405ep_machine_init)
 
 /*****************************************************************************/
 /* AMCC Taihu evaluation board */
@@ -641,24 +637,12 @@  static void taihu_405ep_init(MachineState *machine)
 #endif
 }
 
-static void taihu_class_init(ObjectClass *oc, void *data)
+static void taihu_machine_init(PPCMachineClass *pmc)
 {
-    MachineClass *mc = MACHINE_CLASS(oc);
+    MachineClass *mc = MACHINE_CLASS(pmc);
 
     mc->desc = "taihu";
     mc->init = taihu_405ep_init;
 }
 
-static const TypeInfo taihu_type = {
-    .name = MACHINE_TYPE_NAME("taihu"),
-    .parent = TYPE_MACHINE,
-    .class_init = taihu_class_init,
-};
-
-static void ppc405_machine_init(void)
-{
-    type_register_static(&ref405ep_type);
-    type_register_static(&taihu_type);
-}
-
-type_init(ppc405_machine_init)
+DEFINE_PPC_MACHINE("taihu", taihu_machine_init)
diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c
index 5c535b1..1aa6011 100644
--- a/hw/ppc/ppc440_bamboo.c
+++ b/hw/ppc/ppc440_bamboo.c
@@ -291,10 +291,12 @@  static void bamboo_init(MachineState *machine)
     }
 }
 
-static void bamboo_machine_init(MachineClass *mc)
+static void bamboo_machine_init(PPCMachineClass *pmc)
 {
+    MachineClass *mc = MACHINE_CLASS(pmc);
+
     mc->desc = "bamboo";
     mc->init = bamboo_init;
 }
 
-DEFINE_MACHINE("bamboo", bamboo_machine_init)
+DEFINE_PPC_MACHINE("bamboo", bamboo_machine_init)
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index 3ffb85e..70c671e 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -668,12 +668,14 @@  static void ppc_prep_init(MachineState *machine)
                          graphic_width, graphic_height, graphic_depth);
 }
 
-static void prep_machine_init(MachineClass *mc)
+static void prep_machine_init(PPCMachineClass *pmc)
 {
+    MachineClass *mc = MACHINE_CLASS(pmc);
+
     mc->desc = "PowerPC PREP platform";
     mc->init = ppc_prep_init;
     mc->max_cpus = MAX_CPUS;
     mc->default_boot_order = "cad";
 }
 
-DEFINE_MACHINE("prep", prep_machine_init)
+DEFINE_PPC_MACHINE("prep", prep_machine_init)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index e7be21e..71f0821 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2296,7 +2296,7 @@  static void spapr_machine_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo spapr_machine_info = {
     .name          = TYPE_SPAPR_MACHINE,
-    .parent        = TYPE_MACHINE,
+    .parent        = TYPE_PPC_MACHINE,
     .abstract      = true,
     .instance_size = sizeof(sPAPRMachineState),
     .instance_init = spapr_machine_initfn,
diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
index b807a08..865328a 100644
--- a/hw/ppc/virtex_ml507.c
+++ b/hw/ppc/virtex_ml507.c
@@ -299,10 +299,12 @@  static void virtex_init(MachineState *machine)
     env->load_info = &boot_info;
 }
 
-static void virtex_machine_init(MachineClass *mc)
+static void virtex_machine_init(PPCMachineClass *pmc)
 {
+    MachineClass *mc = MACHINE_CLASS(pmc);
+
     mc->desc = "Xilinx Virtex ML507 reference design";
     mc->init = virtex_init;
 }
 
-DEFINE_MACHINE("virtex-ml507", virtex_machine_init)
+DEFINE_PPC_MACHINE("virtex-ml507", virtex_machine_init)
diff --git a/include/hw/ppc/ppc.h b/include/hw/ppc/ppc.h
index f1be147..dd085e9 100644
--- a/include/hw/ppc/ppc.h
+++ b/include/hw/ppc/ppc.h
@@ -16,7 +16,26 @@  struct PPCMachineClass {
 #define TYPE_PPC_MACHINE "generic-ppc-machine"
 #define PPC_MACHINE(obj) \
     OBJECT_CHECK(PPCMachineState, (obj), TYPE_PPC_MACHINE)
-
+#define PPC_MACHINE_CLASS(klass) \
+    OBJECT_CLASS_CHECK(PPCMachineClass, (klass), TYPE_PPC_MACHINE)
+
+#define DEFINE_PPC_MACHINE(namestr, machine_initfn) \
+    static void machine_initfn##_class_init(ObjectClass *oc, void *data) \
+    { \
+        PPCMachineClass *mc = PPC_MACHINE_CLASS(oc); \
+        machine_initfn(mc); \
+    } \
+    static const TypeInfo machine_initfn##_typeinfo = { \
+        .name       = MACHINE_TYPE_NAME(namestr), \
+        .parent     = TYPE_PPC_MACHINE, \
+        .class_init = machine_initfn##_class_init, \
+    }; \
+    static void machine_initfn##_register_types(void) \
+    { \
+        type_register_static(&machine_initfn##_typeinfo); \
+    } \
+    type_init(machine_initfn##_register_types)
+    
 void ppc_set_irq(PowerPCCPU *cpu, int n_IRQ, int level);
 
 /* PowerPC hardware exceptions management helpers */