Statistics
| Branch: | Revision:

root / hw / qdev.h @ c06aaf01

History | View | Annotate | Download (13.4 kB)

1 aae9460e Paul Brook
#ifndef QDEV_H
2 aae9460e Paul Brook
#define QDEV_H
3 aae9460e Paul Brook
4 aae9460e Paul Brook
#include "hw.h"
5 72cf2d4f Blue Swirl
#include "qemu-queue.h"
6 313feaab Gerd Hoffmann
#include "qemu-char.h"
7 f31d07d1 Gerd Hoffmann
#include "qemu-option.h"
8 44677ded Anthony Liguori
#include "qapi/qapi-visit-core.h"
9 32fea402 Anthony Liguori
#include "qemu/object.h"
10 56f9107e Luiz Capitulino
#include "error.h"
11 aae9460e Paul Brook
12 ee6847d1 Gerd Hoffmann
typedef struct Property Property;
13 ee6847d1 Gerd Hoffmann
14 ee6847d1 Gerd Hoffmann
typedef struct PropertyInfo PropertyInfo;
15 aae9460e Paul Brook
16 b6b61144 Gerd Hoffmann
typedef struct CompatProperty CompatProperty;
17 b6b61144 Gerd Hoffmann
18 02e2da45 Paul Brook
typedef struct BusState BusState;
19 4d6ae674 Paul Brook
20 0d936928 Anthony Liguori
typedef struct BusClass BusClass;
21 10c4c98a Gerd Hoffmann
22 131ec1bd Gerd Hoffmann
enum DevState {
23 131ec1bd Gerd Hoffmann
    DEV_STATE_CREATED = 1,
24 131ec1bd Gerd Hoffmann
    DEV_STATE_INITIALIZED,
25 131ec1bd Gerd Hoffmann
};
26 131ec1bd Gerd Hoffmann
27 75422b0d Amit Shah
enum {
28 75422b0d Amit Shah
    DEV_NVECTORS_UNSPECIFIED = -1,
29 75422b0d Amit Shah
};
30 75422b0d Amit Shah
31 32fea402 Anthony Liguori
#define TYPE_DEVICE "device"
32 32fea402 Anthony Liguori
#define DEVICE(obj) OBJECT_CHECK(DeviceState, (obj), TYPE_DEVICE)
33 30fbb9fc Anthony Liguori
#define DEVICE_CLASS(klass) OBJECT_CLASS_CHECK(DeviceClass, (klass), TYPE_DEVICE)
34 30fbb9fc Anthony Liguori
#define DEVICE_GET_CLASS(obj) OBJECT_GET_CLASS(DeviceClass, (obj), TYPE_DEVICE)
35 32fea402 Anthony Liguori
36 d307af79 Anthony Liguori
typedef int (*qdev_initfn)(DeviceState *dev);
37 6e008585 Anthony Liguori
typedef int (*qdev_event)(DeviceState *dev);
38 6e008585 Anthony Liguori
typedef void (*qdev_resetfn)(DeviceState *dev);
39 6e008585 Anthony Liguori
40 32fea402 Anthony Liguori
typedef struct DeviceClass {
41 32fea402 Anthony Liguori
    ObjectClass parent_class;
42 6e008585 Anthony Liguori
43 6e008585 Anthony Liguori
    const char *fw_name;
44 6e008585 Anthony Liguori
    const char *desc;
45 6e008585 Anthony Liguori
    Property *props;
46 6e008585 Anthony Liguori
    int no_user;
47 6e008585 Anthony Liguori
48 6e008585 Anthony Liguori
    /* callbacks */
49 94afdadc Anthony Liguori
    void (*reset)(DeviceState *dev);
50 6e008585 Anthony Liguori
51 6e008585 Anthony Liguori
    /* device state */
52 6e008585 Anthony Liguori
    const VMStateDescription *vmsd;
53 6e008585 Anthony Liguori
54 6e008585 Anthony Liguori
    /* Private to qdev / bus.  */
55 6e008585 Anthony Liguori
    qdev_initfn init;
56 6e008585 Anthony Liguori
    qdev_event unplug;
57 6e008585 Anthony Liguori
    qdev_event exit;
58 0d936928 Anthony Liguori
    const char *bus_type;
59 32fea402 Anthony Liguori
} DeviceClass;
60 32fea402 Anthony Liguori
61 aae9460e Paul Brook
/* This structure should not be accessed directly.  We declare it here
62 aae9460e Paul Brook
   so that it can be embedded in individual device state structures.  */
63 02e2da45 Paul Brook
struct DeviceState {
64 32fea402 Anthony Liguori
    Object parent_obj;
65 32fea402 Anthony Liguori
66 f31d07d1 Gerd Hoffmann
    const char *id;
67 131ec1bd Gerd Hoffmann
    enum DevState state;
68 ef80b466 Gerd Hoffmann
    QemuOpts *opts;
69 3418bd25 Gerd Hoffmann
    int hotplugged;
70 02e2da45 Paul Brook
    BusState *parent_bus;
71 aae9460e Paul Brook
    int num_gpio_out;
72 aae9460e Paul Brook
    qemu_irq *gpio_out;
73 aae9460e Paul Brook
    int num_gpio_in;
74 aae9460e Paul Brook
    qemu_irq *gpio_in;
75 72cf2d4f Blue Swirl
    QLIST_HEAD(, BusState) child_bus;
76 d271de9f Gerd Hoffmann
    int num_child_bus;
77 4d2ffa08 Jan Kiszka
    int instance_id_alias;
78 4d2ffa08 Jan Kiszka
    int alias_required_for_version;
79 02e2da45 Paul Brook
};
80 02e2da45 Paul Brook
81 21150814 Gleb Natapov
/*
82 21150814 Gleb Natapov
 * This callback is used to create Open Firmware device path in accordance with
83 21150814 Gleb Natapov
 * OF spec http://forthworks.com/standards/of1275.pdf. Indicidual bus bindings
84 21150814 Gleb Natapov
 * can be found here http://playground.sun.com/1275/bindings/.
85 21150814 Gleb Natapov
 */
86 6772b936 Alex Williamson
87 0d936928 Anthony Liguori
#define TYPE_BUS "bus"
88 0d936928 Anthony Liguori
#define BUS(obj) OBJECT_CHECK(BusState, (obj), TYPE_BUS)
89 0d936928 Anthony Liguori
#define BUS_CLASS(klass) OBJECT_CLASS_CHECK(BusClass, (klass), TYPE_BUS)
90 0d936928 Anthony Liguori
#define BUS_GET_CLASS(obj) OBJECT_GET_CLASS(BusClass, (obj), TYPE_BUS)
91 0d936928 Anthony Liguori
92 0d936928 Anthony Liguori
struct BusClass {
93 0d936928 Anthony Liguori
    ObjectClass parent_class;
94 0d936928 Anthony Liguori
95 0d936928 Anthony Liguori
    /* FIXME first arg should be BusState */
96 0d936928 Anthony Liguori
    void (*print_dev)(Monitor *mon, DeviceState *dev, int indent);
97 0d936928 Anthony Liguori
    char *(*get_dev_path)(DeviceState *dev);
98 0d936928 Anthony Liguori
    char *(*get_fw_dev_path)(DeviceState *dev);
99 0d936928 Anthony Liguori
    int (*reset)(BusState *bus);
100 10c4c98a Gerd Hoffmann
};
101 02e2da45 Paul Brook
102 0866aca1 Anthony Liguori
typedef struct BusChild {
103 0866aca1 Anthony Liguori
    DeviceState *child;
104 0866aca1 Anthony Liguori
    int index;
105 0866aca1 Anthony Liguori
    QTAILQ_ENTRY(BusChild) sibling;
106 0866aca1 Anthony Liguori
} BusChild;
107 0866aca1 Anthony Liguori
108 0d936928 Anthony Liguori
/**
109 0d936928 Anthony Liguori
 * BusState:
110 0d936928 Anthony Liguori
 * @qom_allocated: Indicates whether the object was allocated by QOM.
111 0d936928 Anthony Liguori
 * @glib_allocated: Indicates whether the object was initialized in-place
112 0d936928 Anthony Liguori
 * yet is expected to be freed with g_free().
113 0d936928 Anthony Liguori
 */
114 02e2da45 Paul Brook
struct BusState {
115 0d936928 Anthony Liguori
    Object obj;
116 02e2da45 Paul Brook
    DeviceState *parent;
117 02e2da45 Paul Brook
    const char *name;
118 3418bd25 Gerd Hoffmann
    int allow_hotplug;
119 0d936928 Anthony Liguori
    bool qom_allocated;
120 0d936928 Anthony Liguori
    bool glib_allocated;
121 0866aca1 Anthony Liguori
    int max_index;
122 0866aca1 Anthony Liguori
    QTAILQ_HEAD(ChildrenHead, BusChild) children;
123 72cf2d4f Blue Swirl
    QLIST_ENTRY(BusState) sibling;
124 aae9460e Paul Brook
};
125 aae9460e Paul Brook
126 ee6847d1 Gerd Hoffmann
struct Property {
127 ee6847d1 Gerd Hoffmann
    const char   *name;
128 ee6847d1 Gerd Hoffmann
    PropertyInfo *info;
129 ee6847d1 Gerd Hoffmann
    int          offset;
130 4f2d3d70 Paolo Bonzini
    uint8_t      bitnr;
131 4f2d3d70 Paolo Bonzini
    uint8_t      qtype;
132 4f2d3d70 Paolo Bonzini
    int64_t      defval;
133 ee6847d1 Gerd Hoffmann
};
134 ee6847d1 Gerd Hoffmann
135 ee6847d1 Gerd Hoffmann
struct PropertyInfo {
136 ee6847d1 Gerd Hoffmann
    const char *name;
137 cafe5bdb Paolo Bonzini
    const char *legacy_name;
138 1ce05125 Paolo Bonzini
    const char **enum_table;
139 ee6847d1 Gerd Hoffmann
    int (*parse)(DeviceState *dev, Property *prop, const char *str);
140 ee6847d1 Gerd Hoffmann
    int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len);
141 57c9fafe Anthony Liguori
    ObjectPropertyAccessor *get;
142 57c9fafe Anthony Liguori
    ObjectPropertyAccessor *set;
143 dd0ba250 Paolo Bonzini
    ObjectPropertyRelease *release;
144 ee6847d1 Gerd Hoffmann
};
145 ee6847d1 Gerd Hoffmann
146 458fb679 Gerd Hoffmann
typedef struct GlobalProperty {
147 b6b61144 Gerd Hoffmann
    const char *driver;
148 b6b61144 Gerd Hoffmann
    const char *property;
149 b6b61144 Gerd Hoffmann
    const char *value;
150 458fb679 Gerd Hoffmann
    QTAILQ_ENTRY(GlobalProperty) next;
151 458fb679 Gerd Hoffmann
} GlobalProperty;
152 b6b61144 Gerd Hoffmann
153 aae9460e Paul Brook
/*** Board API.  This should go away once we have a machine config file.  ***/
154 aae9460e Paul Brook
155 02e2da45 Paul Brook
DeviceState *qdev_create(BusState *bus, const char *name);
156 0bcdeda7 Blue Swirl
DeviceState *qdev_try_create(BusState *bus, const char *name);
157 a369da5f Blue Swirl
bool qdev_exists(const char *name);
158 ff952ba2 Markus Armbruster
int qdev_device_help(QemuOpts *opts);
159 f31d07d1 Gerd Hoffmann
DeviceState *qdev_device_add(QemuOpts *opts);
160 747bbdf7 Blue Swirl
int qdev_init(DeviceState *dev) QEMU_WARN_UNUSED_RESULT;
161 e23a1b33 Markus Armbruster
void qdev_init_nofail(DeviceState *dev);
162 4d2ffa08 Jan Kiszka
void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
163 4d2ffa08 Jan Kiszka
                                 int required_for_version);
164 56f9107e Luiz Capitulino
void qdev_unplug(DeviceState *dev, Error **errp);
165 02e2da45 Paul Brook
void qdev_free(DeviceState *dev);
166 3418bd25 Gerd Hoffmann
int qdev_simple_unplug_cb(DeviceState *dev);
167 3418bd25 Gerd Hoffmann
void qdev_machine_creation_done(void);
168 0ac8ef71 Alex Williamson
bool qdev_machine_modified(void);
169 aae9460e Paul Brook
170 aae9460e Paul Brook
qemu_irq qdev_get_gpio_in(DeviceState *dev, int n);
171 aae9460e Paul Brook
void qdev_connect_gpio_out(DeviceState *dev, int n, qemu_irq pin);
172 aae9460e Paul Brook
173 02e2da45 Paul Brook
BusState *qdev_get_child_bus(DeviceState *dev, const char *name);
174 4d6ae674 Paul Brook
175 aae9460e Paul Brook
/*** Device API.  ***/
176 aae9460e Paul Brook
177 aae9460e Paul Brook
/* Register device properties.  */
178 067a3ddc Paul Brook
/* GPIO inputs also double as IRQ sinks.  */
179 aae9460e Paul Brook
void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n);
180 aae9460e Paul Brook
void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n);
181 aae9460e Paul Brook
182 02e2da45 Paul Brook
BusState *qdev_get_parent_bus(DeviceState *dev);
183 aae9460e Paul Brook
184 02e2da45 Paul Brook
/*** BUS API. ***/
185 02e2da45 Paul Brook
186 a2ee6b4f Isaku Yamahata
DeviceState *qdev_find_recursive(BusState *bus, const char *id);
187 a2ee6b4f Isaku Yamahata
188 81699d8a Anthony Liguori
/* Returns 0 to walk children, > 0 to skip walk, < 0 to terminate walk. */
189 81699d8a Anthony Liguori
typedef int (qbus_walkerfn)(BusState *bus, void *opaque);
190 81699d8a Anthony Liguori
typedef int (qdev_walkerfn)(DeviceState *dev, void *opaque);
191 81699d8a Anthony Liguori
192 0d936928 Anthony Liguori
void qbus_create_inplace(BusState *bus, const char *typename,
193 cd739fb6 Gerd Hoffmann
                         DeviceState *parent, const char *name);
194 0d936928 Anthony Liguori
BusState *qbus_create(const char *typename, DeviceState *parent, const char *name);
195 81699d8a Anthony Liguori
/* Returns > 0 if either devfn or busfn skip walk somewhere in cursion,
196 81699d8a Anthony Liguori
 *         < 0 if either devfn or busfn terminate walk somewhere in cursion,
197 81699d8a Anthony Liguori
 *           0 otherwise. */
198 81699d8a Anthony Liguori
int qbus_walk_children(BusState *bus, qdev_walkerfn *devfn,
199 81699d8a Anthony Liguori
                       qbus_walkerfn *busfn, void *opaque);
200 81699d8a Anthony Liguori
int qdev_walk_children(DeviceState *dev, qdev_walkerfn *devfn,
201 81699d8a Anthony Liguori
                       qbus_walkerfn *busfn, void *opaque);
202 5af0a04b Isaku Yamahata
void qdev_reset_all(DeviceState *dev);
203 80376c3f Isaku Yamahata
void qbus_reset_all_fn(void *opaque);
204 80376c3f Isaku Yamahata
205 131ec1bd Gerd Hoffmann
void qbus_free(BusState *bus);
206 02e2da45 Paul Brook
207 02e2da45 Paul Brook
#define FROM_QBUS(type, dev) DO_UPCAST(type, qbus, dev)
208 02e2da45 Paul Brook
209 ec990eb6 Anthony Liguori
/* This should go away once we get rid of the NULL bus hack */
210 ec990eb6 Anthony Liguori
BusState *sysbus_get_default(void);
211 ec990eb6 Anthony Liguori
212 cae4956e Gerd Hoffmann
/*** monitor commands ***/
213 cae4956e Gerd Hoffmann
214 cae4956e Gerd Hoffmann
void do_info_qtree(Monitor *mon);
215 f6c64e0e Gerd Hoffmann
void do_info_qdm(Monitor *mon);
216 8bc27249 Markus Armbruster
int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
217 17a38eaa Markus Armbruster
int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
218 cae4956e Gerd Hoffmann
219 ee6847d1 Gerd Hoffmann
/*** qdev-properties.c ***/
220 ee6847d1 Gerd Hoffmann
221 d2364ee4 Michael S. Tsirkin
extern PropertyInfo qdev_prop_bit;
222 c7cc172d Juan Quintela
extern PropertyInfo qdev_prop_uint8;
223 ee6847d1 Gerd Hoffmann
extern PropertyInfo qdev_prop_uint16;
224 ee6847d1 Gerd Hoffmann
extern PropertyInfo qdev_prop_uint32;
225 316940b0 Gerd Hoffmann
extern PropertyInfo qdev_prop_int32;
226 5a053d1f Blue Swirl
extern PropertyInfo qdev_prop_uint64;
227 6835678c Jan Kiszka
extern PropertyInfo qdev_prop_hex8;
228 ee6847d1 Gerd Hoffmann
extern PropertyInfo qdev_prop_hex32;
229 5a053d1f Blue Swirl
extern PropertyInfo qdev_prop_hex64;
230 59419663 Gerd Hoffmann
extern PropertyInfo qdev_prop_string;
231 313feaab Gerd Hoffmann
extern PropertyInfo qdev_prop_chr;
232 ee6847d1 Gerd Hoffmann
extern PropertyInfo qdev_prop_ptr;
233 ee6847d1 Gerd Hoffmann
extern PropertyInfo qdev_prop_macaddr;
234 4e4fa398 Jan Kiszka
extern PropertyInfo qdev_prop_losttickpolicy;
235 14b41872 Gerd Hoffmann
extern PropertyInfo qdev_prop_drive;
236 851bec09 Gerd Hoffmann
extern PropertyInfo qdev_prop_netdev;
237 851bec09 Gerd Hoffmann
extern PropertyInfo qdev_prop_vlan;
238 05cb5fe4 Gerd Hoffmann
extern PropertyInfo qdev_prop_pci_devfn;
239 02fda01c Stefan Hajnoczi
extern PropertyInfo qdev_prop_blocksize;
240 679042f0 Anthony PERARD
extern PropertyInfo qdev_prop_pci_host_devaddr;
241 ee6847d1 Gerd Hoffmann
242 cf12b95b Gerd Hoffmann
#define DEFINE_PROP(_name, _state, _field, _prop, _type) { \
243 cf12b95b Gerd Hoffmann
        .name      = (_name),                                    \
244 cf12b95b Gerd Hoffmann
        .info      = &(_prop),                                   \
245 cf12b95b Gerd Hoffmann
        .offset    = offsetof(_state, _field)                    \
246 cf12b95b Gerd Hoffmann
            + type_check(_type,typeof_field(_state, _field)),    \
247 cf12b95b Gerd Hoffmann
        }
248 cf12b95b Gerd Hoffmann
#define DEFINE_PROP_DEFAULT(_name, _state, _field, _defval, _prop, _type) { \
249 cf12b95b Gerd Hoffmann
        .name      = (_name),                                           \
250 cf12b95b Gerd Hoffmann
        .info      = &(_prop),                                          \
251 cf12b95b Gerd Hoffmann
        .offset    = offsetof(_state, _field)                           \
252 cf12b95b Gerd Hoffmann
            + type_check(_type,typeof_field(_state, _field)),           \
253 4f2d3d70 Paolo Bonzini
        .qtype     = QTYPE_QINT,                                        \
254 4f2d3d70 Paolo Bonzini
        .defval    = (_type)_defval,                                    \
255 cf12b95b Gerd Hoffmann
        }
256 d2364ee4 Michael S. Tsirkin
#define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) {  \
257 d2364ee4 Michael S. Tsirkin
        .name      = (_name),                                    \
258 d2364ee4 Michael S. Tsirkin
        .info      = &(qdev_prop_bit),                           \
259 d2364ee4 Michael S. Tsirkin
        .bitnr    = (_bit),                                      \
260 d2364ee4 Michael S. Tsirkin
        .offset    = offsetof(_state, _field)                    \
261 d2364ee4 Michael S. Tsirkin
            + type_check(uint32_t,typeof_field(_state, _field)), \
262 4f2d3d70 Paolo Bonzini
        .qtype     = QTYPE_QBOOL,                                \
263 4f2d3d70 Paolo Bonzini
        .defval    = (bool)_defval,                              \
264 d2364ee4 Michael S. Tsirkin
        }
265 cf12b95b Gerd Hoffmann
266 c7cc172d Juan Quintela
#define DEFINE_PROP_UINT8(_n, _s, _f, _d)                       \
267 c7cc172d Juan Quintela
    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)
268 cf12b95b Gerd Hoffmann
#define DEFINE_PROP_UINT16(_n, _s, _f, _d)                      \
269 cf12b95b Gerd Hoffmann
    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint16, uint16_t)
270 cf12b95b Gerd Hoffmann
#define DEFINE_PROP_UINT32(_n, _s, _f, _d)                      \
271 cf12b95b Gerd Hoffmann
    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint32, uint32_t)
272 316940b0 Gerd Hoffmann
#define DEFINE_PROP_INT32(_n, _s, _f, _d)                      \
273 316940b0 Gerd Hoffmann
    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_int32, int32_t)
274 cf12b95b Gerd Hoffmann
#define DEFINE_PROP_UINT64(_n, _s, _f, _d)                      \
275 cf12b95b Gerd Hoffmann
    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint64, uint64_t)
276 6835678c Jan Kiszka
#define DEFINE_PROP_HEX8(_n, _s, _f, _d)                       \
277 6835678c Jan Kiszka
    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex8, uint8_t)
278 cf12b95b Gerd Hoffmann
#define DEFINE_PROP_HEX32(_n, _s, _f, _d)                       \
279 cf12b95b Gerd Hoffmann
    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex32, uint32_t)
280 cf12b95b Gerd Hoffmann
#define DEFINE_PROP_HEX64(_n, _s, _f, _d)                       \
281 cf12b95b Gerd Hoffmann
    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex64, uint64_t)
282 cf12b95b Gerd Hoffmann
#define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d)                   \
283 09f1bbcd Michael Roth
    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t)
284 cf12b95b Gerd Hoffmann
285 cf12b95b Gerd Hoffmann
#define DEFINE_PROP_PTR(_n, _s, _f)             \
286 cf12b95b Gerd Hoffmann
    DEFINE_PROP(_n, _s, _f, qdev_prop_ptr, void*)
287 313feaab Gerd Hoffmann
#define DEFINE_PROP_CHR(_n, _s, _f)             \
288 313feaab Gerd Hoffmann
    DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharDriverState*)
289 59419663 Gerd Hoffmann
#define DEFINE_PROP_STRING(_n, _s, _f)             \
290 59419663 Gerd Hoffmann
    DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*)
291 2ef924b4 Gerd Hoffmann
#define DEFINE_PROP_NETDEV(_n, _s, _f)             \
292 2ef924b4 Gerd Hoffmann
    DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, VLANClientState*)
293 851bec09 Gerd Hoffmann
#define DEFINE_PROP_VLAN(_n, _s, _f)             \
294 851bec09 Gerd Hoffmann
    DEFINE_PROP(_n, _s, _f, qdev_prop_vlan, VLANState*)
295 f8b6cc00 Markus Armbruster
#define DEFINE_PROP_DRIVE(_n, _s, _f) \
296 f8b6cc00 Markus Armbruster
    DEFINE_PROP(_n, _s, _f, qdev_prop_drive, BlockDriverState *)
297 cf12b95b Gerd Hoffmann
#define DEFINE_PROP_MACADDR(_n, _s, _f)         \
298 1503fff3 Gerd Hoffmann
    DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, MACAddr)
299 4e4fa398 Jan Kiszka
#define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \
300 4e4fa398 Jan Kiszka
    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_losttickpolicy, \
301 4e4fa398 Jan Kiszka
                        LostTickPolicy)
302 02fda01c Stefan Hajnoczi
#define DEFINE_PROP_BLOCKSIZE(_n, _s, _f, _d) \
303 02fda01c Stefan Hajnoczi
    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_blocksize, uint16_t)
304 679042f0 Anthony PERARD
#define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \
305 679042f0 Anthony PERARD
    DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddress)
306 cf12b95b Gerd Hoffmann
307 cf12b95b Gerd Hoffmann
#define DEFINE_PROP_END_OF_LIST()               \
308 cf12b95b Gerd Hoffmann
    {}
309 cf12b95b Gerd Hoffmann
310 ee6847d1 Gerd Hoffmann
/* Set properties between creation and init.  */
311 ee6847d1 Gerd Hoffmann
void *qdev_get_prop_ptr(DeviceState *dev, Property *prop);
312 ee6847d1 Gerd Hoffmann
int qdev_prop_parse(DeviceState *dev, const char *name, const char *value);
313 f4594a3b Isaku Yamahata
void qdev_prop_set_bit(DeviceState *dev, const char *name, bool value);
314 c7cc172d Juan Quintela
void qdev_prop_set_uint8(DeviceState *dev, const char *name, uint8_t value);
315 ee6847d1 Gerd Hoffmann
void qdev_prop_set_uint16(DeviceState *dev, const char *name, uint16_t value);
316 ee6847d1 Gerd Hoffmann
void qdev_prop_set_uint32(DeviceState *dev, const char *name, uint32_t value);
317 316940b0 Gerd Hoffmann
void qdev_prop_set_int32(DeviceState *dev, const char *name, int32_t value);
318 5a053d1f Blue Swirl
void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value);
319 cc984673 Markus Armbruster
void qdev_prop_set_string(DeviceState *dev, const char *name, char *value);
320 313feaab Gerd Hoffmann
void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value);
321 2ef924b4 Gerd Hoffmann
void qdev_prop_set_netdev(DeviceState *dev, const char *name, VLANClientState *value);
322 851bec09 Gerd Hoffmann
void qdev_prop_set_vlan(DeviceState *dev, const char *name, VLANState *value);
323 18846dee Markus Armbruster
int qdev_prop_set_drive(DeviceState *dev, const char *name, BlockDriverState *value) QEMU_WARN_UNUSED_RESULT;
324 18846dee Markus Armbruster
void qdev_prop_set_drive_nofail(DeviceState *dev, const char *name, BlockDriverState *value);
325 1503fff3 Gerd Hoffmann
void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value);
326 9b170e60 Paolo Bonzini
void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
327 ee6847d1 Gerd Hoffmann
/* FIXME: Remove opaque pointer properties.  */
328 ee6847d1 Gerd Hoffmann
void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
329 ee6847d1 Gerd Hoffmann
330 458fb679 Gerd Hoffmann
void qdev_prop_register_global_list(GlobalProperty *props);
331 458fb679 Gerd Hoffmann
void qdev_prop_set_globals(DeviceState *dev);
332 7db4c4e8 Paolo Bonzini
void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
333 7db4c4e8 Paolo Bonzini
                                    Property *prop, const char *value);
334 b6b61144 Gerd Hoffmann
335 1ca4d09a Gleb Natapov
char *qdev_get_fw_dev_path(DeviceState *dev);
336 4be9f0d1 Anthony Liguori
337 85ed303b Anthony Liguori
/**
338 ca2cc788 Paolo Bonzini
 * @qdev_property_add_static - add a @Property to a device referencing a
339 ca2cc788 Paolo Bonzini
 * field in a struct.
340 a5296ca9 Anthony Liguori
 */
341 ca2cc788 Paolo Bonzini
void qdev_property_add_static(DeviceState *dev, Property *prop, Error **errp);
342 a5296ca9 Anthony Liguori
343 a10f07a7 Anthony Liguori
/**
344 1de81d28 Anthony Liguori
 * @qdev_machine_init
345 1de81d28 Anthony Liguori
 *
346 1de81d28 Anthony Liguori
 * Initialize platform devices before machine init.  This is a hack until full
347 1de81d28 Anthony Liguori
 * support for composition is added.
348 1de81d28 Anthony Liguori
 */
349 1de81d28 Anthony Liguori
void qdev_machine_init(void);
350 1de81d28 Anthony Liguori
351 94afdadc Anthony Liguori
/**
352 94afdadc Anthony Liguori
 * @device_reset
353 94afdadc Anthony Liguori
 *
354 94afdadc Anthony Liguori
 * Reset a single device (by calling the reset method).
355 94afdadc Anthony Liguori
 */
356 94afdadc Anthony Liguori
void device_reset(DeviceState *dev);
357 94afdadc Anthony Liguori
358 4be9f0d1 Anthony Liguori
const VMStateDescription *qdev_get_vmsd(DeviceState *dev);
359 4be9f0d1 Anthony Liguori
360 4be9f0d1 Anthony Liguori
const char *qdev_fw_name(DeviceState *dev);
361 4be9f0d1 Anthony Liguori
362 f05f6b4a Paolo Bonzini
Object *qdev_get_machine(void);
363 f05f6b4a Paolo Bonzini
364 9fbe6127 Anthony Liguori
/* FIXME: make this a link<> */
365 9fbe6127 Anthony Liguori
void qdev_set_parent_bus(DeviceState *dev, BusState *bus);
366 9fbe6127 Anthony Liguori
367 ee46d8a5 Anthony Liguori
extern int qdev_hotplug;
368 ee46d8a5 Anthony Liguori
369 09e5ab63 Anthony Liguori
char *qdev_get_dev_path(DeviceState *dev);
370 09e5ab63 Anthony Liguori
371 aae9460e Paul Brook
#endif