really fix net.h
[qemu.git] / hw / hw.h
blobeb5c639250d0e7b740f5beee7ade1e3bb014556d
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);
47 QEMUFile *qemu_fopen_ops(void *opaque, QEMUFilePutBufferFunc *put_buffer,
48 QEMUFileGetBufferFunc *get_buffer,
49 QEMUFileCloseFunc *close,
50 QEMUFileRateLimit *rate_limit,
51 QEMUFileSetRateLimit *set_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 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
93 * resume output. */
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);
217 #ifdef NEED_CPU_H
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
227 #else
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
236 #endif
237 #endif
239 int64_t qemu_ftell(QEMUFile *f);
240 int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence);
242 typedef void SaveStateHandler(QEMUFile *f, void *opaque);
243 typedef int SaveLiveStateHandler(QEMUFile *f, int stage, void *opaque);
244 typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
246 int register_savevm(const char *idstr,
247 int instance_id,
248 int version_id,
249 SaveStateHandler *save_state,
250 LoadStateHandler *load_state,
251 void *opaque);
253 int register_savevm_live(const char *idstr,
254 int instance_id,
255 int version_id,
256 SaveLiveStateHandler *save_live_state,
257 SaveStateHandler *save_state,
258 LoadStateHandler *load_state,
259 void *opaque);
261 void unregister_savevm(const char *idstr, void *opaque);
263 typedef void QEMUResetHandler(void *opaque);
265 void qemu_register_reset(QEMUResetHandler *func, void *opaque);
266 void qemu_unregister_reset(QEMUResetHandler *func, void *opaque);
268 /* handler to set the boot_device order for a specific type of QEMUMachine */
269 /* return 0 if success */
270 typedef int QEMUBootSetHandler(void *opaque, const char *boot_devices);
271 void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque);
272 int qemu_boot_set(const char *boot_devices);
274 typedef struct VMStateInfo VMStateInfo;
275 typedef struct VMStateDescription VMStateDescription;
277 struct VMStateInfo {
278 const char *name;
279 int (*get)(QEMUFile *f, void *pv, size_t size);
280 void (*put)(QEMUFile *f, void *pv, size_t size);
283 enum VMStateFlags {
284 VMS_SINGLE = 0x001,
285 VMS_POINTER = 0x002,
286 VMS_ARRAY = 0x004,
287 VMS_STRUCT = 0x008,
288 VMS_VARRAY_INT32 = 0x010, /* Array with size in int32_t field*/
289 VMS_BUFFER = 0x020, /* static sized buffer */
290 VMS_ARRAY_OF_POINTER = 0x040,
291 VMS_VARRAY_UINT16 = 0x080, /* Array with size in uint16_t field */
294 typedef struct {
295 const char *name;
296 size_t offset;
297 size_t size;
298 int num;
299 size_t num_offset;
300 const VMStateInfo *info;
301 enum VMStateFlags flags;
302 const VMStateDescription *vmsd;
303 int version_id;
304 bool (*field_exists)(void *opaque, int version_id);
305 } VMStateField;
307 struct VMStateDescription {
308 const char *name;
309 int version_id;
310 int minimum_version_id;
311 int minimum_version_id_old;
312 LoadStateHandler *load_state_old;
313 int (*pre_load)(void *opaque);
314 int (*post_load)(void *opaque, int version_id);
315 void (*pre_save)(void *opaque);
316 void (*post_save)(void *opaque);
317 VMStateField *fields;
320 extern const VMStateInfo vmstate_info_int8;
321 extern const VMStateInfo vmstate_info_int16;
322 extern const VMStateInfo vmstate_info_int32;
323 extern const VMStateInfo vmstate_info_int64;
325 extern const VMStateInfo vmstate_info_uint8_equal;
326 extern const VMStateInfo vmstate_info_uint16_equal;
327 extern const VMStateInfo vmstate_info_int32_equal;
328 extern const VMStateInfo vmstate_info_int32_le;
330 extern const VMStateInfo vmstate_info_uint8;
331 extern const VMStateInfo vmstate_info_uint16;
332 extern const VMStateInfo vmstate_info_uint32;
333 extern const VMStateInfo vmstate_info_uint64;
335 extern const VMStateInfo vmstate_info_timer;
336 extern const VMStateInfo vmstate_info_ptimer;
337 extern const VMStateInfo vmstate_info_buffer;
338 extern const VMStateInfo vmstate_info_unused_buffer;
340 #define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0)
341 #define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0)
343 #define vmstate_offset_value(_state, _field, _type) \
344 (offsetof(_state, _field) + \
345 type_check(_type, typeof_field(_state, _field)))
347 #define vmstate_offset_pointer(_state, _field, _type) \
348 (offsetof(_state, _field) + \
349 type_check_pointer(_type, typeof_field(_state, _field)))
351 #define vmstate_offset_array(_state, _field, _type, _num) \
352 (offsetof(_state, _field) + \
353 type_check_array(_type, typeof_field(_state, _field), _num))
355 #define vmstate_offset_sub_array(_state, _field, _type, _start) \
356 (offsetof(_state, _field[_start]))
358 #define vmstate_offset_buffer(_state, _field) \
359 vmstate_offset_array(_state, _field, uint8_t, \
360 sizeof(typeof_field(_state, _field)))
362 #define VMSTATE_SINGLE_TEST(_field, _state, _test, _version, _info, _type) { \
363 .name = (stringify(_field)), \
364 .version_id = (_version), \
365 .field_exists = (_test), \
366 .size = sizeof(_type), \
367 .info = &(_info), \
368 .flags = VMS_SINGLE, \
369 .offset = vmstate_offset_value(_state, _field, _type), \
372 #define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \
373 .name = (stringify(_field)), \
374 .version_id = (_version), \
375 .info = &(_info), \
376 .size = sizeof(_type), \
377 .flags = VMS_SINGLE|VMS_POINTER, \
378 .offset = vmstate_offset_value(_state, _field, _type), \
381 #define VMSTATE_ARRAY(_field, _state, _num, _version, _info, _type) {\
382 .name = (stringify(_field)), \
383 .version_id = (_version), \
384 .num = (_num), \
385 .info = &(_info), \
386 .size = sizeof(_type), \
387 .flags = VMS_ARRAY, \
388 .offset = vmstate_offset_array(_state, _field, _type, _num), \
391 #define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\
392 .name = (stringify(_field)), \
393 .field_exists = (_test), \
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_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \
402 .name = (stringify(_field)), \
403 .version_id = (_version), \
404 .num = (_num), \
405 .info = &(_info), \
406 .size = sizeof(_type), \
407 .flags = VMS_ARRAY, \
408 .offset = vmstate_offset_sub_array(_state, _field, _type, _start), \
411 #define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, _type) {\
412 .name = (stringify(_field)), \
413 .version_id = (_version), \
414 .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
415 .info = &(_info), \
416 .size = sizeof(_type), \
417 .flags = VMS_VARRAY_INT32|VMS_POINTER, \
418 .offset = vmstate_offset_pointer(_state, _field, _type), \
421 #define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version, _info, _type) {\
422 .name = (stringify(_field)), \
423 .version_id = (_version), \
424 .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\
425 .info = &(_info), \
426 .size = sizeof(_type), \
427 .flags = VMS_VARRAY_UINT16, \
428 .offset = offsetof(_state, _field), \
431 #define VMSTATE_STRUCT(_field, _state, _version, _vmsd, _type) { \
432 .name = (stringify(_field)), \
433 .version_id = (_version), \
434 .vmsd = &(_vmsd), \
435 .size = sizeof(_type), \
436 .flags = VMS_STRUCT, \
437 .offset = vmstate_offset_value(_state, _field, _type), \
440 #define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type) { \
441 .name = (stringify(_field)), \
442 .vmsd = &(_vmsd), \
443 .size = sizeof(_type), \
444 .flags = VMS_STRUCT|VMS_POINTER, \
445 .offset = vmstate_offset_value(_state, _field, _type), \
448 #define VMSTATE_ARRAY_OF_POINTER(_field, _state, _num, _version, _info, _type) {\
449 .name = (stringify(_field)), \
450 .version_id = (_version), \
451 .num = (_num), \
452 .info = &(_info), \
453 .size = sizeof(_type), \
454 .flags = VMS_ARRAY|VMS_ARRAY_OF_POINTER, \
455 .offset = vmstate_offset_array(_state, _field, _type, _num), \
458 #define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _version, _vmsd, _type) { \
459 .name = (stringify(_field)), \
460 .num = (_num), \
461 .version_id = (_version), \
462 .vmsd = &(_vmsd), \
463 .size = sizeof(_type), \
464 .flags = VMS_STRUCT|VMS_ARRAY, \
465 .offset = vmstate_offset_array(_state, _field, _type, _num), \
468 #define VMSTATE_STRUCT_ARRAY_SIZE_UINT8(_field, _state, _field__num, _version, _vmsd, _type) { \
469 .name = (stringify(_field)), \
470 .num_offset = vmstate_offset_value(_state, _field_num, uint8_t), \
471 .version_id = (_version), \
472 .vmsd = &(_vmsd), \
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_UNSAFE(_field, _state, _version, _size) { \
489 .name = (stringify(_field)), \
490 .version_id = (_version), \
491 .size = (_size), \
492 .info = &vmstate_info_buffer, \
493 .flags = VMS_BUFFER, \
494 .offset = offsetof(_state, _field), \
497 #define VMSTATE_UNUSED_BUFFER(_test, _version, _size) { \
498 .name = "unused", \
499 .field_exists = (_test), \
500 .version_id = (_version), \
501 .size = (_size), \
502 .info = &vmstate_info_unused_buffer, \
503 .flags = VMS_BUFFER, \
505 extern const VMStateDescription vmstate_pci_device;
507 #define VMSTATE_PCI_DEVICE(_field, _state) { \
508 .name = (stringify(_field)), \
509 .size = sizeof(PCIDevice), \
510 .vmsd = &vmstate_pci_device, \
511 .flags = VMS_STRUCT, \
512 .offset = vmstate_offset_value(_state, _field, PCIDevice), \
515 extern const VMStateDescription vmstate_i2c_slave;
517 #define VMSTATE_I2C_SLAVE(_field, _state) { \
518 .name = (stringify(_field)), \
519 .size = sizeof(i2c_slave), \
520 .vmsd = &vmstate_i2c_slave, \
521 .flags = VMS_STRUCT, \
522 .offset = vmstate_offset_value(_state, _field, i2c_slave), \
525 #define vmstate_offset_macaddr(_state, _field) \
526 vmstate_offset_array(_state, _field.a, uint8_t, \
527 sizeof(typeof_field(_state, _field)))
529 #define VMSTATE_MACADDR(_field, _state) { \
530 .name = (stringify(_field)), \
531 .size = sizeof(MACAddr), \
532 .info = &vmstate_info_uint8, \
533 .flags = VMS_BUFFER, \
534 .offset = vmstate_offset_macaddr(_state, _field), \
537 /* _f : field name
538 _f_n : num of elements field_name
539 _n : num of elements
540 _s : struct state name
541 _v : version
544 #define VMSTATE_SINGLE(_field, _state, _version, _info, _type) \
545 VMSTATE_SINGLE_TEST(_field, _state, NULL, _version, _info, _type)
547 #define VMSTATE_INT8_V(_f, _s, _v) \
548 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t)
549 #define VMSTATE_INT16_V(_f, _s, _v) \
550 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int16, int16_t)
551 #define VMSTATE_INT32_V(_f, _s, _v) \
552 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int32, int32_t)
553 #define VMSTATE_INT64_V(_f, _s, _v) \
554 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int64, int64_t)
556 #define VMSTATE_UINT8_V(_f, _s, _v) \
557 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint8, uint8_t)
558 #define VMSTATE_UINT16_V(_f, _s, _v) \
559 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16, uint16_t)
560 #define VMSTATE_UINT32_V(_f, _s, _v) \
561 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32, uint32_t)
562 #define VMSTATE_UINT64_V(_f, _s, _v) \
563 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t)
565 #define VMSTATE_INT8(_f, _s) \
566 VMSTATE_INT8_V(_f, _s, 0)
567 #define VMSTATE_INT16(_f, _s) \
568 VMSTATE_INT16_V(_f, _s, 0)
569 #define VMSTATE_INT32(_f, _s) \
570 VMSTATE_INT32_V(_f, _s, 0)
571 #define VMSTATE_INT64(_f, _s) \
572 VMSTATE_INT64_V(_f, _s, 0)
574 #define VMSTATE_UINT8(_f, _s) \
575 VMSTATE_UINT8_V(_f, _s, 0)
576 #define VMSTATE_UINT16(_f, _s) \
577 VMSTATE_UINT16_V(_f, _s, 0)
578 #define VMSTATE_UINT32(_f, _s) \
579 VMSTATE_UINT32_V(_f, _s, 0)
580 #define VMSTATE_UINT64(_f, _s) \
581 VMSTATE_UINT64_V(_f, _s, 0)
583 #define VMSTATE_UINT8_EQUAL(_f, _s) \
584 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t)
586 #define VMSTATE_UINT16_EQUAL(_f, _s) \
587 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint16_equal, uint16_t)
589 #define VMSTATE_UINT16_EQUAL_V(_f, _s, _v) \
590 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16_equal, uint16_t)
592 #define VMSTATE_INT32_EQUAL(_f, _s) \
593 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t)
595 #define VMSTATE_INT32_LE(_f, _s) \
596 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)
598 #define VMSTATE_UINT32_TEST(_f, _s, _t) \
599 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t)
601 #define VMSTATE_TIMER_V(_f, _s, _v) \
602 VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *)
604 #define VMSTATE_TIMER(_f, _s) \
605 VMSTATE_TIMER_V(_f, _s, 0)
607 #define VMSTATE_TIMER_ARRAY(_f, _s, _n) \
608 VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *)
610 #define VMSTATE_PTIMER_V(_f, _s, _v) \
611 VMSTATE_POINTER(_f, _s, _v, vmstate_info_ptimer, ptimer_state *)
613 #define VMSTATE_PTIMER(_f, _s) \
614 VMSTATE_PTIMER_V(_f, _s, 0)
616 #define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \
617 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t)
619 #define VMSTATE_UINT16_ARRAY(_f, _s, _n) \
620 VMSTATE_UINT16_ARRAY_V(_f, _s, _n, 0)
622 #define VMSTATE_UINT8_ARRAY_V(_f, _s, _n, _v) \
623 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint8, uint8_t)
625 #define VMSTATE_UINT8_ARRAY(_f, _s, _n) \
626 VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0)
628 #define VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) \
629 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t)
631 #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
632 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
634 #define VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v) \
635 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint64, uint64_t)
637 #define VMSTATE_UINT64_ARRAY(_f, _s, _n) \
638 VMSTATE_UINT64_ARRAY_V(_f, _s, _n, 0)
640 #define VMSTATE_INT16_ARRAY_V(_f, _s, _n, _v) \
641 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int16, int16_t)
643 #define VMSTATE_INT16_ARRAY(_f, _s, _n) \
644 VMSTATE_INT16_ARRAY_V(_f, _s, _n, 0)
646 #define VMSTATE_INT32_ARRAY_V(_f, _s, _n, _v) \
647 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t)
649 #define VMSTATE_INT32_ARRAY(_f, _s, _n) \
650 VMSTATE_INT32_ARRAY_V(_f, _s, _n, 0)
652 #define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num) \
653 VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t)
655 #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
656 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
658 #define VMSTATE_BUFFER_V(_f, _s, _v) \
659 VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))
661 #define VMSTATE_BUFFER(_f, _s) \
662 VMSTATE_BUFFER_V(_f, _s, 0)
664 #define VMSTATE_PARTIAL_BUFFER(_f, _s, _size) \
665 VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, 0, _size)
667 #define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \
668 VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, _start, sizeof(typeof_field(_s, _f)))
670 #define VMSTATE_BUFFER_TEST(_f, _s, _test) \
671 VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f)))
673 #define VMSTATE_UNUSED_V(_v, _size) \
674 VMSTATE_UNUSED_BUFFER(NULL, _v, _size)
676 #define VMSTATE_UNUSED(_size) \
677 VMSTATE_UNUSED_V(0, _size)
679 #define VMSTATE_UNUSED_TEST(_test, _size) \
680 VMSTATE_UNUSED_BUFFER(_test, 0, _size)
682 #ifdef NEED_CPU_H
683 #if TARGET_LONG_BITS == 64
684 #define VMSTATE_UINTTL_V(_f, _s, _v) \
685 VMSTATE_UINT64_V(_f, _s, _v)
686 #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v) \
687 VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v)
688 #else
689 #define VMSTATE_UINTTL_V(_f, _s, _v) \
690 VMSTATE_UINT32_V(_f, _s, _v)
691 #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v) \
692 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v)
693 #endif
694 #define VMSTATE_UINTTL(_f, _s) \
695 VMSTATE_UINTTL_V(_f, _s, 0)
696 #define VMSTATE_UINTTL_ARRAY(_f, _s, _n) \
697 VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, 0)
699 #endif
701 #define VMSTATE_END_OF_LIST() \
704 extern int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
705 void *opaque, int version_id);
706 extern void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
707 void *opaque);
708 extern int vmstate_register(int instance_id, const VMStateDescription *vmsd,
709 void *base);
710 void vmstate_unregister(const VMStateDescription *vmsd, void *opaque);
711 #endif