From db895a1e6a97e919f9b86d60c969377357b05066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sun, 25 Nov 2012 02:37:14 +0100 Subject: isa: Use realizefn for ISADevice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Drop ISADeviceClass::init and the resulting no-op initfn and let children implement their own realizefn. Adapt error handling. Split off an instance_init where sensible. Signed-off-by: Andreas Färber --- include/hw/char/serial.h | 2 +- include/hw/isa/isa.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'include') diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h index bca79f17b5..c15354ae05 100644 --- a/include/hw/char/serial.h +++ b/include/hw/char/serial.h @@ -83,7 +83,7 @@ struct SerialState { extern const VMStateDescription vmstate_serial; extern const MemoryRegionOps serial_io_ops; -void serial_init_core(SerialState *s); +void serial_realize_core(SerialState *s, Error **errp); void serial_exit_core(SerialState *s); void serial_set_frequency(SerialState *s, uint32_t frequency); diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h index 82da37c11d..1f6ff55605 100644 --- a/include/hw/isa/isa.h +++ b/include/hw/isa/isa.h @@ -22,7 +22,6 @@ typedef struct ISADeviceClass { DeviceClass parent_class; - int (*init)(ISADevice *dev); } ISADeviceClass; struct ISABus { -- cgit v1.2.3 From 3afe7e14a42309578d324df5fe1b303a496a8466 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sun, 25 Nov 2012 18:05:53 +0100 Subject: i8254: QOM'ify some more MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce type constant and avoid DO_UPCAST(). Prepares for PIT realizefn. Signed-off-by: Andreas Färber --- include/hw/timer/i8254.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/hw/timer/i8254.h b/include/hw/timer/i8254.h index 75bb530ad9..016f990440 100644 --- a/include/hw/timer/i8254.h +++ b/include/hw/timer/i8254.h @@ -37,18 +37,22 @@ typedef struct PITChannelInfo { int out; } PITChannelInfo; +#define TYPE_I8254 "isa-pit" + static inline ISADevice *pit_init(ISABus *bus, int base, int isa_irq, qemu_irq alt_irq) { - ISADevice *dev; + DeviceState *dev; + ISADevice *d; - dev = isa_create(bus, "isa-pit"); - qdev_prop_set_uint32(&dev->qdev, "iobase", base); - qdev_init_nofail(&dev->qdev); - qdev_connect_gpio_out(&dev->qdev, 0, - isa_irq >= 0 ? isa_get_irq(dev, isa_irq) : alt_irq); + d = isa_create(bus, TYPE_I8254); + dev = DEVICE(d); + qdev_prop_set_uint32(dev, "iobase", base); + qdev_init_nofail(dev); + qdev_connect_gpio_out(dev, 0, + isa_irq >= 0 ? isa_get_irq(d, isa_irq) : alt_irq); - return dev; + return d; } static inline ISADevice *kvm_pit_init(ISABus *bus, int base) -- cgit v1.2.3 From 58cd986422d7353e7fac56969ac59daab3cdca67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sun, 25 Nov 2012 18:13:38 +0100 Subject: kvm/i8254: QOM'ify some more MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce type constant and cast macro to obsolete DO_UPCAST(). Prepares for PIT realizefn. Signed-off-by: Andreas Färber --- include/hw/timer/i8254.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/hw/timer/i8254.h b/include/hw/timer/i8254.h index 016f990440..434903348c 100644 --- a/include/hw/timer/i8254.h +++ b/include/hw/timer/i8254.h @@ -38,6 +38,7 @@ typedef struct PITChannelInfo { } PITChannelInfo; #define TYPE_I8254 "isa-pit" +#define TYPE_KVM_I8254 "kvm-pit" static inline ISADevice *pit_init(ISABus *bus, int base, int isa_irq, qemu_irq alt_irq) @@ -57,13 +58,15 @@ static inline ISADevice *pit_init(ISABus *bus, int base, int isa_irq, static inline ISADevice *kvm_pit_init(ISABus *bus, int base) { - ISADevice *dev; + DeviceState *dev; + ISADevice *d; - dev = isa_create(bus, "kvm-pit"); - qdev_prop_set_uint32(&dev->qdev, "iobase", base); - qdev_init_nofail(&dev->qdev); + d = isa_create(bus, TYPE_KVM_I8254); + dev = DEVICE(d); + qdev_prop_set_uint32(dev, "iobase", base); + qdev_init_nofail(dev); - return dev; + return d; } void pit_set_gate(ISADevice *dev, int channel, int val); -- cgit v1.2.3 From a15d09127b104d1c35fc22bdd65263fe62462b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sun, 25 Nov 2012 18:47:58 +0100 Subject: i8254: Convert PITCommonState to QOM realizefn MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of having the parent provide PITCommonClass::init, let the children override DeviceClass::realize themselves. This pushes the responsibility for saving and calling the parent's realizefn to the children. Signed-off-by: Andreas Färber --- include/hw/timer/i8254_internal.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/hw/timer/i8254_internal.h b/include/hw/timer/i8254_internal.h index e0cff0cf5a..61a1bfbc4e 100644 --- a/include/hw/timer/i8254_internal.h +++ b/include/hw/timer/i8254_internal.h @@ -68,7 +68,6 @@ typedef struct PITCommonState { typedef struct PITCommonClass { ISADeviceClass parent_class; - int (*init)(PITCommonState *s); void (*set_channel_gate)(PITCommonState *s, PITChannelState *sc, int val); void (*get_channel_info)(PITCommonState *s, PITChannelState *sc, PITChannelInfo *info); -- cgit v1.2.3 From d2628b7d18521dacd3d4d246602e9bb3fc2a43dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sun, 25 Nov 2012 22:54:47 +0100 Subject: i8259: Convert PICCommonState to use QOM realizefn MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of having the parent provide PICCommonClass::init, let the children override DeviceClass::realize themselves. This pushes the responsibility of saving and calling the parent's realizefn to the children. Signed-off-by: Andreas Färber --- include/hw/isa/i8259_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/hw/isa/i8259_internal.h b/include/hw/isa/i8259_internal.h index b4e757a461..cded509636 100644 --- a/include/hw/isa/i8259_internal.h +++ b/include/hw/isa/i8259_internal.h @@ -42,7 +42,7 @@ typedef struct PICCommonState PICCommonState; typedef struct PICCommonClass { ISADeviceClass parent_class; - void (*init)(PICCommonState *s); + void (*pre_save)(PICCommonState *s); void (*post_load)(PICCommonState *s); } PICCommonClass; -- cgit v1.2.3 From 2ae0e48d5fd2cb7c5bc5c392edf2dc33ac2959d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Fri, 7 Jun 2013 14:11:07 +0200 Subject: isa: QOM'ify ISABus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename its parent field and use ISA_BUS() where necessary. Signed-off-by: Andreas Färber --- include/hw/isa/isa.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h index 1f6ff55605..da731d7bc7 100644 --- a/include/hw/isa/isa.h +++ b/include/hw/isa/isa.h @@ -25,7 +25,10 @@ typedef struct ISADeviceClass { } ISADeviceClass; struct ISABus { - BusState qbus; + /*< private >*/ + BusState parent_obj; + /*< public >*/ + MemoryRegion *address_space_io; qemu_irq *irqs; }; -- cgit v1.2.3 From 4a17cc4f285d7ffe41847bf728cd88c736237416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Fri, 7 Jun 2013 13:49:13 +0200 Subject: isa: QOM'ify ISADevice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename its parent field and use DEVICE() where necessary. Signed-off-by: Andreas Färber --- include/hw/audio/pcspk.h | 14 ++++++++------ include/hw/i386/pc.h | 30 +++++++++++++++++------------- include/hw/isa/isa.h | 5 ++++- 3 files changed, 29 insertions(+), 20 deletions(-) (limited to 'include') diff --git a/include/hw/audio/pcspk.h b/include/hw/audio/pcspk.h index 7625137991..ef95dd1360 100644 --- a/include/hw/audio/pcspk.h +++ b/include/hw/audio/pcspk.h @@ -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 */ diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 61540587a4..5d883eb647 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -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; } diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h index da731d7bc7..e1bf96ca69 100644 --- a/include/hw/isa/isa.h +++ b/include/hw/isa/isa.h @@ -34,7 +34,10 @@ struct ISABus { }; struct ISADevice { - DeviceState qdev; + /*< private >*/ + DeviceState parent_obj; + /*< public >*/ + uint32_t isairq[2]; int nirqs; int ioport_id; -- cgit v1.2.3 From fef7fbc92496f5f6d2b7395263830bce15ebf410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Fri, 7 Jun 2013 14:45:17 +0200 Subject: qdev: Drop FROM_QBUS() macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use QOM cast macros I2C_BUS(), SSI_BUS(), PCI_BUS() instead. Signed-off-by: Andreas Färber --- include/hw/qdev-core.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index cf83d5471a..7fbffcbaad 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -261,8 +261,6 @@ void qbus_reset_all_fn(void *opaque); void qbus_free(BusState *bus); -#define FROM_QBUS(type, dev) DO_UPCAST(type, qbus, dev) - /* This should go away once we get rid of the NULL bus hack */ BusState *sysbus_get_default(void); -- cgit v1.2.3