From patchwork Thu Dec 24 08:09:07 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 41763 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0FECFB7BF4 for ; Thu, 24 Dec 2009 20:14:51 +1100 (EST) Received: from localhost ([127.0.0.1]:57880 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NNjmS-0007p7-6r for incoming@patchwork.ozlabs.org; Thu, 24 Dec 2009 04:14:48 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NNj9N-0001n1-6C for qemu-devel@nongnu.org; Thu, 24 Dec 2009 03:34:25 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NNj9I-0001h6-HI for qemu-devel@nongnu.org; Thu, 24 Dec 2009 03:34:24 -0500 Received: from [199.232.76.173] (port=41411 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NNj9I-0001gk-AA for qemu-devel@nongnu.org; Thu, 24 Dec 2009 03:34:20 -0500 Received: from mail.valinux.co.jp ([210.128.90.3]:55631) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NNj9H-0006Zj-Mv for qemu-devel@nongnu.org; Thu, 24 Dec 2009 03:34:20 -0500 Received: from ps.local.valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with SMTP id A80BA106ACF; Thu, 24 Dec 2009 17:09:25 +0900 (JST) Received: (nullmailer pid 22811 invoked by uid 1000); Thu, 24 Dec 2009 08:09:20 -0000 From: Isaku Yamahata To: qemu-devel@nongnu.org, kraxel@redhat.com Date: Thu, 24 Dec 2009 17:09:07 +0900 Message-Id: <1261642160-22754-15-git-send-email-yamahata@valinux.co.jp> X-Mailer: git-send-email 1.6.5.4 In-Reply-To: <1261642160-22754-1-git-send-email-yamahata@valinux.co.jp> References: <1261642160-22754-1-git-send-email-yamahata@valinux.co.jp> X-Virus-Scanned: clamav-milter 0.95.2 at va-mail.local.valinux.co.jp X-Virus-Status: Clean X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: yamahata@valinux.co.jp Subject: [Qemu-devel] [PATCH V10 14/27] pc: split out memory allocation from pc_init1() into pc_memory_init() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Split out memory allocation and rom/bios loading which doesn't depend on piix from pc_init1() into pc_memory_init(). Later it will be used. Signed-off-by: Isaku Yamahata --- hw/pc.c | 74 +++++++++++++++++++++++++++++++++++++++----------------------- 1 files changed, 46 insertions(+), 28 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index a188d9b..32e27dd 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -1007,34 +1007,19 @@ static qemu_irq *pc_allocate_cpu_irq(void) return qemu_allocate_irqs(pic_irq_request, NULL, 1); } -/* PC hardware initialisation */ -static void pc_init1(ram_addr_t ram_size, - const char *boot_device, - const char *kernel_filename, - const char *kernel_cmdline, - const char *initrd_filename, - const char *cpu_model, - int pci_enabled) +static void pc_memory_init(ram_addr_t ram_size, + const char *kernel_filename, + const char *kernel_cmdline, + const char *initrd_filename, + ram_addr_t *below_4g_mem_size_p, + ram_addr_t *above_4g_mem_size_p, + void **fw_cfg) { char *filename; int ret, linux_boot, i; ram_addr_t ram_addr, bios_offset, option_rom_offset; ram_addr_t below_4g_mem_size, above_4g_mem_size = 0; int bios_size, isa_bios_size; - PCIBus *pci_bus; - ISADevice *isa_dev; - PCII440FXState *i440fx_state; - int piix3_devfn = -1; - qemu_irq *cpu_irq; - qemu_irq *isa_irq; - qemu_irq *i8259; - IsaIrqState *isa_irq_state; - DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; - DriveInfo *fd[MAX_FD]; - void *fw_cfg; - fdctrl_t *floppy_controller; - RTCState *rtc_state; - PITState *pit; if (ram_size >= 0xe0000000 ) { above_4g_mem_size = ram_size - 0xe0000000; @@ -1042,13 +1027,11 @@ static void pc_init1(ram_addr_t ram_size, } else { below_4g_mem_size = ram_size; } + *above_4g_mem_size_p = above_4g_mem_size; + *below_4g_mem_size_p = below_4g_mem_size; linux_boot = (kernel_filename != NULL); - pc_cpus_init(cpu_model); - - vmport_init(); - /* allocate RAM */ ram_addr = qemu_ram_alloc(0xa0000); cpu_register_physical_memory(0, 0xa0000, ram_addr); @@ -1117,15 +1100,50 @@ static void pc_init1(ram_addr_t ram_size, cpu_register_physical_memory((uint32_t)(-bios_size), bios_size, bios_offset | IO_MEM_ROM); - fw_cfg = bochs_bios_init(); + *fw_cfg = bochs_bios_init(); if (linux_boot) { - load_linux(fw_cfg, kernel_filename, initrd_filename, kernel_cmdline, below_4g_mem_size); + load_linux(*fw_cfg, kernel_filename, initrd_filename, kernel_cmdline, below_4g_mem_size); } for (i = 0; i < nb_option_roms; i++) { rom_add_option(option_rom[i]); } +} + +/* PC hardware initialisation */ +static void pc_init1(ram_addr_t ram_size, + const char *boot_device, + const char *kernel_filename, + const char *kernel_cmdline, + const char *initrd_filename, + const char *cpu_model, + int pci_enabled) +{ + int i; + ram_addr_t below_4g_mem_size, above_4g_mem_size; + PCIBus *pci_bus; + ISADevice *isa_dev; + PCII440FXState *i440fx_state; + int piix3_devfn = -1; + qemu_irq *cpu_irq; + qemu_irq *isa_irq; + qemu_irq *i8259; + IsaIrqState *isa_irq_state; + DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; + DriveInfo *fd[MAX_FD]; + void *fw_cfg; + fdctrl_t *floppy_controller; + RTCState *rtc_state; + PITState *pit; + + pc_cpus_init(cpu_model); + + vmport_init(); + + /* allocate ram and load rom/bios */ + pc_memory_init(ram_size, kernel_filename, kernel_cmdline, initrd_filename, + &below_4g_mem_size, &above_4g_mem_size, &fw_cfg); cpu_irq = pc_allocate_cpu_irq(); i8259 = i8259_init(cpu_irq[0]);