hw/arm/virt: introduce DEFINE_VIRT_MACHINE
[qemu/ar7.git] / include / hw / hotplug.h
blobda1d0e4ab80b7c9e57c002951da954b40876c68a
1 /*
2 * Hotplug handler interface.
4 * Copyright (c) 2014 Red Hat Inc.
6 * Authors:
7 * Igor Mammedov <imammedo@redhat.com>,
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
12 #ifndef HOTPLUG_H
13 #define HOTPLUG_H
15 #include "qom/object.h"
17 #define TYPE_HOTPLUG_HANDLER "hotplug-handler"
19 #define HOTPLUG_HANDLER_CLASS(klass) \
20 OBJECT_CLASS_CHECK(HotplugHandlerClass, (klass), TYPE_HOTPLUG_HANDLER)
21 #define HOTPLUG_HANDLER_GET_CLASS(obj) \
22 OBJECT_GET_CLASS(HotplugHandlerClass, (obj), TYPE_HOTPLUG_HANDLER)
23 #define HOTPLUG_HANDLER(obj) \
24 INTERFACE_CHECK(HotplugHandler, (obj), TYPE_HOTPLUG_HANDLER)
27 typedef struct HotplugHandler {
28 /* <private> */
29 Object Parent;
30 } HotplugHandler;
32 /**
33 * hotplug_fn:
34 * @plug_handler: a device performing plug/uplug action
35 * @plugged_dev: a device that has been (un)plugged
36 * @errp: returns an error if this function fails
38 typedef void (*hotplug_fn)(HotplugHandler *plug_handler,
39 DeviceState *plugged_dev, Error **errp);
41 /**
42 * HotplugDeviceClass:
44 * Interface to be implemented by a device performing
45 * hardware (un)plug functions.
47 * @parent: Opaque parent interface.
48 * @plug: plug callback.
49 * @unplug_request: unplug request callback.
50 * Used as a means to initiate device unplug for devices that
51 * require asynchronous unplug handling.
52 * @unplug: unplug callback.
53 * Used for device removal with devices that implement
54 * asynchronous and synchronous (surprise) removal.
56 typedef struct HotplugHandlerClass {
57 /* <private> */
58 InterfaceClass parent;
60 /* <public> */
61 hotplug_fn plug;
62 hotplug_fn unplug_request;
63 hotplug_fn unplug;
64 } HotplugHandlerClass;
66 /**
67 * hotplug_handler_plug:
69 * Call #HotplugHandlerClass.plug callback of @plug_handler.
71 void hotplug_handler_plug(HotplugHandler *plug_handler,
72 DeviceState *plugged_dev,
73 Error **errp);
75 /**
76 * hotplug_handler_unplug_request:
78 * Calls #HotplugHandlerClass.unplug_request callback of @plug_handler.
80 void hotplug_handler_unplug_request(HotplugHandler *plug_handler,
81 DeviceState *plugged_dev,
82 Error **errp);
83 /**
84 * hotplug_handler_unplug:
86 * Calls #HotplugHandlerClass.unplug callback of @plug_handler.
88 void hotplug_handler_unplug(HotplugHandler *plug_handler,
89 DeviceState *plugged_dev,
90 Error **errp);
91 #endif