qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 2/2] qdev/prop: helper macros.


From: Gerd Hoffmann
Subject: [Qemu-devel] [PATCH 2/2] qdev/prop: helper macros.
Date: Mon, 13 Jul 2009 15:33:51 +0200

Signed-off-by: Gerd Hoffmann <address@hidden>
---
 hw/pci.c       |    5 +++++
 hw/qdev-addr.h |    3 +++
 hw/qdev.h      |   20 ++++++++++++++++++++
 3 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/hw/pci.c b/hw/pci.c
index 4e92c4c..1a1cbc6 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -56,6 +56,7 @@ static struct BusInfo pci_bus_info = {
     .print_dev  = pcibus_dev_print,
     .add_dev    = pci_create,
     .props      = (Property[]) {
+#if 0
         {
             .name   = "devfn",
             .info   = &qdev_prop_uint32,
@@ -63,6 +64,10 @@ static struct BusInfo pci_bus_info = {
             .defval = (uint32_t[]) { -1 },
         },
         {/* end of list */}
+#else
+        DEF_PROP_UINT32("devfn", PCIDevice, devfn, -1),
+        DEF_PROP_END_OF_LIST()
+#endif
     }
 };
 
diff --git a/hw/qdev-addr.h b/hw/qdev-addr.h
index f02bd7a..7160989 100644
--- a/hw/qdev-addr.h
+++ b/hw/qdev-addr.h
@@ -1,2 +1,5 @@
+#define DEF_PROP_TADDR(_n, _s, _f, _d)                                  \
+    DEF_PROP(_n, _s, _f, _d, target_phys_addr_t, qdev_prop_taddr)
+
 extern PropertyInfo qdev_prop_taddr;
 void qdev_prop_set_taddr(DeviceState *dev, const char *name, 
target_phys_addr_t value);
diff --git a/hw/qdev.h b/hw/qdev.h
index 584617e..1edefcc 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -144,6 +144,26 @@ extern PropertyInfo qdev_prop_hex32;
 extern PropertyInfo qdev_prop_ptr;
 extern PropertyInfo qdev_prop_mac;
 
+#define DEF_PROP(_name, _state, _field, _defval, _type, _prop) { \
+        .name      = (_name),                                    \
+        .info      = &(_prop),                                   \
+        .offset    = offsetof(_state, _field),                   \
+        .defval    = (_type[]) { (_defval) },                    \
+        }
+
+#define DEF_PROP_UINT16(_n, _s, _f, _d)                         \
+    DEF_PROP(_n, _s, _f, _d, uint16_t, qdev_prop_uint16)
+#define DEF_PROP_UINT32(_n, _s, _f, _d)                         \
+    DEF_PROP(_n, _s, _f, _d, uint32_t, qdev_prop_uint32)
+#define DEF_PROP_HEX32(_n, _s, _f, _d)                  \
+    DEF_PROP(_n, _s, _f, _d, uint32_t, qdev_prop_hex32)
+#define DEF_PROP_PTR(_n, _s, _f, _d)                    \
+    DEF_PROP(_n, _s, _f, _d, void*, qdev_prop_ptr)
+#define DEF_PROP_MAC(_n, _s, _f, _d)                    \
+    DEF_PROP(_n, _s, _f, _d, void*, qdev_prop_mac)
+#define DEF_PROP_END_OF_LIST()                  \
+    {}
+
 /* Set properties between creation and init.  */
 void *qdev_get_prop_ptr(DeviceState *dev, Property *prop);
 int qdev_prop_parse(DeviceState *dev, const char *name, const char *value);
-- 
1.6.2.5





reply via email to

[Prev in Thread] Current Thread [Next in Thread]