[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/2] qbus: make bus reset overrideable by subclasses
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [PATCH 2/2] qbus: make bus reset overrideable by subclasses |
Date: |
Fri, 11 Jan 2013 08:17:16 -0600 |
Signed-off-by: Anthony Liguori <address@hidden>
---
hw/qdev-core.h | 15 +++++++++++++++
hw/qdev.c | 16 +++++++++++++++-
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/hw/qdev-core.h b/hw/qdev-core.h
index f40fd15..453a061 100644
--- a/hw/qdev-core.h
+++ b/hw/qdev-core.h
@@ -100,7 +100,22 @@ struct BusClass {
* bindings can be found at http://playground.sun.com/1275/bindings/.
*/
char *(*get_fw_dev_path)(DeviceState *dev);
+
+ /**
+ * reset:
+ *
+ * Cold reset of a bus. This only resets the controller state of the bus.
+ */
int (*reset)(BusState *bus);
+
+ /**
+ * reset_all:
+ *
+ * Cold reset of a bus with children. The default implementation of this
+ * method will invoke BusState::reset and then recursively call
+ * qdev_reset_all() on each child in an arbitrary order.
+ */
+ void (*reset_all)(BusState *bus);
};
typedef struct BusChild {
diff --git a/hw/qdev.c b/hw/qdev.c
index e02b5be..db19b14 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -234,11 +234,17 @@ void qdev_reset_all(DeviceState *dev)
dc->reset_all(dev);
}
-void qbus_reset_all(BusState *bus)
+static void qbus_reset_children(BusState *bus)
{
qbus_walk_children(bus, qdev_reset_one, qbus_reset_one, NULL);
}
+void qbus_reset_all(BusState *bus)
+{
+ BusClass *bc = BUS_GET_CLASS(bus);
+ bc->reset_all(bus);
+}
+
void qbus_reset_all_fn(void *opaque)
{
BusState *bus = opaque;
@@ -758,6 +764,13 @@ static const TypeInfo device_type_info = {
.class_size = sizeof(DeviceClass),
};
+static void qbus_class_initfn(ObjectClass *klass, void *data)
+{
+ BusClass *bc = BUS_CLASS(klass);
+
+ bc->reset_all = qbus_reset_children;
+}
+
static void qbus_initfn(Object *obj)
{
BusState *bus = BUS(obj);
@@ -789,6 +802,7 @@ static const TypeInfo bus_info = {
.parent = TYPE_OBJECT,
.instance_size = sizeof(BusState),
.abstract = true,
+ .class_init = qbus_class_initfn,
.class_size = sizeof(BusClass),
.instance_init = qbus_initfn,
.instance_finalize = qbus_finalize,
--
1.8.0