diff mbox

[V8,15/18] pc: split out basic device init from pc_init1() into pc_basic_device_init()

Message ID 1259905865-25295-16-git-send-email-yamahata@valinux.co.jp
State New
Headers show

Commit Message

Isaku Yamahata Dec. 4, 2009, 5:51 a.m. UTC
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 <yamahata@valinux.co.jp>
---
 hw/pc.c |   89 +++++++++++++++++++++++++++++++++++---------------------------
 1 files changed, 50 insertions(+), 39 deletions(-)
diff mbox

Patch

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);