isa: QOM'ify ISADevice

Rename its parent field and use DEVICE() where necessary.

Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
Andreas Färber 2013-06-07 13:49:13 +02:00
parent 2ae0e48d5f
commit 4a17cc4f28
11 changed files with 68 additions and 51 deletions

View File

@ -2022,22 +2022,24 @@ static int fdctrl_connect_drives(FDCtrl *fdctrl)
ISADevice *fdctrl_init_isa(ISABus *bus, DriveInfo **fds)
{
ISADevice *dev;
DeviceState *dev;
ISADevice *isadev;
dev = isa_try_create(bus, TYPE_ISA_FDC);
if (!dev) {
isadev = isa_try_create(bus, TYPE_ISA_FDC);
if (!isadev) {
return NULL;
}
dev = DEVICE(isadev);
if (fds[0]) {
qdev_prop_set_drive_nofail(&dev->qdev, "driveA", fds[0]->bdrv);
qdev_prop_set_drive_nofail(dev, "driveA", fds[0]->bdrv);
}
if (fds[1]) {
qdev_prop_set_drive_nofail(&dev->qdev, "driveB", fds[1]->bdrv);
qdev_prop_set_drive_nofail(dev, "driveB", fds[1]->bdrv);
}
qdev_init_nofail(&dev->qdev);
qdev_init_nofail(dev);
return dev;
return isadev;
}
void fdctrl_init_sysbus(qemu_irq irq, int dma_chann,

View File

@ -120,15 +120,17 @@ type_init(serial_register_types)
bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr)
{
ISADevice *dev;
DeviceState *dev;
ISADevice *isadev;
dev = isa_try_create(bus, TYPE_ISA_SERIAL);
if (!dev) {
isadev = isa_try_create(bus, TYPE_ISA_SERIAL);
if (!isadev) {
return false;
}
qdev_prop_set_uint32(&dev->qdev, "index", index);
qdev_prop_set_chr(&dev->qdev, "chardev", chr);
if (qdev_init(&dev->qdev) < 0) {
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;

View File

@ -1095,7 +1095,7 @@ DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus)
dev = pcidev ? &pcidev->qdev : NULL;
} else if (isa_bus) {
ISADevice *isadev = isa_vga_init(isa_bus);
dev = isadev ? &isadev->qdev : NULL;
dev = isadev ? DEVICE(isadev) : NULL;
}
return dev;
}
@ -1182,7 +1182,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
}
if (hpet) {
/* connect PIT to output control line of the HPET */
qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(&pit->qdev, 0));
qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(DEVICE(pit), 0));
}
pcspk_init(isa_bus, pit);
}
@ -1210,8 +1210,9 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
vmmouse = NULL;
}
if (vmmouse) {
qdev_prop_set_ptr(&vmmouse->qdev, "ps2_mouse", i8042);
qdev_init_nofail(&vmmouse->qdev);
DeviceState *dev = DEVICE(vmmouse);
qdev_prop_set_ptr(dev, "ps2_mouse", i8042);
qdev_init_nofail(dev);
}
port92 = isa_create_simple(isa_bus, "port92");
port92_init(port92, &a20_line[1]);

View File

@ -199,7 +199,7 @@ static void pc_init1(MemoryRegion *system_memory,
dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
ide_irq[i],
hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
idebus[i] = qdev_get_child_bus(&dev->qdev, "ide.0");
idebus[i] = qdev_get_child_bus(DEVICE(dev), "ide.0");
}
}

View File

@ -80,16 +80,18 @@ static void pic_common_realize(DeviceState *dev, Error **errp)
ISADevice *i8259_init_chip(const char *name, ISABus *bus, bool master)
{
ISADevice *dev;
DeviceState *dev;
ISADevice *isadev;
dev = isa_create(bus, name);
qdev_prop_set_uint32(&dev->qdev, "iobase", master ? 0x20 : 0xa0);
qdev_prop_set_uint32(&dev->qdev, "elcr_addr", master ? 0x4d0 : 0x4d1);
qdev_prop_set_uint8(&dev->qdev, "elcr_mask", master ? 0xf8 : 0xde);
qdev_prop_set_bit(&dev->qdev, "master", master);
qdev_init_nofail(&dev->qdev);
isadev = isa_create(bus, name);
dev = DEVICE(isadev);
qdev_prop_set_uint32(dev, "iobase", master ? 0x20 : 0xa0);
qdev_prop_set_uint32(dev, "elcr_addr", master ? 0x4d0 : 0x4d1);
qdev_prop_set_uint8(dev, "elcr_mask", master ? 0xf8 : 0xde);
qdev_prop_set_bit(dev, "master", master);
qdev_init_nofail(dev);
return dev;
return isadev;
}
static const VMStateDescription vmstate_pic_common = {

View File

@ -201,7 +201,7 @@ static void i82378_init(DeviceState *dev, I82378State *s)
/* 2 82C37 (dma) */
isa = isa_create_simple(isabus, "i82374");
qdev_connect_gpio_out(&isa->qdev, 0, s->out[1]);
qdev_connect_gpio_out(DEVICE(isa), 0, s->out[1]);
/* timer */
isa_create_simple(isabus, "mc146818rtc");

View File

@ -156,7 +156,7 @@ ISADevice *isa_create_simple(ISABus *bus, const char *name)
ISADevice *dev;
dev = isa_create(bus, name);
qdev_init_nofail(&dev->qdev);
qdev_init_nofail(DEVICE(dev));
return dev;
}
@ -240,7 +240,7 @@ static void isabus_register_types(void)
static char *isabus_get_fw_dev_path(DeviceState *dev)
{
ISADevice *d = (ISADevice*)dev;
ISADevice *d = ISA_DEVICE(dev);
char path[40];
int off;

View File

@ -605,8 +605,9 @@ static void ppc_prep_init(QEMUMachineInitArgs *args)
/* Super I/O (parallel + serial ports) */
isa = isa_create(isa_bus, TYPE_PC87312);
qdev_prop_set_uint8(&isa->qdev, "config", 13); /* fdc, ser0, ser1, par0 */
qdev_init_nofail(&isa->qdev);
dev = DEVICE(isa);
qdev_prop_set_uint8(dev, "config", 13); /* fdc, ser0, ser1, par0 */
qdev_init_nofail(dev);
/* Register 8 MB of ISA IO space (needed for non-contiguous map) */
memory_region_init_io(PPC_io_memory, &PPC_prep_io_ops, sysctrl,

View File

@ -32,14 +32,16 @@
static inline ISADevice *pcspk_init(ISABus *bus, ISADevice *pit)
{
ISADevice *dev;
DeviceState *dev;
ISADevice *isadev;
dev = isa_create(bus, TYPE_PC_SPEAKER);
qdev_prop_set_uint32(&dev->qdev, "iobase", 0x61);
qdev_prop_set_ptr(&dev->qdev, "pit", pit);
qdev_init_nofail(&dev->qdev);
isadev = isa_create(bus, TYPE_PC_SPEAKER);
dev = DEVICE(isadev);
qdev_prop_set_uint32(dev, "iobase", 0x61);
qdev_prop_set_ptr(dev, "pit", pit);
qdev_init_nofail(dev);
return dev;
return isadev;
}
#endif /* !HW_PCSPK_H */

View File

@ -14,15 +14,17 @@
/* parallel.c */
static inline bool parallel_init(ISABus *bus, int index, CharDriverState *chr)
{
ISADevice *dev;
DeviceState *dev;
ISADevice *isadev;
dev = isa_try_create(bus, "isa-parallel");
if (!dev) {
isadev = isa_try_create(bus, "isa-parallel");
if (!isadev) {
return false;
}
qdev_prop_set_uint32(&dev->qdev, "index", index);
qdev_prop_set_chr(&dev->qdev, "chardev", chr);
if (qdev_init(&dev->qdev) < 0) {
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;
@ -155,18 +157,20 @@ int isa_vga_mm_init(hwaddr vram_base,
/* ne2000.c */
static inline bool isa_ne2000_init(ISABus *bus, int base, int irq, NICInfo *nd)
{
ISADevice *dev;
DeviceState *dev;
ISADevice *isadev;
qemu_check_nic_model(nd, "ne2k_isa");
dev = isa_try_create(bus, "ne2k_isa");
if (!dev) {
isadev = isa_try_create(bus, "ne2k_isa");
if (!isadev) {
return false;
}
qdev_prop_set_uint32(&dev->qdev, "iobase", base);
qdev_prop_set_uint32(&dev->qdev, "irq", irq);
qdev_set_nic_properties(&dev->qdev, nd);
qdev_init_nofail(&dev->qdev);
dev = DEVICE(isadev);
qdev_prop_set_uint32(dev, "iobase", base);
qdev_prop_set_uint32(dev, "irq", irq);
qdev_set_nic_properties(dev, nd);
qdev_init_nofail(dev);
return true;
}

View File

@ -34,7 +34,10 @@ struct ISABus {
};
struct ISADevice {
DeviceState qdev;
/*< private >*/
DeviceState parent_obj;
/*< public >*/
uint32_t isairq[2];
int nirqs;
int ioport_id;