diff options
author | Andreas Färber <afaerber@suse.de> | 2012-11-25 22:54:47 +0100 |
---|---|---|
committer | Andreas Färber <afaerber@suse.de> | 2013-06-07 14:55:24 +0200 |
commit | d2628b7d18521dacd3d4d246602e9bb3fc2a43dd (patch) | |
tree | 5133522cc12f037f226839917bdbf441b8f7417a /hw/intc | |
parent | 49fdb0c1c42f02ab163206f34fcf59bb0815afa2 (diff) | |
download | qemu-d2628b7d18521dacd3d4d246602e9bb3fc2a43dd.zip qemu-d2628b7d18521dacd3d4d246602e9bb3fc2a43dd.tar.gz qemu-d2628b7d18521dacd3d4d246602e9bb3fc2a43dd.tar.bz2 |
i8259: Convert PICCommonState to use QOM realizefn
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 <afaerber@suse.de>
Diffstat (limited to 'hw/intc')
-rw-r--r-- | hw/intc/i8259.c | 25 | ||||
-rw-r--r-- | hw/intc/i8259_common.c | 3 |
2 files changed, 21 insertions, 7 deletions
diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c index 1b513ff..192a0ba 100644 --- a/hw/intc/i8259.c +++ b/hw/intc/i8259.c @@ -42,6 +42,18 @@ //#define DEBUG_IRQ_COUNT #define TYPE_I8259 "isa-i8259" +#define PIC_CLASS(class) OBJECT_CLASS_CHECK(PICClass, (class), TYPE_I8259) +#define PIC_GET_CLASS(obj) OBJECT_GET_CLASS(PICClass, (obj), TYPE_I8259) + +/** + * PICClass: + * @parent_realize: The parent's realizefn. + */ +typedef struct PICClass { + PICCommonClass parent_class; + + DeviceRealize parent_realize; +} PICClass; #if defined(DEBUG_PIC) || defined(DEBUG_IRQ_COUNT) static int irq_level[16]; @@ -400,15 +412,18 @@ static const MemoryRegionOps pic_elcr_ioport_ops = { }, }; -static void pic_init(PICCommonState *s) +static void pic_realize(DeviceState *dev, Error **err) { - DeviceState *dev = DEVICE(s); + PICCommonState *s = PIC_COMMON(dev); + PICClass *pc = PIC_GET_CLASS(dev); memory_region_init_io(&s->base_io, &pic_base_ioport_ops, s, "pic", 2); memory_region_init_io(&s->elcr_io, &pic_elcr_ioport_ops, s, "elcr", 1); qdev_init_gpio_out(dev, s->int_out, ARRAY_SIZE(s->int_out)); qdev_init_gpio_in(dev, pic_set_irq, 8); + + pc->parent_realize(dev, err); } void pic_info(Monitor *mon, const QDict *qdict) @@ -481,10 +496,11 @@ qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq) static void i8259_class_init(ObjectClass *klass, void *data) { - PICCommonClass *k = PIC_COMMON_CLASS(klass); + PICClass *k = PIC_CLASS(klass); DeviceClass *dc = DEVICE_CLASS(klass); - k->init = pic_init; + k->parent_realize = dc->realize; + dc->realize = pic_realize; dc->reset = pic_reset; } @@ -493,6 +509,7 @@ static const TypeInfo i8259_info = { .instance_size = sizeof(PICCommonState), .parent = TYPE_PIC_COMMON, .class_init = i8259_class_init, + .class_size = sizeof(PICClass), }; static void pic_register_types(void) diff --git a/hw/intc/i8259_common.c b/hw/intc/i8259_common.c index a3dee38..7613547 100644 --- a/hw/intc/i8259_common.c +++ b/hw/intc/i8259_common.c @@ -69,9 +69,6 @@ static int pic_dispatch_post_load(void *opaque, int version_id) static void pic_common_realize(DeviceState *dev, Error **errp) { PICCommonState *s = PIC_COMMON(dev); - PICCommonClass *info = PIC_COMMON_GET_CLASS(s); - - info->init(s); isa_register_ioport(NULL, &s->base_io, s->iobase); if (s->elcr_addr != -1) { |