aboutsummaryrefslogtreecommitdiff
path: root/hw/tcx.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/tcx.c')
-rw-r--r--hw/tcx.c65
1 files changed, 48 insertions, 17 deletions
diff --git a/hw/tcx.c b/hw/tcx.c
index 76acae809d..c5925240b5 100644
--- a/hw/tcx.c
+++ b/hw/tcx.c
@@ -26,6 +26,7 @@
#include "console.h"
#include "pixel_ops.h"
#include "sysbus.h"
+#include "qdev-addr.h"
#define MAXX 1024
#define MAXY 768
@@ -41,6 +42,7 @@ typedef struct TCXState {
uint8_t *vram;
uint32_t *vram24, *cplane;
ram_addr_t vram_offset, vram24_offset, cplane_offset;
+ uint32_t vram_size;
uint16_t width, height, depth;
uint8_t r[256], g[256], b[256];
uint32_t palette[256];
@@ -520,11 +522,11 @@ void tcx_init(target_phys_addr_t addr, int vram_size, int width, int height,
SysBusDevice *s;
dev = qdev_create(NULL, "SUNW,tcx");
- qdev_set_prop_int(dev, "addr", addr);
- qdev_set_prop_int(dev, "vram_size", vram_size);
- qdev_set_prop_int(dev, "width", width);
- qdev_set_prop_int(dev, "height", height);
- qdev_set_prop_int(dev, "depth", depth);
+ qdev_prop_set_taddr(dev, "addr", addr);
+ qdev_prop_set_uint32(dev, "vram_size", vram_size);
+ qdev_prop_set_uint16(dev, "width", width);
+ qdev_prop_set_uint16(dev, "height", height);
+ qdev_prop_set_uint16(dev, "depth", depth);
qdev_init(dev);
s = sysbus_from_qdev(dev);
/* 8-bit plane */
@@ -551,22 +553,16 @@ static void tcx_init1(SysBusDevice *dev)
TCXState *s = FROM_SYSBUS(TCXState, dev);
int io_memory, dummy_memory;
ram_addr_t vram_offset;
- int size, vram_size;
+ int size;
uint8_t *vram_base;
- vram_size = qdev_get_prop_int(&dev->qdev, "vram_size", -1);
-
- vram_offset = qemu_ram_alloc(vram_size * (1 + 4 + 4));
+ vram_offset = qemu_ram_alloc(s->vram_size * (1 + 4 + 4));
vram_base = qemu_get_ram_ptr(vram_offset);
- s->addr = qdev_get_prop_int(&dev->qdev, "addr", -1);
s->vram_offset = vram_offset;
- s->width = qdev_get_prop_int(&dev->qdev, "width", -1);
- s->height = qdev_get_prop_int(&dev->qdev, "height", -1);
- s->depth = qdev_get_prop_int(&dev->qdev, "depth", -1);
/* 8-bit plane */
s->vram = vram_base;
- size = vram_size;
+ size = s->vram_size;
sysbus_init_mmio(dev, size, s->vram_offset);
vram_offset += size;
vram_base += size;
@@ -584,7 +580,7 @@ static void tcx_init1(SysBusDevice *dev)
if (s->depth == 24) {
/* 24-bit plane */
- size = vram_size * 4;
+ size = s->vram_size * 4;
s->vram24 = (uint32_t *)vram_base;
s->vram24_offset = vram_offset;
sysbus_init_mmio(dev, size, vram_offset);
@@ -592,7 +588,7 @@ static void tcx_init1(SysBusDevice *dev)
vram_base += size;
/* Control plane */
- size = vram_size * 4;
+ size = s->vram_size * 4;
s->cplane = (uint32_t *)vram_base;
s->cplane_offset = vram_offset;
sysbus_init_mmio(dev, size, vram_offset);
@@ -678,9 +674,44 @@ static void tcx24_screen_dump(void *opaque, const char *filename)
return;
}
+static SysBusDeviceInfo tcx_info = {
+ .init = tcx_init1,
+ .qdev.name = "SUNW,tcx",
+ .qdev.size = sizeof(TCXState),
+ .qdev.props = (Property[]) {
+ {
+ .name = "addr",
+ .info = &qdev_prop_taddr,
+ .offset = offsetof(TCXState, addr),
+ .defval = (target_phys_addr_t[]) { -1 },
+ },{
+ .name = "vram_size",
+ .info = &qdev_prop_hex32,
+ .offset = offsetof(TCXState, vram_size),
+ .defval = (uint32_t[]) { -1 },
+ },{
+ .name = "width",
+ .info = &qdev_prop_uint16,
+ .offset = offsetof(TCXState, width),
+ .defval = (uint16_t[]) { -1 },
+ },{
+ .name = "height",
+ .info = &qdev_prop_uint16,
+ .offset = offsetof(TCXState, height),
+ .defval = (uint16_t[]) { -1 },
+ },{
+ .name = "depth",
+ .info = &qdev_prop_uint16,
+ .offset = offsetof(TCXState, depth),
+ .defval = (uint16_t[]) { -1 },
+ },
+ {/* end of list */}
+ }
+};
+
static void tcx_register_devices(void)
{
- sysbus_register_dev("SUNW,tcx", sizeof(TCXState), tcx_init1);
+ sysbus_register_withprop(&tcx_info);
}
device_init(tcx_register_devices)