diff options
Diffstat (limited to 'hw/ide/cmd646.c')
-rw-r--r-- | hw/ide/cmd646.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c index e191ee6..89ba836 100644 --- a/hw/ide/cmd646.c +++ b/hw/ide/cmd646.c @@ -167,10 +167,6 @@ static void bmdma_map(PCIDevice *pci_dev, int region_num, for(i = 0;i < 2; i++) { BMDMAState *bm = &d->bmdma[i]; - bmdma_init(&d->bus[i], bm); - bm->bus = d->bus+i; - qemu_add_vm_change_state_handler(d->bus[i].dma->ops->restart_cb, - &bm->dma); if (i == 0) { register_ioport_write(addr, 4, 1, bmdma_writeb_0, d); @@ -228,6 +224,7 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev) PCIIDEState *d = DO_UPCAST(PCIIDEState, dev, dev); uint8_t *pci_conf = d->dev.config; qemu_irq *irq; + int i; pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_CMD); pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_CMD_646); @@ -253,10 +250,15 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev) pci_conf[PCI_INTERRUPT_PIN] = 0x01; // interrupt on pin 1 irq = qemu_allocate_irqs(cmd646_set_irq, d, 2); - ide_bus_new(&d->bus[0], &d->dev.qdev, 0); - ide_bus_new(&d->bus[1], &d->dev.qdev, 1); - ide_init2(&d->bus[0], irq[0]); - ide_init2(&d->bus[1], irq[1]); + for (i = 0; i < 2; i++) { + ide_bus_new(&d->bus[i], &d->dev.qdev, i); + ide_init2(&d->bus[i], irq[i]); + + bmdma_init(&d->bus[i], &d->bmdma[i]); + bm->bus = &d->bus[i]; + qemu_add_vm_change_state_handler(d->bus[i].dma->ops->restart_cb, + &d->bmdma[i]->dma); + } vmstate_register(&dev->qdev, 0, &vmstate_ide_pci, d); qemu_register_reset(cmd646_reset, d); |