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/i386 | |
parent | 49fdb0c1c42f02ab163206f34fcf59bb0815afa2 (diff) |
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/i386')
-rw-r--r-- | hw/i386/kvm/i8259.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/hw/i386/kvm/i8259.c b/hw/i386/kvm/i8259.c index 0bfbe34c86..125022422a 100644 --- a/hw/i386/kvm/i8259.c +++ b/hw/i386/kvm/i8259.c @@ -14,6 +14,20 @@ #include "sysemu/kvm.h" #define TYPE_KVM_I8259 "kvm-i8259" +#define KVM_PIC_CLASS(class) \ + OBJECT_CLASS_CHECK(KVMPICClass, (class), TYPE_KVM_I8259) +#define KVM_PIC_GET_CLASS(obj) \ + OBJECT_GET_CLASS(KVMPICClass, (obj), TYPE_KVM_I8259) + +/** + * KVMPICClass: + * @parent_realize: The parent's realizefn. + */ +typedef struct KVMPICClass { + PICCommonClass parent_class; + + DeviceRealize parent_realize; +} KVMPICClass; static void kvm_pic_get(PICCommonState *s) { @@ -100,10 +114,15 @@ static void kvm_pic_set_irq(void *opaque, int irq, int level) apic_report_irq_delivered(delivered); } -static void kvm_pic_init(PICCommonState *s) +static void kvm_pic_realize(DeviceState *dev, Error **errp) { + PICCommonState *s = PIC_COMMON(dev); + KVMPICClass *kpc = KVM_PIC_GET_CLASS(dev); + memory_region_init_reservation(&s->base_io, "kvm-pic", 2); memory_region_init_reservation(&s->elcr_io, "kvm-elcr", 1); + + kpc->parent_realize(dev, errp); } qemu_irq *kvm_i8259_init(ISABus *bus) @@ -116,11 +135,13 @@ qemu_irq *kvm_i8259_init(ISABus *bus) static void kvm_i8259_class_init(ObjectClass *klass, void *data) { + KVMPICClass *kpc = KVM_PIC_CLASS(klass); PICCommonClass *k = PIC_COMMON_CLASS(klass); DeviceClass *dc = DEVICE_CLASS(klass); dc->reset = kvm_pic_reset; - k->init = kvm_pic_init; + kpc->parent_realize = dc->realize; + dc->realize = kvm_pic_realize; k->pre_save = kvm_pic_get; k->post_load = kvm_pic_put; } @@ -130,6 +151,7 @@ static const TypeInfo kvm_i8259_info = { .parent = TYPE_PIC_COMMON, .instance_size = sizeof(PICCommonState), .class_init = kvm_i8259_class_init, + .class_size = sizeof(KVMPICClass), }; static void kvm_pic_register_types(void) |