Qemu's internal TFTP server breaks lock-step-iness of TFTP
[qemu/aliguori-queue.git] / hw / hw.h
blob7b500f4e440525f4d2eb57d49bfbb2489161e1e1
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(Monitor *mon, QEMUFile *f, int stage,
248 void *opaque);
249 typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
251 int register_savevm(const char *idstr,
252 int instance_id,
253 int version_id,
254 SaveStateHandler *save_state,
255 LoadStateHandler *load_state,
256 void *opaque);
258 int register_savevm_live(const char *idstr,
259 int instance_id,
260 int version_id,
261 SaveSetParamsHandler *set_params,
262 SaveLiveStateHandler *save_live_state,
263 SaveStateHandler *save_state,
264 LoadStateHandler *load_state,
265 void *opaque);
267 void unregister_savevm(const char *idstr, void *opaque);
269 typedef void QEMUResetHandler(void *opaque);
271 void qemu_register_reset(QEMUResetHandler *func, void *opaque);
272 void qemu_unregister_reset(QEMUResetHandler *func, void *opaque);
274 /* handler to set the boot_device order for a specific type of QEMUMachine */
275 /* return 0 if success */
276 typedef int QEMUBootSetHandler(void *opaque, const char *boot_devices);
277 void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque);
278 int qemu_boot_set(const char *boot_devices);
280 typedef struct VMStateInfo VMStateInfo;
281 typedef struct VMStateDescription VMStateDescription;
283 struct VMStateInfo {
284 const char *name;
285 int (*get)(QEMUFile *f, void *pv, size_t size);
286 void (*put)(QEMUFile *f, void *pv, size_t size);
289 enum VMStateFlags {
290 VMS_SINGLE = 0x001,
291 VMS_POINTER = 0x002,
292 VMS_ARRAY = 0x004,
293 VMS_STRUCT = 0x008,
294 VMS_VARRAY_INT32 = 0x010, /* Array with size in int32_t field*/
295 VMS_BUFFER = 0x020, /* static sized buffer */
296 VMS_ARRAY_OF_POINTER = 0x040,
297 VMS_VARRAY_UINT16 = 0x080, /* Array with size in uint16_t field */
298 VMS_VBUFFER = 0x100, /* Buffer with size in int32_t field */
299 VMS_MULTIPLY = 0x200, /* multiply "size" field by field_size */
302 typedef struct {
303 const char *name;
304 size_t offset;
305 size_t size;
306 size_t start;
307 int num;
308 size_t num_offset;
309 size_t size_offset;
310 const VMStateInfo *info;
311 enum VMStateFlags flags;
312 const VMStateDescription *vmsd;
313 int version_id;
314 bool (*field_exists)(void *opaque, int version_id);
315 } VMStateField;
317 struct VMStateDescription {
318 const char *name;
319 int version_id;
320 int minimum_version_id;
321 int minimum_version_id_old;
322 LoadStateHandler *load_state_old;
323 int (*pre_load)(void *opaque);
324 int (*post_load)(void *opaque, int version_id);
325 void (*pre_save)(void *opaque);
326 void (*post_save)(void *opaque);
327 VMStateField *fields;
330 extern const VMStateInfo vmstate_info_int8;
331 extern const VMStateInfo vmstate_info_int16;
332 extern const VMStateInfo vmstate_info_int32;
333 extern const VMStateInfo vmstate_info_int64;
335 extern const VMStateInfo vmstate_info_uint8_equal;
336 extern const VMStateInfo vmstate_info_uint16_equal;
337 extern const VMStateInfo vmstate_info_int32_equal;
338 extern const VMStateInfo vmstate_info_int32_le;
340 extern const VMStateInfo vmstate_info_uint8;
341 extern const VMStateInfo vmstate_info_uint16;
342 extern const VMStateInfo vmstate_info_uint32;
343 extern const VMStateInfo vmstate_info_uint64;
345 extern const VMStateInfo vmstate_info_timer;
346 extern const VMStateInfo vmstate_info_ptimer;
347 extern const VMStateInfo vmstate_info_buffer;
348 extern const VMStateInfo vmstate_info_unused_buffer;
350 #define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0)
351 #define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0)
353 #define vmstate_offset_value(_state, _field, _type) \
354 (offsetof(_state, _field) + \
355 type_check(_type, typeof_field(_state, _field)))
357 #define vmstate_offset_pointer(_state, _field, _type) \
358 (offsetof(_state, _field) + \
359 type_check_pointer(_type, typeof_field(_state, _field)))
361 #define vmstate_offset_array(_state, _field, _type, _num) \
362 (offsetof(_state, _field) + \
363 type_check_array(_type, typeof_field(_state, _field), _num))
365 #define vmstate_offset_sub_array(_state, _field, _type, _start) \
366 (offsetof(_state, _field[_start]))
368 #define vmstate_offset_buffer(_state, _field) \
369 vmstate_offset_array(_state, _field, uint8_t, \
370 sizeof(typeof_field(_state, _field)))
372 #define VMSTATE_SINGLE_TEST(_field, _state, _test, _version, _info, _type) { \
373 .name = (stringify(_field)), \
374 .version_id = (_version), \
375 .field_exists = (_test), \
376 .size = sizeof(_type), \
377 .info = &(_info), \
378 .flags = VMS_SINGLE, \
379 .offset = vmstate_offset_value(_state, _field, _type), \
382 #define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \
383 .name = (stringify(_field)), \
384 .version_id = (_version), \
385 .info = &(_info), \
386 .size = sizeof(_type), \
387 .flags = VMS_SINGLE|VMS_POINTER, \
388 .offset = vmstate_offset_value(_state, _field, _type), \
391 #define VMSTATE_ARRAY(_field, _state, _num, _version, _info, _type) {\
392 .name = (stringify(_field)), \
393 .version_id = (_version), \
394 .num = (_num), \
395 .info = &(_info), \
396 .size = sizeof(_type), \
397 .flags = VMS_ARRAY, \
398 .offset = vmstate_offset_array(_state, _field, _type, _num), \
401 #define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\
402 .name = (stringify(_field)), \
403 .field_exists = (_test), \
404 .num = (_num), \
405 .info = &(_info), \
406 .size = sizeof(_type), \
407 .flags = VMS_ARRAY, \
408 .offset = vmstate_offset_array(_state, _field, _type, _num),\
411 #define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \
412 .name = (stringify(_field)), \
413 .version_id = (_version), \
414 .num = (_num), \
415 .info = &(_info), \
416 .size = sizeof(_type), \
417 .flags = VMS_ARRAY, \
418 .offset = vmstate_offset_sub_array(_state, _field, _type, _start), \
421 #define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, _type) {\
422 .name = (stringify(_field)), \
423 .version_id = (_version), \
424 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
425 .info = &(_info), \
426 .size = sizeof(_type), \
427 .flags = VMS_VARRAY_INT32|VMS_POINTER, \
428 .offset = vmstate_offset_pointer(_state, _field, _type), \
431 #define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version, _info, _type) {\
432 .name = (stringify(_field)), \
433 .version_id = (_version), \
434 .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\
435 .info = &(_info), \
436 .size = sizeof(_type), \
437 .flags = VMS_VARRAY_UINT16, \
438 .offset = offsetof(_state, _field), \
441 #define VMSTATE_STRUCT_TEST(_field, _state, _test, _version, _vmsd, _type) { \
442 .name = (stringify(_field)), \
443 .version_id = (_version), \
444 .field_exists = (_test), \
445 .vmsd = &(_vmsd), \
446 .size = sizeof(_type), \
447 .flags = VMS_STRUCT, \
448 .offset = vmstate_offset_value(_state, _field, _type), \
451 #define VMSTATE_STRUCT_POINTER_TEST(_field, _state, _test, _vmsd, _type) { \
452 .name = (stringify(_field)), \
453 .field_exists = (_test), \
454 .vmsd = &(_vmsd), \
455 .size = sizeof(_type), \
456 .flags = VMS_STRUCT|VMS_POINTER, \
457 .offset = vmstate_offset_value(_state, _field, _type), \
460 #define VMSTATE_ARRAY_OF_POINTER(_field, _state, _num, _version, _info, _type) {\
461 .name = (stringify(_field)), \
462 .version_id = (_version), \
463 .num = (_num), \
464 .info = &(_info), \
465 .size = sizeof(_type), \
466 .flags = VMS_ARRAY|VMS_ARRAY_OF_POINTER, \
467 .offset = vmstate_offset_array(_state, _field, _type, _num), \
470 #define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _version, _vmsd, _type) { \
471 .name = (stringify(_field)), \
472 .num = (_num), \
473 .version_id = (_version), \
474 .vmsd = &(_vmsd), \
475 .size = sizeof(_type), \
476 .flags = VMS_STRUCT|VMS_ARRAY, \
477 .offset = vmstate_offset_array(_state, _field, _type, _num), \
480 #define VMSTATE_STATIC_BUFFER(_field, _state, _version, _test, _start, _size) { \
481 .name = (stringify(_field)), \
482 .version_id = (_version), \
483 .field_exists = (_test), \
484 .size = (_size - _start), \
485 .info = &vmstate_info_buffer, \
486 .flags = VMS_BUFFER, \
487 .offset = vmstate_offset_buffer(_state, _field) + _start, \
490 #define VMSTATE_BUFFER_MULTIPLY(_field, _state, _version, _test, _start, _field_size, _multiply) { \
491 .name = (stringify(_field)), \
492 .version_id = (_version), \
493 .field_exists = (_test), \
494 .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\
495 .size = (_multiply), \
496 .info = &vmstate_info_buffer, \
497 .flags = VMS_VBUFFER|VMS_MULTIPLY, \
498 .offset = offsetof(_state, _field), \
499 .start = (_start), \
502 #define VMSTATE_VBUFFER(_field, _state, _version, _test, _start, _field_size) { \
503 .name = (stringify(_field)), \
504 .version_id = (_version), \
505 .field_exists = (_test), \
506 .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\
507 .info = &vmstate_info_buffer, \
508 .flags = VMS_VBUFFER|VMS_POINTER, \
509 .offset = offsetof(_state, _field), \
510 .start = (_start), \
513 #define VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, _info, _size) { \
514 .name = (stringify(_field)), \
515 .version_id = (_version), \
516 .size = (_size), \
517 .info = &(_info), \
518 .flags = VMS_BUFFER, \
519 .offset = offsetof(_state, _field), \
522 #define VMSTATE_UNUSED_BUFFER(_test, _version, _size) { \
523 .name = "unused", \
524 .field_exists = (_test), \
525 .version_id = (_version), \
526 .size = (_size), \
527 .info = &vmstate_info_unused_buffer, \
528 .flags = VMS_BUFFER, \
530 extern const VMStateDescription vmstate_pci_device;
532 #define VMSTATE_PCI_DEVICE(_field, _state) { \
533 .name = (stringify(_field)), \
534 .size = sizeof(PCIDevice), \
535 .vmsd = &vmstate_pci_device, \
536 .flags = VMS_STRUCT, \
537 .offset = vmstate_offset_value(_state, _field, PCIDevice), \
540 extern const VMStateDescription vmstate_pcie_device;
542 #define VMSTATE_PCIE_DEVICE(_field, _state) { \
543 .name = (stringify(_field)), \
544 .version_id = 2, \
545 .size = sizeof(PCIDevice), \
546 .vmsd = &vmstate_pcie_device, \
547 .flags = VMS_STRUCT, \
548 .offset = vmstate_offset_value(_state, _field, PCIDevice), \
551 extern const VMStateDescription vmstate_i2c_slave;
553 #define VMSTATE_I2C_SLAVE(_field, _state) { \
554 .name = (stringify(_field)), \
555 .size = sizeof(i2c_slave), \
556 .vmsd = &vmstate_i2c_slave, \
557 .flags = VMS_STRUCT, \
558 .offset = vmstate_offset_value(_state, _field, i2c_slave), \
561 #define vmstate_offset_macaddr(_state, _field) \
562 vmstate_offset_array(_state, _field.a, uint8_t, \
563 sizeof(typeof_field(_state, _field)))
565 #define VMSTATE_MACADDR(_field, _state) { \
566 .name = (stringify(_field)), \
567 .size = sizeof(MACAddr), \
568 .info = &vmstate_info_buffer, \
569 .flags = VMS_BUFFER, \
570 .offset = vmstate_offset_macaddr(_state, _field), \
573 /* _f : field name
574 _f_n : num of elements field_name
575 _n : num of elements
576 _s : struct state name
577 _v : version
580 #define VMSTATE_SINGLE(_field, _state, _version, _info, _type) \
581 VMSTATE_SINGLE_TEST(_field, _state, NULL, _version, _info, _type)
583 #define VMSTATE_STRUCT(_field, _state, _version, _vmsd, _type) \
584 VMSTATE_STRUCT_TEST(_field, _state, NULL, _version, _vmsd, _type)
586 #define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type) \
587 VMSTATE_STRUCT_POINTER_TEST(_field, _state, NULL, _vmsd, _type)
589 #define VMSTATE_INT8_V(_f, _s, _v) \
590 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t)
591 #define VMSTATE_INT16_V(_f, _s, _v) \
592 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int16, int16_t)
593 #define VMSTATE_INT32_V(_f, _s, _v) \
594 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int32, int32_t)
595 #define VMSTATE_INT64_V(_f, _s, _v) \
596 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int64, int64_t)
598 #define VMSTATE_UINT8_V(_f, _s, _v) \
599 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint8, uint8_t)
600 #define VMSTATE_UINT16_V(_f, _s, _v) \
601 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16, uint16_t)
602 #define VMSTATE_UINT32_V(_f, _s, _v) \
603 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32, uint32_t)
604 #define VMSTATE_UINT64_V(_f, _s, _v) \
605 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t)
607 #define VMSTATE_INT8(_f, _s) \
608 VMSTATE_INT8_V(_f, _s, 0)
609 #define VMSTATE_INT16(_f, _s) \
610 VMSTATE_INT16_V(_f, _s, 0)
611 #define VMSTATE_INT32(_f, _s) \
612 VMSTATE_INT32_V(_f, _s, 0)
613 #define VMSTATE_INT64(_f, _s) \
614 VMSTATE_INT64_V(_f, _s, 0)
616 #define VMSTATE_UINT8(_f, _s) \
617 VMSTATE_UINT8_V(_f, _s, 0)
618 #define VMSTATE_UINT16(_f, _s) \
619 VMSTATE_UINT16_V(_f, _s, 0)
620 #define VMSTATE_UINT32(_f, _s) \
621 VMSTATE_UINT32_V(_f, _s, 0)
622 #define VMSTATE_UINT64(_f, _s) \
623 VMSTATE_UINT64_V(_f, _s, 0)
625 #define VMSTATE_UINT8_EQUAL(_f, _s) \
626 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t)
628 #define VMSTATE_UINT16_EQUAL(_f, _s) \
629 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint16_equal, uint16_t)
631 #define VMSTATE_UINT16_EQUAL_V(_f, _s, _v) \
632 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16_equal, uint16_t)
634 #define VMSTATE_INT32_EQUAL(_f, _s) \
635 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t)
637 #define VMSTATE_INT32_LE(_f, _s) \
638 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)
640 #define VMSTATE_UINT16_TEST(_f, _s, _t) \
641 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint16, uint16_t)
643 #define VMSTATE_UINT32_TEST(_f, _s, _t) \
644 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t)
646 #define VMSTATE_TIMER_V(_f, _s, _v) \
647 VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *)
649 #define VMSTATE_TIMER(_f, _s) \
650 VMSTATE_TIMER_V(_f, _s, 0)
652 #define VMSTATE_TIMER_ARRAY(_f, _s, _n) \
653 VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *)
655 #define VMSTATE_PTIMER_V(_f, _s, _v) \
656 VMSTATE_POINTER(_f, _s, _v, vmstate_info_ptimer, ptimer_state *)
658 #define VMSTATE_PTIMER(_f, _s) \
659 VMSTATE_PTIMER_V(_f, _s, 0)
661 #define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \
662 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t)
664 #define VMSTATE_UINT16_ARRAY(_f, _s, _n) \
665 VMSTATE_UINT16_ARRAY_V(_f, _s, _n, 0)
667 #define VMSTATE_UINT8_ARRAY_V(_f, _s, _n, _v) \
668 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint8, uint8_t)
670 #define VMSTATE_UINT8_ARRAY(_f, _s, _n) \
671 VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0)
673 #define VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) \
674 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t)
676 #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
677 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
679 #define VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v) \
680 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint64, uint64_t)
682 #define VMSTATE_UINT64_ARRAY(_f, _s, _n) \
683 VMSTATE_UINT64_ARRAY_V(_f, _s, _n, 0)
685 #define VMSTATE_INT16_ARRAY_V(_f, _s, _n, _v) \
686 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int16, int16_t)
688 #define VMSTATE_INT16_ARRAY(_f, _s, _n) \
689 VMSTATE_INT16_ARRAY_V(_f, _s, _n, 0)
691 #define VMSTATE_INT32_ARRAY_V(_f, _s, _n, _v) \
692 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t)
694 #define VMSTATE_INT32_ARRAY(_f, _s, _n) \
695 VMSTATE_INT32_ARRAY_V(_f, _s, _n, 0)
697 #define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num) \
698 VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t)
700 #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
701 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
703 #define VMSTATE_BUFFER_V(_f, _s, _v) \
704 VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))
706 #define VMSTATE_BUFFER(_f, _s) \
707 VMSTATE_BUFFER_V(_f, _s, 0)
709 #define VMSTATE_PARTIAL_BUFFER(_f, _s, _size) \
710 VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, 0, _size)
712 #define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \
713 VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, _start, sizeof(typeof_field(_s, _f)))
715 #define VMSTATE_PARTIAL_VBUFFER(_f, _s, _size) \
716 VMSTATE_VBUFFER(_f, _s, 0, NULL, 0, _size)
718 #define VMSTATE_SUB_VBUFFER(_f, _s, _start, _size) \
719 VMSTATE_VBUFFER(_f, _s, 0, NULL, _start, _size)
721 #define VMSTATE_BUFFER_TEST(_f, _s, _test) \
722 VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f)))
724 #define VMSTATE_BUFFER_UNSAFE(_field, _state, _version, _size) \
725 VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, vmstate_info_buffer, _size)
727 #define VMSTATE_UNUSED_V(_v, _size) \
728 VMSTATE_UNUSED_BUFFER(NULL, _v, _size)
730 #define VMSTATE_UNUSED(_size) \
731 VMSTATE_UNUSED_V(0, _size)
733 #define VMSTATE_UNUSED_TEST(_test, _size) \
734 VMSTATE_UNUSED_BUFFER(_test, 0, _size)
736 #ifdef NEED_CPU_H
737 #if TARGET_LONG_BITS == 64
738 #define VMSTATE_UINTTL_V(_f, _s, _v) \
739 VMSTATE_UINT64_V(_f, _s, _v)
740 #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v) \
741 VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v)
742 #else
743 #define VMSTATE_UINTTL_V(_f, _s, _v) \
744 VMSTATE_UINT32_V(_f, _s, _v)
745 #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v) \
746 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v)
747 #endif
748 #define VMSTATE_UINTTL(_f, _s) \
749 VMSTATE_UINTTL_V(_f, _s, 0)
750 #define VMSTATE_UINTTL_ARRAY(_f, _s, _n) \
751 VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, 0)
753 #endif
755 #define VMSTATE_END_OF_LIST() \
758 extern int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
759 void *opaque, int version_id);
760 extern void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
761 void *opaque);
762 extern int vmstate_register(int instance_id, const VMStateDescription *vmsd,
763 void *base);
764 void vmstate_unregister(const VMStateDescription *vmsd, void *opaque);
765 #endif