Merge tag 'hw-misc-20240716' of https://github.com/philmd/qemu into staging
[qemu/armbru.git] / include / hw / hotplug.h
bloba9840ed485404f9bdf6531bc563ca46242dc89c8
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 typedef struct HotplugHandlerClass HotplugHandlerClass;
20 DECLARE_CLASS_CHECKERS(HotplugHandlerClass, HOTPLUG_HANDLER,
21 TYPE_HOTPLUG_HANDLER)
22 #define HOTPLUG_HANDLER(obj) \
23 INTERFACE_CHECK(HotplugHandler, (obj), TYPE_HOTPLUG_HANDLER)
25 typedef struct HotplugHandler HotplugHandler;
27 /**
28 * hotplug_fn:
29 * @plug_handler: a device performing plug/uplug action
30 * @plugged_dev: a device that has been (un)plugged
31 * @errp: returns an error if this function fails
33 typedef void (*hotplug_fn)(HotplugHandler *plug_handler,
34 DeviceState *plugged_dev, Error **errp);
36 /**
37 * HotplugDeviceClass:
39 * Interface to be implemented by a device performing
40 * hardware (un)plug functions.
42 * @parent: Opaque parent interface.
43 * @pre_plug: pre plug callback called at start of device.realize(true)
44 * @plug: plug callback called at end of device.realize(true).
45 * @unplug_request: unplug request callback.
46 * Used as a means to initiate device unplug for devices that
47 * require asynchronous unplug handling.
48 * @unplug: unplug callback.
49 * Used for device removal with devices that implement
50 * asynchronous and synchronous (surprise) removal.
51 * @is_hotpluggable_bus: called to check if bus/its parent allow hotplug on bus
53 struct HotplugHandlerClass {
54 /* <private> */
55 InterfaceClass parent;
57 /* <public> */
58 hotplug_fn pre_plug;
59 hotplug_fn plug;
60 hotplug_fn unplug_request;
61 hotplug_fn unplug;
62 bool (*is_hotpluggable_bus)(HotplugHandler *plug_handler, BusState *bus);
65 /**
66 * hotplug_handler_plug:
68 * Call #HotplugHandlerClass.plug callback of @plug_handler.
70 void hotplug_handler_plug(HotplugHandler *plug_handler,
71 DeviceState *plugged_dev,
72 Error **errp);
74 /**
75 * hotplug_handler_pre_plug:
77 * Call #HotplugHandlerClass.pre_plug callback of @plug_handler.
79 void hotplug_handler_pre_plug(HotplugHandler *plug_handler,
80 DeviceState *plugged_dev,
81 Error **errp);
83 /**
84 * hotplug_handler_unplug_request:
86 * Calls #HotplugHandlerClass.unplug_request callback of @plug_handler.
88 void hotplug_handler_unplug_request(HotplugHandler *plug_handler,
89 DeviceState *plugged_dev,
90 Error **errp);
91 /**
92 * hotplug_handler_unplug:
94 * Calls #HotplugHandlerClass.unplug callback of @plug_handler.
96 void hotplug_handler_unplug(HotplugHandler *plug_handler,
97 DeviceState *plugged_dev,
98 Error **errp);
99 #endif