aboutsummaryrefslogtreecommitdiff
path: root/hw/qdev.h
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2010-01-10 13:52:41 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2010-01-11 13:40:59 -0600
commitd2364ee424ebf9180afaf21128a71da55321ad00 (patch)
tree519adc359962cf6c269b291a054cbaf2916deb73 /hw/qdev.h
parentc0ced0f3a76c9f3ad680141f751dd1a20c91bbbf (diff)
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 <mst@redhat.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/qdev.h')
-rw-r--r--hw/qdev.h11
1 files changed, 11 insertions, 0 deletions
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)