[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 16/61] pc: split out basic device init from pc_init1
From: |
Isaku Yamahata |
Subject: |
[Qemu-devel] [PATCH 16/61] pc: split out basic device init from pc_init1() into pc_basic_device_init() |
Date: |
Wed, 30 Sep 2009 19:17:52 +0900 |
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 <address@hidden>
---
hw/pc.c | 97 +++++++++++++++++++++++++++++++++++----------------------------
1 files changed, 54 insertions(+), 43 deletions(-)
diff --git a/hw/pc.c b/hw/pc.c
index 5c461a6..380a66f 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1309,6 +1309,58 @@ 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 *dinfo;
+ BlockDriverState *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_init(serial_io[i], isa_reserve_irq(serial_irq[i]), 115200,
+ serial_hds[i]);
+ }
+ }
+
+ for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
+ if (parallel_hds[i]) {
+ parallel_init(parallel_io[i], isa_reserve_irq(parallel_irq[i]),
+ parallel_hds[i]);
+ }
+ }
+
+ *isa_dev = isa_create_simple("i8042");
+ DMA_init(0);
+
+ for(i = 0; i < MAX_FD; i++) {
+ dinfo = drive_get(IF_FLOPPY, 0, i);
+ fd[i] = dinfo ? dinfo->bdrv : NULL;
+ }
+ *floppy_controller = fdctrl_init_isa(fd);
+}
+
/* PC hardware initialisation */
static void pc_init1(ram_addr_t ram_size,
const char *boot_device,
@@ -1328,12 +1380,9 @@ static void pc_init1(ram_addr_t ram_size,
qemu_irq *isa_irq;
qemu_irq *i8259;
IsaIrqState *isa_irq_state;
- DriveInfo *dinfo;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
- BlockDriverState *fd[MAX_FD];
fdctrl_t *floppy_controller;
RTCState *rtc_state;
- PITState *pit;
pc_cpus_init(cpu_model);
@@ -1359,43 +1408,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_init(serial_io[i], isa_reserve_irq(serial_irq[i]), 115200,
- serial_hds[i]);
- }
- }
-
- for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
- if (parallel_hds[i]) {
- parallel_init(parallel_io[i], isa_reserve_irq(parallel_irq[i]),
- parallel_hds[i]);
- }
- }
for(i = 0; i < nb_nics; i++) {
NICInfo *nd = &nd_table[i];
@@ -1426,18 +1445,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++) {
- dinfo = drive_get(IF_FLOPPY, 0, i);
- fd[i] = dinfo ? dinfo->bdrv : NULL;
- }
- floppy_controller = fdctrl_init_isa(fd);
-
cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device, hd,
floppy_controller, rtc_state);
--
1.6.0.2
- [Qemu-devel] [PATCH 31/61] pci: pcie host and mmcfg support., (continued)
- [Qemu-devel] [PATCH 31/61] pci: pcie host and mmcfg support., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 02/61] acpi: split out apm register emulation from acpi.c, Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 26/61] pci: 64bit bar support., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 04/61] acpi: split acpi.c into the common part and the piix4 part., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 28/61] pci: factor out while(bus) bus->next loop logic into pci_find_bus_from()., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 21/61] pci: introduce constant PCI_NUM_PINS for the number of interrupt pins, 4., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 17/61] pc: split out pci device init from pc_init1() into pc_pci_device_init(), Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 15/61] pc: split out vga initialization from pc_init1() into pc_vga_init()., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 09/61] pc: remove a global variable, floppy_controller., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 59/61] ioapic: make irr accept more than 32 pins., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 16/61] pc: split out basic device init from pc_init1() into pc_basic_device_init(),
Isaku Yamahata <=
- [Qemu-devel] [PATCH 14/61] pc: split out memory allocation from pc_init1() into pc_memory_init(), Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 56/61] ioapic: clean up of #ifdef DEBUG_IOAPIC., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 03/61] acpi: add acpi constants from linux header files and use them., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 49/61] pci hot add: pass opaque argument to callback., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 01/61] acpi: split out pc smbus routines from acpi.c into pc_smbus.c, Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 61/61] pc_q35: apic mode for pci interrupt routing., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 11/61] pc: introduce a function to allocate cpu irq., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 51/61] vmstate: add a macro for pointer to struct, VMSTATE_STRUCT_POINTER., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 54/61] pci: add opaque argument to pci_map_irq_fn()., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 30/61] pci_host.h: split non-inline static function in pci_host.h into pci_host_c.h, Isaku Yamahata, 2009/09/30