From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52271) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aqyh4-0002aN-Ou for qemu-devel@nongnu.org; Fri, 15 Apr 2016 04:01:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aqyh0-0001fD-PZ for qemu-devel@nongnu.org; Fri, 15 Apr 2016 04:01:34 -0400 Date: Fri, 15 Apr 2016 15:17:43 +1000 From: David Gibson Message-ID: <20160415051743.GM18218@voom.redhat.com> References: <1460042594-8056-1-git-send-email-mark.cave-ayland@ilande.co.uk> <1460042594-8056-3-git-send-email-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="EOHJn1TVIJfeVXv2" Content-Disposition: inline In-Reply-To: <1460042594-8056-3-git-send-email-mark.cave-ayland@ilande.co.uk> Subject: Re: [Qemu-devel] [RFC 2/4] target-ppc: derive all PPC machine classes to have PPCMachineClass as their superclass List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mark Cave-Ayland Cc: aik@ozlabs.ru, agraf@suse.de, qemu-ppc@nongnu.org, qemu-devel@nongnu.org --EOHJn1TVIJfeVXv2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 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(-) >=20 > 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" > =20 > @@ -57,12 +58,14 @@ static void e500plat_init(MachineState *machine) > ppce500_init(machine, ¶ms); > } > =20 > -static void e500plat_machine_init(MachineClass *mc) > +static void e500plat_machine_init(PPCMachineClass *pmc) > { > + MachineClass *mc =3D MACHINE_CLASS(pmc); > + > mc->desc =3D "generic paravirt e500 platform"; > mc->init =3D e500plat_init; > mc->max_cpus =3D 32; > mc->has_dynamic_sysbus =3D true; > } > =20 > -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; > } > =20 > -static void core99_machine_class_init(ObjectClass *oc, void *data) > +static void core99_machine_init(PPCMachineClass *pmc) > { > - MachineClass *mc =3D MACHINE_CLASS(oc); > + MachineClass *mc =3D MACHINE_CLASS(pmc); > =20 > mc->desc =3D "Mac99 based PowerMAC"; > mc->init =3D ppc_core99_init; > @@ -521,15 +521,4 @@ static void core99_machine_class_init(ObjectClass *o= c, void *data) > mc->kvm_type =3D core99_kvm_type; > } > =20 > -static const TypeInfo core99_machine_info =3D { > - .name =3D MACHINE_TYPE_NAME("mac99"), > - .parent =3D TYPE_MACHINE, > - .class_init =3D 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; > } > =20 > -static void heathrow_machine_init(MachineClass *mc) > +static void heathrow_machine_init(PPCMachineClass *pmc) > { > + MachineClass *mc =3D MACHINE_CLASS(pmc); > + > mc->desc =3D "Heathrow based PowerMAC"; > mc->init =3D ppc_heathrow_init; > mc->max_cpus =3D MAX_CPUS; > @@ -376,4 +378,4 @@ static void heathrow_machine_init(MachineClass *mc) > mc->kvm_type =3D heathrow_kvm_type; > } > =20 > -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" > =20 > @@ -50,11 +51,13 @@ static void mpc8544ds_init(MachineState *machine) > } > =20 > =20 > -static void ppce500_machine_init(MachineClass *mc) > +static void ppce500_machine_init(PPCMachineClass *pmc) > { > + MachineClass *mc =3D MACHINE_CLASS(pmc); > + > mc->desc =3D "mpc8544ds"; > mc->init =3D mpc8544ds_init; > mc->max_cpus =3D 15; > } > =20 > -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 > } > =20 > -static void ref405ep_class_init(ObjectClass *oc, void *data) > +static void ref405ep_machine_init(PPCMachineClass *pmc) > { > - MachineClass *mc =3D MACHINE_CLASS(oc); > + MachineClass *mc =3D MACHINE_CLASS(pmc); > =20 > mc->desc =3D "ref405ep"; > mc->init =3D ref405ep_init; > } > =20 > -static const TypeInfo ref405ep_type =3D { > - .name =3D MACHINE_TYPE_NAME("ref405ep"), > - .parent =3D TYPE_MACHINE, > - .class_init =3D ref405ep_class_init, > -}; > +DEFINE_PPC_MACHINE("ref405ep", ref405ep_machine_init) > =20 > /***********************************************************************= ******/ > /* AMCC Taihu evaluation board */ > @@ -641,24 +637,12 @@ static void taihu_405ep_init(MachineState *machine) > #endif > } > =20 > -static void taihu_class_init(ObjectClass *oc, void *data) > +static void taihu_machine_init(PPCMachineClass *pmc) > { > - MachineClass *mc =3D MACHINE_CLASS(oc); > + MachineClass *mc =3D MACHINE_CLASS(pmc); > =20 > mc->desc =3D "taihu"; > mc->init =3D taihu_405ep_init; > } > =20 > -static const TypeInfo taihu_type =3D { > - .name =3D MACHINE_TYPE_NAME("taihu"), > - .parent =3D TYPE_MACHINE, > - .class_init =3D 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) > } > } > =20 > -static void bamboo_machine_init(MachineClass *mc) > +static void bamboo_machine_init(PPCMachineClass *pmc) > { > + MachineClass *mc =3D MACHINE_CLASS(pmc); > + > mc->desc =3D "bamboo"; > mc->init =3D bamboo_init; > } > =20 > -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); > } > =20 > -static void prep_machine_init(MachineClass *mc) > +static void prep_machine_init(PPCMachineClass *pmc) > { > + MachineClass *mc =3D MACHINE_CLASS(pmc); > + > mc->desc =3D "PowerPC PREP platform"; > mc->init =3D ppc_prep_init; > mc->max_cpus =3D MAX_CPUS; > mc->default_boot_order =3D "cad"; > } > =20 > -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 *o= c, void *data) > =20 > static const TypeInfo spapr_machine_info =3D { > .name =3D TYPE_SPAPR_MACHINE, > - .parent =3D TYPE_MACHINE, > + .parent =3D TYPE_PPC_MACHINE, > .abstract =3D true, > .instance_size =3D sizeof(sPAPRMachineState), > .instance_init =3D 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 =3D &boot_info; > } > =20 > -static void virtex_machine_init(MachineClass *mc) > +static void virtex_machine_init(PPCMachineClass *pmc) > { > + MachineClass *mc =3D MACHINE_CLASS(pmc); > + > mc->desc =3D "Xilinx Virtex ML507 reference design"; > mc->init =3D virtex_init; > } > =20 > -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 =3D PPC_MACHINE_CLASS(oc); \ > + machine_initfn(mc); \ > + } \ > + static const TypeInfo machine_initfn##_typeinfo =3D { \ > + .name =3D MACHINE_TYPE_NAME(namestr), \ > + .parent =3D TYPE_PPC_MACHINE, \ > + .class_init =3D machine_initfn##_class_init, \ > + }; \ > + static void machine_initfn##_register_types(void) \ > + { \ > + type_register_static(&machine_initfn##_typeinfo); \ > + } \ > + type_init(machine_initfn##_register_types) > + =20 > void ppc_set_irq(PowerPCCPU *cpu, int n_IRQ, int level); > =20 > /* PowerPC hardware exceptions management helpers */ --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --EOHJn1TVIJfeVXv2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXEHl3AAoJEGw4ysog2bOSMKEQANQMDafkswOUMuEguAPhGWl+ AHVLMq+Re35vutNbQ75Wq4/rPA1yeJZ9T/2Q/8J3Yi2yM0H1pDH88gjssHfph8GT Z+5Dxioi3JWdjguKTScSlM1xPCdFcWFLoBPLrd807QF5zqJ8OAGkFpecry+QjzKf zdHv1bGhpFi/parXub1bVciXTHHSfqhAVPTR/+U9m4K7jATwxfqzsL61lX8mHiUc gMbuLNHSg6tq/5zr37yCj/unIha/lmE43D3rJPLqeWdCnUBtKSg+WSFJRB0gC6oh iaTEuK/hMe1WuEfmw1/2L40802ZTWcjlbzP8o2+FwfyDEGAS7SvUAncXn1Cart47 LLyraS0onNMjmXGL/tOxY3+T5+XQfcf5BARt8AcgTcYt8gfQPKUcaUjA4nEQXWDF x5XbY2ElxUcLwHL7MiYqSKj9C/4/jpE6yicv5SwVNJUg6TDua9W7hPEsm9khJEmm nMWJ8VGUpSKzuLZh3ATI+cwtxL8G4aza35JtAbJBF/BDwvgpG9CTWte5wdsXYEzU uv5y5xCz7fjipf6FQ3+9jiSGJA+UBTzV6BLFzWvvmN+PdjczrtjamUVXWthp9KRc Ydw7EOhakT1S4aJ51OBSleTX+IOWK/e28q8nOl0lXKAX0R0gaY9sDmThaCn9wMtV AZE5HSgcAqVs7b7LHEJe =uv9T -----END PGP SIGNATURE----- --EOHJn1TVIJfeVXv2--