[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 34/37] qdev: introduce QDEV_FIND_PROP_FROM_BIT and q
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH 34/37] qdev: introduce QDEV_FIND_PROP_FROM_BIT and qdev_prop_find_bit() |
Date: |
Mon, 22 Oct 2012 17:03:20 +0200 |
it allows to find bit static property corresponding to a specific bit
in specified field.
Signed-off-by: Igor Mammedov <address@hidden>
---
* it will be used by next commit to print cpuid feature names for
unavailable feature bits.
---
hw/qdev-properties.h | 8 ++++++++
qom/qdev-properties.c | 15 +++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/hw/qdev-properties.h b/hw/qdev-properties.h
index 19b55c0..88b6782 100644
--- a/hw/qdev-properties.h
+++ b/hw/qdev-properties.h
@@ -144,4 +144,12 @@ const Property *qdev_prop_find(const DeviceClass *dc,
const char *name);
for ((_var) = (_class); \
(_var) != DEVICE_CLASS(object_class_by_name(TYPE_DEVICE)); \
(_var) = DEVICE_CLASS(object_class_get_parent(OBJECT_CLASS((_var)))))
+
+const Property *qdev_prop_find_bit(const DeviceClass *dc, const int offset,
+ const uint8_t bitnr);
+#define QDEV_FIND_PROP_FROM_BIT(_class, _state, _field, _bitnr) \
+ qdev_prop_find_bit(_class, \
+ offsetof(_state, _field) + \
+ type_check(uint32_t, typeof_field(_state, _field)), \
+ _bitnr)
#endif
diff --git a/qom/qdev-properties.c b/qom/qdev-properties.c
index 3d3eefa..2e589c6 100644
--- a/qom/qdev-properties.c
+++ b/qom/qdev-properties.c
@@ -787,6 +787,21 @@ const Property *qdev_prop_find(const DeviceClass *dc,
const char *name)
return NULL;
}
+const Property *qdev_prop_find_bit(const DeviceClass *dc, const int offset,
+ const uint8_t bitnr)
+{
+ const Property *prop;
+
+ QDEV_CLASS_FOREACH(dc, dc) {
+ QDEV_PROP_FOREACH(prop, dc) {
+ if (prop->offset == offset && prop->bitnr == bitnr) {
+ return prop;
+ }
+ }
+ }
+ return NULL;
+}
+
void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
Property *prop, const char *value)
{
--
1.7.11.7
- [Qemu-devel] [PATCH 06/37] add visitor for parsing hz[KMG] input string, (continued)
- [Qemu-devel] [PATCH 21/37] target-i386: convert 'hv_relaxed' to static property, Igor Mammedov, 2012/10/22
- [Qemu-devel] [PATCH 11/37] target-i386: introduce vendor-override static property, Igor Mammedov, 2012/10/22
- [Qemu-devel] [PATCH 28/37] target-i386: convert "model-id" to static property, Igor Mammedov, 2012/10/22
- [Qemu-devel] [PATCH 20/37] target-i386: convert 'hv_spinlocks' to static property, Igor Mammedov, 2012/10/22
- [Qemu-devel] [PATCH 19/37] qdev: add DEFINE_ABSTRACT_PROP() helper, Igor Mammedov, 2012/10/22
- [Qemu-devel] [PATCH 34/37] qdev: introduce QDEV_FIND_PROP_FROM_BIT and qdev_prop_find_bit(),
Igor Mammedov <=
- [Qemu-devel] [PATCH 25/37] target-i386: replace uint32_t vendor fields by vendor string in x86_def_t, Igor Mammedov, 2012/10/22
- [Qemu-devel] [PATCH 23/37] target-i386: convert 'check' and 'enforce' to static properties, Igor Mammedov, 2012/10/22
- [Qemu-devel] [PATCH 36/37] target-i386: use static properties to list CPUID features, Igor Mammedov, 2012/10/22
- Re: [Qemu-devel] [PATCH 36/37] target-i386: use static properties to list CPUID features, Don Slutz, 2012/10/23
[Qemu-devel] [PATCH 37/37] target-i386: cleanup cpu_x86_find_by_name(), only fill x86_def_t in it, Igor Mammedov, 2012/10/22
[Qemu-devel] [PATCH 26/37] target-i386: convert "vendor" property to static property, Igor Mammedov, 2012/10/22