xref: /qemu/include/hw/qdev-core.h (revision 0c24db2b8c60cb578d7af6fb50c0ad60a723a02d)
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"
61de7afc9SPaolo Bonzini #include "qemu/typedefs.h"
7949fc823SMarcel Apfelbaum #include "qemu/bitmap.h"
814cccb61SPaolo Bonzini #include "qom/object.h"
9074a86fcSAnthony Liguori #include "hw/irq.h"
107b1b5d19SPaolo Bonzini #include "qapi/error.h"
110ee4de6cSIgor Mammedov #include "hw/hotplug.h"
12074a86fcSAnthony Liguori 
13074a86fcSAnthony Liguori enum {
14074a86fcSAnthony Liguori     DEV_NVECTORS_UNSPECIFIED = -1,
15074a86fcSAnthony Liguori };
16074a86fcSAnthony Liguori 
17074a86fcSAnthony Liguori #define TYPE_DEVICE "device"
18074a86fcSAnthony Liguori #define DEVICE(obj) OBJECT_CHECK(DeviceState, (obj), TYPE_DEVICE)
19074a86fcSAnthony Liguori #define DEVICE_CLASS(klass) OBJECT_CLASS_CHECK(DeviceClass, (klass), TYPE_DEVICE)
20074a86fcSAnthony Liguori #define DEVICE_GET_CLASS(obj) OBJECT_GET_CLASS(DeviceClass, (obj), TYPE_DEVICE)
21074a86fcSAnthony Liguori 
223d1237fbSMarcel Apfelbaum typedef enum DeviceCategory {
233d1237fbSMarcel Apfelbaum     DEVICE_CATEGORY_BRIDGE,
243d1237fbSMarcel Apfelbaum     DEVICE_CATEGORY_USB,
253d1237fbSMarcel Apfelbaum     DEVICE_CATEGORY_STORAGE,
263d1237fbSMarcel Apfelbaum     DEVICE_CATEGORY_NETWORK,
273d1237fbSMarcel Apfelbaum     DEVICE_CATEGORY_INPUT,
283d1237fbSMarcel Apfelbaum     DEVICE_CATEGORY_DISPLAY,
293d1237fbSMarcel Apfelbaum     DEVICE_CATEGORY_SOUND,
303d1237fbSMarcel Apfelbaum     DEVICE_CATEGORY_MISC,
313d1237fbSMarcel Apfelbaum     DEVICE_CATEGORY_MAX
323d1237fbSMarcel Apfelbaum } DeviceCategory;
333d1237fbSMarcel Apfelbaum 
34074a86fcSAnthony Liguori typedef int (*qdev_initfn)(DeviceState *dev);
35074a86fcSAnthony Liguori typedef int (*qdev_event)(DeviceState *dev);
36074a86fcSAnthony Liguori typedef void (*qdev_resetfn)(DeviceState *dev);
37249d4172SAndreas Färber typedef void (*DeviceRealize)(DeviceState *dev, Error **errp);
38249d4172SAndreas Färber typedef void (*DeviceUnrealize)(DeviceState *dev, Error **errp);
3902e7f85dSBandan Das typedef void (*BusRealize)(BusState *bus, Error **errp);
4002e7f85dSBandan Das typedef void (*BusUnrealize)(BusState *bus, Error **errp);
41074a86fcSAnthony Liguori 
42074a86fcSAnthony Liguori struct VMStateDescription;
43074a86fcSAnthony Liguori 
44249d4172SAndreas Färber /**
45249d4172SAndreas Färber  * DeviceClass:
46249d4172SAndreas Färber  * @props: Properties accessing state fields.
47249d4172SAndreas Färber  * @realize: Callback function invoked when the #DeviceState:realized
48249d4172SAndreas Färber  * property is changed to %true. The default invokes @init if not %NULL.
49249d4172SAndreas Färber  * @unrealize: Callback function invoked when the #DeviceState:realized
50249d4172SAndreas Färber  * property is changed to %false.
51249d4172SAndreas Färber  * @init: Callback function invoked when the #DeviceState::realized property
52249d4172SAndreas Färber  * is changed to %true. Deprecated, new types inheriting directly from
53249d4172SAndreas Färber  * TYPE_DEVICE should use @realize instead, new leaf types should consult
54249d4172SAndreas Färber  * their respective parent type.
551a37eca1SIgor Mammedov  * @hotpluggable: indicates if #DeviceClass is hotpluggable, available
561a37eca1SIgor Mammedov  * as readonly "hotpluggable" property of #DeviceState instance
57249d4172SAndreas Färber  *
58249d4172SAndreas Färber  * # Realization #
59249d4172SAndreas Färber  * Devices are constructed in two stages,
60249d4172SAndreas Färber  * 1) object instantiation via object_initialize() and
61249d4172SAndreas Färber  * 2) device realization via #DeviceState:realized property.
62249d4172SAndreas Färber  * The former may not fail (it might assert or exit), the latter may return
63249d4172SAndreas Färber  * error information to the caller and must be re-entrant.
64249d4172SAndreas Färber  * Trivial field initializations should go into #TypeInfo.instance_init.
65249d4172SAndreas Färber  * Operations depending on @props static properties should go into @realize.
66249d4172SAndreas Färber  * After successful realization, setting static properties will fail.
67249d4172SAndreas Färber  *
68249d4172SAndreas Färber  * As an interim step, the #DeviceState:realized property is set by deprecated
69249d4172SAndreas Färber  * functions qdev_init() and qdev_init_nofail().
70249d4172SAndreas Färber  * In the future, devices will propagate this state change to their children
71249d4172SAndreas Färber  * and along busses they expose.
72249d4172SAndreas Färber  * The point in time will be deferred to machine creation, so that values
73249d4172SAndreas Färber  * set in @realize will not be introspectable beforehand. Therefore devices
74249d4172SAndreas Färber  * must not create children during @realize; they should initialize them via
75249d4172SAndreas Färber  * object_initialize() in their own #TypeInfo.instance_init and forward the
76249d4172SAndreas Färber  * realization events appropriately.
77249d4172SAndreas Färber  *
78249d4172SAndreas Färber  * The @init callback is considered private to a particular bus implementation
79249d4172SAndreas Färber  * (immediate abstract child types of TYPE_DEVICE). Derived leaf types set an
80249d4172SAndreas Färber  * "init" callback on their parent class instead.
81782beb52SAndreas Färber  *
82249d4172SAndreas Färber  * Any type may override the @realize and/or @unrealize callbacks but needs
83782beb52SAndreas Färber  * to call the parent type's implementation if keeping their functionality
84782beb52SAndreas Färber  * is desired. Refer to QOM documentation for further discussion and examples.
85782beb52SAndreas Färber  *
86782beb52SAndreas Färber  * <note>
87782beb52SAndreas Färber  *   <para>
88249d4172SAndreas Färber  * If a type derived directly from TYPE_DEVICE implements @realize, it does
89249d4172SAndreas Färber  * not need to implement @init and therefore does not need to store and call
90249d4172SAndreas Färber  * #DeviceClass' default @realize callback.
91782beb52SAndreas Färber  * For other types consult the documentation and implementation of the
92782beb52SAndreas Färber  * respective parent types.
93782beb52SAndreas Färber  *   </para>
94782beb52SAndreas Färber  * </note>
95249d4172SAndreas Färber  */
96074a86fcSAnthony Liguori typedef struct DeviceClass {
97249d4172SAndreas Färber     /*< private >*/
98074a86fcSAnthony Liguori     ObjectClass parent_class;
99249d4172SAndreas Färber     /*< public >*/
100074a86fcSAnthony Liguori 
1013d1237fbSMarcel Apfelbaum     DECLARE_BITMAP(categories, DEVICE_CATEGORY_MAX);
102074a86fcSAnthony Liguori     const char *fw_name;
103074a86fcSAnthony Liguori     const char *desc;
104074a86fcSAnthony Liguori     Property *props;
105efec3dd6SMarkus Armbruster 
106efec3dd6SMarkus Armbruster     /*
107efec3dd6SMarkus Armbruster      * Shall we hide this device model from -device / device_add?
108efec3dd6SMarkus Armbruster      * All devices should support instantiation with device_add, and
109efec3dd6SMarkus Armbruster      * this flag should not exist.  But we're not there, yet.  Some
110efec3dd6SMarkus Armbruster      * devices fail to instantiate with cryptic error messages.
111efec3dd6SMarkus Armbruster      * Others instantiate, but don't work.  Exposing users to such
112efec3dd6SMarkus Armbruster      * behavior would be cruel; this flag serves to protect them.  It
113efec3dd6SMarkus Armbruster      * should never be set without a comment explaining why it is set.
114efec3dd6SMarkus Armbruster      * TODO remove once we're there
115efec3dd6SMarkus Armbruster      */
116efec3dd6SMarkus Armbruster     bool cannot_instantiate_with_device_add_yet;
1171a37eca1SIgor Mammedov     bool hotpluggable;
118074a86fcSAnthony Liguori 
119074a86fcSAnthony Liguori     /* callbacks */
120074a86fcSAnthony Liguori     void (*reset)(DeviceState *dev);
121249d4172SAndreas Färber     DeviceRealize realize;
122249d4172SAndreas Färber     DeviceUnrealize unrealize;
123074a86fcSAnthony Liguori 
124074a86fcSAnthony Liguori     /* device state */
125074a86fcSAnthony Liguori     const struct VMStateDescription *vmsd;
126074a86fcSAnthony Liguori 
127074a86fcSAnthony Liguori     /* Private to qdev / bus.  */
128249d4172SAndreas Färber     qdev_initfn init; /* TODO remove, once users are converted to realize */
129fe6c2117SAndreas Färber     qdev_event exit; /* TODO remove, once users are converted to unrealize */
130074a86fcSAnthony Liguori     const char *bus_type;
131074a86fcSAnthony Liguori } DeviceClass;
132074a86fcSAnthony Liguori 
133a5f54290SPeter Crosthwaite typedef struct NamedGPIOList NamedGPIOList;
134a5f54290SPeter Crosthwaite 
135a5f54290SPeter Crosthwaite struct NamedGPIOList {
136a5f54290SPeter Crosthwaite     char *name;
137a5f54290SPeter Crosthwaite     qemu_irq *in;
138a5f54290SPeter Crosthwaite     int num_in;
139a5f54290SPeter Crosthwaite     qemu_irq *out;
140a5f54290SPeter Crosthwaite     int num_out;
141a5f54290SPeter Crosthwaite     QLIST_ENTRY(NamedGPIOList) node;
142a5f54290SPeter Crosthwaite };
143a5f54290SPeter Crosthwaite 
1447983c8a3SAndreas Färber /**
1457983c8a3SAndreas Färber  * DeviceState:
1467983c8a3SAndreas Färber  * @realized: Indicates whether the device has been fully constructed.
1477983c8a3SAndreas Färber  *
1487983c8a3SAndreas Färber  * This structure should not be accessed directly.  We declare it here
1497983c8a3SAndreas Färber  * so that it can be embedded in individual device state structures.
1507983c8a3SAndreas Färber  */
151074a86fcSAnthony Liguori struct DeviceState {
1527983c8a3SAndreas Färber     /*< private >*/
153074a86fcSAnthony Liguori     Object parent_obj;
1547983c8a3SAndreas Färber     /*< public >*/
155074a86fcSAnthony Liguori 
156074a86fcSAnthony Liguori     const char *id;
1577983c8a3SAndreas Färber     bool realized;
158352e8da7SPaolo Bonzini     bool pending_deleted_event;
159074a86fcSAnthony Liguori     QemuOpts *opts;
160074a86fcSAnthony Liguori     int hotplugged;
161074a86fcSAnthony Liguori     BusState *parent_bus;
162a5f54290SPeter Crosthwaite     QLIST_HEAD(, NamedGPIOList) gpios;
163074a86fcSAnthony Liguori     QLIST_HEAD(, BusState) child_bus;
164074a86fcSAnthony Liguori     int num_child_bus;
165074a86fcSAnthony Liguori     int instance_id_alias;
166074a86fcSAnthony Liguori     int alias_required_for_version;
167074a86fcSAnthony Liguori };
168074a86fcSAnthony Liguori 
169074a86fcSAnthony Liguori #define TYPE_BUS "bus"
170074a86fcSAnthony Liguori #define BUS(obj) OBJECT_CHECK(BusState, (obj), TYPE_BUS)
171074a86fcSAnthony Liguori #define BUS_CLASS(klass) OBJECT_CLASS_CHECK(BusClass, (klass), TYPE_BUS)
172074a86fcSAnthony Liguori #define BUS_GET_CLASS(obj) OBJECT_GET_CLASS(BusClass, (obj), TYPE_BUS)
173074a86fcSAnthony Liguori 
174074a86fcSAnthony Liguori struct BusClass {
175074a86fcSAnthony Liguori     ObjectClass parent_class;
176074a86fcSAnthony Liguori 
177074a86fcSAnthony Liguori     /* FIXME first arg should be BusState */
178074a86fcSAnthony Liguori     void (*print_dev)(Monitor *mon, DeviceState *dev, int indent);
179074a86fcSAnthony Liguori     char *(*get_dev_path)(DeviceState *dev);
180074a86fcSAnthony Liguori     /*
181074a86fcSAnthony Liguori      * This callback is used to create Open Firmware device path in accordance
182074a86fcSAnthony Liguori      * with OF spec http://forthworks.com/standards/of1275.pdf. Individual bus
183074a86fcSAnthony Liguori      * bindings can be found at http://playground.sun.com/1275/bindings/.
184074a86fcSAnthony Liguori      */
185074a86fcSAnthony Liguori     char *(*get_fw_dev_path)(DeviceState *dev);
186dcc20931SPaolo Bonzini     void (*reset)(BusState *bus);
18702e7f85dSBandan Das     BusRealize realize;
18802e7f85dSBandan Das     BusUnrealize unrealize;
18902e7f85dSBandan Das 
1901395af6fSKONRAD Frederic     /* maximum devices allowed on the bus, 0: no limit. */
1911395af6fSKONRAD Frederic     int max_dev;
19261de3676SAlexander Graf     /* number of automatically allocated bus ids (e.g. ide.0) */
19361de3676SAlexander Graf     int automatic_ids;
194074a86fcSAnthony Liguori };
195074a86fcSAnthony Liguori 
196074a86fcSAnthony Liguori typedef struct BusChild {
197074a86fcSAnthony Liguori     DeviceState *child;
198074a86fcSAnthony Liguori     int index;
199074a86fcSAnthony Liguori     QTAILQ_ENTRY(BusChild) sibling;
200074a86fcSAnthony Liguori } BusChild;
201074a86fcSAnthony Liguori 
2020ee4de6cSIgor Mammedov #define QDEV_HOTPLUG_HANDLER_PROPERTY "hotplug-handler"
2030ee4de6cSIgor Mammedov 
204074a86fcSAnthony Liguori /**
205074a86fcSAnthony Liguori  * BusState:
2060ee4de6cSIgor Mammedov  * @hotplug_device: link to a hotplug device associated with bus.
207074a86fcSAnthony Liguori  */
208074a86fcSAnthony Liguori struct BusState {
209074a86fcSAnthony Liguori     Object obj;
210074a86fcSAnthony Liguori     DeviceState *parent;
211074a86fcSAnthony Liguori     const char *name;
2120ee4de6cSIgor Mammedov     HotplugHandler *hotplug_handler;
213074a86fcSAnthony Liguori     int max_index;
21402e7f85dSBandan Das     bool realized;
215074a86fcSAnthony Liguori     QTAILQ_HEAD(ChildrenHead, BusChild) children;
216074a86fcSAnthony Liguori     QLIST_ENTRY(BusState) sibling;
217074a86fcSAnthony Liguori };
218074a86fcSAnthony Liguori 
219074a86fcSAnthony Liguori struct Property {
220074a86fcSAnthony Liguori     const char   *name;
221074a86fcSAnthony Liguori     PropertyInfo *info;
222074a86fcSAnthony Liguori     int          offset;
223074a86fcSAnthony Liguori     uint8_t      bitnr;
224074a86fcSAnthony Liguori     uint8_t      qtype;
225074a86fcSAnthony Liguori     int64_t      defval;
2260be6bfacSPeter Maydell     int          arrayoffset;
2270be6bfacSPeter Maydell     PropertyInfo *arrayinfo;
2280be6bfacSPeter Maydell     int          arrayfieldsize;
229074a86fcSAnthony Liguori };
230074a86fcSAnthony Liguori 
231074a86fcSAnthony Liguori struct PropertyInfo {
232074a86fcSAnthony Liguori     const char *name;
23351b2e8c3SGonglei     const char *description;
234074a86fcSAnthony Liguori     const char **enum_table;
235074a86fcSAnthony Liguori     int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len);
236074a86fcSAnthony Liguori     ObjectPropertyAccessor *get;
237074a86fcSAnthony Liguori     ObjectPropertyAccessor *set;
238074a86fcSAnthony Liguori     ObjectPropertyRelease *release;
239074a86fcSAnthony Liguori };
240074a86fcSAnthony Liguori 
2419f9260a3SDon Slutz /**
2429f9260a3SDon Slutz  * GlobalProperty:
243b3ce84feSEduardo Habkost  * @user_provided: Set to true if property comes from user-provided config
244b3ce84feSEduardo Habkost  * (command-line or config file).
245b3ce84feSEduardo Habkost  * @used: Set to true if property was used when initializing a device.
2469f9260a3SDon Slutz  */
247074a86fcSAnthony Liguori typedef struct GlobalProperty {
248074a86fcSAnthony Liguori     const char *driver;
249074a86fcSAnthony Liguori     const char *property;
250074a86fcSAnthony Liguori     const char *value;
251b3ce84feSEduardo Habkost     bool user_provided;
252b3ce84feSEduardo Habkost     bool used;
253074a86fcSAnthony Liguori     QTAILQ_ENTRY(GlobalProperty) next;
254074a86fcSAnthony Liguori } GlobalProperty;
255074a86fcSAnthony Liguori 
256074a86fcSAnthony Liguori /*** Board API.  This should go away once we have a machine config file.  ***/
257074a86fcSAnthony Liguori 
258074a86fcSAnthony Liguori DeviceState *qdev_create(BusState *bus, const char *name);
259074a86fcSAnthony Liguori DeviceState *qdev_try_create(BusState *bus, const char *name);
260074a86fcSAnthony Liguori int qdev_init(DeviceState *dev) QEMU_WARN_UNUSED_RESULT;
261074a86fcSAnthony Liguori void qdev_init_nofail(DeviceState *dev);
262074a86fcSAnthony Liguori void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
263074a86fcSAnthony Liguori                                  int required_for_version);
264074a86fcSAnthony Liguori void qdev_unplug(DeviceState *dev, Error **errp);
265014176f9SIgor Mammedov void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev,
266014176f9SIgor Mammedov                                   DeviceState *dev, Error **errp);
267074a86fcSAnthony Liguori void qdev_machine_creation_done(void);
268074a86fcSAnthony Liguori bool qdev_machine_modified(void);
269074a86fcSAnthony Liguori 
270074a86fcSAnthony Liguori qemu_irq qdev_get_gpio_in(DeviceState *dev, int n);
271a5f54290SPeter Crosthwaite qemu_irq qdev_get_gpio_in_named(DeviceState *dev, const char *name, int n);
272a5f54290SPeter Crosthwaite 
273074a86fcSAnthony Liguori void qdev_connect_gpio_out(DeviceState *dev, int n, qemu_irq pin);
274a5f54290SPeter Crosthwaite void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n,
275a5f54290SPeter Crosthwaite                                  qemu_irq pin);
276*0c24db2bSPeter Crosthwaite qemu_irq qdev_intercept_gpio_out(DeviceState *dev, qemu_irq icpt,
277*0c24db2bSPeter Crosthwaite                                  const char *name, int n);
278074a86fcSAnthony Liguori 
279074a86fcSAnthony Liguori BusState *qdev_get_child_bus(DeviceState *dev, const char *name);
280074a86fcSAnthony Liguori 
281074a86fcSAnthony Liguori /*** Device API.  ***/
282074a86fcSAnthony Liguori 
283074a86fcSAnthony Liguori /* Register device properties.  */
284074a86fcSAnthony Liguori /* GPIO inputs also double as IRQ sinks.  */
285074a86fcSAnthony Liguori void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n);
286074a86fcSAnthony Liguori void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n);
287a5f54290SPeter Crosthwaite void qdev_init_gpio_in_named(DeviceState *dev, qemu_irq_handler handler,
288a5f54290SPeter Crosthwaite                              const char *name, int n);
289a5f54290SPeter Crosthwaite void qdev_init_gpio_out_named(DeviceState *dev, qemu_irq *pins,
290a5f54290SPeter Crosthwaite                               const char *name, int n);
291074a86fcSAnthony Liguori 
292074a86fcSAnthony Liguori BusState *qdev_get_parent_bus(DeviceState *dev);
293074a86fcSAnthony Liguori 
294074a86fcSAnthony Liguori /*** BUS API. ***/
295074a86fcSAnthony Liguori 
296074a86fcSAnthony Liguori DeviceState *qdev_find_recursive(BusState *bus, const char *id);
297074a86fcSAnthony Liguori 
298074a86fcSAnthony Liguori /* Returns 0 to walk children, > 0 to skip walk, < 0 to terminate walk. */
299074a86fcSAnthony Liguori typedef int (qbus_walkerfn)(BusState *bus, void *opaque);
300074a86fcSAnthony Liguori typedef int (qdev_walkerfn)(DeviceState *dev, void *opaque);
301074a86fcSAnthony Liguori 
302fb17dfe0SAndreas Färber void qbus_create_inplace(void *bus, size_t size, const char *typename,
303074a86fcSAnthony Liguori                          DeviceState *parent, const char *name);
304074a86fcSAnthony Liguori BusState *qbus_create(const char *typename, DeviceState *parent, const char *name);
305074a86fcSAnthony Liguori /* Returns > 0 if either devfn or busfn skip walk somewhere in cursion,
306074a86fcSAnthony Liguori  *         < 0 if either devfn or busfn terminate walk somewhere in cursion,
307074a86fcSAnthony Liguori  *           0 otherwise. */
3080293214bSPaolo Bonzini int qbus_walk_children(BusState *bus,
3090293214bSPaolo Bonzini                        qdev_walkerfn *pre_devfn, qbus_walkerfn *pre_busfn,
3100293214bSPaolo Bonzini                        qdev_walkerfn *post_devfn, qbus_walkerfn *post_busfn,
3110293214bSPaolo Bonzini                        void *opaque);
3120293214bSPaolo Bonzini int qdev_walk_children(DeviceState *dev,
3130293214bSPaolo Bonzini                        qdev_walkerfn *pre_devfn, qbus_walkerfn *pre_busfn,
3140293214bSPaolo Bonzini                        qdev_walkerfn *post_devfn, qbus_walkerfn *post_busfn,
3150293214bSPaolo Bonzini                        void *opaque);
3160293214bSPaolo Bonzini 
317074a86fcSAnthony Liguori void qdev_reset_all(DeviceState *dev);
318d0508c36SPaolo Bonzini 
319d0508c36SPaolo Bonzini /**
320d0508c36SPaolo Bonzini  * @qbus_reset_all:
321d0508c36SPaolo Bonzini  * @bus: Bus to be reset.
322d0508c36SPaolo Bonzini  *
323d0508c36SPaolo Bonzini  * Reset @bus and perform a bus-level ("hard") reset of all devices connected
324d0508c36SPaolo Bonzini  * to it, including recursive processing of all buses below @bus itself.  A
325d0508c36SPaolo Bonzini  * hard reset means that qbus_reset_all will reset all state of the device.
326d0508c36SPaolo Bonzini  * For PCI devices, for example, this will include the base address registers
327d0508c36SPaolo Bonzini  * or configuration space.
328d0508c36SPaolo Bonzini  */
329d0508c36SPaolo Bonzini void qbus_reset_all(BusState *bus);
330074a86fcSAnthony Liguori void qbus_reset_all_fn(void *opaque);
331074a86fcSAnthony Liguori 
332074a86fcSAnthony Liguori /* This should go away once we get rid of the NULL bus hack */
333074a86fcSAnthony Liguori BusState *sysbus_get_default(void);
334074a86fcSAnthony Liguori 
335074a86fcSAnthony Liguori char *qdev_get_fw_dev_path(DeviceState *dev);
336074a86fcSAnthony Liguori 
337074a86fcSAnthony Liguori /**
338074a86fcSAnthony Liguori  * @qdev_machine_init
339074a86fcSAnthony Liguori  *
340074a86fcSAnthony Liguori  * Initialize platform devices before machine init.  This is a hack until full
341074a86fcSAnthony Liguori  * support for composition is added.
342074a86fcSAnthony Liguori  */
343074a86fcSAnthony Liguori void qdev_machine_init(void);
344074a86fcSAnthony Liguori 
345074a86fcSAnthony Liguori /**
346074a86fcSAnthony Liguori  * @device_reset
347074a86fcSAnthony Liguori  *
348074a86fcSAnthony Liguori  * Reset a single device (by calling the reset method).
349074a86fcSAnthony Liguori  */
350074a86fcSAnthony Liguori void device_reset(DeviceState *dev);
351074a86fcSAnthony Liguori 
352074a86fcSAnthony Liguori const struct VMStateDescription *qdev_get_vmsd(DeviceState *dev);
353074a86fcSAnthony Liguori 
354074a86fcSAnthony Liguori const char *qdev_fw_name(DeviceState *dev);
355074a86fcSAnthony Liguori 
356074a86fcSAnthony Liguori Object *qdev_get_machine(void);
357074a86fcSAnthony Liguori 
358074a86fcSAnthony Liguori /* FIXME: make this a link<> */
359074a86fcSAnthony Liguori void qdev_set_parent_bus(DeviceState *dev, BusState *bus);
360074a86fcSAnthony Liguori 
361074a86fcSAnthony Liguori extern int qdev_hotplug;
362074a86fcSAnthony Liguori 
363074a86fcSAnthony Liguori char *qdev_get_dev_path(DeviceState *dev);
364074a86fcSAnthony Liguori 
365431bbb26SIgor Mammedov void qbus_set_hotplug_handler(BusState *bus, DeviceState *handler,
366431bbb26SIgor Mammedov                               Error **errp);
367431bbb26SIgor Mammedov 
368431bbb26SIgor Mammedov void qbus_set_bus_hotplug_handler(BusState *bus, Error **errp);
36939b888bdSIgor Mammedov 
37039b888bdSIgor Mammedov static inline bool qbus_is_hotpluggable(BusState *bus)
37139b888bdSIgor Mammedov {
3722d9a982fSIgor Mammedov    return bus->hotplug_handler;
37339b888bdSIgor Mammedov }
374074a86fcSAnthony Liguori #endif
375