aboutsummaryrefslogtreecommitdiff
path: root/hw/display/cg3.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/display/cg3.c')
-rw-r--r--hw/display/cg3.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/hw/display/cg3.c b/hw/display/cg3.c
index 1c199ab369..b271faaa48 100644
--- a/hw/display/cg3.c
+++ b/hw/display/cg3.c
@@ -24,13 +24,19 @@
*/
#include "qemu/osdep.h"
+#include "qemu/datadir.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "qemu/error-report.h"
#include "ui/console.h"
#include "hw/sysbus.h"
+#include "migration/vmstate.h"
+#include "hw/irq.h"
#include "hw/loader.h"
+#include "hw/qdev-properties.h"
#include "qemu/log.h"
+#include "qemu/module.h"
+#include "trace.h"
+#include "qom/object.h"
/* Change to 1 to enable debugging */
#define DEBUG_CG3 0
@@ -59,16 +65,10 @@
#define CG3_VRAM_SIZE 0x100000
#define CG3_VRAM_OFFSET 0x800000
-#define DPRINTF(fmt, ...) do { \
- if (DEBUG_CG3) { \
- printf("CG3: " fmt , ## __VA_ARGS__); \
- } \
-} while (0)
-
#define TYPE_CG3 "cgthree"
-#define CG3(obj) OBJECT_CHECK(CG3State, (obj), TYPE_CG3)
+OBJECT_DECLARE_SIMPLE_TYPE(CG3State, CG3)
-typedef struct CG3State {
+struct CG3State {
SysBusDevice parent_obj;
QemuConsole *con;
@@ -83,7 +83,7 @@ typedef struct CG3State {
uint8_t r[256], g[256], b[256];
uint16_t width, height, depth;
uint8_t dac_index, dac_state;
-} CG3State;
+};
static void cg3_update_display(void *opaque)
{
@@ -191,7 +191,8 @@ static uint64_t cg3_reg_read(void *opaque, hwaddr addr, unsigned size)
val = 0;
break;
}
- DPRINTF("read %02x from reg %" HWADDR_PRIx "\n", val, addr);
+ trace_cg3_read(addr, val, size);
+
return val;
}
@@ -202,9 +203,7 @@ static void cg3_reg_write(void *opaque, hwaddr addr, uint64_t val,
uint8_t regval;
int i;
- DPRINTF("write %" PRIx64 " to reg %" HWADDR_PRIx " size %d\n",
- val, addr, size);
-
+ trace_cg3_write(addr, val, size);
switch (addr) {
case CG3_REG_BT458_ADDR:
s->dac_index = val;
@@ -283,9 +282,8 @@ static void cg3_initfn(Object *obj)
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
CG3State *s = CG3(obj);
- memory_region_init_ram_nomigrate(&s->rom, obj, "cg3.prom", FCODE_MAX_ROM_SIZE,
- &error_fatal);
- memory_region_set_readonly(&s->rom, true);
+ memory_region_init_rom_nomigrate(&s->rom, obj, "cg3.prom",
+ FCODE_MAX_ROM_SIZE, &error_fatal);
sysbus_init_mmio(sbd, &s->rom);
memory_region_init_io(&s->reg, obj, &cg3_reg_ops, s, "cg3.reg",
@@ -307,7 +305,7 @@ static void cg3_realizefn(DeviceState *dev, Error **errp)
ret = load_image_mr(fcode_filename, &s->rom);
g_free(fcode_filename);
if (ret < 0 || ret > FCODE_MAX_ROM_SIZE) {
- error_report("cg3: could not load prom '%s'", CG3_ROM_FILE);
+ warn_report("cg3: could not load prom '%s'", CG3_ROM_FILE);
}
}
@@ -318,7 +316,7 @@ static void cg3_realizefn(DeviceState *dev, Error **errp)
sysbus_init_irq(sbd, &s->irq);
- s->con = graphic_console_init(DEVICE(dev), 0, &cg3_ops, s);
+ s->con = graphic_console_init(dev, 0, &cg3_ops, s);
qemu_console_resize(s->con, s->width, s->height);
}
@@ -336,7 +334,7 @@ static const VMStateDescription vmstate_cg3 = {
.version_id = 1,
.minimum_version_id = 1,
.post_load = vmstate_cg3_post_load,
- .fields = (VMStateField[]) {
+ .fields = (const VMStateField[]) {
VMSTATE_UINT16(height, CG3State),
VMSTATE_UINT16(width, CG3State),
VMSTATE_UINT16(depth, CG3State),
@@ -378,7 +376,7 @@ static void cg3_class_init(ObjectClass *klass, void *data)
dc->realize = cg3_realizefn;
dc->reset = cg3_reset;
dc->vmsd = &vmstate_cg3;
- dc->props = cg3_properties;
+ device_class_set_props(dc, cg3_properties);
}
static const TypeInfo cg3_info = {