summary refs log tree commit diff stats
path: root/hw/slavio_intctl.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/slavio_intctl.c
parentf114784f69ec3b9af342148025de14dbd1b429a5 (diff)
downloadfocaccia-qemu-ee6847d19be16c789b8bd4e553b7cd6701ba1245.tar.gz
focaccia-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/slavio_intctl.c')
-rw-r--r--hw/slavio_intctl.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/hw/slavio_intctl.c b/hw/slavio_intctl.c
index 235e8c3745..188511e84f 100644
--- a/hw/slavio_intctl.c
+++ b/hw/slavio_intctl.c
@@ -69,6 +69,7 @@ typedef struct SLAVIO_INTCTLState {
     qemu_irq cpu_irqs[MAX_CPUS][MAX_PILS];
     const uint32_t *intbit_to_level;
     uint32_t cputimer_lbit, cputimer_mbit;
+    uint32_t cputimer_bit;
     uint32_t pil_out[MAX_CPUS];
     SLAVIO_CPUINTCTLState slaves[MAX_CPUS];
 } SLAVIO_INTCTLState;
@@ -388,17 +389,15 @@ static void slavio_intctl_reset(void *opaque)
 static void slavio_intctl_init1(SysBusDevice *dev)
 {
     SLAVIO_INTCTLState *s = FROM_SYSBUS(SLAVIO_INTCTLState, dev);
-    int io_memory, cputimer;
+    int io_memory;
     unsigned int i, j;
 
     qdev_init_gpio_in(&dev->qdev, slavio_set_irq_all, 32 + MAX_CPUS);
     io_memory = cpu_register_io_memory(slavio_intctlm_mem_read,
                                        slavio_intctlm_mem_write, s);
     sysbus_init_mmio(dev, INTCTLM_SIZE, io_memory);
-    s->intbit_to_level = qdev_get_prop_ptr(&dev->qdev, "intbit_to_level");
-    cputimer = qdev_get_prop_int(&dev->qdev, "cputimer_bit", -1);
-    s->cputimer_mbit = 1 << cputimer;
-    s->cputimer_lbit = 1 << s->intbit_to_level[cputimer];
+    s->cputimer_mbit = 1 << s->cputimer_bit;
+    s->cputimer_lbit = 1 << s->intbit_to_level[s->cputimer_bit];
 
     for (i = 0; i < MAX_CPUS; i++) {
         for (j = 0; j < MAX_PILS; j++) {
@@ -427,8 +426,8 @@ DeviceState *slavio_intctl_init(target_phys_addr_t addr,
     unsigned int i, j;
 
     dev = qdev_create(NULL, "slavio_intctl");
-    qdev_set_prop_ptr(dev, "intbit_to_level", (void *)intbit_to_level);
-    qdev_set_prop_int(dev, "cputimer_bit", cputimer);
+    qdev_prop_set_ptr(dev, "intbit_to_level", (void *)intbit_to_level);
+    qdev_prop_set_uint32(dev, "cputimer_bit", cputimer);
     qdev_init(dev);
 
     s = sysbus_from_qdev(dev);
@@ -450,10 +449,18 @@ static SysBusDeviceInfo slavio_intctl_info = {
     .init = slavio_intctl_init1,
     .qdev.name  = "slavio_intctl",
     .qdev.size  = sizeof(SLAVIO_INTCTLState),
-    .qdev.props = (DevicePropList[]) {
-        {.name = "intbit_to_level", .type = PROP_TYPE_PTR},
-        {.name = "cputimer_bit", .type = PROP_TYPE_INT},
-        {.name = NULL}
+    .qdev.props = (Property[]) {
+        {
+            .name = "intbit_to_level",
+            .info = &qdev_prop_ptr,
+            .offset = offsetof(SLAVIO_INTCTLState, intbit_to_level),
+        },
+        {
+            .name = "cputimer_bit",
+            .info = &qdev_prop_uint32,
+            .offset = offsetof(SLAVIO_INTCTLState, cputimer_bit),
+        },
+        {/* end of property list */}
     }
 };