1074a86fcSAnthony Liguori #ifndef QDEV_CORE_H 2074a86fcSAnthony Liguori #define QDEV_CORE_H 3074a86fcSAnthony Liguori 41de7afc9SPaolo Bonzini #include "qemu/queue.h" 51de7afc9SPaolo Bonzini #include "qemu/option.h" 6949fc823SMarcel Apfelbaum #include "qemu/bitmap.h" 714cccb61SPaolo Bonzini #include "qom/object.h" 8074a86fcSAnthony Liguori #include "hw/irq.h" 90ee4de6cSIgor Mammedov #include "hw/hotplug.h" 10074a86fcSAnthony Liguori 11074a86fcSAnthony Liguori enum { 12074a86fcSAnthony Liguori DEV_NVECTORS_UNSPECIFIED = -1, 13074a86fcSAnthony Liguori }; 14074a86fcSAnthony Liguori 15074a86fcSAnthony Liguori #define TYPE_DEVICE "device" 16074a86fcSAnthony Liguori #define DEVICE(obj) OBJECT_CHECK(DeviceState, (obj), TYPE_DEVICE) 17074a86fcSAnthony Liguori #define DEVICE_CLASS(klass) OBJECT_CLASS_CHECK(DeviceClass, (klass), TYPE_DEVICE) 18074a86fcSAnthony Liguori #define DEVICE_GET_CLASS(obj) OBJECT_GET_CLASS(DeviceClass, (obj), TYPE_DEVICE) 19074a86fcSAnthony Liguori 203d1237fbSMarcel Apfelbaum typedef enum DeviceCategory { 213d1237fbSMarcel Apfelbaum DEVICE_CATEGORY_BRIDGE, 223d1237fbSMarcel Apfelbaum DEVICE_CATEGORY_USB, 233d1237fbSMarcel Apfelbaum DEVICE_CATEGORY_STORAGE, 243d1237fbSMarcel Apfelbaum DEVICE_CATEGORY_NETWORK, 253d1237fbSMarcel Apfelbaum DEVICE_CATEGORY_INPUT, 263d1237fbSMarcel Apfelbaum DEVICE_CATEGORY_DISPLAY, 273d1237fbSMarcel Apfelbaum DEVICE_CATEGORY_SOUND, 283d1237fbSMarcel Apfelbaum DEVICE_CATEGORY_MISC, 293d1237fbSMarcel Apfelbaum DEVICE_CATEGORY_MAX 303d1237fbSMarcel Apfelbaum } DeviceCategory; 313d1237fbSMarcel Apfelbaum 32074a86fcSAnthony Liguori typedef int (*qdev_initfn)(DeviceState *dev); 33074a86fcSAnthony Liguori typedef int (*qdev_event)(DeviceState *dev); 34074a86fcSAnthony Liguori typedef void (*qdev_resetfn)(DeviceState *dev); 35249d4172SAndreas Färber typedef void (*DeviceRealize)(DeviceState *dev, Error **errp); 36249d4172SAndreas Färber typedef void (*DeviceUnrealize)(DeviceState *dev, Error **errp); 3702e7f85dSBandan Das typedef void (*BusRealize)(BusState *bus, Error **errp); 3802e7f85dSBandan Das typedef void (*BusUnrealize)(BusState *bus, Error **errp); 39074a86fcSAnthony Liguori 40074a86fcSAnthony Liguori struct VMStateDescription; 41074a86fcSAnthony Liguori 42249d4172SAndreas Färber /** 43249d4172SAndreas Färber * DeviceClass: 44249d4172SAndreas Färber * @props: Properties accessing state fields. 45249d4172SAndreas Färber * @realize: Callback function invoked when the #DeviceState:realized 46249d4172SAndreas Färber * property is changed to %true. The default invokes @init if not %NULL. 47249d4172SAndreas Färber * @unrealize: Callback function invoked when the #DeviceState:realized 48249d4172SAndreas Färber * property is changed to %false. 49249d4172SAndreas Färber * @init: Callback function invoked when the #DeviceState::realized property 50249d4172SAndreas Färber * is changed to %true. Deprecated, new types inheriting directly from 51249d4172SAndreas Färber * TYPE_DEVICE should use @realize instead, new leaf types should consult 52249d4172SAndreas Färber * their respective parent type. 531a37eca1SIgor Mammedov * @hotpluggable: indicates if #DeviceClass is hotpluggable, available 541a37eca1SIgor Mammedov * as readonly "hotpluggable" property of #DeviceState instance 55249d4172SAndreas Färber * 56249d4172SAndreas Färber * # Realization # 57249d4172SAndreas Färber * Devices are constructed in two stages, 58249d4172SAndreas Färber * 1) object instantiation via object_initialize() and 59249d4172SAndreas Färber * 2) device realization via #DeviceState:realized property. 60249d4172SAndreas Färber * The former may not fail (it might assert or exit), the latter may return 61249d4172SAndreas Färber * error information to the caller and must be re-entrant. 62249d4172SAndreas Färber * Trivial field initializations should go into #TypeInfo.instance_init. 63249d4172SAndreas Färber * Operations depending on @props static properties should go into @realize. 64249d4172SAndreas Färber * After successful realization, setting static properties will fail. 65249d4172SAndreas Färber * 66daeba969SMarkus Armbruster * As an interim step, the #DeviceState:realized property can also be 67daeba969SMarkus Armbruster * set with qdev_init_nofail(). 68249d4172SAndreas Färber * In the future, devices will propagate this state change to their children 69249d4172SAndreas Färber * and along busses they expose. 70249d4172SAndreas Färber * The point in time will be deferred to machine creation, so that values 71249d4172SAndreas Färber * set in @realize will not be introspectable beforehand. Therefore devices 72249d4172SAndreas Färber * must not create children during @realize; they should initialize them via 73249d4172SAndreas Färber * object_initialize() in their own #TypeInfo.instance_init and forward the 74249d4172SAndreas Färber * realization events appropriately. 75249d4172SAndreas Färber * 76249d4172SAndreas Färber * The @init callback is considered private to a particular bus implementation 77249d4172SAndreas Färber * (immediate abstract child types of TYPE_DEVICE). Derived leaf types set an 78249d4172SAndreas Färber * "init" callback on their parent class instead. 79782beb52SAndreas Färber * 80249d4172SAndreas Färber * Any type may override the @realize and/or @unrealize callbacks but needs 81782beb52SAndreas Färber * to call the parent type's implementation if keeping their functionality 82782beb52SAndreas Färber * is desired. Refer to QOM documentation for further discussion and examples. 83782beb52SAndreas Färber * 84782beb52SAndreas Färber * <note> 85782beb52SAndreas Färber * <para> 86249d4172SAndreas Färber * If a type derived directly from TYPE_DEVICE implements @realize, it does 87249d4172SAndreas Färber * not need to implement @init and therefore does not need to store and call 88249d4172SAndreas Färber * #DeviceClass' default @realize callback. 89782beb52SAndreas Färber * For other types consult the documentation and implementation of the 90782beb52SAndreas Färber * respective parent types. 91782beb52SAndreas Färber * </para> 92782beb52SAndreas Färber * </note> 93249d4172SAndreas Färber */ 94074a86fcSAnthony Liguori typedef struct DeviceClass { 95249d4172SAndreas Färber /*< private >*/ 96074a86fcSAnthony Liguori ObjectClass parent_class; 97249d4172SAndreas Färber /*< public >*/ 98074a86fcSAnthony Liguori 993d1237fbSMarcel Apfelbaum DECLARE_BITMAP(categories, DEVICE_CATEGORY_MAX); 100074a86fcSAnthony Liguori const char *fw_name; 101074a86fcSAnthony Liguori const char *desc; 102074a86fcSAnthony Liguori Property *props; 103efec3dd6SMarkus Armbruster 104efec3dd6SMarkus Armbruster /* 105efec3dd6SMarkus Armbruster * Shall we hide this device model from -device / device_add? 106efec3dd6SMarkus Armbruster * All devices should support instantiation with device_add, and 107efec3dd6SMarkus Armbruster * this flag should not exist. But we're not there, yet. Some 108efec3dd6SMarkus Armbruster * devices fail to instantiate with cryptic error messages. 109efec3dd6SMarkus Armbruster * Others instantiate, but don't work. Exposing users to such 110efec3dd6SMarkus Armbruster * behavior would be cruel; this flag serves to protect them. It 111efec3dd6SMarkus Armbruster * should never be set without a comment explaining why it is set. 112efec3dd6SMarkus Armbruster * TODO remove once we're there 113efec3dd6SMarkus Armbruster */ 114efec3dd6SMarkus Armbruster bool cannot_instantiate_with_device_add_yet; 1154c315c27SMarkus Armbruster /* 1164c315c27SMarkus Armbruster * Does this device model survive object_unref(object_new(TNAME))? 1174c315c27SMarkus Armbruster * All device models should, and this flag shouldn't exist. Some 1184c315c27SMarkus Armbruster * devices crash in object_new(), some crash or hang in 1194c315c27SMarkus Armbruster * object_unref(). Makes introspecting properties with 1204c315c27SMarkus Armbruster * qmp_device_list_properties() dangerous. Bad, because it's used 1214c315c27SMarkus Armbruster * by -device FOO,help. This flag serves to protect that code. 1224c315c27SMarkus Armbruster * It should never be set without a comment explaining why it is 1234c315c27SMarkus Armbruster * set. 1244c315c27SMarkus Armbruster * TODO remove once we're there 1254c315c27SMarkus Armbruster */ 1264c315c27SMarkus Armbruster bool cannot_destroy_with_object_finalize_yet; 1274c315c27SMarkus Armbruster 1281a37eca1SIgor Mammedov bool hotpluggable; 129074a86fcSAnthony Liguori 130074a86fcSAnthony Liguori /* callbacks */ 131074a86fcSAnthony Liguori void (*reset)(DeviceState *dev); 132249d4172SAndreas Färber DeviceRealize realize; 133249d4172SAndreas Färber DeviceUnrealize unrealize; 134074a86fcSAnthony Liguori 135074a86fcSAnthony Liguori /* device state */ 136074a86fcSAnthony Liguori const struct VMStateDescription *vmsd; 137074a86fcSAnthony Liguori 138074a86fcSAnthony Liguori /* Private to qdev / bus. */ 139249d4172SAndreas Färber qdev_initfn init; /* TODO remove, once users are converted to realize */ 140fe6c2117SAndreas Färber qdev_event exit; /* TODO remove, once users are converted to unrealize */ 141074a86fcSAnthony Liguori const char *bus_type; 142074a86fcSAnthony Liguori } DeviceClass; 143074a86fcSAnthony Liguori 144a5f54290SPeter Crosthwaite typedef struct NamedGPIOList NamedGPIOList; 145a5f54290SPeter Crosthwaite 146a5f54290SPeter Crosthwaite struct NamedGPIOList { 147a5f54290SPeter Crosthwaite char *name; 148a5f54290SPeter Crosthwaite qemu_irq *in; 149a5f54290SPeter Crosthwaite int num_in; 150a5f54290SPeter Crosthwaite int num_out; 151a5f54290SPeter Crosthwaite QLIST_ENTRY(NamedGPIOList) node; 152a5f54290SPeter Crosthwaite }; 153a5f54290SPeter Crosthwaite 1547983c8a3SAndreas Färber /** 1557983c8a3SAndreas Färber * DeviceState: 1567983c8a3SAndreas Färber * @realized: Indicates whether the device has been fully constructed. 1577983c8a3SAndreas Färber * 1587983c8a3SAndreas Färber * This structure should not be accessed directly. We declare it here 1597983c8a3SAndreas Färber * so that it can be embedded in individual device state structures. 1607983c8a3SAndreas Färber */ 161074a86fcSAnthony Liguori struct DeviceState { 1627983c8a3SAndreas Färber /*< private >*/ 163074a86fcSAnthony Liguori Object parent_obj; 1647983c8a3SAndreas Färber /*< public >*/ 165074a86fcSAnthony Liguori 166074a86fcSAnthony Liguori const char *id; 1677983c8a3SAndreas Färber bool realized; 168352e8da7SPaolo Bonzini bool pending_deleted_event; 169074a86fcSAnthony Liguori QemuOpts *opts; 170074a86fcSAnthony Liguori int hotplugged; 171074a86fcSAnthony Liguori BusState *parent_bus; 172a5f54290SPeter Crosthwaite QLIST_HEAD(, NamedGPIOList) gpios; 173074a86fcSAnthony Liguori QLIST_HEAD(, BusState) child_bus; 174074a86fcSAnthony Liguori int num_child_bus; 175074a86fcSAnthony Liguori int instance_id_alias; 176074a86fcSAnthony Liguori int alias_required_for_version; 177074a86fcSAnthony Liguori }; 178074a86fcSAnthony Liguori 179707ff800SPaul Durrant struct DeviceListener { 180707ff800SPaul Durrant void (*realize)(DeviceListener *listener, DeviceState *dev); 181707ff800SPaul Durrant void (*unrealize)(DeviceListener *listener, DeviceState *dev); 182707ff800SPaul Durrant QTAILQ_ENTRY(DeviceListener) link; 183707ff800SPaul Durrant }; 184707ff800SPaul Durrant 185074a86fcSAnthony Liguori #define TYPE_BUS "bus" 186074a86fcSAnthony Liguori #define BUS(obj) OBJECT_CHECK(BusState, (obj), TYPE_BUS) 187074a86fcSAnthony Liguori #define BUS_CLASS(klass) OBJECT_CLASS_CHECK(BusClass, (klass), TYPE_BUS) 188074a86fcSAnthony Liguori #define BUS_GET_CLASS(obj) OBJECT_GET_CLASS(BusClass, (obj), TYPE_BUS) 189074a86fcSAnthony Liguori 190074a86fcSAnthony Liguori struct BusClass { 191074a86fcSAnthony Liguori ObjectClass parent_class; 192074a86fcSAnthony Liguori 193074a86fcSAnthony Liguori /* FIXME first arg should be BusState */ 194074a86fcSAnthony Liguori void (*print_dev)(Monitor *mon, DeviceState *dev, int indent); 195074a86fcSAnthony Liguori char *(*get_dev_path)(DeviceState *dev); 196074a86fcSAnthony Liguori /* 197074a86fcSAnthony Liguori * This callback is used to create Open Firmware device path in accordance 198074a86fcSAnthony Liguori * with OF spec http://forthworks.com/standards/of1275.pdf. Individual bus 199074a86fcSAnthony Liguori * bindings can be found at http://playground.sun.com/1275/bindings/. 200074a86fcSAnthony Liguori */ 201074a86fcSAnthony Liguori char *(*get_fw_dev_path)(DeviceState *dev); 202dcc20931SPaolo Bonzini void (*reset)(BusState *bus); 20302e7f85dSBandan Das BusRealize realize; 20402e7f85dSBandan Das BusUnrealize unrealize; 20502e7f85dSBandan Das 2061395af6fSKONRAD Frederic /* maximum devices allowed on the bus, 0: no limit. */ 2071395af6fSKONRAD Frederic int max_dev; 20861de3676SAlexander Graf /* number of automatically allocated bus ids (e.g. ide.0) */ 20961de3676SAlexander Graf int automatic_ids; 210074a86fcSAnthony Liguori }; 211074a86fcSAnthony Liguori 212074a86fcSAnthony Liguori typedef struct BusChild { 213074a86fcSAnthony Liguori DeviceState *child; 214074a86fcSAnthony Liguori int index; 215074a86fcSAnthony Liguori QTAILQ_ENTRY(BusChild) sibling; 216074a86fcSAnthony Liguori } BusChild; 217074a86fcSAnthony Liguori 2180ee4de6cSIgor Mammedov #define QDEV_HOTPLUG_HANDLER_PROPERTY "hotplug-handler" 2190ee4de6cSIgor Mammedov 220074a86fcSAnthony Liguori /** 221074a86fcSAnthony Liguori * BusState: 2220ee4de6cSIgor Mammedov * @hotplug_device: link to a hotplug device associated with bus. 223074a86fcSAnthony Liguori */ 224074a86fcSAnthony Liguori struct BusState { 225074a86fcSAnthony Liguori Object obj; 226074a86fcSAnthony Liguori DeviceState *parent; 227*f73480c3SMarc-André Lureau char *name; 2280ee4de6cSIgor Mammedov HotplugHandler *hotplug_handler; 229074a86fcSAnthony Liguori int max_index; 23002e7f85dSBandan Das bool realized; 231074a86fcSAnthony Liguori QTAILQ_HEAD(ChildrenHead, BusChild) children; 232074a86fcSAnthony Liguori QLIST_ENTRY(BusState) sibling; 233074a86fcSAnthony Liguori }; 234074a86fcSAnthony Liguori 235074a86fcSAnthony Liguori struct Property { 236074a86fcSAnthony Liguori const char *name; 237074a86fcSAnthony Liguori PropertyInfo *info; 2383b6ca402SIldar Isaev ptrdiff_t offset; 239074a86fcSAnthony Liguori uint8_t bitnr; 2401310a3d3SEric Blake QType qtype; 241074a86fcSAnthony Liguori int64_t defval; 2420be6bfacSPeter Maydell int arrayoffset; 2430be6bfacSPeter Maydell PropertyInfo *arrayinfo; 2440be6bfacSPeter Maydell int arrayfieldsize; 245074a86fcSAnthony Liguori }; 246074a86fcSAnthony Liguori 247074a86fcSAnthony Liguori struct PropertyInfo { 248074a86fcSAnthony Liguori const char *name; 24951b2e8c3SGonglei const char *description; 2502e4450ffSDaniel P. Berrange const char * const *enum_table; 251074a86fcSAnthony Liguori int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len); 252074a86fcSAnthony Liguori ObjectPropertyAccessor *get; 253074a86fcSAnthony Liguori ObjectPropertyAccessor *set; 254074a86fcSAnthony Liguori ObjectPropertyRelease *release; 255074a86fcSAnthony Liguori }; 256074a86fcSAnthony Liguori 2579f9260a3SDon Slutz /** 2589f9260a3SDon Slutz * GlobalProperty: 259b3ce84feSEduardo Habkost * @user_provided: Set to true if property comes from user-provided config 260b3ce84feSEduardo Habkost * (command-line or config file). 261b3ce84feSEduardo Habkost * @used: Set to true if property was used when initializing a device. 26277280adbSEduardo Habkost * @errp: Error destination, used like first argument of error_setg() 26377280adbSEduardo Habkost * in case property setting fails later. If @errp is NULL, we 264b3443f43SGreg Kurz * print warnings instead of ignoring errors silently. For 265b3443f43SGreg Kurz * hotplugged devices, errp is always ignored and warnings are 266b3443f43SGreg Kurz * printed instead. 2679f9260a3SDon Slutz */ 268074a86fcSAnthony Liguori typedef struct GlobalProperty { 269074a86fcSAnthony Liguori const char *driver; 270074a86fcSAnthony Liguori const char *property; 271074a86fcSAnthony Liguori const char *value; 272b3ce84feSEduardo Habkost bool user_provided; 273b3ce84feSEduardo Habkost bool used; 27477280adbSEduardo Habkost Error **errp; 275074a86fcSAnthony Liguori } GlobalProperty; 276074a86fcSAnthony Liguori 277074a86fcSAnthony Liguori /*** Board API. This should go away once we have a machine config file. ***/ 278074a86fcSAnthony Liguori 279074a86fcSAnthony Liguori DeviceState *qdev_create(BusState *bus, const char *name); 280074a86fcSAnthony Liguori DeviceState *qdev_try_create(BusState *bus, const char *name); 281074a86fcSAnthony Liguori void qdev_init_nofail(DeviceState *dev); 282074a86fcSAnthony Liguori void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id, 283074a86fcSAnthony Liguori int required_for_version); 284c06b2ffbSZhu Guihua HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev); 285074a86fcSAnthony Liguori void qdev_unplug(DeviceState *dev, Error **errp); 286014176f9SIgor Mammedov void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev, 287014176f9SIgor Mammedov DeviceState *dev, Error **errp); 288074a86fcSAnthony Liguori void qdev_machine_creation_done(void); 289074a86fcSAnthony Liguori bool qdev_machine_modified(void); 290074a86fcSAnthony Liguori 291074a86fcSAnthony Liguori qemu_irq qdev_get_gpio_in(DeviceState *dev, int n); 292a5f54290SPeter Crosthwaite qemu_irq qdev_get_gpio_in_named(DeviceState *dev, const char *name, int n); 293a5f54290SPeter Crosthwaite 294074a86fcSAnthony Liguori void qdev_connect_gpio_out(DeviceState *dev, int n, qemu_irq pin); 295a5f54290SPeter Crosthwaite void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n, 296a5f54290SPeter Crosthwaite qemu_irq pin); 297b7973186SAlexander Graf qemu_irq qdev_get_gpio_out_connector(DeviceState *dev, const char *name, int n); 2980c24db2bSPeter Crosthwaite qemu_irq qdev_intercept_gpio_out(DeviceState *dev, qemu_irq icpt, 2990c24db2bSPeter Crosthwaite const char *name, int n); 300074a86fcSAnthony Liguori 301074a86fcSAnthony Liguori BusState *qdev_get_child_bus(DeviceState *dev, const char *name); 302074a86fcSAnthony Liguori 303074a86fcSAnthony Liguori /*** Device API. ***/ 304074a86fcSAnthony Liguori 305074a86fcSAnthony Liguori /* Register device properties. */ 306074a86fcSAnthony Liguori /* GPIO inputs also double as IRQ sinks. */ 307074a86fcSAnthony Liguori void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n); 308074a86fcSAnthony Liguori void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n); 309a5f54290SPeter Crosthwaite void qdev_init_gpio_in_named(DeviceState *dev, qemu_irq_handler handler, 310a5f54290SPeter Crosthwaite const char *name, int n); 311a5f54290SPeter Crosthwaite void qdev_init_gpio_out_named(DeviceState *dev, qemu_irq *pins, 312a5f54290SPeter Crosthwaite const char *name, int n); 313074a86fcSAnthony Liguori 31417a96a14SPeter Crosthwaite void qdev_pass_gpios(DeviceState *dev, DeviceState *container, 31517a96a14SPeter Crosthwaite const char *name); 31617a96a14SPeter Crosthwaite 317074a86fcSAnthony Liguori BusState *qdev_get_parent_bus(DeviceState *dev); 318074a86fcSAnthony Liguori 319074a86fcSAnthony Liguori /*** BUS API. ***/ 320074a86fcSAnthony Liguori 321074a86fcSAnthony Liguori DeviceState *qdev_find_recursive(BusState *bus, const char *id); 322074a86fcSAnthony Liguori 323074a86fcSAnthony Liguori /* Returns 0 to walk children, > 0 to skip walk, < 0 to terminate walk. */ 324074a86fcSAnthony Liguori typedef int (qbus_walkerfn)(BusState *bus, void *opaque); 325074a86fcSAnthony Liguori typedef int (qdev_walkerfn)(DeviceState *dev, void *opaque); 326074a86fcSAnthony Liguori 327fb17dfe0SAndreas Färber void qbus_create_inplace(void *bus, size_t size, const char *typename, 328074a86fcSAnthony Liguori DeviceState *parent, const char *name); 329074a86fcSAnthony Liguori BusState *qbus_create(const char *typename, DeviceState *parent, const char *name); 330074a86fcSAnthony Liguori /* Returns > 0 if either devfn or busfn skip walk somewhere in cursion, 331074a86fcSAnthony Liguori * < 0 if either devfn or busfn terminate walk somewhere in cursion, 332074a86fcSAnthony Liguori * 0 otherwise. */ 3330293214bSPaolo Bonzini int qbus_walk_children(BusState *bus, 3340293214bSPaolo Bonzini qdev_walkerfn *pre_devfn, qbus_walkerfn *pre_busfn, 3350293214bSPaolo Bonzini qdev_walkerfn *post_devfn, qbus_walkerfn *post_busfn, 3360293214bSPaolo Bonzini void *opaque); 3370293214bSPaolo Bonzini int qdev_walk_children(DeviceState *dev, 3380293214bSPaolo Bonzini qdev_walkerfn *pre_devfn, qbus_walkerfn *pre_busfn, 3390293214bSPaolo Bonzini qdev_walkerfn *post_devfn, qbus_walkerfn *post_busfn, 3400293214bSPaolo Bonzini void *opaque); 3410293214bSPaolo Bonzini 342074a86fcSAnthony Liguori void qdev_reset_all(DeviceState *dev); 343ff8de075SDavid Hildenbrand void qdev_reset_all_fn(void *opaque); 344d0508c36SPaolo Bonzini 345d0508c36SPaolo Bonzini /** 346d0508c36SPaolo Bonzini * @qbus_reset_all: 347d0508c36SPaolo Bonzini * @bus: Bus to be reset. 348d0508c36SPaolo Bonzini * 349d0508c36SPaolo Bonzini * Reset @bus and perform a bus-level ("hard") reset of all devices connected 350d0508c36SPaolo Bonzini * to it, including recursive processing of all buses below @bus itself. A 351d0508c36SPaolo Bonzini * hard reset means that qbus_reset_all will reset all state of the device. 352d0508c36SPaolo Bonzini * For PCI devices, for example, this will include the base address registers 353d0508c36SPaolo Bonzini * or configuration space. 354d0508c36SPaolo Bonzini */ 355d0508c36SPaolo Bonzini void qbus_reset_all(BusState *bus); 356074a86fcSAnthony Liguori void qbus_reset_all_fn(void *opaque); 357074a86fcSAnthony Liguori 358074a86fcSAnthony Liguori /* This should go away once we get rid of the NULL bus hack */ 359074a86fcSAnthony Liguori BusState *sysbus_get_default(void); 360074a86fcSAnthony Liguori 361074a86fcSAnthony Liguori char *qdev_get_fw_dev_path(DeviceState *dev); 3620be63901SGonglei char *qdev_get_own_fw_dev_path_from_handler(BusState *bus, DeviceState *dev); 363074a86fcSAnthony Liguori 364074a86fcSAnthony Liguori /** 365074a86fcSAnthony Liguori * @qdev_machine_init 366074a86fcSAnthony Liguori * 367074a86fcSAnthony Liguori * Initialize platform devices before machine init. This is a hack until full 368074a86fcSAnthony Liguori * support for composition is added. 369074a86fcSAnthony Liguori */ 370074a86fcSAnthony Liguori void qdev_machine_init(void); 371074a86fcSAnthony Liguori 372074a86fcSAnthony Liguori /** 373074a86fcSAnthony Liguori * @device_reset 374074a86fcSAnthony Liguori * 375074a86fcSAnthony Liguori * Reset a single device (by calling the reset method). 376074a86fcSAnthony Liguori */ 377074a86fcSAnthony Liguori void device_reset(DeviceState *dev); 378074a86fcSAnthony Liguori 379074a86fcSAnthony Liguori const struct VMStateDescription *qdev_get_vmsd(DeviceState *dev); 380074a86fcSAnthony Liguori 381074a86fcSAnthony Liguori const char *qdev_fw_name(DeviceState *dev); 382074a86fcSAnthony Liguori 383074a86fcSAnthony Liguori Object *qdev_get_machine(void); 384074a86fcSAnthony Liguori 385074a86fcSAnthony Liguori /* FIXME: make this a link<> */ 386074a86fcSAnthony Liguori void qdev_set_parent_bus(DeviceState *dev, BusState *bus); 387074a86fcSAnthony Liguori 388074a86fcSAnthony Liguori extern int qdev_hotplug; 389074a86fcSAnthony Liguori 390074a86fcSAnthony Liguori char *qdev_get_dev_path(DeviceState *dev); 391074a86fcSAnthony Liguori 3924cae4d5aSMarcel Apfelbaum GSList *qdev_build_hotpluggable_device_list(Object *peripheral); 39366e56b13SZhu Guihua 394431bbb26SIgor Mammedov void qbus_set_hotplug_handler(BusState *bus, DeviceState *handler, 395431bbb26SIgor Mammedov Error **errp); 396431bbb26SIgor Mammedov 397431bbb26SIgor Mammedov void qbus_set_bus_hotplug_handler(BusState *bus, Error **errp); 39839b888bdSIgor Mammedov 39939b888bdSIgor Mammedov static inline bool qbus_is_hotpluggable(BusState *bus) 40039b888bdSIgor Mammedov { 4012d9a982fSIgor Mammedov return bus->hotplug_handler; 40239b888bdSIgor Mammedov } 403707ff800SPaul Durrant 404707ff800SPaul Durrant void device_listener_register(DeviceListener *listener); 405707ff800SPaul Durrant void device_listener_unregister(DeviceListener *listener); 406707ff800SPaul Durrant 407074a86fcSAnthony Liguori #endif 408