aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2010-06-01 20:32:29 +0200
committerKevin Wolf <kwolf@redhat.com>2010-06-04 11:43:39 +0200
commit57234ee40d314f91cf5bd16a926f30a6985e06e2 (patch)
tree89271b523f0196d0fbdf41d4b75307c30122f8ee /hw
parent870111c8ed95df62a101eae0acd08c84233a6341 (diff)
ide: Split non-qdev code off ide_init2()
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/ide/cmd646.c4
-rw-r--r--hw/ide/core.c30
-rw-r--r--hw/ide/internal.h5
-rw-r--r--hw/ide/isa.c2
-rw-r--r--hw/ide/macio.c2
-rw-r--r--hw/ide/microdrive.c3
-rw-r--r--hw/ide/mmio.c2
-rw-r--r--hw/ide/piix.c4
8 files changed, 34 insertions, 18 deletions
diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c
index cdcc9bf1aa..559147ff43 100644
--- a/hw/ide/cmd646.c
+++ b/hw/ide/cmd646.c
@@ -260,8 +260,8 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev)
irq = qemu_allocate_irqs(cmd646_set_irq, d, 2);
ide_bus_new(&d->bus[0], &d->dev.qdev);
ide_bus_new(&d->bus[1], &d->dev.qdev);
- ide_init2(&d->bus[0], NULL, NULL, irq[0]);
- ide_init2(&d->bus[1], NULL, NULL, irq[1]);
+ ide_init2(&d->bus[0], irq[0]);
+ ide_init2(&d->bus[1], irq[1]);
vmstate_register(0, &vmstate_ide_pci, d);
qemu_register_reset(cmd646_reset, d);
diff --git a/hw/ide/core.c b/hw/ide/core.c
index cb7af388f1..d3328cd02f 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2632,7 +2632,7 @@ void ide_init_drive(IDEState *s, DriveInfo *dinfo, const char *version)
ide_reset(s);
}
-static void ide_init1(IDEBus *bus, int unit, DriveInfo *dinfo)
+static void ide_init1(IDEBus *bus, int unit)
{
static int drive_serial = 1;
IDEState *s = &bus->ifs[unit];
@@ -2645,20 +2645,34 @@ static void ide_init1(IDEBus *bus, int unit, DriveInfo *dinfo)
s->smart_selftest_data = qemu_blockalign(s->bs, 512);
s->sector_write_timer = qemu_new_timer(vm_clock,
ide_sector_write_timer_cb, s);
- if (dinfo) {
- ide_init_drive(s, dinfo, NULL);
- } else {
- ide_reset(s);
+}
+
+void ide_init2(IDEBus *bus, qemu_irq irq)
+{
+ int i;
+
+ for(i = 0; i < 2; i++) {
+ ide_init1(bus, i);
+ ide_reset(&bus->ifs[i]);
}
+ bus->irq = irq;
}
-void ide_init2(IDEBus *bus, DriveInfo *hd0, DriveInfo *hd1,
- qemu_irq irq)
+/* TODO convert users to qdev and remove */
+void ide_init2_with_non_qdev_drives(IDEBus *bus, DriveInfo *hd0,
+ DriveInfo *hd1, qemu_irq irq)
{
int i;
+ DriveInfo *dinfo;
for(i = 0; i < 2; i++) {
- ide_init1(bus, i, i == 0 ? hd0 : hd1);
+ dinfo = i == 0 ? hd0 : hd1;
+ ide_init1(bus, i);
+ if (dinfo) {
+ ide_init_drive(&bus->ifs[i], dinfo, NULL);
+ } else {
+ ide_reset(&bus->ifs[i]);
+ }
}
bus->irq = irq;
}
diff --git a/hw/ide/internal.h b/hw/ide/internal.h
index cf7101924d..6b0024d4c9 100644
--- a/hw/ide/internal.h
+++ b/hw/ide/internal.h
@@ -555,8 +555,9 @@ void ide_data_writel(void *opaque, uint32_t addr, uint32_t val);
uint32_t ide_data_readl(void *opaque, uint32_t addr);
void ide_init_drive(IDEState *s, DriveInfo *dinfo, const char *version);
-void ide_init2(IDEBus *bus, DriveInfo *hd0, DriveInfo *hd1,
- qemu_irq irq);
+void ide_init2(IDEBus *bus, qemu_irq irq);
+void ide_init2_with_non_qdev_drives(IDEBus *bus, DriveInfo *hd0,
+ DriveInfo *hd1, qemu_irq irq);
void ide_init_ioport(IDEBus *bus, int iobase, int iobase2);
/* hw/ide/qdev.c */
diff --git a/hw/ide/isa.c b/hw/ide/isa.c
index dff7c796f7..b6c6347289 100644
--- a/hw/ide/isa.c
+++ b/hw/ide/isa.c
@@ -70,7 +70,7 @@ static int isa_ide_initfn(ISADevice *dev)
ide_bus_new(&s->bus, &s->dev.qdev);
ide_init_ioport(&s->bus, s->iobase, s->iobase2);
isa_init_irq(dev, &s->irq, s->isairq);
- ide_init2(&s->bus, NULL, NULL, s->irq);
+ ide_init2(&s->bus, s->irq);
vmstate_register(0, &vmstate_ide_isa, s);
return 0;
};
diff --git a/hw/ide/macio.c b/hw/ide/macio.c
index 639f3f6a65..f76c0fa31c 100644
--- a/hw/ide/macio.c
+++ b/hw/ide/macio.c
@@ -314,7 +314,7 @@ int pmac_ide_init (DriveInfo **hd_table, qemu_irq irq,
int pmac_ide_memory;
d = qemu_mallocz(sizeof(MACIOIDEState));
- ide_init2(&d->bus, hd_table[0], hd_table[1], irq);
+ ide_init2_with_non_qdev_drives(&d->bus, hd_table[0], hd_table[1], irq);
if (dbdma)
DBDMA_register_channel(dbdma, channel, dma_irq, pmac_ide_transfer, pmac_ide_flush, d);
diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c
index bfdb8c8b05..a7beac552a 100644
--- a/hw/ide/microdrive.c
+++ b/hw/ide/microdrive.c
@@ -539,7 +539,8 @@ PCMCIACardState *dscm1xxxx_init(DriveInfo *bdrv)
md->card.cis = dscm1xxxx_cis;
md->card.cis_len = sizeof(dscm1xxxx_cis);
- ide_init2(&md->bus, bdrv, NULL, qemu_allocate_irqs(md_set_irq, md, 1)[0]);
+ ide_init2_with_non_qdev_drives(&md->bus, bdrv, NULL,
+ qemu_allocate_irqs(md_set_irq, md, 1)[0]);
md->bus.ifs[0].is_cf = 1;
md->bus.ifs[0].mdata_size = METADATA_SIZE;
md->bus.ifs[0].mdata_storage = (uint8_t *) qemu_mallocz(METADATA_SIZE);
diff --git a/hw/ide/mmio.c b/hw/ide/mmio.c
index cca883f613..e75cccf56e 100644
--- a/hw/ide/mmio.c
+++ b/hw/ide/mmio.c
@@ -125,7 +125,7 @@ void mmio_ide_init (target_phys_addr_t membase, target_phys_addr_t membase2,
MMIOState *s = qemu_mallocz(sizeof(MMIOState));
int mem1, mem2;
- ide_init2(&s->bus, hd0, hd1, irq);
+ ide_init2_with_non_qdev_drives(&s->bus, hd0, hd1, irq);
s->shift = shift;
diff --git a/hw/ide/piix.c b/hw/ide/piix.c
index 4fa38519ef..dad6e86ff6 100644
--- a/hw/ide/piix.c
+++ b/hw/ide/piix.c
@@ -135,8 +135,8 @@ static int pci_piix_ide_initfn(PCIIDEState *d)
ide_init_ioport(&d->bus[0], 0x1f0, 0x3f6);
ide_init_ioport(&d->bus[1], 0x170, 0x376);
- ide_init2(&d->bus[0], NULL, NULL, isa_reserve_irq(14));
- ide_init2(&d->bus[1], NULL, NULL, isa_reserve_irq(15));
+ ide_init2(&d->bus[0], isa_reserve_irq(14));
+ ide_init2(&d->bus[1], isa_reserve_irq(15));
return 0;
}