diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2009-09-15 20:05:00 +0000 |
---|---|---|
committer | Blue Swirl <blauwirbel@gmail.com> | 2009-09-15 20:05:00 +0000 |
commit | dea21e97f433093bd93b0fb55ec1e1eec3171158 (patch) | |
tree | 27ac97f2e9786e674f4a271cb5bba0e153ef0ad4 /hw | |
parent | feef310217d4935e41f5ff5751f7c43e8d6403d3 (diff) |
ide/isa: convert to qdev.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/ide.h | 4 | ||||
-rw-r--r-- | hw/ide/isa.c | 61 | ||||
-rw-r--r-- | hw/mips_r4k.c | 2 | ||||
-rw-r--r-- | hw/pc.c | 3 | ||||
-rw-r--r-- | hw/ppc_prep.c | 2 |
5 files changed, 58 insertions, 14 deletions
@@ -4,8 +4,8 @@ #include "qdev.h" /* ide-isa.c */ -void isa_ide_init(int iobase, int iobase2, qemu_irq irq, - DriveInfo *hd0, DriveInfo *hd1); +int isa_ide_init(int iobase, int iobase2, int isairq, + DriveInfo *hd0, DriveInfo *hd1); /* ide-pci.c */ void pci_cmd646_ide_init(PCIBus *bus, DriveInfo **hd_table, diff --git a/hw/ide/isa.c b/hw/ide/isa.c index ec2d6fbd87..d2fe0c0379 100644 --- a/hw/ide/isa.c +++ b/hw/ide/isa.c @@ -24,6 +24,7 @@ */ #include <hw/hw.h> #include <hw/pc.h> +#include <hw/isa.h> #include "block.h" #include "block_int.h" #include "sysemu.h" @@ -35,7 +36,12 @@ /* ISA IDE definitions */ typedef struct ISAIDEState { - IDEBus *bus; + ISADevice dev; + IDEBus *bus; + uint32_t iobase; + uint32_t iobase2; + uint32_t isairq; + qemu_irq irq; } ISAIDEState; static void isa_ide_save(QEMUFile* f, void *opaque) @@ -57,15 +63,54 @@ static int isa_ide_load(QEMUFile* f, void *opaque, int version_id) return 0; } -void isa_ide_init(int iobase, int iobase2, qemu_irq irq, - DriveInfo *hd0, DriveInfo *hd1) +static int isa_ide_initfn(ISADevice *dev) { + ISAIDEState *s = DO_UPCAST(ISAIDEState, dev, dev); + + s->bus = ide_bus_new(&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); + register_savevm("isa-ide", 0, 3, isa_ide_save, isa_ide_load, s); + return 0; +}; + +int isa_ide_init(int iobase, int iobase2, int isairq, + DriveInfo *hd0, DriveInfo *hd1) +{ + ISADevice *dev; ISAIDEState *s; - s = qemu_mallocz(sizeof(*s)); - s->bus = qemu_mallocz(sizeof(IDEBus)); + dev = isa_create("isa-ide"); + qdev_prop_set_uint32(&dev->qdev, "iobase", iobase); + qdev_prop_set_uint32(&dev->qdev, "iobase2", iobase2); + qdev_prop_set_uint32(&dev->qdev, "irq", isairq); + if (qdev_init(&dev->qdev) != 0) + return -1; - ide_init2(s->bus, hd0, hd1, irq); - ide_init_ioport(s->bus, iobase, iobase2); - register_savevm("isa-ide", 0, 3, isa_ide_save, isa_ide_load, s); + s = DO_UPCAST(ISAIDEState, dev, dev); + if (hd0) + ide_create_drive(s->bus, 0, hd0); + if (hd1) + ide_create_drive(s->bus, 1, hd1); + return 0; +} + +static ISADeviceInfo isa_ide_info = { + .qdev.name = "isa-ide", + .qdev.size = sizeof(ISAIDEState), + .init = isa_ide_initfn, + .qdev.props = (Property[]) { + DEFINE_PROP_HEX32("iobase", ISAIDEState, iobase, 0x1f0), + DEFINE_PROP_HEX32("iobase2", ISAIDEState, iobase2, 0x3f6), + DEFINE_PROP_UINT32("irq", ISAIDEState, isairq, 14), + DEFINE_PROP_END_OF_LIST(), + }, +}; + +static void isa_ide_register_devices(void) +{ + isa_qdev_register(&isa_ide_info); } + +device_init(isa_ide_register_devices) diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c index d801417f56..fcc7fed5f1 100644 --- a/hw/mips_r4k.c +++ b/hw/mips_r4k.c @@ -274,7 +274,7 @@ void mips_r4k_init (ram_addr_t ram_size, } for(i = 0; i < MAX_IDE_BUS; i++) - isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]], + isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i], hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]); @@ -1366,8 +1366,7 @@ static void pc_init1(ram_addr_t ram_size, pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1); } else { for(i = 0; i < MAX_IDE_BUS; i++) { - isa_ide_init(ide_iobase[i], ide_iobase2[i], - isa_reserve_irq(ide_irq[i]), + isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i], hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]); } } diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c index 743dad2b77..5392072982 100644 --- a/hw/ppc_prep.c +++ b/hw/ppc_prep.c @@ -710,7 +710,7 @@ static void ppc_prep_init (ram_addr_t ram_size, } for(i = 0; i < MAX_IDE_BUS; i++) { - isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]], + isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i], hd[2 * i], hd[2 * i + 1]); } |