From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S10wg-0004yB-87 for qemu-devel@nongnu.org; Fri, 24 Feb 2012 14:36:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S10wb-0003Wm-Kn for qemu-devel@nongnu.org; Fri, 24 Feb 2012 14:36:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56010) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S10wb-0003Wc-D0 for qemu-devel@nongnu.org; Fri, 24 Feb 2012 14:36:41 -0500 From: Luiz Capitulino Date: Fri, 24 Feb 2012 17:36:29 -0200 Message-Id: <1330112189-29280-4-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1330112189-29280-1-git-send-email-lcapitulino@redhat.com> References: <1330112189-29280-1-git-send-email-lcapitulino@redhat.com> Subject: [Qemu-devel] [PATCH 3/3] boards: move all machine type functions to boards.c List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, aliguori@us.ibm.com, afaerber@suse.de The license text is the same as used in vl.c. Also note that it's necessary to make machine_parse() public. Signed-off-by: Luiz Capitulino --- Makefile.target | 1 + hw/boards.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/boards.h | 1 + vl.c | 69 ------------------------------------------- 4 files changed, 90 insertions(+), 69 deletions(-) create mode 100644 hw/boards.c diff --git a/Makefile.target b/Makefile.target index 68a5641..20ba1e7 100644 --- a/Makefile.target +++ b/Makefile.target @@ -196,6 +196,7 @@ endif #CONFIG_BSD_USER ifdef CONFIG_SOFTMMU obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o balloon.o ioport.o +obj-y += boards.o # virtio has to be here due to weird dependency between PCI and virtio-net. # need to fix this properly obj-$(CONFIG_NO_PCI) += pci-stub.o diff --git a/hw/boards.c b/hw/boards.c new file mode 100644 index 0000000..2692930 --- /dev/null +++ b/hw/boards.c @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#include "hw/boards.h" + +static QEMUMachine *first_machine = NULL; +QEMUMachine *current_machine = NULL; + +void qemu_register_machine(QEMUMachine *m) +{ + QEMUMachine **pm; + pm = &first_machine; + while (*pm != NULL) + pm = &(*pm)->next; + m->next = NULL; + *pm = m; +} + +static QEMUMachine *find_machine(const char *name) +{ + QEMUMachine *m; + + for(m = first_machine; m != NULL; m = m->next) { + if (!strcmp(m->name, name)) + return m; + if (m->alias && !strcmp(m->alias, name)) + return m; + } + return NULL; +} + +QEMUMachine *find_default_machine(void) +{ + QEMUMachine *m; + + for(m = first_machine; m != NULL; m = m->next) { + if (m->is_default) { + return m; + } + } + return NULL; +} + +static void machine_print_all(void) +{ + QEMUMachine *m; + + printf("Supported machines are:\n"); + for (m = first_machine; m != NULL; m = m->next) { + if (m->alias) { + printf("%-20s %s (alias of %s)\n", m->alias, m->desc, m->name); + } + printf("%-20s %s%s\n", m->name, m->desc, + m->is_default ? " (default)" : ""); + } +} + +QEMUMachine *machine_parse(const char *name) +{ + QEMUMachine *machine = NULL; + + if (name) { + machine = find_machine(name); + } + if (machine) { + return machine; + } + machine_print_all(); + exit(!name || *name != '?'); +} diff --git a/hw/boards.h b/hw/boards.h index 7a9899f..a9b0c8c 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -33,6 +33,7 @@ typedef struct QEMUMachine { void qemu_register_machine(QEMUMachine *m); QEMUMachine *find_default_machine(void); +QEMUMachine *machine_parse(const char *name); extern QEMUMachine *current_machine; diff --git a/vl.c b/vl.c index ced7068..949cfd8 100644 --- a/vl.c +++ b/vl.c @@ -1158,61 +1158,6 @@ void pcmcia_info(Monitor *mon) } /***********************************************************/ -/* machine registration */ - -static QEMUMachine *first_machine = NULL; -QEMUMachine *current_machine = NULL; - -void qemu_register_machine(QEMUMachine *m) -{ - QEMUMachine **pm; - pm = &first_machine; - while (*pm != NULL) - pm = &(*pm)->next; - m->next = NULL; - *pm = m; -} - -static QEMUMachine *find_machine(const char *name) -{ - QEMUMachine *m; - - for(m = first_machine; m != NULL; m = m->next) { - if (!strcmp(m->name, name)) - return m; - if (m->alias && !strcmp(m->alias, name)) - return m; - } - return NULL; -} - -QEMUMachine *find_default_machine(void) -{ - QEMUMachine *m; - - for(m = first_machine; m != NULL; m = m->next) { - if (m->is_default) { - return m; - } - } - return NULL; -} - -static void machine_print_all(void) -{ - QEMUMachine *m; - - printf("Supported machines are:\n"); - for (m = first_machine; m != NULL; m = m->next) { - if (m->alias) { - printf("%-20s %s (alias of %s)\n", m->alias, m->desc, m->name); - } - printf("%-20s %s%s\n", m->name, m->desc, - m->is_default ? " (default)" : ""); - } -} - -/***********************************************************/ /* main execution loop */ static void gui_update(void *opaque) @@ -2004,20 +1949,6 @@ static int debugcon_parse(const char *devname) return 0; } -static QEMUMachine *machine_parse(const char *name) -{ - QEMUMachine *machine = NULL; - - if (name) { - machine = find_machine(name); - } - if (machine) { - return machine; - } - machine_print_all(); - exit(!name || *name != '?'); -} - static int tcg_init(void) { tcg_exec_init(tcg_tb_size * 1024 * 1024); -- 1.7.9.111.gf3fb0.dirty