1 /* Declarations for use by hardware emulation. */
5 #include "qemu-common.h"
7 #if defined(TARGET_PHYS_ADDR_BITS) && !defined(NEED_CPU_H)
8 #include "cpu-common.h"
16 /* This function writes a chunk of data to a file at the given position.
17 * The pos argument can be ignored if the file is only being used for
18 * streaming. The handler should try to write all of the data it can.
20 typedef int (QEMUFilePutBufferFunc
)(void *opaque
, const uint8_t *buf
,
21 int64_t pos
, int size
);
23 /* Read a chunk of data from a file at the given position. The pos argument
24 * can be ignored if the file is only be used for streaming. The number of
25 * bytes actually read should be returned.
27 typedef int (QEMUFileGetBufferFunc
)(void *opaque
, uint8_t *buf
,
28 int64_t pos
, int size
);
30 /* Close a file and return an error code */
31 typedef int (QEMUFileCloseFunc
)(void *opaque
);
33 /* Called to determine if the file has exceeded it's bandwidth allocation. The
34 * bandwidth capping is a soft limit, not a hard limit.
36 typedef int (QEMUFileRateLimit
)(void *opaque
);
38 /* Called to change the current bandwidth allocation. This function must return
39 * the new actual bandwidth. It should be new_rate if everything goes ok, and
40 * the old rate otherwise
42 typedef size_t (QEMUFileSetRateLimit
)(void *opaque
, size_t new_rate
);
43 typedef size_t (QEMUFileGetRateLimit
)(void *opaque
);
45 QEMUFile
*qemu_fopen_ops(void *opaque
, QEMUFilePutBufferFunc
*put_buffer
,
46 QEMUFileGetBufferFunc
*get_buffer
,
47 QEMUFileCloseFunc
*close
,
48 QEMUFileRateLimit
*rate_limit
,
49 QEMUFileSetRateLimit
*set_rate_limit
,
50 QEMUFileGetRateLimit
*get_rate_limit
);
51 QEMUFile
*qemu_fopen(const char *filename
, const char *mode
);
52 QEMUFile
*qemu_fdopen(int fd
, const char *mode
);
53 QEMUFile
*qemu_fopen_socket(int fd
);
54 QEMUFile
*qemu_popen(FILE *popen_file
, const char *mode
);
55 QEMUFile
*qemu_popen_cmd(const char *command
, const char *mode
);
56 int qemu_stdio_fd(QEMUFile
*f
);
57 void qemu_fflush(QEMUFile
*f
);
58 int qemu_fclose(QEMUFile
*f
);
59 void qemu_put_buffer(QEMUFile
*f
, const uint8_t *buf
, int size
);
60 void qemu_put_byte(QEMUFile
*f
, int v
);
62 static inline void qemu_put_ubyte(QEMUFile
*f
, unsigned int v
)
64 qemu_put_byte(f
, (int)v
);
67 #define qemu_put_sbyte qemu_put_byte
69 void qemu_put_be16(QEMUFile
*f
, unsigned int v
);
70 void qemu_put_be32(QEMUFile
*f
, unsigned int v
);
71 void qemu_put_be64(QEMUFile
*f
, uint64_t v
);
72 int qemu_get_buffer(QEMUFile
*f
, uint8_t *buf
, int size
);
73 int qemu_get_byte(QEMUFile
*f
);
75 static inline unsigned int qemu_get_ubyte(QEMUFile
*f
)
77 return (unsigned int)qemu_get_byte(f
);
80 #define qemu_get_sbyte qemu_get_byte
82 unsigned int qemu_get_be16(QEMUFile
*f
);
83 unsigned int qemu_get_be32(QEMUFile
*f
);
84 uint64_t qemu_get_be64(QEMUFile
*f
);
85 int qemu_file_rate_limit(QEMUFile
*f
);
86 size_t qemu_file_set_rate_limit(QEMUFile
*f
, size_t new_rate
);
87 size_t qemu_file_get_rate_limit(QEMUFile
*f
);
88 int qemu_file_has_error(QEMUFile
*f
);
89 void qemu_file_set_error(QEMUFile
*f
);
91 /* Try to send any outstanding data. This function is useful when output is
92 * halted due to rate limiting or EAGAIN errors occur as it can be used to
94 void qemu_file_put_notify(QEMUFile
*f
);
96 static inline void qemu_put_be64s(QEMUFile
*f
, const uint64_t *pv
)
98 qemu_put_be64(f
, *pv
);
101 static inline void qemu_put_be32s(QEMUFile
*f
, const uint32_t *pv
)
103 qemu_put_be32(f
, *pv
);
106 static inline void qemu_put_be16s(QEMUFile
*f
, const uint16_t *pv
)
108 qemu_put_be16(f
, *pv
);
111 static inline void qemu_put_8s(QEMUFile
*f
, const uint8_t *pv
)
113 qemu_put_byte(f
, *pv
);
116 static inline void qemu_get_be64s(QEMUFile
*f
, uint64_t *pv
)
118 *pv
= qemu_get_be64(f
);
121 static inline void qemu_get_be32s(QEMUFile
*f
, uint32_t *pv
)
123 *pv
= qemu_get_be32(f
);
126 static inline void qemu_get_be16s(QEMUFile
*f
, uint16_t *pv
)
128 *pv
= qemu_get_be16(f
);
131 static inline void qemu_get_8s(QEMUFile
*f
, uint8_t *pv
)
133 *pv
= qemu_get_byte(f
);
136 // Signed versions for type safety
137 static inline void qemu_put_sbuffer(QEMUFile
*f
, const int8_t *buf
, int size
)
139 qemu_put_buffer(f
, (const uint8_t *)buf
, size
);
142 static inline void qemu_put_sbe16(QEMUFile
*f
, int v
)
144 qemu_put_be16(f
, (unsigned int)v
);
147 static inline void qemu_put_sbe32(QEMUFile
*f
, int v
)
149 qemu_put_be32(f
, (unsigned int)v
);
152 static inline void qemu_put_sbe64(QEMUFile
*f
, int64_t v
)
154 qemu_put_be64(f
, (uint64_t)v
);
157 static inline size_t qemu_get_sbuffer(QEMUFile
*f
, int8_t *buf
, int size
)
159 return qemu_get_buffer(f
, (uint8_t *)buf
, size
);
162 static inline int qemu_get_sbe16(QEMUFile
*f
)
164 return (int)qemu_get_be16(f
);
167 static inline int qemu_get_sbe32(QEMUFile
*f
)
169 return (int)qemu_get_be32(f
);
172 static inline int64_t qemu_get_sbe64(QEMUFile
*f
)
174 return (int64_t)qemu_get_be64(f
);
177 static inline void qemu_put_s8s(QEMUFile
*f
, const int8_t *pv
)
179 qemu_put_8s(f
, (const uint8_t *)pv
);
182 static inline void qemu_put_sbe16s(QEMUFile
*f
, const int16_t *pv
)
184 qemu_put_be16s(f
, (const uint16_t *)pv
);
187 static inline void qemu_put_sbe32s(QEMUFile
*f
, const int32_t *pv
)
189 qemu_put_be32s(f
, (const uint32_t *)pv
);
192 static inline void qemu_put_sbe64s(QEMUFile
*f
, const int64_t *pv
)
194 qemu_put_be64s(f
, (const uint64_t *)pv
);
197 static inline void qemu_get_s8s(QEMUFile
*f
, int8_t *pv
)
199 qemu_get_8s(f
, (uint8_t *)pv
);
202 static inline void qemu_get_sbe16s(QEMUFile
*f
, int16_t *pv
)
204 qemu_get_be16s(f
, (uint16_t *)pv
);
207 static inline void qemu_get_sbe32s(QEMUFile
*f
, int32_t *pv
)
209 qemu_get_be32s(f
, (uint32_t *)pv
);
212 static inline void qemu_get_sbe64s(QEMUFile
*f
, int64_t *pv
)
214 qemu_get_be64s(f
, (uint64_t *)pv
);
218 #if TARGET_LONG_BITS == 64
219 #define qemu_put_betl qemu_put_be64
220 #define qemu_get_betl qemu_get_be64
221 #define qemu_put_betls qemu_put_be64s
222 #define qemu_get_betls qemu_get_be64s
223 #define qemu_put_sbetl qemu_put_sbe64
224 #define qemu_get_sbetl qemu_get_sbe64
225 #define qemu_put_sbetls qemu_put_sbe64s
226 #define qemu_get_sbetls qemu_get_sbe64s
228 #define qemu_put_betl qemu_put_be32
229 #define qemu_get_betl qemu_get_be32
230 #define qemu_put_betls qemu_put_be32s
231 #define qemu_get_betls qemu_get_be32s
232 #define qemu_put_sbetl qemu_put_sbe32
233 #define qemu_get_sbetl qemu_get_sbe32
234 #define qemu_put_sbetls qemu_put_sbe32s
235 #define qemu_get_sbetls qemu_get_sbe32s
239 int64_t qemu_ftell(QEMUFile
*f
);
240 int64_t qemu_fseek(QEMUFile
*f
, int64_t pos
, int whence
);
242 typedef void SaveSetParamsHandler(int blk_enable
, int shared
, void * opaque
);
243 typedef void SaveStateHandler(QEMUFile
*f
, void *opaque
);
244 typedef int SaveLiveStateHandler(Monitor
*mon
, QEMUFile
*f
, int stage
,
246 typedef int LoadStateHandler(QEMUFile
*f
, void *opaque
, int version_id
);
248 int register_savevm(DeviceState
*dev
,
252 SaveStateHandler
*save_state
,
253 LoadStateHandler
*load_state
,
256 int register_savevm_live(DeviceState
*dev
,
260 SaveSetParamsHandler
*set_params
,
261 SaveLiveStateHandler
*save_live_state
,
262 SaveStateHandler
*save_state
,
263 LoadStateHandler
*load_state
,
266 void unregister_savevm(DeviceState
*dev
, const char *idstr
, void *opaque
);
267 void register_device_unmigratable(DeviceState
*dev
, const char *idstr
,
270 typedef void QEMUResetHandler(void *opaque
);
272 void qemu_register_reset(QEMUResetHandler
*func
, void *opaque
);
273 void qemu_unregister_reset(QEMUResetHandler
*func
, void *opaque
);
275 /* handler to set the boot_device order for a specific type of QEMUMachine */
276 /* return 0 if success */
277 typedef int QEMUBootSetHandler(void *opaque
, const char *boot_devices
);
278 void qemu_register_boot_set(QEMUBootSetHandler
*func
, void *opaque
);
279 int qemu_boot_set(const char *boot_devices
);
281 typedef struct VMStateInfo VMStateInfo
;
282 typedef struct VMStateDescription VMStateDescription
;
286 int (*get
)(QEMUFile
*f
, void *pv
, size_t size
);
287 void (*put
)(QEMUFile
*f
, void *pv
, size_t size
);
295 VMS_VARRAY_INT32
= 0x010, /* Array with size in int32_t field*/
296 VMS_BUFFER
= 0x020, /* static sized buffer */
297 VMS_ARRAY_OF_POINTER
= 0x040,
298 VMS_VARRAY_UINT16
= 0x080, /* Array with size in uint16_t field */
299 VMS_VBUFFER
= 0x100, /* Buffer with size in int32_t field */
300 VMS_MULTIPLY
= 0x200, /* multiply "size" field by field_size */
311 const VMStateInfo
*info
;
312 enum VMStateFlags flags
;
313 const VMStateDescription
*vmsd
;
315 bool (*field_exists
)(void *opaque
, int version_id
);
318 typedef struct VMStateSubsection
{
319 const VMStateDescription
*vmsd
;
320 bool (*needed
)(void *opaque
);
323 struct VMStateDescription
{
326 int minimum_version_id
;
327 int minimum_version_id_old
;
328 LoadStateHandler
*load_state_old
;
329 int (*pre_load
)(void *opaque
);
330 int (*post_load
)(void *opaque
, int version_id
);
331 void (*pre_save
)(void *opaque
);
332 VMStateField
*fields
;
333 const VMStateSubsection
*subsections
;
336 extern const VMStateInfo vmstate_info_int8
;
337 extern const VMStateInfo vmstate_info_int16
;
338 extern const VMStateInfo vmstate_info_int32
;
339 extern const VMStateInfo vmstate_info_int64
;
341 extern const VMStateInfo vmstate_info_uint8_equal
;
342 extern const VMStateInfo vmstate_info_uint16_equal
;
343 extern const VMStateInfo vmstate_info_int32_equal
;
344 extern const VMStateInfo vmstate_info_int32_le
;
346 extern const VMStateInfo vmstate_info_uint8
;
347 extern const VMStateInfo vmstate_info_uint16
;
348 extern const VMStateInfo vmstate_info_uint32
;
349 extern const VMStateInfo vmstate_info_uint64
;
351 extern const VMStateInfo vmstate_info_timer
;
352 extern const VMStateInfo vmstate_info_ptimer
;
353 extern const VMStateInfo vmstate_info_buffer
;
354 extern const VMStateInfo vmstate_info_unused_buffer
;
356 #define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0)
357 #define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0)
359 #define vmstate_offset_value(_state, _field, _type) \
360 (offsetof(_state, _field) + \
361 type_check(_type, typeof_field(_state, _field)))
363 #define vmstate_offset_pointer(_state, _field, _type) \
364 (offsetof(_state, _field) + \
365 type_check_pointer(_type, typeof_field(_state, _field)))
367 #define vmstate_offset_array(_state, _field, _type, _num) \
368 (offsetof(_state, _field) + \
369 type_check_array(_type, typeof_field(_state, _field), _num))
371 #define vmstate_offset_sub_array(_state, _field, _type, _start) \
372 (offsetof(_state, _field[_start]))
374 #define vmstate_offset_buffer(_state, _field) \
375 vmstate_offset_array(_state, _field, uint8_t, \
376 sizeof(typeof_field(_state, _field)))
378 #define VMSTATE_SINGLE_TEST(_field, _state, _test, _version, _info, _type) { \
379 .name = (stringify(_field)), \
380 .version_id = (_version), \
381 .field_exists = (_test), \
382 .size = sizeof(_type), \
384 .flags = VMS_SINGLE, \
385 .offset = vmstate_offset_value(_state, _field, _type), \
388 #define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \
389 .name = (stringify(_field)), \
390 .version_id = (_version), \
392 .size = sizeof(_type), \
393 .flags = VMS_SINGLE|VMS_POINTER, \
394 .offset = vmstate_offset_value(_state, _field, _type), \
397 #define VMSTATE_ARRAY(_field, _state, _num, _version, _info, _type) {\
398 .name = (stringify(_field)), \
399 .version_id = (_version), \
402 .size = sizeof(_type), \
403 .flags = VMS_ARRAY, \
404 .offset = vmstate_offset_array(_state, _field, _type, _num), \
407 #define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\
408 .name = (stringify(_field)), \
409 .field_exists = (_test), \
412 .size = sizeof(_type), \
413 .flags = VMS_ARRAY, \
414 .offset = vmstate_offset_array(_state, _field, _type, _num),\
417 #define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \
418 .name = (stringify(_field)), \
419 .version_id = (_version), \
422 .size = sizeof(_type), \
423 .flags = VMS_ARRAY, \
424 .offset = vmstate_offset_sub_array(_state, _field, _type, _start), \
427 #define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, _type) {\
428 .name = (stringify(_field)), \
429 .version_id = (_version), \
430 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
432 .size = sizeof(_type), \
433 .flags = VMS_VARRAY_INT32|VMS_POINTER, \
434 .offset = vmstate_offset_pointer(_state, _field, _type), \
437 #define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version, _info, _type) {\
438 .name = (stringify(_field)), \
439 .version_id = (_version), \
440 .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\
442 .size = sizeof(_type), \
443 .flags = VMS_VARRAY_UINT16, \
444 .offset = offsetof(_state, _field), \
447 #define VMSTATE_STRUCT_TEST(_field, _state, _test, _version, _vmsd, _type) { \
448 .name = (stringify(_field)), \
449 .version_id = (_version), \
450 .field_exists = (_test), \
452 .size = sizeof(_type), \
453 .flags = VMS_STRUCT, \
454 .offset = vmstate_offset_value(_state, _field, _type), \
457 #define VMSTATE_STRUCT_POINTER_TEST(_field, _state, _test, _vmsd, _type) { \
458 .name = (stringify(_field)), \
459 .field_exists = (_test), \
461 .size = sizeof(_type), \
462 .flags = VMS_STRUCT|VMS_POINTER, \
463 .offset = vmstate_offset_value(_state, _field, _type), \
466 #define VMSTATE_ARRAY_OF_POINTER(_field, _state, _num, _version, _info, _type) {\
467 .name = (stringify(_field)), \
468 .version_id = (_version), \
471 .size = sizeof(_type), \
472 .flags = VMS_ARRAY|VMS_ARRAY_OF_POINTER, \
473 .offset = vmstate_offset_array(_state, _field, _type, _num), \
476 #define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _version, _vmsd, _type) { \
477 .name = (stringify(_field)), \
479 .version_id = (_version), \
481 .size = sizeof(_type), \
482 .flags = VMS_STRUCT|VMS_ARRAY, \
483 .offset = vmstate_offset_array(_state, _field, _type, _num), \
486 #define VMSTATE_STRUCT_VARRAY_UINT8(_field, _state, _field_num, _version, _vmsd, _type) { \
487 .name = (stringify(_field)), \
488 .num_offset = vmstate_offset_value(_state, _field_num, uint8_t), \
489 .version_id = (_version), \
491 .size = sizeof(_type), \
492 .flags = VMS_STRUCT|VMS_VARRAY_INT32, \
493 .offset = offsetof(_state, _field), \
496 #define VMSTATE_STATIC_BUFFER(_field, _state, _version, _test, _start, _size) { \
497 .name = (stringify(_field)), \
498 .version_id = (_version), \
499 .field_exists = (_test), \
500 .size = (_size - _start), \
501 .info = &vmstate_info_buffer, \
502 .flags = VMS_BUFFER, \
503 .offset = vmstate_offset_buffer(_state, _field) + _start, \
506 #define VMSTATE_BUFFER_MULTIPLY(_field, _state, _version, _test, _start, _field_size, _multiply) { \
507 .name = (stringify(_field)), \
508 .version_id = (_version), \
509 .field_exists = (_test), \
510 .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\
511 .size = (_multiply), \
512 .info = &vmstate_info_buffer, \
513 .flags = VMS_VBUFFER|VMS_MULTIPLY, \
514 .offset = offsetof(_state, _field), \
518 #define VMSTATE_VBUFFER(_field, _state, _version, _test, _start, _field_size) { \
519 .name = (stringify(_field)), \
520 .version_id = (_version), \
521 .field_exists = (_test), \
522 .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\
523 .info = &vmstate_info_buffer, \
524 .flags = VMS_VBUFFER|VMS_POINTER, \
525 .offset = offsetof(_state, _field), \
529 #define VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, _info, _size) { \
530 .name = (stringify(_field)), \
531 .version_id = (_version), \
534 .flags = VMS_BUFFER, \
535 .offset = offsetof(_state, _field), \
538 #define VMSTATE_UNUSED_BUFFER(_test, _version, _size) { \
540 .field_exists = (_test), \
541 .version_id = (_version), \
543 .info = &vmstate_info_unused_buffer, \
544 .flags = VMS_BUFFER, \
546 extern const VMStateDescription vmstate_pci_device
;
548 #define VMSTATE_PCI_DEVICE(_field, _state) { \
549 .name = (stringify(_field)), \
550 .size = sizeof(PCIDevice), \
551 .vmsd = &vmstate_pci_device, \
552 .flags = VMS_STRUCT, \
553 .offset = vmstate_offset_value(_state, _field, PCIDevice), \
556 extern const VMStateDescription vmstate_pcie_device
;
558 #define VMSTATE_PCIE_DEVICE(_field, _state) { \
559 .name = (stringify(_field)), \
561 .size = sizeof(PCIDevice), \
562 .vmsd = &vmstate_pcie_device, \
563 .flags = VMS_STRUCT, \
564 .offset = vmstate_offset_value(_state, _field, PCIDevice), \
567 extern const VMStateDescription vmstate_i2c_slave
;
569 #define VMSTATE_I2C_SLAVE(_field, _state) { \
570 .name = (stringify(_field)), \
571 .size = sizeof(i2c_slave), \
572 .vmsd = &vmstate_i2c_slave, \
573 .flags = VMS_STRUCT, \
574 .offset = vmstate_offset_value(_state, _field, i2c_slave), \
577 #define vmstate_offset_macaddr(_state, _field) \
578 vmstate_offset_array(_state, _field.a, uint8_t, \
579 sizeof(typeof_field(_state, _field)))
581 #define VMSTATE_MACADDR(_field, _state) { \
582 .name = (stringify(_field)), \
583 .size = sizeof(MACAddr), \
584 .info = &vmstate_info_buffer, \
585 .flags = VMS_BUFFER, \
586 .offset = vmstate_offset_macaddr(_state, _field), \
590 _f_n : num of elements field_name
592 _s : struct state name
596 #define VMSTATE_SINGLE(_field, _state, _version, _info, _type) \
597 VMSTATE_SINGLE_TEST(_field, _state, NULL, _version, _info, _type)
599 #define VMSTATE_STRUCT(_field, _state, _version, _vmsd, _type) \
600 VMSTATE_STRUCT_TEST(_field, _state, NULL, _version, _vmsd, _type)
602 #define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type) \
603 VMSTATE_STRUCT_POINTER_TEST(_field, _state, NULL, _vmsd, _type)
605 #define VMSTATE_INT8_V(_f, _s, _v) \
606 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t)
607 #define VMSTATE_INT16_V(_f, _s, _v) \
608 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int16, int16_t)
609 #define VMSTATE_INT32_V(_f, _s, _v) \
610 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int32, int32_t)
611 #define VMSTATE_INT64_V(_f, _s, _v) \
612 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int64, int64_t)
614 #define VMSTATE_UINT8_V(_f, _s, _v) \
615 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint8, uint8_t)
616 #define VMSTATE_UINT16_V(_f, _s, _v) \
617 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16, uint16_t)
618 #define VMSTATE_UINT32_V(_f, _s, _v) \
619 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32, uint32_t)
620 #define VMSTATE_UINT64_V(_f, _s, _v) \
621 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t)
623 #define VMSTATE_INT8(_f, _s) \
624 VMSTATE_INT8_V(_f, _s, 0)
625 #define VMSTATE_INT16(_f, _s) \
626 VMSTATE_INT16_V(_f, _s, 0)
627 #define VMSTATE_INT32(_f, _s) \
628 VMSTATE_INT32_V(_f, _s, 0)
629 #define VMSTATE_INT64(_f, _s) \
630 VMSTATE_INT64_V(_f, _s, 0)
632 #define VMSTATE_UINT8(_f, _s) \
633 VMSTATE_UINT8_V(_f, _s, 0)
634 #define VMSTATE_UINT16(_f, _s) \
635 VMSTATE_UINT16_V(_f, _s, 0)
636 #define VMSTATE_UINT32(_f, _s) \
637 VMSTATE_UINT32_V(_f, _s, 0)
638 #define VMSTATE_UINT64(_f, _s) \
639 VMSTATE_UINT64_V(_f, _s, 0)
641 #define VMSTATE_UINT8_EQUAL(_f, _s) \
642 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t)
644 #define VMSTATE_UINT16_EQUAL(_f, _s) \
645 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint16_equal, uint16_t)
647 #define VMSTATE_UINT16_EQUAL_V(_f, _s, _v) \
648 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16_equal, uint16_t)
650 #define VMSTATE_INT32_EQUAL(_f, _s) \
651 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t)
653 #define VMSTATE_INT32_LE(_f, _s) \
654 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)
656 #define VMSTATE_UINT16_TEST(_f, _s, _t) \
657 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint16, uint16_t)
659 #define VMSTATE_UINT32_TEST(_f, _s, _t) \
660 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t)
662 #define VMSTATE_TIMER_V(_f, _s, _v) \
663 VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *)
665 #define VMSTATE_TIMER(_f, _s) \
666 VMSTATE_TIMER_V(_f, _s, 0)
668 #define VMSTATE_TIMER_ARRAY(_f, _s, _n) \
669 VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *)
671 #define VMSTATE_PTIMER_V(_f, _s, _v) \
672 VMSTATE_POINTER(_f, _s, _v, vmstate_info_ptimer, ptimer_state *)
674 #define VMSTATE_PTIMER(_f, _s) \
675 VMSTATE_PTIMER_V(_f, _s, 0)
677 #define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \
678 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t)
680 #define VMSTATE_UINT16_ARRAY(_f, _s, _n) \
681 VMSTATE_UINT16_ARRAY_V(_f, _s, _n, 0)
683 #define VMSTATE_UINT8_ARRAY_V(_f, _s, _n, _v) \
684 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint8, uint8_t)
686 #define VMSTATE_UINT8_ARRAY(_f, _s, _n) \
687 VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0)
689 #define VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) \
690 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t)
692 #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
693 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
695 #define VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v) \
696 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint64, uint64_t)
698 #define VMSTATE_UINT64_ARRAY(_f, _s, _n) \
699 VMSTATE_UINT64_ARRAY_V(_f, _s, _n, 0)
701 #define VMSTATE_INT16_ARRAY_V(_f, _s, _n, _v) \
702 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int16, int16_t)
704 #define VMSTATE_INT16_ARRAY(_f, _s, _n) \
705 VMSTATE_INT16_ARRAY_V(_f, _s, _n, 0)
707 #define VMSTATE_INT32_ARRAY_V(_f, _s, _n, _v) \
708 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t)
710 #define VMSTATE_INT32_ARRAY(_f, _s, _n) \
711 VMSTATE_INT32_ARRAY_V(_f, _s, _n, 0)
713 #define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num) \
714 VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t)
716 #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
717 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
719 #define VMSTATE_BUFFER_V(_f, _s, _v) \
720 VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))
722 #define VMSTATE_BUFFER(_f, _s) \
723 VMSTATE_BUFFER_V(_f, _s, 0)
725 #define VMSTATE_PARTIAL_BUFFER(_f, _s, _size) \
726 VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, 0, _size)
728 #define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \
729 VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, _start, sizeof(typeof_field(_s, _f)))
731 #define VMSTATE_PARTIAL_VBUFFER(_f, _s, _size) \
732 VMSTATE_VBUFFER(_f, _s, 0, NULL, 0, _size)
734 #define VMSTATE_SUB_VBUFFER(_f, _s, _start, _size) \
735 VMSTATE_VBUFFER(_f, _s, 0, NULL, _start, _size)
737 #define VMSTATE_BUFFER_TEST(_f, _s, _test) \
738 VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f)))
740 #define VMSTATE_BUFFER_UNSAFE(_field, _state, _version, _size) \
741 VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, vmstate_info_buffer, _size)
743 #define VMSTATE_UNUSED_V(_v, _size) \
744 VMSTATE_UNUSED_BUFFER(NULL, _v, _size)
746 #define VMSTATE_UNUSED(_size) \
747 VMSTATE_UNUSED_V(0, _size)
749 #define VMSTATE_UNUSED_TEST(_test, _size) \
750 VMSTATE_UNUSED_BUFFER(_test, 0, _size)
753 #if TARGET_LONG_BITS == 64
754 #define VMSTATE_UINTTL_V(_f, _s, _v) \
755 VMSTATE_UINT64_V(_f, _s, _v)
756 #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v) \
757 VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v)
759 #define VMSTATE_UINTTL_V(_f, _s, _v) \
760 VMSTATE_UINT32_V(_f, _s, _v)
761 #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v) \
762 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v)
764 #define VMSTATE_UINTTL(_f, _s) \
765 VMSTATE_UINTTL_V(_f, _s, 0)
766 #define VMSTATE_UINTTL_ARRAY(_f, _s, _n) \
767 VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, 0)
771 #define VMSTATE_END_OF_LIST() \
774 extern int vmstate_load_state(QEMUFile
*f
, const VMStateDescription
*vmsd
,
775 void *opaque
, int version_id
);
776 extern void vmstate_save_state(QEMUFile
*f
, const VMStateDescription
*vmsd
,
778 extern int vmstate_register(DeviceState
*dev
, int instance_id
,
779 const VMStateDescription
*vmsd
, void *base
);
780 extern int vmstate_register_with_alias_id(DeviceState
*dev
,
782 const VMStateDescription
*vmsd
,
783 void *base
, int alias_id
,
784 int required_for_version
);
785 void vmstate_unregister(DeviceState
*dev
, const VMStateDescription
*vmsd
,