From 81699d8a90deac361e9e14fd853f8341f40b2fad Mon Sep 17 00:00:00 2001 From: Anthony Liguori Date: Fri, 19 Nov 2010 18:55:58 +0900 Subject: qbus: add functions to walk both devices and busses There are some cases where you want to walk the busses, in particular, when searching for a bus either by name or DeviceInfo. Paolo suggested that we model the return values on how GCC's walkers work which allows an actor to skip child transversal, or terminate walking with a positive value that's returned as the qbus_walk_children's result. Signed-off-by: Isaku Yamahata Signed-off-by: Anthony Liguori Signed-off-by: Michael S. Tsirkin --- hw/qdev.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'hw/qdev.h') diff --git a/hw/qdev.h b/hw/qdev.h index 579328afc2..550fd9bbdc 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -173,9 +173,20 @@ BusState *qdev_get_parent_bus(DeviceState *dev); /*** BUS API. ***/ +/* Returns 0 to walk children, > 0 to skip walk, < 0 to terminate walk. */ +typedef int (qbus_walkerfn)(BusState *bus, void *opaque); +typedef int (qdev_walkerfn)(DeviceState *dev, void *opaque); + void qbus_create_inplace(BusState *bus, BusInfo *info, DeviceState *parent, const char *name); BusState *qbus_create(BusInfo *info, 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. */ +int qbus_walk_children(BusState *bus, qdev_walkerfn *devfn, + qbus_walkerfn *busfn, void *opaque); +int qdev_walk_children(DeviceState *dev, qdev_walkerfn *devfn, + qbus_walkerfn *busfn, void *opaque); void qbus_free(BusState *bus); #define FROM_QBUS(type, dev) DO_UPCAST(type, qbus, dev) -- cgit v1.2.3 From ec990eb622ad46df5ddcb1e94c418c271894d416 Mon Sep 17 00:00:00 2001 From: Anthony Liguori Date: Fri, 19 Nov 2010 18:55:59 +0900 Subject: qdev: reset qdev along with qdev tree This patch changes the reset handling so that qdev has no knowledge of the global system reset. Instead, a new bus/device level function is introduced that allows all devices/buses on the bus/device to be reset using a depth first transversal. N.B. we have to expose the implicit system bus because we have various hacks that result in an implicit system bus existing. Instead, we ought to have an explicitly created system bus that we can trigger reset from. That's a topic for a future patch though. Signed-off-by: Anthony Liguori Signed-off-by: Isaku Yamahata Signed-off-by: Michael S. Tsirkin --- hw/qdev.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'hw/qdev.h') diff --git a/hw/qdev.h b/hw/qdev.h index 550fd9bbdc..e5ed3333a2 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -187,10 +187,14 @@ int qbus_walk_children(BusState *bus, qdev_walkerfn *devfn, qbus_walkerfn *busfn, void *opaque); int qdev_walk_children(DeviceState *dev, qdev_walkerfn *devfn, qbus_walkerfn *busfn, void *opaque); +void qbus_reset_all(BusState *bus); void qbus_free(BusState *bus); #define FROM_QBUS(type, dev) DO_UPCAST(type, qbus, dev) +/* This should go away once we get rid of the NULL bus hack */ +BusState *sysbus_get_default(void); + /*** monitor commands ***/ void do_info_qtree(Monitor *mon); -- cgit v1.2.3 From b4694b7ce8bd87c4b9c6c14ad74075a31b15c784 Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Fri, 19 Nov 2010 18:56:00 +0900 Subject: qdev: introduce reset call back for qbus level and make it called via qbus_reset_all(). The qbus reset callback will be used by pci bus reset. Signed-off-by: Isaku Yamahata Signed-off-by: Anthony Liguori Signed-off-by: Michael S. Tsirkin --- hw/qdev.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'hw/qdev.h') diff --git a/hw/qdev.h b/hw/qdev.h index e5ed3333a2..5ac084f7de 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -49,12 +49,14 @@ struct DeviceState { typedef void (*bus_dev_printfn)(Monitor *mon, DeviceState *dev, int indent); typedef char *(*bus_get_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; + qbus_resetfn *reset; Property *props; }; -- cgit v1.2.3 From 5af0a04bea1f1704432b7c118c00a466e862bf00 Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Fri, 19 Nov 2010 18:56:01 +0900 Subject: qdev: trigger reset from a given device Introduce a helper function which triggers reset from a given device. Will be used by pci bus emulation. Signed-off-by: Isaku Yamahata Signed-off-by: Anthony Liguori Signed-off-by: Michael S. Tsirkin --- hw/qdev.h | 1 + 1 file changed, 1 insertion(+) (limited to 'hw/qdev.h') diff --git a/hw/qdev.h b/hw/qdev.h index 5ac084f7de..3fac364c6b 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -189,6 +189,7 @@ int qbus_walk_children(BusState *bus, qdev_walkerfn *devfn, qbus_walkerfn *busfn, void *opaque); int qdev_walk_children(DeviceState *dev, qdev_walkerfn *devfn, qbus_walkerfn *busfn, void *opaque); +void qdev_reset_all(DeviceState *dev); void qbus_reset_all(BusState *bus); void qbus_free(BusState *bus); -- cgit v1.2.3