[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 17/20] qdev: introduce QDEV_FIND_PROP_FROM_BIT and q
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH 17/20] qdev: introduce QDEV_FIND_PROP_FROM_BIT and qdev_prop_find_bit() |
Date: |
Tue, 16 Jul 2013 00:26:12 +0200 |
helper to find a static property corresponding to a specific bit
in specified field.
Signed-off-by: Igor Mammedov <address@hidden>
---
hw/core/qdev-properties.c | 15 +++++++++++++++
include/hw/qdev-properties.h | 18 ++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 3a324fb..5c3575b 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -964,6 +964,21 @@ static Property *qdev_prop_find(DeviceState *dev, 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)
{
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 39448b7..cf57e3a 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -192,4 +192,22 @@ void qdev_property_add_static(DeviceState *dev, Property
*prop, Error **errp);
*/
void qdev_prop_set_after_realize(DeviceState *dev, const char *name,
Error **errp);
+
+#define QDEV_PROP_FOREACH(_var, _class) \
+ for ((_var) = DEVICE_CLASS((_class))->props; \
+ (_var) && (_var)->name; \
+ (_var)++)
+
+#define QDEV_CLASS_FOREACH(_var, _class) \
+ 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
--
1.8.3.1
- [Qemu-devel] [PATCH 08/20] target-i386: cpu: convert 'level' to static property, (continued)
- [Qemu-devel] [PATCH 08/20] target-i386: cpu: convert 'level' to static property, Igor Mammedov, 2013/07/15
- [Qemu-devel] [PATCH 09/20] target-i386: cpu: convert 'xlevel' to static property, Igor Mammedov, 2013/07/15
- [Qemu-devel] [PATCH 10/20] target-i386: cpu: convert 'family' to static property, Igor Mammedov, 2013/07/15
- [Qemu-devel] [PATCH 11/20] target-i386: cpu: convert 'model' to static property, Igor Mammedov, 2013/07/15
- [Qemu-devel] [PATCH 12/20] target-i386: cpu: convert 'stepping' to static property, Igor Mammedov, 2013/07/15
- [Qemu-devel] [PATCH 13/20] target-i386: cpu: convert 'vendor' to static property, Igor Mammedov, 2013/07/15
- [Qemu-devel] [PATCH 14/20] target-i386: cpu: convert 'model-id' to static property, Igor Mammedov, 2013/07/15
- [Qemu-devel] [PATCH 15/20] target-i386: cpu: convert 'tsc-frequency' to static property, Igor Mammedov, 2013/07/15
- [Qemu-devel] [PATCH 15/21] target-i386: cpu: substitute '_' with '-' for +-foo feature bits as well, Igor Mammedov, 2013/07/15
- [Qemu-devel] [PATCH 16/21] target-i386: cpu: convert 'tsc-frequency' to static property, Igor Mammedov, 2013/07/15
- [Qemu-devel] [PATCH 17/20] qdev: introduce QDEV_FIND_PROP_FROM_BIT and qdev_prop_find_bit(),
Igor Mammedov <=
- [Qemu-devel] [PATCH 16/20] target-i386: set [+-]feature using static properties, Igor Mammedov, 2013/07/15
- [Qemu-devel] [PATCH 17/20] qdev: introduce qdev_prop_find_bit(), Igor Mammedov, 2013/07/15
- [Qemu-devel] [PATCH 18/21] qdev: introduce QDEV_FIND_PROP_FROM_BIT and qdev_prop_find_bit(), Igor Mammedov, 2013/07/15
- [Qemu-devel] [PATCH 17/21] target-i386: set [+-]feature using static properties, Igor Mammedov, 2013/07/15
- [Qemu-devel] [PATCH 18/20] target-i386: use static properties in check_features_against_host() to print CPUID feature names, Igor Mammedov, 2013/07/15
- [Qemu-devel] [PATCH 19/21] target-i386: use static properties in check_features_against_host() to print CPUID feature names, Igor Mammedov, 2013/07/15
- [Qemu-devel] [PATCH 19/20] target-i386: use static properties to list CPUID features, Igor Mammedov, 2013/07/15
- [Qemu-devel] [PATCH 20/20] target-i386: remove unused *_feature_name arrays, Igor Mammedov, 2013/07/15
- [Qemu-devel] [PATCH 20/21] target-i386: use static properties to list CPUID features, Igor Mammedov, 2013/07/15
- [Qemu-devel] [PATCH 21/21] target-i386: remove unused *_feature_name arrays, Igor Mammedov, 2013/07/15