From patchwork Tue Jun 14 14:13:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 9175969 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A68BE6075D for ; Tue, 14 Jun 2016 14:40:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97BBB1FEC1 for ; Tue, 14 Jun 2016 14:40:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C4A5282ED; Tue, 14 Jun 2016 14:40:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 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 mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7AAB01FEC1 for ; Tue, 14 Jun 2016 14:40:16 +0000 (UTC) Received: from localhost ([::1]:35741 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCpVm-0003cP-W9 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 14 Jun 2016 10:40:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCp6d-0003OG-Ic for qemu-devel@nongnu.org; Tue, 14 Jun 2016 10:14:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCp6X-0007zs-HE for qemu-devel@nongnu.org; Tue, 14 Jun 2016 10:14:15 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:57707) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCp6X-0007zT-A3 for qemu-devel@nongnu.org; Tue, 14 Jun 2016 10:14:09 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1bCp6W-0006DZ-Rv for qemu-devel@nongnu.org; Tue, 14 Jun 2016 15:14:08 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 14 Jun 2016 15:13:41 +0100 Message-Id: <1465913645-19346-7-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465913645-19346-1-git-send-email-peter.maydell@linaro.org> References: <1465913645-19346-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 06/30] hw/arm/virt: introduce DEFINE_VIRT_MACHINE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Andrew Jones Use DEFINE_VIRT_MACHINE to generate versioned machine type info. Signed-off-by: Andrew Jones Reviewed-by: Peter Maydell Message-id: 1465746713-30414-3-git-send-email-drjones@redhat.com Signed-off-by: Peter Maydell --- hw/arm/virt.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 84c7c36..86a1a51 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -98,6 +98,28 @@ typedef struct { #define VIRT_MACHINE_CLASS(klass) \ OBJECT_CLASS_CHECK(VirtMachineClass, klass, TYPE_VIRT_MACHINE) + +#define DEFINE_VIRT_MACHINE(major, minor) \ + static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ + void *data) \ + { \ + MachineClass *mc = MACHINE_CLASS(oc); \ + virt_machine_##major##_##minor##_options(mc); \ + mc->desc = "QEMU " # major "." # minor " ARM Virtual Machine"; \ + } \ + static const TypeInfo machvirt_##major##_##minor##_info = { \ + .name = MACHINE_TYPE_NAME("virt-" # major "." # minor), \ + .parent = TYPE_VIRT_MACHINE, \ + .instance_init = virt_##major##_##minor##_instance_init, \ + .class_init = virt_##major##_##minor##_class_init, \ + }; \ + static void machvirt_machine_##major##_##minor##_init(void) \ + { \ + type_register_static(&machvirt_##major##_##minor##_info); \ + } \ + type_init(machvirt_machine_##major##_##minor##_init); + + /* RAM limit in GB. Since VIRT_MEM starts at the 1GB mark, this means * RAM can go up to the 256GB mark, leaving 256GB of the physical * address space unallocated and free for future use between 256G and 512G. @@ -1459,23 +1481,8 @@ static void virt_2_6_instance_init(Object *obj) "Valid values are 2, 3 and host", NULL); } -static void virt_2_6_class_init(ObjectClass *oc, void *data) +static void virt_machine_2_6_options(MachineClass *mc) { - MachineClass *mc = MACHINE_CLASS(oc); - - mc->desc = "QEMU 2.6 ARM Virtual Machine"; mc->alias = "virt"; } - -static const TypeInfo machvirt_2_6_info = { - .name = MACHINE_TYPE_NAME("virt-2.6"), - .parent = TYPE_VIRT_MACHINE, - .instance_init = virt_2_6_instance_init, - .class_init = virt_2_6_class_init, -}; - -static void machvirt_machine_2_6_init(void) -{ - type_register_static(&machvirt_2_6_info); -} -type_init(machvirt_machine_2_6_init); +DEFINE_VIRT_MACHINE(2, 6)