Provide marshalling mechanism for json
[qemu/aliguori-queue.git] / hw / hw.h
blob7889aa3ceece42aaa1da19019d194eba07172c67
1 /* Declarations for use by hardware emulation. */
2 #ifndef QEMU_HW_H
3 #define QEMU_HW_H
5 #include "qemu-common.h"
7 #if defined(TARGET_PHYS_ADDR_BITS) && !defined(NEED_CPU_H)
8 #include "targphys.h"
9 #include "poison.h"
10 #include "cpu-common.h"
11 #endif
13 #include <stdbool.h>
14 #include "ioport.h"
15 #include "irq.h"
17 /* VM Load/Save */
19 /* This function writes a chunk of data to a file at the given position.
20 * The pos argument can be ignored if the file is only being used for
21 * streaming. The handler should try to write all of the data it can.
23 typedef int (QEMUFilePutBufferFunc)(void *opaque, const uint8_t *buf,
24 int64_t pos, int size);
26 /* Read a chunk of data from a file at the given position. The pos argument
27 * can be ignored if the file is only be used for streaming. The number of
28 * bytes actually read should be returned.
30 typedef int (QEMUFileGetBufferFunc)(void *opaque, uint8_t *buf,
31 int64_t pos, int size);
33 /* Close a file and return an error code */
34 typedef int (QEMUFileCloseFunc)(void *opaque);
36 /* Called to determine if the file has exceeded it's bandwidth allocation. The
37 * bandwidth capping is a soft limit, not a hard limit.
39 typedef int (QEMUFileRateLimit)(void *opaque);
41 /* Called to change the current bandwidth allocation. This function must return
42 * the new actual bandwidth. It should be new_rate if everything goes ok, and
43 * the old rate otherwise
45 typedef size_t (QEMUFileSetRateLimit)(void *opaque, size_t new_rate);
46 typedef size_t (QEMUFileGetRateLimit)(void *opaque);
48 QEMUFile *qemu_fopen_ops(void *opaque, QEMUFilePutBufferFunc *put_buffer,
49 QEMUFileGetBufferFunc *get_buffer,
50 QEMUFileCloseFunc *close,
51 QEMUFileRateLimit *rate_limit,
52 QEMUFileSetRateLimit *set_rate_limit,
53 QEMUFileGetRateLimit *get_rate_limit);
54 QEMUFile *qemu_fopen(const char *filename, const char *mode);
55 QEMUFile *qemu_fdopen(int fd, const char *mode);
56 QEMUFile *qemu_fopen_socket(int fd);
57 QEMUFile *qemu_popen(FILE *popen_file, const char *mode);
58 QEMUFile *qemu_popen_cmd(const char *command, const char *mode);
59 int qemu_stdio_fd(QEMUFile *f);
60 void qemu_fflush(QEMUFile *f);
61 int qemu_fclose(QEMUFile *f);
62 void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size);
63 void qemu_put_byte(QEMUFile *f, int v);
65 static inline void qemu_put_ubyte(QEMUFile *f, unsigned int v)
67 qemu_put_byte(f, (int)v);
70 #define qemu_put_sbyte qemu_put_byte
72 void qemu_put_be16(QEMUFile *f, unsigned int v);
73 void qemu_put_be32(QEMUFile *f, unsigned int v);
74 void qemu_put_be64(QEMUFile *f, uint64_t v);
75 int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size);
76 int qemu_get_byte(QEMUFile *f);
78 static inline unsigned int qemu_get_ubyte(QEMUFile *f)
80 return (unsigned int)qemu_get_byte(f);
83 #define qemu_get_sbyte qemu_get_byte
85 unsigned int qemu_get_be16(QEMUFile *f);
86 unsigned int qemu_get_be32(QEMUFile *f);
87 uint64_t qemu_get_be64(QEMUFile *f);
88 int qemu_file_rate_limit(QEMUFile *f);
89 size_t qemu_file_set_rate_limit(QEMUFile *f, size_t new_rate);
90 size_t qemu_file_get_rate_limit(QEMUFile *f);
91 int qemu_file_has_error(QEMUFile *f);
92 void qemu_file_set_error(QEMUFile *f);
94 /* Try to send any outstanding data. This function is useful when output is
95 * halted due to rate limiting or EAGAIN errors occur as it can be used to
96 * resume output. */
97 void qemu_file_put_notify(QEMUFile *f);
99 static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv)
101 qemu_put_be64(f, *pv);
104 static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv)
106 qemu_put_be32(f, *pv);
109 static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv)
111 qemu_put_be16(f, *pv);
114 static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv)
116 qemu_put_byte(f, *pv);
119 static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv)
121 *pv = qemu_get_be64(f);
124 static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv)
126 *pv = qemu_get_be32(f);
129 static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv)
131 *pv = qemu_get_be16(f);
134 static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv)
136 *pv = qemu_get_byte(f);
139 // Signed versions for type safety
140 static inline void qemu_put_sbuffer(QEMUFile *f, const int8_t *buf, int size)
142 qemu_put_buffer(f, (const uint8_t *)buf, size);
145 static inline void qemu_put_sbe16(QEMUFile *f, int v)
147 qemu_put_be16(f, (unsigned int)v);
150 static inline void qemu_put_sbe32(QEMUFile *f, int v)
152 qemu_put_be32(f, (unsigned int)v);
155 static inline void qemu_put_sbe64(QEMUFile *f, int64_t v)
157 qemu_put_be64(f, (uint64_t)v);
160 static inline size_t qemu_get_sbuffer(QEMUFile *f, int8_t *buf, int size)
162 return qemu_get_buffer(f, (uint8_t *)buf, size);
165 static inline int qemu_get_sbe16(QEMUFile *f)
167 return (int)qemu_get_be16(f);
170 static inline int qemu_get_sbe32(QEMUFile *f)
172 return (int)qemu_get_be32(f);
175 static inline int64_t qemu_get_sbe64(QEMUFile *f)
177 return (int64_t)qemu_get_be64(f);
180 static inline void qemu_put_s8s(QEMUFile *f, const int8_t *pv)
182 qemu_put_8s(f, (const uint8_t *)pv);
185 static inline void qemu_put_sbe16s(QEMUFile *f, const int16_t *pv)
187 qemu_put_be16s(f, (const uint16_t *)pv);
190 static inline void qemu_put_sbe32s(QEMUFile *f, const int32_t *pv)
192 qemu_put_be32s(f, (const uint32_t *)pv);
195 static inline void qemu_put_sbe64s(QEMUFile *f, const int64_t *pv)
197 qemu_put_be64s(f, (const uint64_t *)pv);
200 static inline void qemu_get_s8s(QEMUFile *f, int8_t *pv)
202 qemu_get_8s(f, (uint8_t *)pv);
205 static inline void qemu_get_sbe16s(QEMUFile *f, int16_t *pv)
207 qemu_get_be16s(f, (uint16_t *)pv);
210 static inline void qemu_get_sbe32s(QEMUFile *f, int32_t *pv)
212 qemu_get_be32s(f, (uint32_t *)pv);
215 static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv)
217 qemu_get_be64s(f, (uint64_t *)pv);
220 #ifdef NEED_CPU_H
221 #if TARGET_LONG_BITS == 64
222 #define qemu_put_betl qemu_put_be64
223 #define qemu_get_betl qemu_get_be64
224 #define qemu_put_betls qemu_put_be64s
225 #define qemu_get_betls qemu_get_be64s
226 #define qemu_put_sbetl qemu_put_sbe64
227 #define qemu_get_sbetl qemu_get_sbe64
228 #define qemu_put_sbetls qemu_put_sbe64s
229 #define qemu_get_sbetls qemu_get_sbe64s
230 #else
231 #define qemu_put_betl qemu_put_be32
232 #define qemu_get_betl qemu_get_be32
233 #define qemu_put_betls qemu_put_be32s
234 #define qemu_get_betls qemu_get_be32s
235 #define qemu_put_sbetl qemu_put_sbe32
236 #define qemu_get_sbetl qemu_get_sbe32
237 #define qemu_put_sbetls qemu_put_sbe32s
238 #define qemu_get_sbetls qemu_get_sbe32s
239 #endif
240 #endif
242 int64_t qemu_ftell(QEMUFile *f);
243 int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence);
245 typedef void SaveSetParamsHandler(int blk_enable, int shared, void * opaque);
246 typedef void SaveStateHandler(QEMUFile *f, void *opaque);
247 typedef int SaveLiveStateHandler(QEMUFile *f, int stage, void *opaque);
248 typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
250 int register_savevm(const char *idstr,
251 int instance_id,
252 int version_id,
253 SaveStateHandler *save_state,
254 LoadStateHandler *load_state,
255 void *opaque);
257 int register_savevm_live(const char *idstr,
258 int instance_id,
259 int version_id,
260 SaveSetParamsHandler *set_params,
261 SaveLiveStateHandler *save_live_state,
262 SaveStateHandler *save_state,
263 LoadStateHandler *load_state,
264 void *opaque);
266 void unregister_savevm(const char *idstr, void *opaque);
268 typedef void QEMUResetHandler(void *opaque);
270 void qemu_register_reset(QEMUResetHandler *func, void *opaque);
271 void qemu_unregister_reset(QEMUResetHandler *func, void *opaque);
273 /* handler to set the boot_device order for a specific type of QEMUMachine */
274 /* return 0 if success */
275 typedef int QEMUBootSetHandler(void *opaque, const char *boot_devices);
276 void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque);
277 int qemu_boot_set(const char *boot_devices);
279 typedef struct VMStateInfo VMStateInfo;
280 typedef struct VMStateDescription VMStateDescription;
282 struct VMStateInfo {
283 const char *name;
284 int (*get)(QEMUFile *f, void *pv, size_t size);
285 void (*put)(QEMUFile *f, void *pv, size_t size);
288 enum VMStateFlags {
289 VMS_SINGLE = 0x001,
290 VMS_POINTER = 0x002,
291 VMS_ARRAY = 0x004,
292 VMS_STRUCT = 0x008,
293 VMS_VARRAY_INT32 = 0x010, /* Array with size in int32_t field*/
294 VMS_BUFFER = 0x020, /* static sized buffer */
295 VMS_ARRAY_OF_POINTER = 0x040,
296 VMS_VARRAY_UINT16 = 0x080, /* Array with size in uint16_t field */
299 typedef struct {
300 const char *name;
301 size_t offset;
302 size_t size;
303 int num;
304 size_t num_offset;
305 const VMStateInfo *info;
306 enum VMStateFlags flags;
307 const VMStateDescription *vmsd;
308 int version_id;
309 bool (*field_exists)(void *opaque, int version_id);
310 } VMStateField;
312 struct VMStateDescription {
313 const char *name;
314 int version_id;
315 int minimum_version_id;
316 int minimum_version_id_old;
317 LoadStateHandler *load_state_old;
318 int (*pre_load)(void *opaque);
319 int (*post_load)(void *opaque, int version_id);
320 void (*pre_save)(void *opaque);
321 void (*post_save)(void *opaque);
322 VMStateField *fields;
325 extern const VMStateInfo vmstate_info_int8;
326 extern const VMStateInfo vmstate_info_int16;
327 extern const VMStateInfo vmstate_info_int32;
328 extern const VMStateInfo vmstate_info_int64;
330 extern const VMStateInfo vmstate_info_uint8_equal;
331 extern const VMStateInfo vmstate_info_uint16_equal;
332 extern const VMStateInfo vmstate_info_int32_equal;
333 extern const VMStateInfo vmstate_info_int32_le;
335 extern const VMStateInfo vmstate_info_uint8;
336 extern const VMStateInfo vmstate_info_uint16;
337 extern const VMStateInfo vmstate_info_uint32;
338 extern const VMStateInfo vmstate_info_uint64;
340 extern const VMStateInfo vmstate_info_timer;
341 extern const VMStateInfo vmstate_info_ptimer;
342 extern const VMStateInfo vmstate_info_buffer;
343 extern const VMStateInfo vmstate_info_unused_buffer;
345 #define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0)
346 #define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0)
348 #define vmstate_offset_value(_state, _field, _type) \
349 (offsetof(_state, _field) + \
350 type_check(_type, typeof_field(_state, _field)))
352 #define vmstate_offset_pointer(_state, _field, _type) \
353 (offsetof(_state, _field) + \
354 type_check_pointer(_type, typeof_field(_state, _field)))
356 #define vmstate_offset_array(_state, _field, _type, _num) \
357 (offsetof(_state, _field) + \
358 type_check_array(_type, typeof_field(_state, _field), _num))
360 #define vmstate_offset_sub_array(_state, _field, _type, _start) \
361 (offsetof(_state, _field[_start]))
363 #define vmstate_offset_buffer(_state, _field) \
364 vmstate_offset_array(_state, _field, uint8_t, \
365 sizeof(typeof_field(_state, _field)))
367 #define VMSTATE_SINGLE_TEST(_field, _state, _test, _version, _info, _type) { \
368 .name = (stringify(_field)), \
369 .version_id = (_version), \
370 .field_exists = (_test), \
371 .size = sizeof(_type), \
372 .info = &(_info), \
373 .flags = VMS_SINGLE, \
374 .offset = vmstate_offset_value(_state, _field, _type), \
377 #define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \
378 .name = (stringify(_field)), \
379 .version_id = (_version), \
380 .info = &(_info), \
381 .size = sizeof(_type), \
382 .flags = VMS_SINGLE|VMS_POINTER, \
383 .offset = vmstate_offset_value(_state, _field, _type), \
386 #define VMSTATE_ARRAY(_field, _state, _num, _version, _info, _type) {\
387 .name = (stringify(_field)), \
388 .version_id = (_version), \
389 .num = (_num), \
390 .info = &(_info), \
391 .size = sizeof(_type), \
392 .flags = VMS_ARRAY, \
393 .offset = vmstate_offset_array(_state, _field, _type, _num), \
396 #define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\
397 .name = (stringify(_field)), \
398 .field_exists = (_test), \
399 .num = (_num), \
400 .info = &(_info), \
401 .size = sizeof(_type), \
402 .flags = VMS_ARRAY, \
403 .offset = vmstate_offset_array(_state, _field, _type, _num),\
406 #define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \
407 .name = (stringify(_field)), \
408 .version_id = (_version), \
409 .num = (_num), \
410 .info = &(_info), \
411 .size = sizeof(_type), \
412 .flags = VMS_ARRAY, \
413 .offset = vmstate_offset_sub_array(_state, _field, _type, _start), \
416 #define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, _type) {\
417 .name = (stringify(_field)), \
418 .version_id = (_version), \
419 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
420 .info = &(_info), \
421 .size = sizeof(_type), \
422 .flags = VMS_VARRAY_INT32|VMS_POINTER, \
423 .offset = vmstate_offset_pointer(_state, _field, _type), \
426 #define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version, _info, _type) {\
427 .name = (stringify(_field)), \
428 .version_id = (_version), \
429 .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\
430 .info = &(_info), \
431 .size = sizeof(_type), \
432 .flags = VMS_VARRAY_UINT16, \
433 .offset = offsetof(_state, _field), \
436 #define VMSTATE_STRUCT(_field, _state, _version, _vmsd, _type) { \
437 .name = (stringify(_field)), \
438 .version_id = (_version), \
439 .vmsd = &(_vmsd), \
440 .size = sizeof(_type), \
441 .flags = VMS_STRUCT, \
442 .offset = vmstate_offset_value(_state, _field, _type), \
445 #define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type) { \
446 .name = (stringify(_field)), \
447 .vmsd = &(_vmsd), \
448 .size = sizeof(_type), \
449 .flags = VMS_STRUCT|VMS_POINTER, \
450 .offset = vmstate_offset_value(_state, _field, _type), \
453 #define VMSTATE_ARRAY_OF_POINTER(_field, _state, _num, _version, _info, _type) {\
454 .name = (stringify(_field)), \
455 .version_id = (_version), \
456 .num = (_num), \
457 .info = &(_info), \
458 .size = sizeof(_type), \
459 .flags = VMS_ARRAY|VMS_ARRAY_OF_POINTER, \
460 .offset = vmstate_offset_array(_state, _field, _type, _num), \
463 #define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _version, _vmsd, _type) { \
464 .name = (stringify(_field)), \
465 .num = (_num), \
466 .version_id = (_version), \
467 .vmsd = &(_vmsd), \
468 .size = sizeof(_type), \
469 .flags = VMS_STRUCT|VMS_ARRAY, \
470 .offset = vmstate_offset_array(_state, _field, _type, _num), \
473 #define VMSTATE_STRUCT_ARRAY_SIZE_UINT8(_field, _state, _field__num, _version, _vmsd, _type) { \
474 .name = (stringify(_field)), \
475 .num_offset = vmstate_offset_value(_state, _field_num, uint8_t), \
476 .version_id = (_version), \
477 .vmsd = &(_vmsd), \
478 .size = sizeof(_type), \
479 .flags = VMS_STRUCT|VMS_ARRAY, \
480 .offset = vmstate_offset_array(_state, _field, _type, _num), \
483 #define VMSTATE_STATIC_BUFFER(_field, _state, _version, _test, _start, _size) { \
484 .name = (stringify(_field)), \
485 .version_id = (_version), \
486 .field_exists = (_test), \
487 .size = (_size - _start), \
488 .info = &vmstate_info_buffer, \
489 .flags = VMS_BUFFER, \
490 .offset = vmstate_offset_buffer(_state, _field) + _start, \
493 #define VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, _info, _size) { \
494 .name = (stringify(_field)), \
495 .version_id = (_version), \
496 .size = (_size), \
497 .info = &(_info), \
498 .flags = VMS_BUFFER, \
499 .offset = offsetof(_state, _field), \
502 #define VMSTATE_UNUSED_BUFFER(_test, _version, _size) { \
503 .name = "unused", \
504 .field_exists = (_test), \
505 .version_id = (_version), \
506 .size = (_size), \
507 .info = &vmstate_info_unused_buffer, \
508 .flags = VMS_BUFFER, \
510 extern const VMStateDescription vmstate_pci_device;
512 #define VMSTATE_PCI_DEVICE(_field, _state) { \
513 .name = (stringify(_field)), \
514 .size = sizeof(PCIDevice), \
515 .vmsd = &vmstate_pci_device, \
516 .flags = VMS_STRUCT, \
517 .offset = vmstate_offset_value(_state, _field, PCIDevice), \
520 extern const VMStateDescription vmstate_pcie_device;
522 #define VMSTATE_PCIE_DEVICE(_field, _state) { \
523 .name = (stringify(_field)), \
524 .version_id = 2, \
525 .size = sizeof(PCIDevice), \
526 .vmsd = &vmstate_pcie_device, \
527 .flags = VMS_STRUCT, \
528 .offset = vmstate_offset_value(_state, _field, PCIDevice), \
531 extern const VMStateDescription vmstate_i2c_slave;
533 #define VMSTATE_I2C_SLAVE(_field, _state) { \
534 .name = (stringify(_field)), \
535 .size = sizeof(i2c_slave), \
536 .vmsd = &vmstate_i2c_slave, \
537 .flags = VMS_STRUCT, \
538 .offset = vmstate_offset_value(_state, _field, i2c_slave), \
541 #define vmstate_offset_macaddr(_state, _field) \
542 vmstate_offset_array(_state, _field.a, uint8_t, \
543 sizeof(typeof_field(_state, _field)))
545 #define VMSTATE_MACADDR(_field, _state) { \
546 .name = (stringify(_field)), \
547 .size = sizeof(MACAddr), \
548 .info = &vmstate_info_uint8, \
549 .flags = VMS_BUFFER, \
550 .offset = vmstate_offset_macaddr(_state, _field), \
553 /* _f : field name
554 _f_n : num of elements field_name
555 _n : num of elements
556 _s : struct state name
557 _v : version
560 #define VMSTATE_SINGLE(_field, _state, _version, _info, _type) \
561 VMSTATE_SINGLE_TEST(_field, _state, NULL, _version, _info, _type)
563 #define VMSTATE_INT8_V(_f, _s, _v) \
564 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t)
565 #define VMSTATE_INT16_V(_f, _s, _v) \
566 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int16, int16_t)
567 #define VMSTATE_INT32_V(_f, _s, _v) \
568 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int32, int32_t)
569 #define VMSTATE_INT64_V(_f, _s, _v) \
570 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int64, int64_t)
572 #define VMSTATE_UINT8_V(_f, _s, _v) \
573 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint8, uint8_t)
574 #define VMSTATE_UINT16_V(_f, _s, _v) \
575 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16, uint16_t)
576 #define VMSTATE_UINT32_V(_f, _s, _v) \
577 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32, uint32_t)
578 #define VMSTATE_UINT64_V(_f, _s, _v) \
579 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t)
581 #define VMSTATE_INT8(_f, _s) \
582 VMSTATE_INT8_V(_f, _s, 0)
583 #define VMSTATE_INT16(_f, _s) \
584 VMSTATE_INT16_V(_f, _s, 0)
585 #define VMSTATE_INT32(_f, _s) \
586 VMSTATE_INT32_V(_f, _s, 0)
587 #define VMSTATE_INT64(_f, _s) \
588 VMSTATE_INT64_V(_f, _s, 0)
590 #define VMSTATE_UINT8(_f, _s) \
591 VMSTATE_UINT8_V(_f, _s, 0)
592 #define VMSTATE_UINT16(_f, _s) \
593 VMSTATE_UINT16_V(_f, _s, 0)
594 #define VMSTATE_UINT32(_f, _s) \
595 VMSTATE_UINT32_V(_f, _s, 0)
596 #define VMSTATE_UINT64(_f, _s) \
597 VMSTATE_UINT64_V(_f, _s, 0)
599 #define VMSTATE_UINT8_EQUAL(_f, _s) \
600 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t)
602 #define VMSTATE_UINT16_EQUAL(_f, _s) \
603 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint16_equal, uint16_t)
605 #define VMSTATE_UINT16_EQUAL_V(_f, _s, _v) \
606 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16_equal, uint16_t)
608 #define VMSTATE_INT32_EQUAL(_f, _s) \
609 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t)
611 #define VMSTATE_INT32_LE(_f, _s) \
612 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)
614 #define VMSTATE_UINT32_TEST(_f, _s, _t) \
615 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t)
617 #define VMSTATE_TIMER_V(_f, _s, _v) \
618 VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *)
620 #define VMSTATE_TIMER(_f, _s) \
621 VMSTATE_TIMER_V(_f, _s, 0)
623 #define VMSTATE_TIMER_ARRAY(_f, _s, _n) \
624 VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *)
626 #define VMSTATE_PTIMER_V(_f, _s, _v) \
627 VMSTATE_POINTER(_f, _s, _v, vmstate_info_ptimer, ptimer_state *)
629 #define VMSTATE_PTIMER(_f, _s) \
630 VMSTATE_PTIMER_V(_f, _s, 0)
632 #define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \
633 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t)
635 #define VMSTATE_UINT16_ARRAY(_f, _s, _n) \
636 VMSTATE_UINT16_ARRAY_V(_f, _s, _n, 0)
638 #define VMSTATE_UINT8_ARRAY_V(_f, _s, _n, _v) \
639 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint8, uint8_t)
641 #define VMSTATE_UINT8_ARRAY(_f, _s, _n) \
642 VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0)
644 #define VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) \
645 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t)
647 #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
648 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
650 #define VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v) \
651 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint64, uint64_t)
653 #define VMSTATE_UINT64_ARRAY(_f, _s, _n) \
654 VMSTATE_UINT64_ARRAY_V(_f, _s, _n, 0)
656 #define VMSTATE_INT16_ARRAY_V(_f, _s, _n, _v) \
657 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int16, int16_t)
659 #define VMSTATE_INT16_ARRAY(_f, _s, _n) \
660 VMSTATE_INT16_ARRAY_V(_f, _s, _n, 0)
662 #define VMSTATE_INT32_ARRAY_V(_f, _s, _n, _v) \
663 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t)
665 #define VMSTATE_INT32_ARRAY(_f, _s, _n) \
666 VMSTATE_INT32_ARRAY_V(_f, _s, _n, 0)
668 #define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num) \
669 VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t)
671 #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
672 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
674 #define VMSTATE_BUFFER_V(_f, _s, _v) \
675 VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))
677 #define VMSTATE_BUFFER(_f, _s) \
678 VMSTATE_BUFFER_V(_f, _s, 0)
680 #define VMSTATE_PARTIAL_BUFFER(_f, _s, _size) \
681 VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, 0, _size)
683 #define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \
684 VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, _start, sizeof(typeof_field(_s, _f)))
686 #define VMSTATE_BUFFER_TEST(_f, _s, _test) \
687 VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f)))
689 #define VMSTATE_BUFFER_UNSAFE(_field, _state, _version, _size) \
690 VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, vmstate_info_buffer, _size)
692 #define VMSTATE_UNUSED_V(_v, _size) \
693 VMSTATE_UNUSED_BUFFER(NULL, _v, _size)
695 #define VMSTATE_UNUSED(_size) \
696 VMSTATE_UNUSED_V(0, _size)
698 #define VMSTATE_UNUSED_TEST(_test, _size) \
699 VMSTATE_UNUSED_BUFFER(_test, 0, _size)
701 #ifdef NEED_CPU_H
702 #if TARGET_LONG_BITS == 64
703 #define VMSTATE_UINTTL_V(_f, _s, _v) \
704 VMSTATE_UINT64_V(_f, _s, _v)
705 #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v) \
706 VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v)
707 #else
708 #define VMSTATE_UINTTL_V(_f, _s, _v) \
709 VMSTATE_UINT32_V(_f, _s, _v)
710 #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v) \
711 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v)
712 #endif
713 #define VMSTATE_UINTTL(_f, _s) \
714 VMSTATE_UINTTL_V(_f, _s, 0)
715 #define VMSTATE_UINTTL_ARRAY(_f, _s, _n) \
716 VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, 0)
718 #endif
720 #define VMSTATE_END_OF_LIST() \
723 extern int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
724 void *opaque, int version_id);
725 extern void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
726 void *opaque);
727 extern int vmstate_register(int instance_id, const VMStateDescription *vmsd,
728 void *base);
729 void vmstate_unregister(const VMStateDescription *vmsd, void *opaque);
730 #endif