aboutsummaryrefslogtreecommitdiff
path: root/hw/qdev.h
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2012-05-02 09:00:20 +0200
committerAndreas Färber <afaerber@suse.de>2012-06-18 15:14:38 +0200
commit0d936928ef87ca1bb7b41b5b89c400c699a7691c (patch)
tree134a900379f06e1e84f31728a866d8afc7e9869a /hw/qdev.h
parent8185d21639ab749979445734ec671122aa96e805 (diff)
qdev: Convert busses to QEMU Object Model
This is far less interesting than it sounds. We simply add an Object to each BusState and then register the types appropriately. Most of the interesting refactoring will follow in the next patches. Since we're changing fundamental type names (BusInfo -> BusClass), it all needs to convert at once. Fortunately, not a lot of code is affected. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> [AF: Made all new bus TypeInfos static const.] [AF: Made qbus_free() call object_delete(), required {qom,glib}_allocated] Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/qdev.h')
-rw-r--r--hw/qdev.h46
1 files changed, 26 insertions, 20 deletions
diff --git a/hw/qdev.h b/hw/qdev.h
index 013ccf2b7a..736271ecef 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -17,7 +17,7 @@ typedef struct CompatProperty CompatProperty;
typedef struct BusState BusState;
-typedef struct BusInfo BusInfo;
+typedef struct BusClass BusClass;
enum DevState {
DEV_STATE_CREATED = 1,
@@ -55,7 +55,7 @@ typedef struct DeviceClass {
qdev_initfn init;
qdev_event unplug;
qdev_event exit;
- BusInfo *bus_info;
+ const char *bus_type;
} DeviceClass;
/* This structure should not be accessed directly. We declare it here
@@ -79,31 +79,40 @@ struct DeviceState {
int alias_required_for_version;
};
-typedef void (*bus_dev_printfn)(Monitor *mon, DeviceState *dev, int indent);
-typedef char *(*bus_get_dev_path)(DeviceState *dev);
/*
* This callback is used to create Open Firmware device path in accordance with
* OF spec http://forthworks.com/standards/of1275.pdf. Indicidual bus bindings
* can be found here http://playground.sun.com/1275/bindings/.
*/
-typedef char *(*bus_get_fw_dev_path)(DeviceState *dev);
-typedef int (qbus_resetfn)(BusState *bus);
-struct BusInfo {
- const char *name;
- size_t size;
- bus_dev_printfn print_dev;
- bus_get_dev_path get_dev_path;
- bus_get_fw_dev_path get_fw_dev_path;
- qbus_resetfn *reset;
+#define TYPE_BUS "bus"
+#define BUS(obj) OBJECT_CHECK(BusState, (obj), TYPE_BUS)
+#define BUS_CLASS(klass) OBJECT_CLASS_CHECK(BusClass, (klass), TYPE_BUS)
+#define BUS_GET_CLASS(obj) OBJECT_GET_CLASS(BusClass, (obj), TYPE_BUS)
+
+struct BusClass {
+ ObjectClass parent_class;
+
+ /* FIXME first arg should be BusState */
+ void (*print_dev)(Monitor *mon, DeviceState *dev, int indent);
+ char *(*get_dev_path)(DeviceState *dev);
+ char *(*get_fw_dev_path)(DeviceState *dev);
+ int (*reset)(BusState *bus);
};
+/**
+ * BusState:
+ * @qom_allocated: Indicates whether the object was allocated by QOM.
+ * @glib_allocated: Indicates whether the object was initialized in-place
+ * yet is expected to be freed with g_free().
+ */
struct BusState {
+ Object obj;
DeviceState *parent;
- BusInfo *info;
const char *name;
int allow_hotplug;
- int qdev_allocated;
+ bool qom_allocated;
+ bool glib_allocated;
QTAILQ_HEAD(ChildrenHead, DeviceState) children;
QLIST_ENTRY(BusState) sibling;
};
@@ -174,9 +183,9 @@ DeviceState *qdev_find_recursive(BusState *bus, const char *id);
typedef int (qbus_walkerfn)(BusState *bus, void *opaque);
typedef int (qdev_walkerfn)(DeviceState *dev, void *opaque);
-void qbus_create_inplace(BusState *bus, BusInfo *info,
+void qbus_create_inplace(BusState *bus, const char *typename,
DeviceState *parent, const char *name);
-BusState *qbus_create(BusInfo *info, DeviceState *parent, const char *name);
+BusState *qbus_create(const char *typename, DeviceState *parent, const char *name);
/* Returns > 0 if either devfn or busfn skip walk somewhere in cursion,
* < 0 if either devfn or busfn terminate walk somewhere in cursion,
* 0 otherwise. */
@@ -317,9 +326,6 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
char *qdev_get_fw_dev_path(DeviceState *dev);
-/* This is a nasty hack to allow passing a NULL bus to qdev_create. */
-extern struct BusInfo system_bus_info;
-
/**
* @qdev_property_add_static - add a @Property to a device referencing a
* field in a struct.