]>
Commit | Line | Data |
---|---|---|
9f117d41 IM |
1 | /* |
2 | * Hotplug handler interface. | |
3 | * | |
4 | * Copyright (c) 2014 Red Hat Inc. | |
5 | * | |
6 | * Authors: | |
7 | * Igor Mammedov <[email protected]>, | |
8 | * | |
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. | |
11 | */ | |
12 | #ifndef HOTPLUG_H | |
13 | #define HOTPLUG_H | |
14 | ||
15 | #include "qom/object.h" | |
9f117d41 IM |
16 | |
17 | #define TYPE_HOTPLUG_HANDLER "hotplug-handler" | |
18 | ||
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) | |
25 | ||
26 | ||
27 | typedef struct HotplugHandler { | |
28 | /* <private> */ | |
29 | Object Parent; | |
30 | } HotplugHandler; | |
31 | ||
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 | |
37 | */ | |
38 | typedef void (*hotplug_fn)(HotplugHandler *plug_handler, | |
39 | DeviceState *plugged_dev, Error **errp); | |
40 | ||
41 | /** | |
42 | * HotplugDeviceClass: | |
43 | * | |
44 | * Interface to be implemented by a device performing | |
45 | * hardware (un)plug functions. | |
46 | * | |
47 | * @parent: Opaque parent interface. | |
41346263 IM |
48 | * @pre_plug: pre plug callback called at start of device.realize(true) |
49 | * @plug: plug callback called at end of device.realize(true). | |
25e89788 SH |
50 | * @post_plug: post plug callback called after device.realize(true) and device |
51 | * reset | |
14d5a28f IM |
52 | * @unplug_request: unplug request callback. |
53 | * Used as a means to initiate device unplug for devices that | |
54 | * require asynchronous unplug handling. | |
181a2c63 IM |
55 | * @unplug: unplug callback. |
56 | * Used for device removal with devices that implement | |
b4952c36 | 57 | * asynchronous and synchronous (surprise) removal. |
9f117d41 IM |
58 | */ |
59 | typedef struct HotplugHandlerClass { | |
60 | /* <private> */ | |
61 | InterfaceClass parent; | |
62 | ||
63 | /* <public> */ | |
41346263 | 64 | hotplug_fn pre_plug; |
9f117d41 | 65 | hotplug_fn plug; |
25e89788 | 66 | void (*post_plug)(HotplugHandler *plug_handler, DeviceState *plugged_dev); |
14d5a28f | 67 | hotplug_fn unplug_request; |
181a2c63 | 68 | hotplug_fn unplug; |
9f117d41 IM |
69 | } HotplugHandlerClass; |
70 | ||
71 | /** | |
72 | * hotplug_handler_plug: | |
73 | * | |
74 | * Call #HotplugHandlerClass.plug callback of @plug_handler. | |
75 | */ | |
76 | void hotplug_handler_plug(HotplugHandler *plug_handler, | |
77 | DeviceState *plugged_dev, | |
78 | Error **errp); | |
79 | ||
41346263 IM |
80 | /** |
81 | * hotplug_handler_pre_plug: | |
82 | * | |
83 | * Call #HotplugHandlerClass.pre_plug callback of @plug_handler. | |
84 | */ | |
85 | void hotplug_handler_pre_plug(HotplugHandler *plug_handler, | |
86 | DeviceState *plugged_dev, | |
87 | Error **errp); | |
88 | ||
25e89788 SH |
89 | /** |
90 | * hotplug_handler_post_plug: | |
91 | * | |
92 | * Call #HotplugHandlerClass.post_plug callback of @plug_handler. | |
93 | */ | |
94 | void hotplug_handler_post_plug(HotplugHandler *plug_handler, | |
95 | DeviceState *plugged_dev); | |
96 | ||
9f117d41 | 97 | /** |
14d5a28f | 98 | * hotplug_handler_unplug_request: |
9f117d41 | 99 | * |
14d5a28f | 100 | * Calls #HotplugHandlerClass.unplug_request callback of @plug_handler. |
9f117d41 | 101 | */ |
14d5a28f IM |
102 | void hotplug_handler_unplug_request(HotplugHandler *plug_handler, |
103 | DeviceState *plugged_dev, | |
104 | Error **errp); | |
181a2c63 IM |
105 | /** |
106 | * hotplug_handler_unplug: | |
107 | * | |
108 | * Calls #HotplugHandlerClass.unplug callback of @plug_handler. | |
109 | */ | |
110 | void hotplug_handler_unplug(HotplugHandler *plug_handler, | |
111 | DeviceState *plugged_dev, | |
112 | Error **errp); | |
9f117d41 | 113 | #endif |