mirror of https://gitee.com/openkylin/qemu.git
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:
parent
2ae0e48d5f
commit
4a17cc4f28
|
@ -2022,22 +2022,24 @@ static int fdctrl_connect_drives(FDCtrl *fdctrl)
|
||||||
|
|
||||||
ISADevice *fdctrl_init_isa(ISABus *bus, DriveInfo **fds)
|
ISADevice *fdctrl_init_isa(ISABus *bus, DriveInfo **fds)
|
||||||
{
|
{
|
||||||
ISADevice *dev;
|
DeviceState *dev;
|
||||||
|
ISADevice *isadev;
|
||||||
|
|
||||||
dev = isa_try_create(bus, TYPE_ISA_FDC);
|
isadev = isa_try_create(bus, TYPE_ISA_FDC);
|
||||||
if (!dev) {
|
if (!isadev) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
dev = DEVICE(isadev);
|
||||||
|
|
||||||
if (fds[0]) {
|
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]) {
|
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,
|
void fdctrl_init_sysbus(qemu_irq irq, int dma_chann,
|
||||||
|
|
|
@ -120,15 +120,17 @@ type_init(serial_register_types)
|
||||||
|
|
||||||
bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr)
|
bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr)
|
||||||
{
|
{
|
||||||
ISADevice *dev;
|
DeviceState *dev;
|
||||||
|
ISADevice *isadev;
|
||||||
|
|
||||||
dev = isa_try_create(bus, TYPE_ISA_SERIAL);
|
isadev = isa_try_create(bus, TYPE_ISA_SERIAL);
|
||||||
if (!dev) {
|
if (!isadev) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
qdev_prop_set_uint32(&dev->qdev, "index", index);
|
dev = DEVICE(isadev);
|
||||||
qdev_prop_set_chr(&dev->qdev, "chardev", chr);
|
qdev_prop_set_uint32(dev, "index", index);
|
||||||
if (qdev_init(&dev->qdev) < 0) {
|
qdev_prop_set_chr(dev, "chardev", chr);
|
||||||
|
if (qdev_init(dev) < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1095,7 +1095,7 @@ DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus)
|
||||||
dev = pcidev ? &pcidev->qdev : NULL;
|
dev = pcidev ? &pcidev->qdev : NULL;
|
||||||
} else if (isa_bus) {
|
} else if (isa_bus) {
|
||||||
ISADevice *isadev = isa_vga_init(isa_bus);
|
ISADevice *isadev = isa_vga_init(isa_bus);
|
||||||
dev = isadev ? &isadev->qdev : NULL;
|
dev = isadev ? DEVICE(isadev) : NULL;
|
||||||
}
|
}
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
@ -1182,7 +1182,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
|
||||||
}
|
}
|
||||||
if (hpet) {
|
if (hpet) {
|
||||||
/* connect PIT to output control line of the 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);
|
pcspk_init(isa_bus, pit);
|
||||||
}
|
}
|
||||||
|
@ -1210,8 +1210,9 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
|
||||||
vmmouse = NULL;
|
vmmouse = NULL;
|
||||||
}
|
}
|
||||||
if (vmmouse) {
|
if (vmmouse) {
|
||||||
qdev_prop_set_ptr(&vmmouse->qdev, "ps2_mouse", i8042);
|
DeviceState *dev = DEVICE(vmmouse);
|
||||||
qdev_init_nofail(&vmmouse->qdev);
|
qdev_prop_set_ptr(dev, "ps2_mouse", i8042);
|
||||||
|
qdev_init_nofail(dev);
|
||||||
}
|
}
|
||||||
port92 = isa_create_simple(isa_bus, "port92");
|
port92 = isa_create_simple(isa_bus, "port92");
|
||||||
port92_init(port92, &a20_line[1]);
|
port92_init(port92, &a20_line[1]);
|
||||||
|
|
|
@ -199,7 +199,7 @@ static void pc_init1(MemoryRegion *system_memory,
|
||||||
dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
|
dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
|
||||||
ide_irq[i],
|
ide_irq[i],
|
||||||
hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
|
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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 *i8259_init_chip(const char *name, ISABus *bus, bool master)
|
||||||
{
|
{
|
||||||
ISADevice *dev;
|
DeviceState *dev;
|
||||||
|
ISADevice *isadev;
|
||||||
|
|
||||||
dev = isa_create(bus, name);
|
isadev = isa_create(bus, name);
|
||||||
qdev_prop_set_uint32(&dev->qdev, "iobase", master ? 0x20 : 0xa0);
|
dev = DEVICE(isadev);
|
||||||
qdev_prop_set_uint32(&dev->qdev, "elcr_addr", master ? 0x4d0 : 0x4d1);
|
qdev_prop_set_uint32(dev, "iobase", master ? 0x20 : 0xa0);
|
||||||
qdev_prop_set_uint8(&dev->qdev, "elcr_mask", master ? 0xf8 : 0xde);
|
qdev_prop_set_uint32(dev, "elcr_addr", master ? 0x4d0 : 0x4d1);
|
||||||
qdev_prop_set_bit(&dev->qdev, "master", master);
|
qdev_prop_set_uint8(dev, "elcr_mask", master ? 0xf8 : 0xde);
|
||||||
qdev_init_nofail(&dev->qdev);
|
qdev_prop_set_bit(dev, "master", master);
|
||||||
|
qdev_init_nofail(dev);
|
||||||
|
|
||||||
return dev;
|
return isadev;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const VMStateDescription vmstate_pic_common = {
|
static const VMStateDescription vmstate_pic_common = {
|
||||||
|
|
|
@ -201,7 +201,7 @@ static void i82378_init(DeviceState *dev, I82378State *s)
|
||||||
|
|
||||||
/* 2 82C37 (dma) */
|
/* 2 82C37 (dma) */
|
||||||
isa = isa_create_simple(isabus, "i82374");
|
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 */
|
/* timer */
|
||||||
isa_create_simple(isabus, "mc146818rtc");
|
isa_create_simple(isabus, "mc146818rtc");
|
||||||
|
|
|
@ -156,7 +156,7 @@ ISADevice *isa_create_simple(ISABus *bus, const char *name)
|
||||||
ISADevice *dev;
|
ISADevice *dev;
|
||||||
|
|
||||||
dev = isa_create(bus, name);
|
dev = isa_create(bus, name);
|
||||||
qdev_init_nofail(&dev->qdev);
|
qdev_init_nofail(DEVICE(dev));
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ static void isabus_register_types(void)
|
||||||
|
|
||||||
static char *isabus_get_fw_dev_path(DeviceState *dev)
|
static char *isabus_get_fw_dev_path(DeviceState *dev)
|
||||||
{
|
{
|
||||||
ISADevice *d = (ISADevice*)dev;
|
ISADevice *d = ISA_DEVICE(dev);
|
||||||
char path[40];
|
char path[40];
|
||||||
int off;
|
int off;
|
||||||
|
|
||||||
|
|
|
@ -605,8 +605,9 @@ static void ppc_prep_init(QEMUMachineInitArgs *args)
|
||||||
|
|
||||||
/* Super I/O (parallel + serial ports) */
|
/* Super I/O (parallel + serial ports) */
|
||||||
isa = isa_create(isa_bus, TYPE_PC87312);
|
isa = isa_create(isa_bus, TYPE_PC87312);
|
||||||
qdev_prop_set_uint8(&isa->qdev, "config", 13); /* fdc, ser0, ser1, par0 */
|
dev = DEVICE(isa);
|
||||||
qdev_init_nofail(&isa->qdev);
|
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) */
|
/* Register 8 MB of ISA IO space (needed for non-contiguous map) */
|
||||||
memory_region_init_io(PPC_io_memory, &PPC_prep_io_ops, sysctrl,
|
memory_region_init_io(PPC_io_memory, &PPC_prep_io_ops, sysctrl,
|
||||||
|
|
|
@ -32,14 +32,16 @@
|
||||||
|
|
||||||
static inline ISADevice *pcspk_init(ISABus *bus, ISADevice *pit)
|
static inline ISADevice *pcspk_init(ISABus *bus, ISADevice *pit)
|
||||||
{
|
{
|
||||||
ISADevice *dev;
|
DeviceState *dev;
|
||||||
|
ISADevice *isadev;
|
||||||
|
|
||||||
dev = isa_create(bus, TYPE_PC_SPEAKER);
|
isadev = isa_create(bus, TYPE_PC_SPEAKER);
|
||||||
qdev_prop_set_uint32(&dev->qdev, "iobase", 0x61);
|
dev = DEVICE(isadev);
|
||||||
qdev_prop_set_ptr(&dev->qdev, "pit", pit);
|
qdev_prop_set_uint32(dev, "iobase", 0x61);
|
||||||
qdev_init_nofail(&dev->qdev);
|
qdev_prop_set_ptr(dev, "pit", pit);
|
||||||
|
qdev_init_nofail(dev);
|
||||||
|
|
||||||
return dev;
|
return isadev;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !HW_PCSPK_H */
|
#endif /* !HW_PCSPK_H */
|
||||||
|
|
|
@ -14,15 +14,17 @@
|
||||||
/* parallel.c */
|
/* parallel.c */
|
||||||
static inline bool parallel_init(ISABus *bus, int index, CharDriverState *chr)
|
static inline bool parallel_init(ISABus *bus, int index, CharDriverState *chr)
|
||||||
{
|
{
|
||||||
ISADevice *dev;
|
DeviceState *dev;
|
||||||
|
ISADevice *isadev;
|
||||||
|
|
||||||
dev = isa_try_create(bus, "isa-parallel");
|
isadev = isa_try_create(bus, "isa-parallel");
|
||||||
if (!dev) {
|
if (!isadev) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
qdev_prop_set_uint32(&dev->qdev, "index", index);
|
dev = DEVICE(isadev);
|
||||||
qdev_prop_set_chr(&dev->qdev, "chardev", chr);
|
qdev_prop_set_uint32(dev, "index", index);
|
||||||
if (qdev_init(&dev->qdev) < 0) {
|
qdev_prop_set_chr(dev, "chardev", chr);
|
||||||
|
if (qdev_init(dev) < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -155,18 +157,20 @@ int isa_vga_mm_init(hwaddr vram_base,
|
||||||
/* ne2000.c */
|
/* ne2000.c */
|
||||||
static inline bool isa_ne2000_init(ISABus *bus, int base, int irq, NICInfo *nd)
|
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");
|
qemu_check_nic_model(nd, "ne2k_isa");
|
||||||
|
|
||||||
dev = isa_try_create(bus, "ne2k_isa");
|
isadev = isa_try_create(bus, "ne2k_isa");
|
||||||
if (!dev) {
|
if (!isadev) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
qdev_prop_set_uint32(&dev->qdev, "iobase", base);
|
dev = DEVICE(isadev);
|
||||||
qdev_prop_set_uint32(&dev->qdev, "irq", irq);
|
qdev_prop_set_uint32(dev, "iobase", base);
|
||||||
qdev_set_nic_properties(&dev->qdev, nd);
|
qdev_prop_set_uint32(dev, "irq", irq);
|
||||||
qdev_init_nofail(&dev->qdev);
|
qdev_set_nic_properties(dev, nd);
|
||||||
|
qdev_init_nofail(dev);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,10 @@ struct ISABus {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ISADevice {
|
struct ISADevice {
|
||||||
DeviceState qdev;
|
/*< private >*/
|
||||||
|
DeviceState parent_obj;
|
||||||
|
/*< public >*/
|
||||||
|
|
||||||
uint32_t isairq[2];
|
uint32_t isairq[2];
|
||||||
int nirqs;
|
int nirqs;
|
||||||
int ioport_id;
|
int ioport_id;
|
||||||
|
|
Loading…
Reference in New Issue