From d2364ee424ebf9180afaf21128a71da55321ad00 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Sun, 10 Jan 2010 13:52:41 +0200 Subject: qdev: add bit property type This adds "bit" property type, which is a boolean stored in a 32 bit integer field, with legal values on and off. Will be used by virtio for feature bits. Signed-off-by: Michael S. Tsirkin Acked-by: Gerd Hoffmann Signed-off-by: Anthony Liguori --- hw/qdev.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'hw/qdev.h') diff --git a/hw/qdev.h b/hw/qdev.h index bbcdba185a..07b9603804 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -64,6 +64,7 @@ struct Property { const char *name; PropertyInfo *info; int offset; + int bitnr; void *defval; }; @@ -82,6 +83,7 @@ enum PropertyType { PROP_TYPE_NETDEV, PROP_TYPE_VLAN, PROP_TYPE_PTR, + PROP_TYPE_BIT, }; struct PropertyInfo { @@ -173,6 +175,7 @@ void do_device_del(Monitor *mon, const QDict *qdict); /*** qdev-properties.c ***/ +extern PropertyInfo qdev_prop_bit; extern PropertyInfo qdev_prop_uint8; extern PropertyInfo qdev_prop_uint16; extern PropertyInfo qdev_prop_uint32; @@ -202,6 +205,14 @@ extern PropertyInfo qdev_prop_pci_devfn; + type_check(_type,typeof_field(_state, _field)), \ .defval = (_type[]) { _defval }, \ } +#define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) { \ + .name = (_name), \ + .info = &(qdev_prop_bit), \ + .bitnr = (_bit), \ + .offset = offsetof(_state, _field) \ + + type_check(uint32_t,typeof_field(_state, _field)), \ + .defval = (bool[]) { (_defval) }, \ + } #define DEFINE_PROP_UINT8(_n, _s, _f, _d) \ DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint8, uint8_t) -- cgit v1.2.3