mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
ide/isa: convert to qdev.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
parent
feef310217
commit
dea21e97f4
5 changed files with 58 additions and 14 deletions
4
hw/ide.h
4
hw/ide.h
|
@ -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,
|
||||
|
|
61
hw/ide/isa.c
61
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)
|
||||
|
|
|
@ -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]);
|
||||
|
||||
|
|
3
hw/pc.c
3
hw/pc.c
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue