From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MQLhT-0003DI-2M for qemu-devel@nongnu.org; Mon, 13 Jul 2009 09:36:11 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MQLhO-0003BZ-5F for qemu-devel@nongnu.org; Mon, 13 Jul 2009 09:36:10 -0400 Received: from [199.232.76.173] (port=56426 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MQLhL-0003BH-QK for qemu-devel@nongnu.org; Mon, 13 Jul 2009 09:36:04 -0400 Received: from mx2.redhat.com ([66.187.237.31]:53123) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MQLhK-0001dq-GA for qemu-devel@nongnu.org; Mon, 13 Jul 2009 09:36:02 -0400 From: Gerd Hoffmann Date: Mon, 13 Jul 2009 15:33:51 +0200 Message-Id: <1247492031-16104-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1247492031-16104-1-git-send-email-kraxel@redhat.com> References: <1247492031-16104-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 2/2] qdev/prop: helper macros. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: paul@codesourcery.com, Gerd Hoffmann Signed-off-by: Gerd Hoffmann --- 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