mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-27 21:40:49 +00:00
hw/i386/pc: Factor out the superio code
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20180308223946.26784-26-f4bug@amsat.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
a4cb773928
commit
ac64273c66
72
hw/i386/pc.c
72
hw/i386/pc.c
@ -1517,6 +1517,44 @@ static const MemoryRegionOps ioportF0_io_ops = {
|
||||
},
|
||||
};
|
||||
|
||||
static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, bool no_vmport)
|
||||
{
|
||||
int i;
|
||||
DriveInfo *fd[MAX_FD];
|
||||
qemu_irq *a20_line;
|
||||
ISADevice *i8042, *port92, *vmmouse;
|
||||
|
||||
serial_hds_isa_init(isa_bus, 0, MAX_SERIAL_PORTS);
|
||||
parallel_hds_isa_init(isa_bus, MAX_PARALLEL_PORTS);
|
||||
|
||||
for (i = 0; i < MAX_FD; i++) {
|
||||
fd[i] = drive_get(IF_FLOPPY, 0, i);
|
||||
create_fdctrl |= !!fd[i];
|
||||
}
|
||||
if (create_fdctrl) {
|
||||
fdctrl_init_isa(isa_bus, fd);
|
||||
}
|
||||
|
||||
i8042 = isa_create_simple(isa_bus, "i8042");
|
||||
if (!no_vmport) {
|
||||
vmport_init(isa_bus);
|
||||
vmmouse = isa_try_create(isa_bus, "vmmouse");
|
||||
} else {
|
||||
vmmouse = NULL;
|
||||
}
|
||||
if (vmmouse) {
|
||||
DeviceState *dev = DEVICE(vmmouse);
|
||||
qdev_prop_set_ptr(dev, "ps2_mouse", i8042);
|
||||
qdev_init_nofail(dev);
|
||||
}
|
||||
port92 = isa_create_simple(isa_bus, "port92");
|
||||
|
||||
a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);
|
||||
i8042_setup_a20_line(i8042, a20_line[0]);
|
||||
port92_init(port92, a20_line[1]);
|
||||
g_free(a20_line);
|
||||
}
|
||||
|
||||
void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
|
||||
ISADevice **rtc_state,
|
||||
bool create_fdctrl,
|
||||
@ -1525,13 +1563,11 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
|
||||
uint32_t hpet_irqs)
|
||||
{
|
||||
int i;
|
||||
DriveInfo *fd[MAX_FD];
|
||||
DeviceState *hpet = NULL;
|
||||
int pit_isa_irq = 0;
|
||||
qemu_irq pit_alt_irq = NULL;
|
||||
qemu_irq rtc_irq = NULL;
|
||||
qemu_irq *a20_line;
|
||||
ISADevice *i8042, *port92, *vmmouse, *pit = NULL;
|
||||
ISADevice *pit = NULL;
|
||||
MemoryRegion *ioport80_io = g_new(MemoryRegion, 1);
|
||||
MemoryRegion *ioportF0_io = g_new(MemoryRegion, 1);
|
||||
|
||||
@ -1588,36 +1624,10 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
|
||||
pcspk_init(isa_bus, pit);
|
||||
}
|
||||
|
||||
serial_hds_isa_init(isa_bus, 0, MAX_SERIAL_PORTS);
|
||||
parallel_hds_isa_init(isa_bus, MAX_PARALLEL_PORTS);
|
||||
|
||||
a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);
|
||||
i8042 = isa_create_simple(isa_bus, "i8042");
|
||||
i8042_setup_a20_line(i8042, a20_line[0]);
|
||||
if (!no_vmport) {
|
||||
vmport_init(isa_bus);
|
||||
vmmouse = isa_try_create(isa_bus, "vmmouse");
|
||||
} else {
|
||||
vmmouse = NULL;
|
||||
}
|
||||
if (vmmouse) {
|
||||
DeviceState *dev = DEVICE(vmmouse);
|
||||
qdev_prop_set_ptr(dev, "ps2_mouse", i8042);
|
||||
qdev_init_nofail(dev);
|
||||
}
|
||||
port92 = isa_create_simple(isa_bus, "port92");
|
||||
port92_init(port92, a20_line[1]);
|
||||
g_free(a20_line);
|
||||
|
||||
i8257_dma_init(isa_bus, 0);
|
||||
|
||||
for(i = 0; i < MAX_FD; i++) {
|
||||
fd[i] = drive_get(IF_FLOPPY, 0, i);
|
||||
create_fdctrl |= !!fd[i];
|
||||
}
|
||||
if (create_fdctrl) {
|
||||
fdctrl_init_isa(isa_bus, fd);
|
||||
}
|
||||
/* Super I/O */
|
||||
pc_superio_init(isa_bus, create_fdctrl, no_vmport);
|
||||
}
|
||||
|
||||
void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_bus, PCIBus *pci_bus)
|
||||
|
Loading…
Reference in New Issue
Block a user