From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:49449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtfQO-0006PU-02 for qemu-devel@nongnu.org; Fri, 11 Jan 2013 09:17:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TtfQL-00057c-TU for qemu-devel@nongnu.org; Fri, 11 Jan 2013 09:17:35 -0500 Received: from e9.ny.us.ibm.com ([32.97.182.139]:49692) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtfQL-00057U-PI for qemu-devel@nongnu.org; Fri, 11 Jan 2013 09:17:33 -0500 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 11 Jan 2013 09:17:33 -0500 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 3F8996E803F for ; Fri, 11 Jan 2013 09:17:28 -0500 (EST) Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r0BEHRrD181226 for ; Fri, 11 Jan 2013 09:17:27 -0500 Received: from d03av05.boulder.ibm.com (loopback [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r0BEHQc1014807 for ; Fri, 11 Jan 2013 07:17:26 -0700 From: Anthony Liguori Date: Fri, 11 Jan 2013 08:17:16 -0600 Message-Id: <1357913836-4560-3-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1357913836-4560-1-git-send-email-aliguori@us.ibm.com> References: <1357913836-4560-1-git-send-email-aliguori@us.ibm.com> Subject: [Qemu-devel] [PATCH 2/2] qbus: make bus reset overrideable by subclasses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Bonzini , Anthony Liguori , Michael Tsirkin Signed-off-by: Anthony Liguori --- 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