From patchwork Fri Dec 4 05:51:02 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 40312 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 DC02FB7BBB for ; Fri, 4 Dec 2009 17:30:31 +1100 (EST) Received: from localhost ([127.0.0.1]:60644 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NGRgR-0005Ty-O7 for incoming@patchwork.ozlabs.org; Fri, 04 Dec 2009 01:30:27 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NGR4y-0001Lb-Bv for qemu-devel@nongnu.org; Fri, 04 Dec 2009 00:51:44 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NGR4n-0001AC-A5 for qemu-devel@nongnu.org; Fri, 04 Dec 2009 00:51:40 -0500 Received: from [199.232.76.173] (port=41611 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NGR4m-00019B-LT for qemu-devel@nongnu.org; Fri, 04 Dec 2009 00:51:32 -0500 Received: from mail.valinux.co.jp ([210.128.90.3]:57111) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NGR4k-0002ta-R5 for qemu-devel@nongnu.org; Fri, 04 Dec 2009 00:51:31 -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 ED83E27D78; Fri, 4 Dec 2009 14:51:24 +0900 (JST) Received: (nullmailer pid 25354 invoked by uid 1000); Fri, 04 Dec 2009 05:51:05 -0000 From: Isaku Yamahata To: qemu-devel@nongnu.org Date: Fri, 4 Dec 2009 14:51:02 +0900 Message-Id: <1259905865-25295-16-git-send-email-yamahata@valinux.co.jp> X-Mailer: git-send-email 1.6.5.4 In-Reply-To: <1259905865-25295-1-git-send-email-yamahata@valinux.co.jp> References: <1259905865-25295-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 V8 15/18] pc: split out basic device init from pc_init1() into pc_basic_device_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 basic device, i.e. legacy devices like floppy, initialization from pc_init1() into pc_basic_device_init(). Later it will be used. Signed-off-by: Isaku Yamahata --- hw/pc.c | 89 +++++++++++++++++++++++++++++++++++--------------------------- 1 files changed, 50 insertions(+), 39 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index ae26e33..10fd337 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -1131,6 +1131,54 @@ static void pc_vga_init(PCIBus *pci_bus) } } +static void pc_basic_device_init(qemu_irq *isa_irq, + ISADevice **isa_dev, + fdctrl_t **floppy_controller, + RTCState **rtc_state) +{ + int i; + DriveInfo *fd[MAX_FD]; + PITState *pit; + + register_ioport_write(0x80, 1, 1, ioport80_write, NULL); + + register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL); + + *rtc_state = rtc_init(2000); + cmos_set_s3_resume_init(*rtc_state); + + qemu_register_boot_set(pc_boot_set, *rtc_state); + + register_ioport_read(0x92, 1, 1, ioport92_read, NULL); + register_ioport_write(0x92, 1, 1, ioport92_write, NULL); + + pit = pit_init(0x40, isa_reserve_irq(0)); + pcspk_init(pit); + if (!no_hpet) { + hpet_init(isa_irq); + } + + for(i = 0; i < MAX_SERIAL_PORTS; i++) { + if (serial_hds[i]) { + serial_isa_init(i, serial_hds[i]); + } + } + + for(i = 0; i < MAX_PARALLEL_PORTS; i++) { + if (parallel_hds[i]) { + parallel_init(i, parallel_hds[i]); + } + } + + *isa_dev = isa_create_simple("i8042"); + DMA_init(0); + + for(i = 0; i < MAX_FD; i++) { + fd[i] = drive_get(IF_FLOPPY, 0, i); + } + *floppy_controller = fdctrl_init_isa(fd); +} + /* PC hardware initialisation */ static void pc_init1(ram_addr_t ram_size, const char *boot_device, @@ -1151,10 +1199,8 @@ static void pc_init1(ram_addr_t ram_size, qemu_irq *i8259; IsaIrqState *isa_irq_state; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; - DriveInfo *fd[MAX_FD]; fdctrl_t *floppy_controller; RTCState *rtc_state; - PITState *pit; pc_cpus_init(cpu_model); @@ -1180,41 +1226,13 @@ static void pc_init1(ram_addr_t ram_size, pc_register_ferr_irq(isa_reserve_irq(13)); - /* init basic PC hardware */ - register_ioport_write(0x80, 1, 1, ioport80_write, NULL); - - register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL); - pc_vga_init(pci_enabled? pci_bus: NULL); - rtc_state = rtc_init(2000); - cmos_set_s3_resume_init(rtc_state); - - qemu_register_boot_set(pc_boot_set, rtc_state); - - register_ioport_read(0x92, 1, 1, ioport92_read, NULL); - register_ioport_write(0x92, 1, 1, ioport92_write, NULL); - + /* init basic PC hardware */ + pc_basic_device_init(isa_irq, &isa_dev, &floppy_controller, &rtc_state); if (pci_enabled) { isa_irq_state->ioapic = ioapic_init(); } - pit = pit_init(0x40, isa_reserve_irq(0)); - pcspk_init(pit); - if (!no_hpet) { - hpet_init(isa_irq); - } - - for(i = 0; i < MAX_SERIAL_PORTS; i++) { - if (serial_hds[i]) { - serial_isa_init(i, serial_hds[i]); - } - } - - for(i = 0; i < MAX_PARALLEL_PORTS; i++) { - if (parallel_hds[i]) { - parallel_init(i, parallel_hds[i]); - } - } for(i = 0; i < nb_nics; i++) { NICInfo *nd = &nd_table[i]; @@ -1243,17 +1261,10 @@ static void pc_init1(ram_addr_t ram_size, } } - isa_dev = isa_create_simple("i8042"); - DMA_init(0); #ifdef HAS_AUDIO audio_init(pci_enabled ? pci_bus : NULL, isa_irq); #endif - for(i = 0; i < MAX_FD; i++) { - fd[i] = drive_get(IF_FLOPPY, 0, i); - } - floppy_controller = fdctrl_init_isa(fd); - cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device, hd, floppy_controller, rtc_state);