diff options
author | Mark Cave-Ayland | 2014-05-24 12:42:36 +0200 |
---|---|---|
committer | Mark Cave-Ayland | 2014-06-05 21:51:19 +0200 |
commit | e09c49f40de32620e99f67a71d4508c7fe97dd84 (patch) | |
tree | 782b879e84fd692b449ad7c65d836bd7ecc397cb /hw/display | |
parent | Merge remote-tracking branch 'remotes/kvm/uq/master' into staging (diff) | |
download | qemu-e09c49f40de32620e99f67a71d4508c7fe97dd84.tar.gz qemu-e09c49f40de32620e99f67a71d4508c7fe97dd84.tar.xz qemu-e09c49f40de32620e99f67a71d4508c7fe97dd84.zip |
cg3: move initialisation from realizefn to initfn
Initialisation cleanup as suggested by Andreas.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
CC: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/display')
-rw-r--r-- | hw/display/cg3.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/hw/display/cg3.c b/hw/display/cg3.c index f5a8299e5e..cd9297defe 100644 --- a/hw/display/cg3.c +++ b/hw/display/cg3.c @@ -274,6 +274,20 @@ static const GraphicHwOps cg3_ops = { .gfx_update = cg3_update_display, }; +static void cg3_initfn(Object *obj) +{ + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); + CG3State *s = CG3(obj); + + memory_region_init_ram(&s->rom, NULL, "cg3.prom", FCODE_MAX_ROM_SIZE); + memory_region_set_readonly(&s->rom, true); + sysbus_init_mmio(sbd, &s->rom); + + memory_region_init_io(&s->reg, NULL, &cg3_reg_ops, s, "cg3.reg", + CG3_REG_SIZE); + sysbus_init_mmio(sbd, &s->reg); +} + static void cg3_realizefn(DeviceState *dev, Error **errp) { SysBusDevice *sbd = SYS_BUS_DEVICE(dev); @@ -282,11 +296,7 @@ static void cg3_realizefn(DeviceState *dev, Error **errp) char *fcode_filename; /* FCode ROM */ - memory_region_init_ram(&s->rom, NULL, "cg3.prom", FCODE_MAX_ROM_SIZE); vmstate_register_ram_global(&s->rom); - memory_region_set_readonly(&s->rom, true); - sysbus_init_mmio(sbd, &s->rom); - fcode_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, CG3_ROM_FILE); if (fcode_filename) { ret = load_image_targphys(fcode_filename, s->prom_addr, @@ -296,10 +306,6 @@ static void cg3_realizefn(DeviceState *dev, Error **errp) } } - memory_region_init_io(&s->reg, NULL, &cg3_reg_ops, s, "cg3.reg", - CG3_REG_SIZE); - sysbus_init_mmio(sbd, &s->reg); - memory_region_init_ram(&s->vram_mem, NULL, "cg3.vram", s->vram_size); vmstate_register_ram_global(&s->vram_mem); sysbus_init_mmio(sbd, &s->vram_mem); @@ -374,6 +380,7 @@ static const TypeInfo cg3_info = { .name = TYPE_CG3, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(CG3State), + .instance_init = cg3_initfn, .class_init = cg3_class_init, }; |