static void cg3_realizefn(DeviceState *dev, Error **errp) { SysBusDevice *sbd = SYS_BUS_DEVICE(dev); CG3State *s = CG3(dev); int ret; char *fcode_filename; /* FCode ROM */ vmstate_register_ram_global(&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, FCODE_MAX_ROM_SIZE); if (ret < 0 || ret > FCODE_MAX_ROM_SIZE) { error_report("cg3: could not load prom '%s'", CG3_ROM_FILE); } } memory_region_init_ram(&s->vram_mem, NULL, "cg3.vram", s->vram_size, &error_abort); vmstate_register_ram_global(&s->vram_mem); sysbus_init_mmio(sbd, &s->vram_mem); sysbus_init_irq(sbd, &s->irq); s->con = graphic_console_init(DEVICE(dev), 0, &cg3_ops, s); qemu_console_resize(s->con, s->width, s->height); }
static void cg3_reset(DeviceState *d) { CG3State *s = CG3(d); /* Initialize palette */ memset(s->r, 0, 256); memset(s->g, 0, 256); memset(s->b, 0, 256); s->dac_state = 0; s->full_update = 1; qemu_irq_lower(s->irq); }
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); }