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"
17 /* This function writes a chunk of data to a file at the given position.
18 * The pos argument can be ignored if the file is only being used for
19 * streaming. The handler should try to write all of the data it can.
21 typedef int (QEMUFilePutBufferFunc
)(void *opaque
, const uint8_t *buf
,
22 int64_t pos
, int size
);
24 /* Read a chunk of data from a file at the given position. The pos argument
25 * can be ignored if the file is only be used for streaming. The number of
26 * bytes actually read should be returned.
28 typedef int (QEMUFileGetBufferFunc
)(void *opaque
, uint8_t *buf
,
29 int64_t pos
, int size
);
31 /* Close a file and return an error code */
32 typedef int (QEMUFileCloseFunc
)(void *opaque
);
34 /* Called to determine if the file has exceeded it's bandwidth allocation. The
35 * bandwidth capping is a soft limit, not a hard limit.
37 typedef int (QEMUFileRateLimit
)(void *opaque
);
39 /* Called to change the current bandwidth allocation. This function must return
40 * the new actual bandwidth. It should be new_rate if everything goes ok, and
41 * the old rate otherwise
43 typedef size_t (QEMUFileSetRateLimit
)(void *opaque
, size_t new_rate
);
44 typedef size_t (QEMUFileGetRateLimit
)(void *opaque
);
46 QEMUFile
*qemu_fopen_ops(void *opaque
, QEMUFilePutBufferFunc
*put_buffer
,
47 QEMUFileGetBufferFunc
*get_buffer
,
48 QEMUFileCloseFunc
*close
,
49 QEMUFileRateLimit
*rate_limit
,
50 QEMUFileSetRateLimit
*set_rate_limit
,
51 QEMUFileGetRateLimit
*get_rate_limit
);
52 QEMUFile
*qemu_fopen(const char *filename
, const char *mode
);
53 QEMUFile
*qemu_fdopen(int fd
, const char *mode
);
54 QEMUFile
*qemu_fopen_socket(int fd
);
55 QEMUFile
*qemu_popen(FILE *popen_file
, const char *mode
);
56 QEMUFile
*qemu_popen_cmd(const char *command
, const char *mode
);
57 int qemu_stdio_fd(QEMUFile
*f
);
58 void qemu_fflush(QEMUFile
*f
);
59 int qemu_fclose(QEMUFile
*f
);
60 void qemu_put_buffer(QEMUFile
*f
, const uint8_t *buf
, int size
);
61 void qemu_put_byte(QEMUFile
*f
, int v
);
63 static inline void qemu_put_ubyte(QEMUFile
*f
, unsigned int v
)
65 qemu_put_byte(f
, (int)v
);
68 #define qemu_put_sbyte qemu_put_byte
70 void qemu_put_be16(QEMUFile
*f
, unsigned int v
);
71 void qemu_put_be32(QEMUFile
*f
, unsigned int v
);
72 void qemu_put_be64(QEMUFile
*f
, uint64_t v
);
73 int qemu_get_buffer(QEMUFile
*f
, uint8_t *buf
, int size
);
74 int qemu_get_byte(QEMUFile
*f
);
76 static inline unsigned int qemu_get_ubyte(QEMUFile
*f
)
78 return (unsigned int)qemu_get_byte(f
);
81 #define qemu_get_sbyte qemu_get_byte
83 unsigned int qemu_get_be16(QEMUFile
*f
);
84 unsigned int qemu_get_be32(QEMUFile
*f
);
85 uint64_t qemu_get_be64(QEMUFile
*f
);
86 int qemu_file_rate_limit(QEMUFile
*f
);
87 size_t qemu_file_set_rate_limit(QEMUFile
*f
, size_t new_rate
);
88 size_t qemu_file_get_rate_limit(QEMUFile
*f
);
89 int qemu_file_has_error(QEMUFile
*f
);
90 void qemu_file_set_error(QEMUFile
*f
);
92 /* Try to send any outstanding data. This function is useful when output is
93 * halted due to rate limiting or EAGAIN errors occur as it can be used to
95 void qemu_file_put_notify(QEMUFile
*f
);
97 static inline void qemu_put_be64s(QEMUFile
*f
, const uint64_t *pv
)
99 qemu_put_be64(f
, *pv
);
102 static inline void qemu_put_be32s(QEMUFile
*f
, const uint32_t *pv
)
104 qemu_put_be32(f
, *pv
);
107 static inline void qemu_put_be16s(QEMUFile
*f
, const uint16_t *pv
)
109 qemu_put_be16(f
, *pv
);
112 static inline void qemu_put_8s(QEMUFile
*f
, const uint8_t *pv
)
114 qemu_put_byte(f
, *pv
);
117 static inline void qemu_get_be64s(QEMUFile
*f
, uint64_t *pv
)
119 *pv
= qemu_get_be64(f
);
122 static inline void qemu_get_be32s(QEMUFile
*f
, uint32_t *pv
)
124 *pv
= qemu_get_be32(f
);
127 static inline void qemu_get_be16s(QEMUFile
*f
, uint16_t *pv
)
129 *pv
= qemu_get_be16(f
);
132 static inline void qemu_get_8s(QEMUFile
*f
, uint8_t *pv
)
134 *pv
= qemu_get_byte(f
);
137 // Signed versions for type safety
138 static inline void qemu_put_sbuffer(QEMUFile
*f
, const int8_t *buf
, int size
)
140 qemu_put_buffer(f
, (const uint8_t *)buf
, size
);
143 static inline void qemu_put_sbe16(QEMUFile
*f
, int v
)
145 qemu_put_be16(f
, (unsigned int)v
);
148 static inline void qemu_put_sbe32(QEMUFile
*f
, int v
)
150 qemu_put_be32(f
, (unsigned int)v
);
153 static inline void qemu_put_sbe64(QEMUFile
*f
, int64_t v
)
155 qemu_put_be64(f
, (uint64_t)v
);
158 static inline size_t qemu_get_sbuffer(QEMUFile
*f
, int8_t *buf
, int size
)
160 return qemu_get_buffer(f
, (uint8_t *)buf
, size
);
163 static inline int qemu_get_sbe16(QEMUFile
*f
)
165 return (int)qemu_get_be16(f
);
168 static inline int qemu_get_sbe32(QEMUFile
*f
)
170 return (int)qemu_get_be32(f
);
173 static inline int64_t qemu_get_sbe64(QEMUFile
*f
)
175 return (int64_t)qemu_get_be64(f
);
178 static inline void qemu_put_s8s(QEMUFile
*f
, const int8_t *pv
)
180 qemu_put_8s(f
, (const uint8_t *)pv
);
183 static inline void qemu_put_sbe16s(QEMUFile
*f
, const int16_t *pv
)
185 qemu_put_be16s(f
, (const uint16_t *)pv
);
188 static inline void qemu_put_sbe32s(QEMUFile
*f
, const int32_t *pv
)
190 qemu_put_be32s(f
, (const uint32_t *)pv
);
193 static inline void qemu_put_sbe64s(QEMUFile
*f
, const int64_t *pv
)
195 qemu_put_be64s(f
, (const uint64_t *)pv
);
198 static inline void qemu_get_s8s(QEMUFile
*f
, int8_t *pv
)
200 qemu_get_8s(f
, (uint8_t *)pv
);
203 static inline void qemu_get_sbe16s(QEMUFile
*f
, int16_t *pv
)
205 qemu_get_be16s(f
, (uint16_t *)pv
);
208 static inline void qemu_get_sbe32s(QEMUFile
*f
, int32_t *pv
)
210 qemu_get_be32s(f
, (uint32_t *)pv
);
213 static inline void qemu_get_sbe64s(QEMUFile
*f
, int64_t *pv
)
215 qemu_get_be64s(f
, (uint64_t *)pv
);
219 #if TARGET_LONG_BITS == 64
220 #define qemu_put_betl qemu_put_be64
221 #define qemu_get_betl qemu_get_be64
222 #define qemu_put_betls qemu_put_be64s
223 #define qemu_get_betls qemu_get_be64s
224 #define qemu_put_sbetl qemu_put_sbe64
225 #define qemu_get_sbetl qemu_get_sbe64
226 #define qemu_put_sbetls qemu_put_sbe64s
227 #define qemu_get_sbetls qemu_get_sbe64s
229 #define qemu_put_betl qemu_put_be32
230 #define qemu_get_betl qemu_get_be32
231 #define qemu_put_betls qemu_put_be32s
232 #define qemu_get_betls qemu_get_be32s
233 #define qemu_put_sbetl qemu_put_sbe32
234 #define qemu_get_sbetl qemu_get_sbe32
235 #define qemu_put_sbetls qemu_put_sbe32s
236 #define qemu_get_sbetls qemu_get_sbe32s
240 int64_t qemu_ftell(QEMUFile
*f
);
241 int64_t qemu_fseek(QEMUFile
*f
, int64_t pos
, int whence
);
243 typedef void SaveSetParamsHandler(int blk_enable
, int shared
, void * opaque
);
244 typedef void SaveStateHandler(QEMUFile
*f
, void *opaque
);
245 typedef int SaveLiveStateHandler(Monitor
*mon
, QEMUFile
*f
, int stage
,
247 typedef int LoadStateHandler(QEMUFile
*f
, void *opaque
, int version_id
);
249 int register_savevm(const char *idstr
,
252 SaveStateHandler
*save_state
,
253 LoadStateHandler
*load_state
,
256 int register_savevm_live(const char *idstr
,
259 SaveSetParamsHandler
*set_params
,
260 SaveLiveStateHandler
*save_live_state
,
261 SaveStateHandler
*save_state
,
262 LoadStateHandler
*load_state
,
265 void unregister_savevm(const char *idstr
, void *opaque
);
267 typedef void QEMUResetHandler(void *opaque
);
269 void qemu_register_reset(QEMUResetHandler
*func
, void *opaque
);
270 void qemu_unregister_reset(QEMUResetHandler
*func
, void *opaque
);
272 /* handler to set the boot_device order for a specific type of QEMUMachine */
273 /* return 0 if success */
274 typedef int QEMUBootSetHandler(void *opaque
, const char *boot_devices
);
275 void qemu_register_boot_set(QEMUBootSetHandler
*func
, void *opaque
);
276 int qemu_boot_set(const char *boot_devices
);
278 typedef struct VMStateInfo VMStateInfo
;
279 typedef struct VMStateDescription VMStateDescription
;
283 int (*get
)(QEMUFile
*f
, void *pv
, size_t size
);
284 void (*put
)(QEMUFile
*f
, void *pv
, size_t size
);
292 VMS_VARRAY_INT32
= 0x010, /* Array with size in int32_t field*/
293 VMS_BUFFER
= 0x020, /* static sized buffer */
294 VMS_ARRAY_OF_POINTER
= 0x040,
295 VMS_VARRAY_UINT16
= 0x080, /* Array with size in uint16_t field */
296 VMS_VBUFFER
= 0x100, /* Buffer with size in int32_t field */
297 VMS_MULTIPLY
= 0x200, /* multiply "size" field by field_size */
308 const VMStateInfo
*info
;
309 enum VMStateFlags flags
;
310 const VMStateDescription
*vmsd
;
312 bool (*field_exists
)(void *opaque
, int version_id
);
315 struct VMStateDescription
{
318 int minimum_version_id
;
319 int minimum_version_id_old
;
320 LoadStateHandler
*load_state_old
;
321 int (*pre_load
)(void *opaque
);
322 int (*post_load
)(void *opaque
, int version_id
);
323 void (*pre_save
)(void *opaque
);
324 void (*post_save
)(void *opaque
);
325 VMStateField
*fields
;
328 extern const VMStateInfo vmstate_info_int8
;
329 extern const VMStateInfo vmstate_info_int16
;
330 extern const VMStateInfo vmstate_info_int32
;
331 extern const VMStateInfo vmstate_info_int64
;
333 extern const VMStateInfo vmstate_info_uint8_equal
;
334 extern const VMStateInfo vmstate_info_uint16_equal
;
335 extern const VMStateInfo vmstate_info_int32_equal
;
336 extern const VMStateInfo vmstate_info_int32_le
;
338 extern const VMStateInfo vmstate_info_uint8
;
339 extern const VMStateInfo vmstate_info_uint16
;
340 extern const VMStateInfo vmstate_info_uint32
;
341 extern const VMStateInfo vmstate_info_uint64
;
343 extern const VMStateInfo vmstate_info_timer
;
344 extern const VMStateInfo vmstate_info_ptimer
;
345 extern const VMStateInfo vmstate_info_buffer
;
346 extern const VMStateInfo vmstate_info_unused_buffer
;
348 #define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0)
349 #define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0)
351 #define vmstate_offset_value(_state, _field, _type) \
352 (offsetof(_state, _field) + \
353 type_check(_type, typeof_field(_state, _field)))
355 #define vmstate_offset_pointer(_state, _field, _type) \
356 (offsetof(_state, _field) + \
357 type_check_pointer(_type, typeof_field(_state, _field)))
359 #define vmstate_offset_array(_state, _field, _type, _num) \
360 (offsetof(_state, _field) + \
361 type_check_array(_type, typeof_field(_state, _field), _num))
363 #define vmstate_offset_sub_array(_state, _field, _type, _start) \
364 (offsetof(_state, _field[_start]))
366 #define vmstate_offset_buffer(_state, _field) \
367 vmstate_offset_array(_state, _field, uint8_t, \
368 sizeof(typeof_field(_state, _field)))
370 #define VMSTATE_SINGLE_TEST(_field, _state, _test, _version, _info, _type) { \
371 .name = (stringify(_field)), \
372 .version_id = (_version), \
373 .field_exists = (_test), \
374 .size = sizeof(_type), \
376 .flags = VMS_SINGLE, \
377 .offset = vmstate_offset_value(_state, _field, _type), \
380 #define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \
381 .name = (stringify(_field)), \
382 .version_id = (_version), \
384 .size = sizeof(_type), \
385 .flags = VMS_SINGLE|VMS_POINTER, \
386 .offset = vmstate_offset_value(_state, _field, _type), \
389 #define VMSTATE_ARRAY(_field, _state, _num, _version, _info, _type) {\
390 .name = (stringify(_field)), \
391 .version_id = (_version), \
394 .size = sizeof(_type), \
395 .flags = VMS_ARRAY, \
396 .offset = vmstate_offset_array(_state, _field, _type, _num), \
399 #define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\
400 .name = (stringify(_field)), \
401 .field_exists = (_test), \
404 .size = sizeof(_type), \
405 .flags = VMS_ARRAY, \
406 .offset = vmstate_offset_array(_state, _field, _type, _num),\
409 #define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \
410 .name = (stringify(_field)), \
411 .version_id = (_version), \
414 .size = sizeof(_type), \
415 .flags = VMS_ARRAY, \
416 .offset = vmstate_offset_sub_array(_state, _field, _type, _start), \
419 #define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, _type) {\
420 .name = (stringify(_field)), \
421 .version_id = (_version), \
422 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
424 .size = sizeof(_type), \
425 .flags = VMS_VARRAY_INT32|VMS_POINTER, \
426 .offset = vmstate_offset_pointer(_state, _field, _type), \
429 #define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version, _info, _type) {\
430 .name = (stringify(_field)), \
431 .version_id = (_version), \
432 .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\
434 .size = sizeof(_type), \
435 .flags = VMS_VARRAY_UINT16, \
436 .offset = offsetof(_state, _field), \
439 #define VMSTATE_STRUCT_TEST(_field, _state, _test, _version, _vmsd, _type) { \
440 .name = (stringify(_field)), \
441 .version_id = (_version), \
442 .field_exists = (_test), \
444 .size = sizeof(_type), \
445 .flags = VMS_STRUCT, \
446 .offset = vmstate_offset_value(_state, _field, _type), \
449 #define VMSTATE_STRUCT_POINTER_TEST(_field, _state, _test, _vmsd, _type) { \
450 .name = (stringify(_field)), \
451 .field_exists = (_test), \
453 .size = sizeof(_type), \
454 .flags = VMS_STRUCT|VMS_POINTER, \
455 .offset = vmstate_offset_value(_state, _field, _type), \
458 #define VMSTATE_ARRAY_OF_POINTER(_field, _state, _num, _version, _info, _type) {\
459 .name = (stringify(_field)), \
460 .version_id = (_version), \
463 .size = sizeof(_type), \
464 .flags = VMS_ARRAY|VMS_ARRAY_OF_POINTER, \
465 .offset = vmstate_offset_array(_state, _field, _type, _num), \
468 #define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _version, _vmsd, _type) { \
469 .name = (stringify(_field)), \
471 .version_id = (_version), \
473 .size = sizeof(_type), \
474 .flags = VMS_STRUCT|VMS_ARRAY, \
475 .offset = vmstate_offset_array(_state, _field, _type, _num), \
478 #define VMSTATE_STATIC_BUFFER(_field, _state, _version, _test, _start, _size) { \
479 .name = (stringify(_field)), \
480 .version_id = (_version), \
481 .field_exists = (_test), \
482 .size = (_size - _start), \
483 .info = &vmstate_info_buffer, \
484 .flags = VMS_BUFFER, \
485 .offset = vmstate_offset_buffer(_state, _field) + _start, \
488 #define VMSTATE_BUFFER_MULTIPLY(_field, _state, _version, _test, _start, _field_size, _multiply) { \
489 .name = (stringify(_field)), \
490 .version_id = (_version), \
491 .field_exists = (_test), \
492 .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\
493 .size = (_multiply), \
494 .info = &vmstate_info_buffer, \
495 .flags = VMS_VBUFFER|VMS_MULTIPLY, \
496 .offset = offsetof(_state, _field), \
500 #define VMSTATE_VBUFFER(_field, _state, _version, _test, _start, _field_size) { \
501 .name = (stringify(_field)), \
502 .version_id = (_version), \
503 .field_exists = (_test), \
504 .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\
505 .info = &vmstate_info_buffer, \
506 .flags = VMS_VBUFFER|VMS_POINTER, \
507 .offset = offsetof(_state, _field), \
511 #define VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, _info, _size) { \
512 .name = (stringify(_field)), \
513 .version_id = (_version), \
516 .flags = VMS_BUFFER, \
517 .offset = offsetof(_state, _field), \
520 #define VMSTATE_UNUSED_BUFFER(_test, _version, _size) { \
522 .field_exists = (_test), \
523 .version_id = (_version), \
525 .info = &vmstate_info_unused_buffer, \
526 .flags = VMS_BUFFER, \
528 extern const VMStateDescription vmstate_pci_device
;
530 #define VMSTATE_PCI_DEVICE(_field, _state) { \
531 .name = (stringify(_field)), \
532 .size = sizeof(PCIDevice), \
533 .vmsd = &vmstate_pci_device, \
534 .flags = VMS_STRUCT, \
535 .offset = vmstate_offset_value(_state, _field, PCIDevice), \
538 extern const VMStateDescription vmstate_pcie_device
;
540 #define VMSTATE_PCIE_DEVICE(_field, _state) { \
541 .name = (stringify(_field)), \
543 .size = sizeof(PCIDevice), \
544 .vmsd = &vmstate_pcie_device, \
545 .flags = VMS_STRUCT, \
546 .offset = vmstate_offset_value(_state, _field, PCIDevice), \
549 extern const VMStateDescription vmstate_i2c_slave
;
551 #define VMSTATE_I2C_SLAVE(_field, _state) { \
552 .name = (stringify(_field)), \
553 .size = sizeof(i2c_slave), \
554 .vmsd = &vmstate_i2c_slave, \
555 .flags = VMS_STRUCT, \
556 .offset = vmstate_offset_value(_state, _field, i2c_slave), \
559 #define vmstate_offset_macaddr(_state, _field) \
560 vmstate_offset_array(_state, _field.a, uint8_t, \
561 sizeof(typeof_field(_state, _field)))
563 #define VMSTATE_MACADDR(_field, _state) { \
564 .name = (stringify(_field)), \
565 .size = sizeof(MACAddr), \
566 .info = &vmstate_info_buffer, \
567 .flags = VMS_BUFFER, \
568 .offset = vmstate_offset_macaddr(_state, _field), \
572 _f_n : num of elements field_name
574 _s : struct state name
578 #define VMSTATE_SINGLE(_field, _state, _version, _info, _type) \
579 VMSTATE_SINGLE_TEST(_field, _state, NULL, _version, _info, _type)
581 #define VMSTATE_STRUCT(_field, _state, _version, _vmsd, _type) \
582 VMSTATE_STRUCT_TEST(_field, _state, NULL, _version, _vmsd, _type)
584 #define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type) \
585 VMSTATE_STRUCT_POINTER_TEST(_field, _state, NULL, _vmsd, _type)
587 #define VMSTATE_INT8_V(_f, _s, _v) \
588 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t)
589 #define VMSTATE_INT16_V(_f, _s, _v) \
590 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int16, int16_t)
591 #define VMSTATE_INT32_V(_f, _s, _v) \
592 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int32, int32_t)
593 #define VMSTATE_INT64_V(_f, _s, _v) \
594 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int64, int64_t)
596 #define VMSTATE_UINT8_V(_f, _s, _v) \
597 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint8, uint8_t)
598 #define VMSTATE_UINT16_V(_f, _s, _v) \
599 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16, uint16_t)
600 #define VMSTATE_UINT32_V(_f, _s, _v) \
601 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32, uint32_t)
602 #define VMSTATE_UINT64_V(_f, _s, _v) \
603 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t)
605 #define VMSTATE_INT8(_f, _s) \
606 VMSTATE_INT8_V(_f, _s, 0)
607 #define VMSTATE_INT16(_f, _s) \
608 VMSTATE_INT16_V(_f, _s, 0)
609 #define VMSTATE_INT32(_f, _s) \
610 VMSTATE_INT32_V(_f, _s, 0)
611 #define VMSTATE_INT64(_f, _s) \
612 VMSTATE_INT64_V(_f, _s, 0)
614 #define VMSTATE_UINT8(_f, _s) \
615 VMSTATE_UINT8_V(_f, _s, 0)
616 #define VMSTATE_UINT16(_f, _s) \
617 VMSTATE_UINT16_V(_f, _s, 0)
618 #define VMSTATE_UINT32(_f, _s) \
619 VMSTATE_UINT32_V(_f, _s, 0)
620 #define VMSTATE_UINT64(_f, _s) \
621 VMSTATE_UINT64_V(_f, _s, 0)
623 #define VMSTATE_UINT8_EQUAL(_f, _s) \
624 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t)
626 #define VMSTATE_UINT16_EQUAL(_f, _s) \
627 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint16_equal, uint16_t)
629 #define VMSTATE_UINT16_EQUAL_V(_f, _s, _v) \
630 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16_equal, uint16_t)
632 #define VMSTATE_INT32_EQUAL(_f, _s) \
633 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t)
635 #define VMSTATE_INT32_LE(_f, _s) \
636 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)
638 #define VMSTATE_UINT16_TEST(_f, _s, _t) \
639 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint16, uint16_t)
641 #define VMSTATE_UINT32_TEST(_f, _s, _t) \
642 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t)
644 #define VMSTATE_TIMER_V(_f, _s, _v) \
645 VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *)
647 #define VMSTATE_TIMER(_f, _s) \
648 VMSTATE_TIMER_V(_f, _s, 0)
650 #define VMSTATE_TIMER_ARRAY(_f, _s, _n) \
651 VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *)
653 #define VMSTATE_PTIMER_V(_f, _s, _v) \
654 VMSTATE_POINTER(_f, _s, _v, vmstate_info_ptimer, ptimer_state *)
656 #define VMSTATE_PTIMER(_f, _s) \
657 VMSTATE_PTIMER_V(_f, _s, 0)
659 #define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \
660 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t)
662 #define VMSTATE_UINT16_ARRAY(_f, _s, _n) \
663 VMSTATE_UINT16_ARRAY_V(_f, _s, _n, 0)
665 #define VMSTATE_UINT8_ARRAY_V(_f, _s, _n, _v) \
666 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint8, uint8_t)
668 #define VMSTATE_UINT8_ARRAY(_f, _s, _n) \
669 VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0)
671 #define VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) \
672 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t)
674 #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
675 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
677 #define VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v) \
678 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint64, uint64_t)
680 #define VMSTATE_UINT64_ARRAY(_f, _s, _n) \
681 VMSTATE_UINT64_ARRAY_V(_f, _s, _n, 0)
683 #define VMSTATE_INT16_ARRAY_V(_f, _s, _n, _v) \
684 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int16, int16_t)
686 #define VMSTATE_INT16_ARRAY(_f, _s, _n) \
687 VMSTATE_INT16_ARRAY_V(_f, _s, _n, 0)
689 #define VMSTATE_INT32_ARRAY_V(_f, _s, _n, _v) \
690 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t)
692 #define VMSTATE_INT32_ARRAY(_f, _s, _n) \
693 VMSTATE_INT32_ARRAY_V(_f, _s, _n, 0)
695 #define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num) \
696 VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t)
698 #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
699 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
701 #define VMSTATE_BUFFER_V(_f, _s, _v) \
702 VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))
704 #define VMSTATE_BUFFER(_f, _s) \
705 VMSTATE_BUFFER_V(_f, _s, 0)
707 #define VMSTATE_PARTIAL_BUFFER(_f, _s, _size) \
708 VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, 0, _size)
710 #define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \
711 VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, _start, sizeof(typeof_field(_s, _f)))
713 #define VMSTATE_PARTIAL_VBUFFER(_f, _s, _size) \
714 VMSTATE_VBUFFER(_f, _s, 0, NULL, 0, _size)
716 #define VMSTATE_SUB_VBUFFER(_f, _s, _start, _size) \
717 VMSTATE_VBUFFER(_f, _s, 0, NULL, _start, _size)
719 #define VMSTATE_BUFFER_TEST(_f, _s, _test) \
720 VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f)))
722 #define VMSTATE_BUFFER_UNSAFE(_field, _state, _version, _size) \
723 VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, vmstate_info_buffer, _size)
725 #define VMSTATE_UNUSED_V(_v, _size) \
726 VMSTATE_UNUSED_BUFFER(NULL, _v, _size)
728 #define VMSTATE_UNUSED(_size) \
729 VMSTATE_UNUSED_V(0, _size)
731 #define VMSTATE_UNUSED_TEST(_test, _size) \
732 VMSTATE_UNUSED_BUFFER(_test, 0, _size)
735 #if TARGET_LONG_BITS == 64
736 #define VMSTATE_UINTTL_V(_f, _s, _v) \
737 VMSTATE_UINT64_V(_f, _s, _v)
738 #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v) \
739 VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v)
741 #define VMSTATE_UINTTL_V(_f, _s, _v) \
742 VMSTATE_UINT32_V(_f, _s, _v)
743 #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v) \
744 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v)
746 #define VMSTATE_UINTTL(_f, _s) \
747 VMSTATE_UINTTL_V(_f, _s, 0)
748 #define VMSTATE_UINTTL_ARRAY(_f, _s, _n) \
749 VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, 0)
753 #define VMSTATE_END_OF_LIST() \
756 extern int vmstate_load_state(QEMUFile
*f
, const VMStateDescription
*vmsd
,
757 void *opaque
, int version_id
);
758 extern void vmstate_save_state(QEMUFile
*f
, const VMStateDescription
*vmsd
,
760 extern int vmstate_register(int instance_id
, const VMStateDescription
*vmsd
,
762 void vmstate_unregister(const VMStateDescription
*vmsd
, void *opaque
);