summaryrefslogtreecommitdiff
path: root/hw/fdc.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/fdc.c
parentf114784f69ec3b9af342148025de14dbd1b429a5 (diff)
downloadqemu-ee6847d19be16c789b8bd4e553b7cd6701ba1245.tar.gz
qemu-ee6847d19be16c789b8bd4e553b7cd6701ba1245.tar.bz2
qemu-ee6847d19be16c789b8bd4e553b7cd6701ba1245.zip
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/fdc.c')
-rw-r--r--hw/fdc.c44
1 files changed, 31 insertions, 13 deletions
diff --git a/hw/fdc.c b/hw/fdc.c
index 3959b112ef..fa154a30cb 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -511,6 +511,8 @@ struct fdctrl_t {
/* Floppy drives */
fdrive_t drives[MAX_FD];
int reset_sensei;
+ uint32_t strict_io;
+ uint32_t mem_mapped;
};
static uint32_t fdctrl_read (void *opaque, uint32_t reg)
@@ -1898,9 +1900,9 @@ fdctrl_t *fdctrl_init (qemu_irq irq, int dma_chann, int mem_mapped,
fdctrl_t *fdctrl;
dev = qdev_create(NULL, "fdc");
- qdev_set_prop_int(dev, "strict_io", 0);
- qdev_set_prop_int(dev, "mem_mapped", mem_mapped);
- qdev_set_prop_int(dev, "sun4m", 0);
+ qdev_prop_set_uint32(dev, "strict_io", 0);
+ qdev_prop_set_uint32(dev, "mem_mapped", mem_mapped);
+ qdev_prop_set_uint32(dev, "sun4m", 0);
qdev_init(dev);
s = sysbus_from_qdev(dev);
sysbus_connect_irq(s, 0, irq);
@@ -1931,9 +1933,9 @@ fdctrl_t *sun4m_fdctrl_init (qemu_irq irq, target_phys_addr_t io_base,
fdctrl_t *fdctrl;
dev = qdev_create(NULL, "fdc");
- qdev_set_prop_int(dev, "strict_io", 1);
- qdev_set_prop_int(dev, "mem_mapped", 1);
- qdev_set_prop_int(dev, "sun4m", 1);
+ qdev_prop_set_uint32(dev, "strict_io", 1);
+ qdev_prop_set_uint32(dev, "mem_mapped", 1);
+ qdev_prop_set_uint32(dev, "sun4m", 1);
qdev_init(dev);
s = sysbus_from_qdev(dev);
sysbus_connect_irq(s, 0, irq);
@@ -1953,7 +1955,7 @@ static void fdc_init1(SysBusDevice *dev)
sysbus_init_irq(dev, &s->irq);
qdev_init_gpio_in(&dev->qdev, fdctrl_handle_tc, 1);
- if (qdev_get_prop_int(&dev->qdev, "strict_io", 0)) {
+ if (s->strict_io) {
io = cpu_register_io_memory(fdctrl_mem_read_strict,
fdctrl_mem_write_strict, s);
} else {
@@ -1967,12 +1969,28 @@ static SysBusDeviceInfo fdc_info = {
.init = fdc_init1,
.qdev.name = "fdc",
.qdev.size = sizeof(fdctrl_t),
- .qdev.props = (DevicePropList[]) {
- {.name = "io_base", .type = PROP_TYPE_INT},
- {.name = "strict_io", .type = PROP_TYPE_INT},
- {.name = "mem_mapped", .type = PROP_TYPE_INT},
- {.name = "sun4m", .type = PROP_TYPE_INT},
- {.name = NULL}
+ .qdev.props = (Property[]) {
+ {
+ .name = "io_base",
+ .info = &qdev_prop_uint32,
+ .offset = offsetof(fdctrl_t, io_base),
+ },
+ {
+ .name = "strict_io",
+ .info = &qdev_prop_uint32,
+ .offset = offsetof(fdctrl_t, strict_io),
+ },
+ {
+ .name = "mem_mapped",
+ .info = &qdev_prop_uint32,
+ .offset = offsetof(fdctrl_t, mem_mapped),
+ },
+ {
+ .name = "sun4m",
+ .info = &qdev_prop_uint32,
+ .offset = offsetof(fdctrl_t, sun4m),
+ },
+ {/* end of properties */}
}
};