root / hw / qdev.h @ e6eaabeb
History | View | Annotate | Download (13.5 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 | 0d936928 | Anthony Liguori | #define TYPE_BUS "bus" |
82 | 0d936928 | Anthony Liguori | #define BUS(obj) OBJECT_CHECK(BusState, (obj), TYPE_BUS)
|
83 | 0d936928 | Anthony Liguori | #define BUS_CLASS(klass) OBJECT_CLASS_CHECK(BusClass, (klass), TYPE_BUS)
|
84 | 0d936928 | Anthony Liguori | #define BUS_GET_CLASS(obj) OBJECT_GET_CLASS(BusClass, (obj), TYPE_BUS)
|
85 | 0d936928 | Anthony Liguori | |
86 | 0d936928 | Anthony Liguori | struct BusClass {
|
87 | 0d936928 | Anthony Liguori | ObjectClass parent_class; |
88 | 0d936928 | Anthony Liguori | |
89 | 0d936928 | Anthony Liguori | /* FIXME first arg should be BusState */
|
90 | 0d936928 | Anthony Liguori | void (*print_dev)(Monitor *mon, DeviceState *dev, int indent); |
91 | 0d936928 | Anthony Liguori | char *(*get_dev_path)(DeviceState *dev);
|
92 | c5788614 | Stefan Weil | /*
|
93 | c5788614 | Stefan Weil | * This callback is used to create Open Firmware device path in accordance
|
94 | c5788614 | Stefan Weil | * with OF spec http://forthworks.com/standards/of1275.pdf. Individual bus
|
95 | c5788614 | Stefan Weil | * bindings can be found at http://playground.sun.com/1275/bindings/.
|
96 | c5788614 | Stefan Weil | */
|
97 | 0d936928 | Anthony Liguori | char *(*get_fw_dev_path)(DeviceState *dev);
|
98 | 0d936928 | Anthony Liguori | int (*reset)(BusState *bus);
|
99 | 10c4c98a | Gerd Hoffmann | }; |
100 | 02e2da45 | Paul Brook | |
101 | 0866aca1 | Anthony Liguori | typedef struct BusChild { |
102 | 0866aca1 | Anthony Liguori | DeviceState *child; |
103 | 0866aca1 | Anthony Liguori | int index;
|
104 | 0866aca1 | Anthony Liguori | QTAILQ_ENTRY(BusChild) sibling; |
105 | 0866aca1 | Anthony Liguori | } BusChild; |
106 | 0866aca1 | Anthony Liguori | |
107 | 0d936928 | Anthony Liguori | /**
|
108 | 0d936928 | Anthony Liguori | * BusState:
|
109 | 0d936928 | Anthony Liguori | * @qom_allocated: Indicates whether the object was allocated by QOM.
|
110 | 0d936928 | Anthony Liguori | * @glib_allocated: Indicates whether the object was initialized in-place
|
111 | 0d936928 | Anthony Liguori | * yet is expected to be freed with g_free().
|
112 | 0d936928 | Anthony Liguori | */
|
113 | 02e2da45 | Paul Brook | struct BusState {
|
114 | 0d936928 | Anthony Liguori | Object obj; |
115 | 02e2da45 | Paul Brook | DeviceState *parent; |
116 | 02e2da45 | Paul Brook | const char *name; |
117 | 3418bd25 | Gerd Hoffmann | int allow_hotplug;
|
118 | 0d936928 | Anthony Liguori | bool qom_allocated;
|
119 | 0d936928 | Anthony Liguori | bool glib_allocated;
|
120 | 0866aca1 | Anthony Liguori | int max_index;
|
121 | 0866aca1 | Anthony Liguori | QTAILQ_HEAD(ChildrenHead, BusChild) children; |
122 | 72cf2d4f | Blue Swirl | QLIST_ENTRY(BusState) sibling; |
123 | aae9460e | Paul Brook | }; |
124 | aae9460e | Paul Brook | |
125 | ee6847d1 | Gerd Hoffmann | struct Property {
|
126 | ee6847d1 | Gerd Hoffmann | const char *name; |
127 | ee6847d1 | Gerd Hoffmann | PropertyInfo *info; |
128 | ee6847d1 | Gerd Hoffmann | int offset;
|
129 | 4f2d3d70 | Paolo Bonzini | uint8_t bitnr; |
130 | 4f2d3d70 | Paolo Bonzini | uint8_t qtype; |
131 | 4f2d3d70 | Paolo Bonzini | int64_t defval; |
132 | ee6847d1 | Gerd Hoffmann | }; |
133 | ee6847d1 | Gerd Hoffmann | |
134 | ee6847d1 | Gerd Hoffmann | struct PropertyInfo {
|
135 | ee6847d1 | Gerd Hoffmann | const char *name; |
136 | cafe5bdb | Paolo Bonzini | const char *legacy_name; |
137 | 1ce05125 | Paolo Bonzini | const char **enum_table; |
138 | ee6847d1 | Gerd Hoffmann | int (*parse)(DeviceState *dev, Property *prop, const char *str); |
139 | ee6847d1 | Gerd Hoffmann | int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len); |
140 | 57c9fafe | Anthony Liguori | ObjectPropertyAccessor *get; |
141 | 57c9fafe | Anthony Liguori | ObjectPropertyAccessor *set; |
142 | dd0ba250 | Paolo Bonzini | ObjectPropertyRelease *release; |
143 | ee6847d1 | Gerd Hoffmann | }; |
144 | ee6847d1 | Gerd Hoffmann | |
145 | 458fb679 | Gerd Hoffmann | typedef struct GlobalProperty { |
146 | b6b61144 | Gerd Hoffmann | const char *driver; |
147 | b6b61144 | Gerd Hoffmann | const char *property; |
148 | b6b61144 | Gerd Hoffmann | const char *value; |
149 | 458fb679 | Gerd Hoffmann | QTAILQ_ENTRY(GlobalProperty) next; |
150 | 458fb679 | Gerd Hoffmann | } GlobalProperty; |
151 | b6b61144 | Gerd Hoffmann | |
152 | aae9460e | Paul Brook | /*** Board API. This should go away once we have a machine config file. ***/
|
153 | aae9460e | Paul Brook | |
154 | 02e2da45 | Paul Brook | DeviceState *qdev_create(BusState *bus, const char *name); |
155 | 0bcdeda7 | Blue Swirl | DeviceState *qdev_try_create(BusState *bus, const char *name); |
156 | a369da5f | Blue Swirl | bool qdev_exists(const char *name); |
157 | ff952ba2 | Markus Armbruster | int qdev_device_help(QemuOpts *opts);
|
158 | f31d07d1 | Gerd Hoffmann | DeviceState *qdev_device_add(QemuOpts *opts); |
159 | 747bbdf7 | Blue Swirl | int qdev_init(DeviceState *dev) QEMU_WARN_UNUSED_RESULT;
|
160 | e23a1b33 | Markus Armbruster | void qdev_init_nofail(DeviceState *dev);
|
161 | 4d2ffa08 | Jan Kiszka | void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id, |
162 | 4d2ffa08 | Jan Kiszka | int required_for_version);
|
163 | 56f9107e | Luiz Capitulino | void qdev_unplug(DeviceState *dev, Error **errp);
|
164 | 02e2da45 | Paul Brook | void qdev_free(DeviceState *dev);
|
165 | 3418bd25 | Gerd Hoffmann | int qdev_simple_unplug_cb(DeviceState *dev);
|
166 | 3418bd25 | Gerd Hoffmann | void qdev_machine_creation_done(void); |
167 | 0ac8ef71 | Alex Williamson | bool qdev_machine_modified(void); |
168 | aae9460e | Paul Brook | |
169 | aae9460e | Paul Brook | qemu_irq qdev_get_gpio_in(DeviceState *dev, int n);
|
170 | aae9460e | Paul Brook | void qdev_connect_gpio_out(DeviceState *dev, int n, qemu_irq pin); |
171 | aae9460e | Paul Brook | |
172 | 02e2da45 | Paul Brook | BusState *qdev_get_child_bus(DeviceState *dev, const char *name); |
173 | 4d6ae674 | Paul Brook | |
174 | aae9460e | Paul Brook | /*** Device API. ***/
|
175 | aae9460e | Paul Brook | |
176 | aae9460e | Paul Brook | /* Register device properties. */
|
177 | 067a3ddc | Paul Brook | /* GPIO inputs also double as IRQ sinks. */
|
178 | aae9460e | Paul Brook | void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n); |
179 | aae9460e | Paul Brook | void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n); |
180 | aae9460e | Paul Brook | |
181 | 02e2da45 | Paul Brook | BusState *qdev_get_parent_bus(DeviceState *dev); |
182 | aae9460e | Paul Brook | |
183 | 02e2da45 | Paul Brook | /*** BUS API. ***/
|
184 | 02e2da45 | Paul Brook | |
185 | a2ee6b4f | Isaku Yamahata | DeviceState *qdev_find_recursive(BusState *bus, const char *id); |
186 | a2ee6b4f | Isaku Yamahata | |
187 | 81699d8a | Anthony Liguori | /* Returns 0 to walk children, > 0 to skip walk, < 0 to terminate walk. */
|
188 | 81699d8a | Anthony Liguori | typedef int (qbus_walkerfn)(BusState *bus, void *opaque); |
189 | 81699d8a | Anthony Liguori | typedef int (qdev_walkerfn)(DeviceState *dev, void *opaque); |
190 | 81699d8a | Anthony Liguori | |
191 | 0d936928 | Anthony Liguori | void qbus_create_inplace(BusState *bus, const char *typename, |
192 | cd739fb6 | Gerd Hoffmann | DeviceState *parent, const char *name); |
193 | 0d936928 | Anthony Liguori | BusState *qbus_create(const char *typename, DeviceState *parent, const char *name); |
194 | 81699d8a | Anthony Liguori | /* Returns > 0 if either devfn or busfn skip walk somewhere in cursion,
|
195 | 81699d8a | Anthony Liguori | * < 0 if either devfn or busfn terminate walk somewhere in cursion,
|
196 | 81699d8a | Anthony Liguori | * 0 otherwise. */
|
197 | 81699d8a | Anthony Liguori | int qbus_walk_children(BusState *bus, qdev_walkerfn *devfn,
|
198 | 81699d8a | Anthony Liguori | qbus_walkerfn *busfn, void *opaque);
|
199 | 81699d8a | Anthony Liguori | int qdev_walk_children(DeviceState *dev, qdev_walkerfn *devfn,
|
200 | 81699d8a | Anthony Liguori | qbus_walkerfn *busfn, void *opaque);
|
201 | 5af0a04b | Isaku Yamahata | void qdev_reset_all(DeviceState *dev);
|
202 | 80376c3f | Isaku Yamahata | void qbus_reset_all_fn(void *opaque); |
203 | 80376c3f | Isaku Yamahata | |
204 | 131ec1bd | Gerd Hoffmann | void qbus_free(BusState *bus);
|
205 | 02e2da45 | Paul Brook | |
206 | 02e2da45 | Paul Brook | #define FROM_QBUS(type, dev) DO_UPCAST(type, qbus, dev)
|
207 | 02e2da45 | Paul Brook | |
208 | ec990eb6 | Anthony Liguori | /* This should go away once we get rid of the NULL bus hack */
|
209 | ec990eb6 | Anthony Liguori | BusState *sysbus_get_default(void);
|
210 | ec990eb6 | Anthony Liguori | |
211 | cae4956e | Gerd Hoffmann | /*** monitor commands ***/
|
212 | cae4956e | Gerd Hoffmann | |
213 | cae4956e | Gerd Hoffmann | void do_info_qtree(Monitor *mon);
|
214 | f6c64e0e | Gerd Hoffmann | void do_info_qdm(Monitor *mon);
|
215 | 8bc27249 | Markus Armbruster | int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data); |
216 | 17a38eaa | Markus Armbruster | int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data); |
217 | cae4956e | Gerd Hoffmann | |
218 | ee6847d1 | Gerd Hoffmann | /*** qdev-properties.c ***/
|
219 | ee6847d1 | Gerd Hoffmann | |
220 | d2364ee4 | Michael S. Tsirkin | extern PropertyInfo qdev_prop_bit;
|
221 | c7cc172d | Juan Quintela | extern PropertyInfo qdev_prop_uint8;
|
222 | ee6847d1 | Gerd Hoffmann | extern PropertyInfo qdev_prop_uint16;
|
223 | ee6847d1 | Gerd Hoffmann | extern PropertyInfo qdev_prop_uint32;
|
224 | 316940b0 | Gerd Hoffmann | extern PropertyInfo qdev_prop_int32;
|
225 | 5a053d1f | Blue Swirl | extern PropertyInfo qdev_prop_uint64;
|
226 | 6835678c | Jan Kiszka | extern PropertyInfo qdev_prop_hex8;
|
227 | ee6847d1 | Gerd Hoffmann | extern PropertyInfo qdev_prop_hex32;
|
228 | 5a053d1f | Blue Swirl | extern PropertyInfo qdev_prop_hex64;
|
229 | 59419663 | Gerd Hoffmann | extern PropertyInfo qdev_prop_string;
|
230 | 313feaab | Gerd Hoffmann | extern PropertyInfo qdev_prop_chr;
|
231 | ee6847d1 | Gerd Hoffmann | extern PropertyInfo qdev_prop_ptr;
|
232 | ee6847d1 | Gerd Hoffmann | extern PropertyInfo qdev_prop_macaddr;
|
233 | 4e4fa398 | Jan Kiszka | extern PropertyInfo qdev_prop_losttickpolicy;
|
234 | 8cd41745 | Markus Armbruster | extern PropertyInfo qdev_prop_bios_chs_trans;
|
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 | 4e68f7a0 | Stefan Hajnoczi | DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, NetClientState*) |
293 | 851bec09 | Gerd Hoffmann | #define DEFINE_PROP_VLAN(_n, _s, _f) \
|
294 | 4e68f7a0 | Stefan Hajnoczi | DEFINE_PROP(_n, _s, _f, qdev_prop_vlan, NetClientState*) |
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 | 8cd41745 | Markus Armbruster | #define DEFINE_PROP_BIOS_CHS_TRANS(_n, _s, _f, _d) \
|
303 | 8cd41745 | Markus Armbruster | DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int)
|
304 | 02fda01c | Stefan Hajnoczi | #define DEFINE_PROP_BLOCKSIZE(_n, _s, _f, _d) \
|
305 | 02fda01c | Stefan Hajnoczi | DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_blocksize, uint16_t) |
306 | 679042f0 | Anthony PERARD | #define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \
|
307 | 679042f0 | Anthony PERARD | DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddress) |
308 | cf12b95b | Gerd Hoffmann | |
309 | cf12b95b | Gerd Hoffmann | #define DEFINE_PROP_END_OF_LIST() \
|
310 | cf12b95b | Gerd Hoffmann | {} |
311 | cf12b95b | Gerd Hoffmann | |
312 | ee6847d1 | Gerd Hoffmann | /* Set properties between creation and init. */
|
313 | ee6847d1 | Gerd Hoffmann | void *qdev_get_prop_ptr(DeviceState *dev, Property *prop);
|
314 | ee6847d1 | Gerd Hoffmann | int qdev_prop_parse(DeviceState *dev, const char *name, const char *value); |
315 | f4594a3b | Isaku Yamahata | void qdev_prop_set_bit(DeviceState *dev, const char *name, bool value); |
316 | c7cc172d | Juan Quintela | void qdev_prop_set_uint8(DeviceState *dev, const char *name, uint8_t value); |
317 | ee6847d1 | Gerd Hoffmann | void qdev_prop_set_uint16(DeviceState *dev, const char *name, uint16_t value); |
318 | ee6847d1 | Gerd Hoffmann | void qdev_prop_set_uint32(DeviceState *dev, const char *name, uint32_t value); |
319 | 316940b0 | Gerd Hoffmann | void qdev_prop_set_int32(DeviceState *dev, const char *name, int32_t value); |
320 | 5a053d1f | Blue Swirl | void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value); |
321 | 3b25597b | Christian Borntraeger | void qdev_prop_set_string(DeviceState *dev, const char *name, const char *value); |
322 | 313feaab | Gerd Hoffmann | void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value); |
323 | 4e68f7a0 | Stefan Hajnoczi | void qdev_prop_set_netdev(DeviceState *dev, const char *name, NetClientState *value); |
324 | 18846dee | Markus Armbruster | int qdev_prop_set_drive(DeviceState *dev, const char *name, BlockDriverState *value) QEMU_WARN_UNUSED_RESULT; |
325 | 18846dee | Markus Armbruster | void qdev_prop_set_drive_nofail(DeviceState *dev, const char *name, BlockDriverState *value); |
326 | 1503fff3 | Gerd Hoffmann | void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value); |
327 | 9b170e60 | Paolo Bonzini | void qdev_prop_set_enum(DeviceState *dev, const char *name, int value); |
328 | ee6847d1 | Gerd Hoffmann | /* FIXME: Remove opaque pointer properties. */
|
329 | ee6847d1 | Gerd Hoffmann | void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value); |
330 | ee6847d1 | Gerd Hoffmann | |
331 | 458fb679 | Gerd Hoffmann | void qdev_prop_register_global_list(GlobalProperty *props);
|
332 | 458fb679 | Gerd Hoffmann | void qdev_prop_set_globals(DeviceState *dev);
|
333 | 7db4c4e8 | Paolo Bonzini | void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev, |
334 | 7db4c4e8 | Paolo Bonzini | Property *prop, const char *value); |
335 | b6b61144 | Gerd Hoffmann | |
336 | 1ca4d09a | Gleb Natapov | char *qdev_get_fw_dev_path(DeviceState *dev);
|
337 | 4be9f0d1 | Anthony Liguori | |
338 | 85ed303b | Anthony Liguori | /**
|
339 | ca2cc788 | Paolo Bonzini | * @qdev_property_add_static - add a @Property to a device referencing a
|
340 | ca2cc788 | Paolo Bonzini | * field in a struct.
|
341 | a5296ca9 | Anthony Liguori | */
|
342 | ca2cc788 | Paolo Bonzini | void qdev_property_add_static(DeviceState *dev, Property *prop, Error **errp);
|
343 | a5296ca9 | Anthony Liguori | |
344 | a10f07a7 | Anthony Liguori | /**
|
345 | 1de81d28 | Anthony Liguori | * @qdev_machine_init
|
346 | 1de81d28 | Anthony Liguori | *
|
347 | 1de81d28 | Anthony Liguori | * Initialize platform devices before machine init. This is a hack until full
|
348 | 1de81d28 | Anthony Liguori | * support for composition is added.
|
349 | 1de81d28 | Anthony Liguori | */
|
350 | 1de81d28 | Anthony Liguori | void qdev_machine_init(void); |
351 | 1de81d28 | Anthony Liguori | |
352 | 94afdadc | Anthony Liguori | /**
|
353 | 94afdadc | Anthony Liguori | * @device_reset
|
354 | 94afdadc | Anthony Liguori | *
|
355 | 94afdadc | Anthony Liguori | * Reset a single device (by calling the reset method).
|
356 | 94afdadc | Anthony Liguori | */
|
357 | 94afdadc | Anthony Liguori | void device_reset(DeviceState *dev);
|
358 | 94afdadc | Anthony Liguori | |
359 | 4be9f0d1 | Anthony Liguori | const VMStateDescription *qdev_get_vmsd(DeviceState *dev);
|
360 | 4be9f0d1 | Anthony Liguori | |
361 | 4be9f0d1 | Anthony Liguori | const char *qdev_fw_name(DeviceState *dev); |
362 | 4be9f0d1 | Anthony Liguori | |
363 | f05f6b4a | Paolo Bonzini | Object *qdev_get_machine(void);
|
364 | f05f6b4a | Paolo Bonzini | |
365 | 9fbe6127 | Anthony Liguori | /* FIXME: make this a link<> */
|
366 | 9fbe6127 | Anthony Liguori | void qdev_set_parent_bus(DeviceState *dev, BusState *bus);
|
367 | 9fbe6127 | Anthony Liguori | |
368 | ee46d8a5 | Anthony Liguori | extern int qdev_hotplug; |
369 | ee46d8a5 | Anthony Liguori | |
370 | 09e5ab63 | Anthony Liguori | char *qdev_get_dev_path(DeviceState *dev);
|
371 | 09e5ab63 | Anthony Liguori | |
372 | aae9460e | Paul Brook | #endif |