parallel: Factor out common parallel_hds_isa_init()

Maintainers of affected machines cc'ed.

Cc: Anthony Liguori <aliguori@amazon.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Leon Alrae <leon.alrae@imgtec.com>
Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
Markus Armbruster 2015-02-04 18:33:07 +01:00 committed by Andreas Färber
parent c6f10a5876
commit 07dc788054
6 changed files with 37 additions and 34 deletions

View File

@ -641,3 +641,34 @@ static void parallel_register_types(void)
}
type_init(parallel_register_types)
static bool parallel_init(ISABus *bus, int index, CharDriverState *chr)
{
DeviceState *dev;
ISADevice *isadev;
isadev = isa_try_create(bus, "isa-parallel");
if (!isadev) {
return false;
}
dev = DEVICE(isadev);
qdev_prop_set_uint32(dev, "index", index);
qdev_prop_set_chr(dev, "chardev", chr);
if (qdev_init(dev) < 0) {
return false;
}
return true;
}
void parallel_hds_isa_init(ISABus *bus, int n)
{
int i;
assert(n <= MAX_PARALLEL_PORTS);
for (i = 0; i < n; i++) {
if (parallel_hds[i]) {
parallel_init(bus, i, parallel_hds[i]);
}
}
}

View File

@ -1420,12 +1420,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
}
serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS);
for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
if (parallel_hds[i]) {
parallel_init(isa_bus, i, parallel_hds[i]);
}
}
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");

View File

@ -384,10 +384,7 @@ static void mips_fulong2e_init(MachineState *machine)
rtc_init(isa_bus, 2000, NULL);
serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS);
if (parallel_hds[0]) {
parallel_init(isa_bus, 0, parallel_hds[0]);
}
parallel_hds_isa_init(isa_bus, 1);
/* Sound card */
audio_init(pci_bus);

View File

@ -1173,8 +1173,8 @@ void mips_malta_init(MachineState *machine)
rtc_init(isa_bus, 2000, NULL);
serial_hds_isa_init(isa_bus, 2);
if (parallel_hds[0])
parallel_init(isa_bus, 0, parallel_hds[0]);
parallel_hds_isa_init(isa_bus, 1);
for(i = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
}

View File

@ -851,12 +851,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,
}
serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS);
for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
if (parallel_hds[i]) {
parallel_init(isa_bus, i, parallel_hds[i]);
}
}
parallel_hds_isa_init(isa_bus, MAX_PARALLEL_PORTS);
for(i = 0; i < nb_nics; i++)
pci_nic_init_nofail(&nd_table[i], pci_bus, "ne2k_pci", NULL);

View File

@ -107,23 +107,8 @@ struct PcGuestInfo {
};
/* parallel.c */
static inline bool parallel_init(ISABus *bus, int index, CharDriverState *chr)
{
DeviceState *dev;
ISADevice *isadev;
isadev = isa_try_create(bus, "isa-parallel");
if (!isadev) {
return false;
}
dev = DEVICE(isadev);
qdev_prop_set_uint32(dev, "index", index);
qdev_prop_set_chr(dev, "chardev", chr);
if (qdev_init(dev) < 0) {
return false;
}
return true;
}
void parallel_hds_isa_init(ISABus *bus, int n);
bool parallel_mm_init(MemoryRegion *address_space,
hwaddr base, int it_shift, qemu_irq irq,