From patchwork Thu Apr 7 15:23:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 607454 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qgmc748Qqz9t5V for ; Fri, 8 Apr 2016 01:24:55 +1000 (AEST) Received: from localhost ([::1]:50560 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoBnh-0004g3-Kk for incoming@patchwork.ozlabs.org; Thu, 07 Apr 2016 11:24:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoBn2-0003Pn-Ue for qemu-devel@nongnu.org; Thu, 07 Apr 2016 11:24:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoBn1-0001yd-JJ for qemu-devel@nongnu.org; Thu, 07 Apr 2016 11:24:12 -0400 Received: from chuckie.co.uk ([82.165.15.123]:32815 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoBmw-0001vT-97; Thu, 07 Apr 2016 11:24:06 -0400 Received: from host81-154-31-210.range81-154.btcentralplus.com ([81.154.31.210] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1aoBml-0003tW-13; Thu, 07 Apr 2016 16:23:56 +0100 From: Mark Cave-Ayland To: david@gibson.dropbear.id.au, aik@ozlabs.ru, agraf@suse.de, qemu-ppc@nongnu.org, qemu-devel@nongnu.org Date: Thu, 7 Apr 2016 16:23:12 +0100 Message-Id: <1460042594-8056-3-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1460042594-8056-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1460042594-8056-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 81.154.31.210 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [RFC 2/4] target-ppc: derive all PPC machine classes to have PPCMachineClass as their superclass X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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, ¶ms); } -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 */