aboutsummaryrefslogtreecommitdiff
path: root/hw/sun4m.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2009-07-15 13:43:31 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-07-16 17:28:51 -0500
commitee6847d19be16c789b8bd4e553b7cd6701ba1245 (patch)
tree41845b3b1e8740ce97daf0582e124c6b6e0a6873 /hw/sun4m.c
parentf114784f69ec3b9af342148025de14dbd1b429a5 (diff)
downloadqemu-ee6847d19be16c789b8bd4e553b7cd6701ba1245.zip
qemu-ee6847d19be16c789b8bd4e553b7cd6701ba1245.tar.gz
qemu-ee6847d19be16c789b8bd4e553b7cd6701ba1245.tar.bz2
qdev: rework device properties.
This patch is a major overhaul of the device properties. The properties are saved directly in the device state struct now, the linked list of property values is gone. Advantages: * We don't have to maintain the list with the property values. * The value in the property list and the value actually used by the device can't go out of sync any more (used to happen for the pci.devfn == -1 case) because there is only one place where the value is stored. * A record describing the property is required now, you can't set random properties any more. There are bus-specific and device-specific properties. The former should be used for properties common to all bus drivers. Typical use case is bus addressing, i.e. pci.devfn and i2c.address. Properties have a PropertyInfo struct attached with name, size and function pointers to parse and print properties. A few common property types have PropertyInfos defined in qdev-properties.c. Drivers are free to implement their own very special property parsers if needed. Properties can have default values. If unset they are zero-filled. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/sun4m.c')
-rw-r--r--hw/sun4m.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/hw/sun4m.c b/hw/sun4m.c
index 220eaae..4954ba3 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -373,8 +373,7 @@ static void lance_init(NICInfo *nd, target_phys_addr_t leaddr,
qemu_check_nic_model(&nd_table[0], "lance");
dev = qdev_create(NULL, "lance");
- qdev_set_netdev(dev, nd);
- qdev_set_prop_ptr(dev, "dma", dma_opaque);
+ dev->nd = nd;
qdev_init(dev);
s = sysbus_from_qdev(dev);
sysbus_mmio_map(s, 0, leaddr);
@@ -410,9 +409,6 @@ static SysBusDeviceInfo idreg_info = {
.init = idreg_init1,
.qdev.name = "macio_idreg",
.qdev.size = sizeof(SysBusDevice),
- .qdev.props = (DevicePropList[]) {
- {.name = NULL}
- }
};
static void idreg_register_devices(void)
@@ -468,8 +464,8 @@ static SysBusDeviceInfo prom_info = {
.init = prom_init1,
.qdev.name = "openprom",
.qdev.size = sizeof(SysBusDevice),
- .qdev.props = (DevicePropList[]) {
- {.name = NULL}
+ .qdev.props = (Property[]) {
+ {/* end of property list */}
}
};
@@ -480,12 +476,19 @@ static void prom_register_devices(void)
device_init(prom_register_devices);
+typedef struct RamDevice
+{
+ SysBusDevice busdev;
+ uint32_t size;
+} RamDevice;
+
/* System RAM */
static void ram_init1(SysBusDevice *dev)
{
ram_addr_t RAM_size, ram_offset;
+ RamDevice *d = FROM_SYSBUS(RamDevice, dev);
- RAM_size = qdev_get_prop_int(&dev->qdev, "size", 0);
+ RAM_size = d->size;
ram_offset = qemu_ram_alloc(RAM_size);
sysbus_init_mmio(dev, RAM_size, ram_offset);
@@ -496,6 +499,7 @@ static void ram_init(target_phys_addr_t addr, ram_addr_t RAM_size,
{
DeviceState *dev;
SysBusDevice *s;
+ RamDevice *d;
/* allocate RAM */
if ((uint64_t)RAM_size > max_mem) {
@@ -506,20 +510,26 @@ static void ram_init(target_phys_addr_t addr, ram_addr_t RAM_size,
exit(1);
}
dev = qdev_create(NULL, "memory");
- qdev_set_prop_int(dev, "size", RAM_size);
qdev_init(dev);
s = sysbus_from_qdev(dev);
+ d = FROM_SYSBUS(RamDevice, s);
+ d->size = RAM_size;
+
sysbus_mmio_map(s, 0, addr);
}
static SysBusDeviceInfo ram_info = {
.init = ram_init1,
.qdev.name = "memory",
- .qdev.size = sizeof(SysBusDevice),
- .qdev.props = (DevicePropList[]) {
- {.name = "size", .type = PROP_TYPE_INT},
- {.name = NULL}
+ .qdev.size = sizeof(RamDevice),
+ .qdev.props = (Property[]) {
+ {
+ .name = "size",
+ .info = &qdev_prop_uint32,
+ .offset = offsetof(RamDevice, size),
+ },
+ {/* end of property list */}
}
};