Statistics
| Branch: | Revision:

root / hw / hw.h @ f89a8e4e

History | View | Annotate | Download (23.4 kB)

1
/* Declarations for use by hardware emulation.  */
2
#ifndef QEMU_HW_H
3
#define QEMU_HW_H
4

    
5
#include "qemu-common.h"
6

    
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
12

    
13
#include "ioport.h"
14
#include "irq.h"
15

    
16
/* VM Load/Save */
17

    
18
/* This function writes a chunk of data to a file at the given position.
19
 * The pos argument can be ignored if the file is only being used for
20
 * streaming.  The handler should try to write all of the data it can.
21
 */
22
typedef int (QEMUFilePutBufferFunc)(void *opaque, const uint8_t *buf,
23
                                    int64_t pos, int size);
24

    
25
/* Read a chunk of data from a file at the given position.  The pos argument
26
 * can be ignored if the file is only be used for streaming.  The number of
27
 * bytes actually read should be returned.
28
 */
29
typedef int (QEMUFileGetBufferFunc)(void *opaque, uint8_t *buf,
30
                                    int64_t pos, int size);
31

    
32
/* Close a file and return an error code */
33
typedef int (QEMUFileCloseFunc)(void *opaque);
34

    
35
/* Called to determine if the file has exceeded it's bandwidth allocation.  The
36
 * bandwidth capping is a soft limit, not a hard limit.
37
 */
38
typedef int (QEMUFileRateLimit)(void *opaque);
39

    
40
/* Called to change the current bandwidth allocation. This function must return
41
 * the new actual bandwidth. It should be new_rate if everything goes ok, and
42
 * the old rate otherwise
43
 */
44
typedef size_t (QEMUFileSetRateLimit)(void *opaque, size_t new_rate);
45

    
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
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);
61

    
62
static inline void qemu_put_ubyte(QEMUFile *f, unsigned int v)
63
{
64
    qemu_put_byte(f, (int)v);
65
}
66

    
67
#define qemu_put_sbyte qemu_put_byte
68

    
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);
74

    
75
static inline unsigned int qemu_get_ubyte(QEMUFile *f)
76
{
77
    return (unsigned int)qemu_get_byte(f);
78
}
79

    
80
#define qemu_get_sbyte qemu_get_byte
81

    
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
int qemu_file_has_error(QEMUFile *f);
88
void qemu_file_set_error(QEMUFile *f);
89

    
90
/* Try to send any outstanding data.  This function is useful when output is
91
 * halted due to rate limiting or EAGAIN errors occur as it can be used to
92
 * resume output. */
93
void qemu_file_put_notify(QEMUFile *f);
94

    
95
static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv)
96
{
97
    qemu_put_be64(f, *pv);
98
}
99

    
100
static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv)
101
{
102
    qemu_put_be32(f, *pv);
103
}
104

    
105
static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv)
106
{
107
    qemu_put_be16(f, *pv);
108
}
109

    
110
static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv)
111
{
112
    qemu_put_byte(f, *pv);
113
}
114

    
115
static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv)
116
{
117
    *pv = qemu_get_be64(f);
118
}
119

    
120
static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv)
121
{
122
    *pv = qemu_get_be32(f);
123
}
124

    
125
static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv)
126
{
127
    *pv = qemu_get_be16(f);
128
}
129

    
130
static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv)
131
{
132
    *pv = qemu_get_byte(f);
133
}
134

    
135
// Signed versions for type safety
136
static inline void qemu_put_sbuffer(QEMUFile *f, const int8_t *buf, int size)
137
{
138
    qemu_put_buffer(f, (const uint8_t *)buf, size);
139
}
140

    
141
static inline void qemu_put_sbe16(QEMUFile *f, int v)
142
{
143
    qemu_put_be16(f, (unsigned int)v);
144
}
145

    
146
static inline void qemu_put_sbe32(QEMUFile *f, int v)
147
{
148
    qemu_put_be32(f, (unsigned int)v);
149
}
150

    
151
static inline void qemu_put_sbe64(QEMUFile *f, int64_t v)
152
{
153
    qemu_put_be64(f, (uint64_t)v);
154
}
155

    
156
static inline size_t qemu_get_sbuffer(QEMUFile *f, int8_t *buf, int size)
157
{
158
    return qemu_get_buffer(f, (uint8_t *)buf, size);
159
}
160

    
161
static inline int qemu_get_sbe16(QEMUFile *f)
162
{
163
    return (int)qemu_get_be16(f);
164
}
165

    
166
static inline int qemu_get_sbe32(QEMUFile *f)
167
{
168
    return (int)qemu_get_be32(f);
169
}
170

    
171
static inline int64_t qemu_get_sbe64(QEMUFile *f)
172
{
173
    return (int64_t)qemu_get_be64(f);
174
}
175

    
176
static inline void qemu_put_s8s(QEMUFile *f, const int8_t *pv)
177
{
178
    qemu_put_8s(f, (const uint8_t *)pv);
179
}
180

    
181
static inline void qemu_put_sbe16s(QEMUFile *f, const int16_t *pv)
182
{
183
    qemu_put_be16s(f, (const uint16_t *)pv);
184
}
185

    
186
static inline void qemu_put_sbe32s(QEMUFile *f, const int32_t *pv)
187
{
188
    qemu_put_be32s(f, (const uint32_t *)pv);
189
}
190

    
191
static inline void qemu_put_sbe64s(QEMUFile *f, const int64_t *pv)
192
{
193
    qemu_put_be64s(f, (const uint64_t *)pv);
194
}
195

    
196
static inline void qemu_get_s8s(QEMUFile *f, int8_t *pv)
197
{
198
    qemu_get_8s(f, (uint8_t *)pv);
199
}
200

    
201
static inline void qemu_get_sbe16s(QEMUFile *f, int16_t *pv)
202
{
203
    qemu_get_be16s(f, (uint16_t *)pv);
204
}
205

    
206
static inline void qemu_get_sbe32s(QEMUFile *f, int32_t *pv)
207
{
208
    qemu_get_be32s(f, (uint32_t *)pv);
209
}
210

    
211
static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv)
212
{
213
    qemu_get_be64s(f, (uint64_t *)pv);
214
}
215

    
216
#ifdef NEED_CPU_H
217
#if TARGET_LONG_BITS == 64
218
#define qemu_put_betl qemu_put_be64
219
#define qemu_get_betl qemu_get_be64
220
#define qemu_put_betls qemu_put_be64s
221
#define qemu_get_betls qemu_get_be64s
222
#define qemu_put_sbetl qemu_put_sbe64
223
#define qemu_get_sbetl qemu_get_sbe64
224
#define qemu_put_sbetls qemu_put_sbe64s
225
#define qemu_get_sbetls qemu_get_sbe64s
226
#else
227
#define qemu_put_betl qemu_put_be32
228
#define qemu_get_betl qemu_get_be32
229
#define qemu_put_betls qemu_put_be32s
230
#define qemu_get_betls qemu_get_be32s
231
#define qemu_put_sbetl qemu_put_sbe32
232
#define qemu_get_sbetl qemu_get_sbe32
233
#define qemu_put_sbetls qemu_put_sbe32s
234
#define qemu_get_sbetls qemu_get_sbe32s
235
#endif
236
#endif
237

    
238
int64_t qemu_ftell(QEMUFile *f);
239
int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence);
240

    
241
typedef void SaveStateHandler(QEMUFile *f, void *opaque);
242
typedef int SaveLiveStateHandler(QEMUFile *f, int stage, void *opaque);
243
typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
244

    
245
int register_savevm(const char *idstr,
246
                    int instance_id,
247
                    int version_id,
248
                    SaveStateHandler *save_state,
249
                    LoadStateHandler *load_state,
250
                    void *opaque);
251

    
252
int register_savevm_live(const char *idstr,
253
                         int instance_id,
254
                         int version_id,
255
                         SaveLiveStateHandler *save_live_state,
256
                         SaveStateHandler *save_state,
257
                         LoadStateHandler *load_state,
258
                         void *opaque);
259

    
260
void unregister_savevm(const char *idstr, void *opaque);
261

    
262
typedef void QEMUResetHandler(void *opaque);
263

    
264
void qemu_register_reset(QEMUResetHandler *func, void *opaque);
265
void qemu_unregister_reset(QEMUResetHandler *func, void *opaque);
266

    
267
/* handler to set the boot_device order for a specific type of QEMUMachine */
268
/* return 0 if success */
269
typedef int QEMUBootSetHandler(void *opaque, const char *boot_devices);
270
void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque);
271
int qemu_boot_set(const char *boot_devices);
272

    
273
typedef struct VMStateInfo VMStateInfo;
274
typedef struct VMStateDescription VMStateDescription;
275

    
276
struct VMStateInfo {
277
    const char *name;
278
    int (*get)(QEMUFile *f, void *pv, size_t size);
279
    void (*put)(QEMUFile *f, void *pv, size_t size);
280
};
281

    
282
enum VMStateFlags {
283
    VMS_SINGLE  = 0x001,
284
    VMS_POINTER = 0x002,
285
    VMS_ARRAY   = 0x004,
286
    VMS_STRUCT  = 0x008,
287
    VMS_VARRAY  = 0x010,  /* Array with size in another field */
288
    VMS_BUFFER  = 0x020,  /* static sized buffer */
289
    VMS_ARRAY_OF_POINTER = 0x040,
290
};
291

    
292
typedef struct {
293
    const char *name;
294
    size_t offset;
295
    size_t size;
296
    int num;
297
    size_t num_offset;
298
    const VMStateInfo *info;
299
    enum VMStateFlags flags;
300
    const VMStateDescription *vmsd;
301
    int version_id;
302
} VMStateField;
303

    
304
struct VMStateDescription {
305
    const char *name;
306
    int version_id;
307
    int minimum_version_id;
308
    int minimum_version_id_old;
309
    LoadStateHandler *load_state_old;
310
    int (*pre_load)(void *opaque);
311
    int (*post_load)(void *opaque, int version_id);
312
    void (*pre_save)(void *opaque);
313
    void (*post_save)(void *opaque);
314
    VMStateField *fields;
315
};
316

    
317
extern const VMStateInfo vmstate_info_int8;
318
extern const VMStateInfo vmstate_info_int16;
319
extern const VMStateInfo vmstate_info_int32;
320
extern const VMStateInfo vmstate_info_int64;
321

    
322
extern const VMStateInfo vmstate_info_uint8_equal;
323
extern const VMStateInfo vmstate_info_int32_equal;
324
extern const VMStateInfo vmstate_info_int32_le;
325

    
326
extern const VMStateInfo vmstate_info_uint8;
327
extern const VMStateInfo vmstate_info_uint16;
328
extern const VMStateInfo vmstate_info_uint32;
329
extern const VMStateInfo vmstate_info_uint64;
330

    
331
extern const VMStateInfo vmstate_info_timer;
332
extern const VMStateInfo vmstate_info_ptimer;
333
extern const VMStateInfo vmstate_info_buffer;
334

    
335
#define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0)
336
#define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0)
337

    
338
#define VMSTATE_SINGLE(_field, _state, _version, _info, _type) {     \
339
    .name       = (stringify(_field)),                               \
340
    .version_id = (_version),                                        \
341
    .size       = sizeof(_type),                                     \
342
    .info       = &(_info),                                          \
343
    .flags      = VMS_SINGLE,                                        \
344
    .offset     = offsetof(_state, _field)                           \
345
            + type_check(_type,typeof_field(_state, _field))         \
346
}
347

    
348
#define VMSTATE_POINTER(_field, _state, _version, _info, _type) {    \
349
    .name       = (stringify(_field)),                               \
350
    .version_id = (_version),                                        \
351
    .info       = &(_info),                                          \
352
    .size       = sizeof(_type),                                     \
353
    .flags      = VMS_SINGLE|VMS_POINTER,                            \
354
    .offset     = offsetof(_state, _field)                           \
355
            + type_check(_type,typeof_field(_state, _field))         \
356
}
357

    
358
#define VMSTATE_ARRAY(_field, _state, _num, _version, _info, _type) {\
359
    .name       = (stringify(_field)),                               \
360
    .version_id = (_version),                                        \
361
    .num        = (_num),                                            \
362
    .info       = &(_info),                                          \
363
    .size       = sizeof(_type),                                     \
364
    .flags      = VMS_ARRAY,                                         \
365
    .offset     = offsetof(_state, _field)                           \
366
        + type_check_array(_type,typeof_field(_state, _field),_num)  \
367
}
368

    
369
#define VMSTATE_VARRAY(_field, _state, _field_num, _version, _info, _type) {\
370
    .name       = (stringify(_field)),                               \
371
    .version_id = (_version),                                        \
372
    .num_offset = offsetof(_state, _field_num)                       \
373
        + type_check(int32_t,typeof_field(_state, _field_num)),      \
374
    .info       = &(_info),                                          \
375
    .size       = sizeof(_type),                                     \
376
    .flags      = VMS_VARRAY|VMS_POINTER,                            \
377
    .offset     = offsetof(_state, _field)                           \
378
        + type_check_pointer(_type,typeof_field(_state, _field))     \
379
}
380

    
381
#define VMSTATE_STRUCT(_field, _state, _version, _vmsd, _type) {     \
382
    .name       = (stringify(_field)),                               \
383
    .version_id = (_version),                                        \
384
    .vmsd       = &(_vmsd),                                          \
385
    .size       = sizeof(_type),                                     \
386
    .flags      = VMS_STRUCT,                                        \
387
    .offset     = offsetof(_state, _field)                           \
388
            + type_check(_type,typeof_field(_state, _field))         \
389
}
390

    
391
#define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type) {       \
392
    .name       = (stringify(_field)),                               \
393
    .vmsd       = &(_vmsd),                                          \
394
    .size       = sizeof(_type),                                     \
395
    .flags      = VMS_STRUCT|VMS_POINTER,                            \
396
    .offset     = offsetof(_state, _field)                           \
397
            + type_check(_type,typeof_field(_state, _field))         \
398
}
399

    
400
#define VMSTATE_ARRAY_OF_POINTER(_field, _state, _num, _version, _info, _type) {\
401
    .name       = (stringify(_field)),                               \
402
    .version_id = (_version),                                        \
403
    .num        = (_num),                                            \
404
    .info       = &(_info),                                          \
405
    .size       = sizeof(_type),                                     \
406
    .flags      = VMS_ARRAY|VMS_ARRAY_OF_POINTER,                    \
407
    .offset     = offsetof(_state, _field)                           \
408
        + type_check_array(_type,typeof_field(_state, _field),_num)  \
409
}
410

    
411
#define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _version, _vmsd, _type) { \
412
    .name       = (stringify(_field)),                               \
413
    .num        = (_num),                                            \
414
    .version_id = (_version),                                        \
415
    .vmsd       = &(_vmsd),                                          \
416
    .size       = sizeof(_type),                                     \
417
    .flags      = VMS_STRUCT|VMS_ARRAY,                              \
418
    .offset     = offsetof(_state, _field)                           \
419
        + type_check_array(_type,typeof_field(_state, _field),_num)  \
420
}
421

    
422
#define VMSTATE_STRUCT_ARRAY_SIZE_UINT8(_field, _state, _field__num, _version, _vmsd, _type) { \
423
    .name       = (stringify(_field)),                               \
424
    .num_offset = offsetof(_state, _field_num)                       \
425
        + type_check(uint8_t,typeof_field(_state, _field_num)),       \
426
    .version_id = (_version),                                        \
427
    .vmsd       = &(_vmsd),                                          \
428
    .size       = sizeof(_type),                                     \
429
    .flags      = VMS_STRUCT|VMS_ARRAY,                              \
430
    .offset     = offsetof(_state, _field)                           \
431
        + type_check_array(_type,typeof_field(_state, _field),_num)  \
432
}
433

    
434
#define VMSTATE_STATIC_BUFFER(_field, _state, _version) {            \
435
    .name       = (stringify(_field)),                               \
436
    .version_id = (_version),                                        \
437
    .size       = sizeof(typeof_field(_state,_field)),               \
438
    .info       = &vmstate_info_buffer,                              \
439
    .flags      = VMS_BUFFER,                                        \
440
    .offset     = offsetof(_state, _field)                           \
441
        + type_check_array(uint8_t,typeof_field(_state, _field),sizeof(typeof_field(_state,_field))) \
442
}
443

    
444
#define VMSTATE_BUFFER_START_MIDDLE(_field, _state, start) {         \
445
    .name       = (stringify(_field)),                               \
446
    .size       = sizeof(typeof_field(_state,_field)) - start,       \
447
    .info       = &vmstate_info_buffer,                              \
448
    .flags      = VMS_BUFFER,                                        \
449
    .offset     = offsetof(_state, _field) + start                   \
450
        + type_check_array(uint8_t,typeof_field(_state, _field),sizeof(typeof_field(_state,_field))) \
451
}
452

    
453
extern const VMStateDescription vmstate_pci_device;
454

    
455
#define VMSTATE_PCI_DEVICE(_field, _state) {                         \
456
    .name       = (stringify(_field)),                               \
457
    .size       = sizeof(PCIDevice),                                 \
458
    .vmsd       = &vmstate_pci_device,                               \
459
    .flags      = VMS_STRUCT,                                        \
460
    .offset     = offsetof(_state, _field)                           \
461
            + type_check(PCIDevice,typeof_field(_state, _field))     \
462
}
463

    
464
extern const VMStateDescription vmstate_i2c_slave;
465

    
466
#define VMSTATE_I2C_SLAVE(_field, _state) {                          \
467
    .name       = (stringify(_field)),                               \
468
    .size       = sizeof(i2c_slave),                                 \
469
    .vmsd       = &vmstate_i2c_slave,                                \
470
    .flags      = VMS_STRUCT,                                        \
471
    .offset     = offsetof(_state, _field)                           \
472
            + type_check(i2c_slave,typeof_field(_state, _field))     \
473
}
474

    
475
/* _f : field name
476
   _f_n : num of elements field_name
477
   _n : num of elements
478
   _s : struct state name
479
   _v : version
480
*/
481

    
482
#define VMSTATE_INT8_V(_f, _s, _v)                                    \
483
    VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t)
484
#define VMSTATE_INT16_V(_f, _s, _v)                                   \
485
    VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int16, int16_t)
486
#define VMSTATE_INT32_V(_f, _s, _v)                                   \
487
    VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int32, int32_t)
488
#define VMSTATE_INT64_V(_f, _s, _v)                                   \
489
    VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int64, int64_t)
490

    
491
#define VMSTATE_UINT8_V(_f, _s, _v)                                   \
492
    VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint8, uint8_t)
493
#define VMSTATE_UINT16_V(_f, _s, _v)                                  \
494
    VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16, uint16_t)
495
#define VMSTATE_UINT32_V(_f, _s, _v)                                  \
496
    VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32, uint32_t)
497
#define VMSTATE_UINT64_V(_f, _s, _v)                                  \
498
    VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t)
499

    
500
#define VMSTATE_INT8(_f, _s)                                          \
501
    VMSTATE_INT8_V(_f, _s, 0)
502
#define VMSTATE_INT16(_f, _s)                                         \
503
    VMSTATE_INT16_V(_f, _s, 0)
504
#define VMSTATE_INT32(_f, _s)                                         \
505
    VMSTATE_INT32_V(_f, _s, 0)
506
#define VMSTATE_INT64(_f, _s)                                         \
507
    VMSTATE_INT64_V(_f, _s, 0)
508

    
509
#define VMSTATE_UINT8(_f, _s)                                         \
510
    VMSTATE_UINT8_V(_f, _s, 0)
511
#define VMSTATE_UINT16(_f, _s)                                        \
512
    VMSTATE_UINT16_V(_f, _s, 0)
513
#define VMSTATE_UINT32(_f, _s)                                        \
514
    VMSTATE_UINT32_V(_f, _s, 0)
515
#define VMSTATE_UINT64(_f, _s)                                        \
516
    VMSTATE_UINT64_V(_f, _s, 0)
517

    
518
#define VMSTATE_UINT8_EQUAL(_f, _s)                                   \
519
    VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t)
520

    
521
#define VMSTATE_INT32_EQUAL(_f, _s)                                   \
522
    VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t)
523

    
524
#define VMSTATE_INT32_LE(_f, _s)                                   \
525
    VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)
526

    
527
#define VMSTATE_TIMER_V(_f, _s, _v)                                   \
528
    VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *)
529

    
530
#define VMSTATE_TIMER(_f, _s)                                         \
531
    VMSTATE_TIMER_V(_f, _s, 0)
532

    
533
#define VMSTATE_TIMER_ARRAY(_f, _s, _n)                              \
534
    VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *)
535

    
536
#define VMSTATE_PTIMER_V(_f, _s, _v)                                  \
537
    VMSTATE_POINTER(_f, _s, _v, vmstate_info_ptimer, ptimer_state *)
538

    
539
#define VMSTATE_PTIMER(_f, _s)                                        \
540
    VMSTATE_PTIMER_V(_f, _s, 0)
541

    
542
#define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v)                         \
543
    VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t)
544

    
545
#define VMSTATE_UINT16_ARRAY(_f, _s, _n)                               \
546
    VMSTATE_UINT16_ARRAY_V(_f, _s, _n, 0)
547

    
548
#define VMSTATE_UINT8_ARRAY_V(_f, _s, _n, _v)                         \
549
    VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint8, uint8_t)
550

    
551
#define VMSTATE_UINT8_ARRAY(_f, _s, _n)                               \
552
    VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0)
553

    
554
#define VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v)                        \
555
    VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t)
556

    
557
#define VMSTATE_UINT32_ARRAY(_f, _s, _n)                              \
558
    VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
559

    
560
#define VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v)                        \
561
    VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint64, uint64_t)
562

    
563
#define VMSTATE_UINT64_ARRAY(_f, _s, _n)                              \
564
    VMSTATE_UINT64_ARRAY_V(_f, _s, _n, 0)
565

    
566
#define VMSTATE_INT16_ARRAY_V(_f, _s, _n, _v)                         \
567
    VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int16, int16_t)
568

    
569
#define VMSTATE_INT16_ARRAY(_f, _s, _n)                               \
570
    VMSTATE_INT16_ARRAY_V(_f, _s, _n, 0)
571

    
572
#define VMSTATE_INT32_ARRAY_V(_f, _s, _n, _v)                         \
573
    VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t)
574

    
575
#define VMSTATE_INT32_ARRAY(_f, _s, _n)                               \
576
    VMSTATE_INT32_ARRAY_V(_f, _s, _n, 0)
577

    
578
#define VMSTATE_INT32_VARRAY_V(_f, _s, _f_n, _v)                      \
579
    VMSTATE_VARRAY(_f, _s, _f_n, _v, vmstate_info_int32, int32_t)
580

    
581
#define VMSTATE_INT32_VARRAY(_f, _s, _f_n)                            \
582
    VMSTATE_INT32_VARRAY_V(_f, _s, _f_n, 0)
583

    
584
#define VMSTATE_BUFFER_V(_f, _s, _v)                                  \
585
    VMSTATE_STATIC_BUFFER(_f, _s, _v)
586

    
587
#define VMSTATE_BUFFER(_f, _s)                                        \
588
    VMSTATE_STATIC_BUFFER(_f, _s, 0)
589

    
590
#ifdef NEED_CPU_H
591
#if TARGET_LONG_BITS == 64
592
#define VMSTATE_UINTTL_V(_f, _s, _v)                                  \
593
    VMSTATE_UINT64_V(_f, _s, _v)
594
#define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v)                        \
595
    VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v)
596
#else
597
#define VMSTATE_UINTTL_V(_f, _s, _v)                                  \
598
    VMSTATE_UINT32_V(_f, _s, _v)
599
#define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v)                        \
600
    VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v)
601
#endif
602
#define VMSTATE_UINTTL(_f, _s)                                        \
603
    VMSTATE_UINTTL_V(_f, _s, 0)
604
#define VMSTATE_UINTTL_ARRAY(_f, _s, _n)                              \
605
    VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, 0)
606

    
607
#endif
608

    
609
#define VMSTATE_END_OF_LIST()                                         \
610
    {}
611

    
612
extern int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
613
                              void *opaque, int version_id);
614
extern void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
615
                               void *opaque);
616
extern int vmstate_register(int instance_id, const VMStateDescription *vmsd,
617
                            void *base);
618
void vmstate_unregister(const VMStateDescription *vmsd, void *opaque);
619
#endif