From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JU63P-0006FB-7T for qemu-devel@nongnu.org; Tue, 26 Feb 2008 15:05:31 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JU63O-0006E2-54 for qemu-devel@nongnu.org; Tue, 26 Feb 2008 15:05:30 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JU63N-0006Df-JY for qemu-devel@nongnu.org; Tue, 26 Feb 2008 15:05:29 -0500 Received: from mx1.redhat.com ([66.187.233.31]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JU63N-0001FA-D0 for qemu-devel@nongnu.org; Tue, 26 Feb 2008 15:05:29 -0500 From: Glauber Costa Date: Tue, 26 Feb 2008 16:56:38 -0300 Message-Id: <1204055805-32349-9-git-send-email-gcosta@redhat.com> In-Reply-To: <1204055805-32349-8-git-send-email-gcosta@redhat.com> References: <1204055805-32349-1-git-send-email-gcosta@redhat.com> <1204055805-32349-2-git-send-email-gcosta@redhat.com> <1204055805-32349-3-git-send-email-gcosta@redhat.com> <1204055805-32349-4-git-send-email-gcosta@redhat.com> <1204055805-32349-5-git-send-email-gcosta@redhat.com> <1204055805-32349-6-git-send-email-gcosta@redhat.com> <1204055805-32349-7-git-send-email-gcosta@redhat.com> <1204055805-32349-8-git-send-email-gcosta@redhat.com> Subject: [Qemu-devel] [PATCH 8/15] isolate cpu initialization function in hw/pc.c Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: kvm-devel@lists.sourceforge.net Cc: marcelo@kvack.org, glommer@gmail.com, qemu-devel@nongnu.org, Glauber Costa , chrisw@sous-sol.org This patch wraps up the piece of code in hw/pc.c that actually allocates and initializates a cpu. After that, plan is to be able to start it later on. Signed-off-by: Glauber Costa --- qemu/hw/pc.c | 40 +++++++++++++++++++++++----------------- qemu/hw/pc.h | 1 + 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c index 77a7d53..982377d 100644 --- a/qemu/hw/pc.c +++ b/qemu/hw/pc.c @@ -740,6 +740,28 @@ static int load_option_rom(const char *f return size; } +CPUState *pc_new_cpu(int cpu, const char *cpu_model, int pci_enabled) +{ + CPUState *env = cpu_init(cpu_model); + if (!env) { + fprintf(stderr, "Unable to find x86 CPU definition\n"); + exit(1); + } + if (cpu != 0) + env->hflags |= HF_HALTED_MASK; + if (smp_cpus > 1) { + /* XXX: enable it in all cases */ + env->cpuid_features |= CPUID_APIC; + } + register_savevm("cpu", cpu, 4, cpu_save, cpu_load, env); + qemu_register_reset(main_cpu_reset, env); + if (pci_enabled) { + apic_init(env); + } + vmport_init(env); + return env; +} + /* PC hardware initialisation */ static void pc_init1(ram_addr_t ram_size, int vga_ram_size, const char *boot_device, DisplayState *ds, @@ -779,23 +801,7 @@ #endif } for(i = 0; i < smp_cpus; i++) { - env = cpu_init(cpu_model); - if (!env) { - fprintf(stderr, "Unable to find x86 CPU definition\n"); - exit(1); - } - if (i != 0) - env->hflags |= HF_HALTED_MASK; - if (smp_cpus > 1) { - /* XXX: enable it in all cases */ - env->cpuid_features |= CPUID_APIC; - } - register_savevm("cpu", i, 4, cpu_save, cpu_load, env); - qemu_register_reset(main_cpu_reset, env); - if (pci_enabled) { - apic_init(env); - } - vmport_init(env); + env = pc_new_cpu(i, cpu_model, pci_enabled); } /* allocate RAM */ diff --git a/qemu/hw/pc.h b/qemu/hw/pc.h index f640395..f70ab55 100644 --- a/qemu/hw/pc.h +++ b/qemu/hw/pc.h @@ -85,6 +85,7 @@ extern int fd_bootchk; void ioport_set_a20(int enable); int ioport_get_a20(void); +CPUState *pc_new_cpu(int cpu, const char *cpu_model, int pci_enabled); /* acpi.c */ extern int acpi_enabled; -- 1.4.2