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 <stdbool.h> 14 #include "ioport.h" 15 #include "irq.h" 16 17 /* VM Load/Save */ 18 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. 22 */ 23 typedef int (QEMUFilePutBufferFunc)(void *opaque, const uint8_t *buf, 24 int64_t pos, int size); 25 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. 29 */ 30 typedef int (QEMUFileGetBufferFunc)(void *opaque, uint8_t *buf, 31 int64_t pos, int size); 32 33 /* Close a file and return an error code */ 34 typedef int (QEMUFileCloseFunc)(void *opaque); 35 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. 38 */ 39 typedef int (QEMUFileRateLimit)(void *opaque); 40 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 44 */ 45 typedef size_t (QEMUFileSetRateLimit)(void *opaque, size_t new_rate); 46 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); 62 63 static inline void qemu_put_ubyte(QEMUFile *f, unsigned int v) 64 { 65 qemu_put_byte(f, (int)v); 66 } 67 68 #define qemu_put_sbyte qemu_put_byte 69 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); 75 76 static inline unsigned int qemu_get_ubyte(QEMUFile *f) 77 { 78 return (unsigned int)qemu_get_byte(f); 79 } 80 81 #define qemu_get_sbyte qemu_get_byte 82 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); 90 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); 95 96 static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv) 97 { 98 qemu_put_be64(f, *pv); 99 } 100 101 static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv) 102 { 103 qemu_put_be32(f, *pv); 104 } 105 106 static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv) 107 { 108 qemu_put_be16(f, *pv); 109 } 110 111 static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv) 112 { 113 qemu_put_byte(f, *pv); 114 } 115 116 static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv) 117 { 118 *pv = qemu_get_be64(f); 119 } 120 121 static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv) 122 { 123 *pv = qemu_get_be32(f); 124 } 125 126 static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv) 127 { 128 *pv = qemu_get_be16(f); 129 } 130 131 static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv) 132 { 133 *pv = qemu_get_byte(f); 134 } 135 136 // Signed versions for type safety 137 static inline void qemu_put_sbuffer(QEMUFile *f, const int8_t *buf, int size) 138 { 139 qemu_put_buffer(f, (const uint8_t *)buf, size); 140 } 141 142 static inline void qemu_put_sbe16(QEMUFile *f, int v) 143 { 144 qemu_put_be16(f, (unsigned int)v); 145 } 146 147 static inline void qemu_put_sbe32(QEMUFile *f, int v) 148 { 149 qemu_put_be32(f, (unsigned int)v); 150 } 151 152 static inline void qemu_put_sbe64(QEMUFile *f, int64_t v) 153 { 154 qemu_put_be64(f, (uint64_t)v); 155 } 156 157 static inline size_t qemu_get_sbuffer(QEMUFile *f, int8_t *buf, int size) 158 { 159 return qemu_get_buffer(f, (uint8_t *)buf, size); 160 } 161 162 static inline int qemu_get_sbe16(QEMUFile *f) 163 { 164 return (int)qemu_get_be16(f); 165 } 166 167 static inline int qemu_get_sbe32(QEMUFile *f) 168 { 169 return (int)qemu_get_be32(f); 170 } 171 172 static inline int64_t qemu_get_sbe64(QEMUFile *f) 173 { 174 return (int64_t)qemu_get_be64(f); 175 } 176 177 static inline void qemu_put_s8s(QEMUFile *f, const int8_t *pv) 178 { 179 qemu_put_8s(f, (const uint8_t *)pv); 180 } 181 182 static inline void qemu_put_sbe16s(QEMUFile *f, const int16_t *pv) 183 { 184 qemu_put_be16s(f, (const uint16_t *)pv); 185 } 186 187 static inline void qemu_put_sbe32s(QEMUFile *f, const int32_t *pv) 188 { 189 qemu_put_be32s(f, (const uint32_t *)pv); 190 } 191 192 static inline void qemu_put_sbe64s(QEMUFile *f, const int64_t *pv) 193 { 194 qemu_put_be64s(f, (const uint64_t *)pv); 195 } 196 197 static inline void qemu_get_s8s(QEMUFile *f, int8_t *pv) 198 { 199 qemu_get_8s(f, (uint8_t *)pv); 200 } 201 202 static inline void qemu_get_sbe16s(QEMUFile *f, int16_t *pv) 203 { 204 qemu_get_be16s(f, (uint16_t *)pv); 205 } 206 207 static inline void qemu_get_sbe32s(QEMUFile *f, int32_t *pv) 208 { 209 qemu_get_be32s(f, (uint32_t *)pv); 210 } 211 212 static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv) 213 { 214 qemu_get_be64s(f, (uint64_t *)pv); 215 } 216 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 238 239 int64_t qemu_ftell(QEMUFile *f); 240 int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence); 241 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); 245 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); 252 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); 260 261 void unregister_savevm(const char *idstr, void *opaque); 262 263 typedef void QEMUResetHandler(void *opaque); 264 265 void qemu_register_reset(QEMUResetHandler *func, void *opaque); 266 void qemu_unregister_reset(QEMUResetHandler *func, void *opaque); 267 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); 273 274 typedef struct VMStateInfo VMStateInfo; 275 typedef struct VMStateDescription VMStateDescription; 276 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); 281 }; 282 283 enum VMStateFlags { 284 VMS_SINGLE = 0x001, 285 VMS_POINTER = 0x002, 286 VMS_ARRAY = 0x004, 287 VMS_STRUCT = 0x008, 288 VMS_VARRAY = 0x010, /* Array with size in another field */ 289 VMS_BUFFER = 0x020, /* static sized buffer */ 290 VMS_ARRAY_OF_POINTER = 0x040, 291 }; 292 293 typedef struct { 294 const char *name; 295 size_t offset; 296 size_t size; 297 int num; 298 size_t num_offset; 299 const VMStateInfo *info; 300 enum VMStateFlags flags; 301 const VMStateDescription *vmsd; 302 int version_id; 303 bool (*field_exists)(void *opaque, int version_id); 304 } VMStateField; 305 306 struct VMStateDescription { 307 const char *name; 308 int version_id; 309 int minimum_version_id; 310 int minimum_version_id_old; 311 LoadStateHandler *load_state_old; 312 int (*pre_load)(void *opaque); 313 int (*post_load)(void *opaque, int version_id); 314 void (*pre_save)(void *opaque); 315 void (*post_save)(void *opaque); 316 VMStateField *fields; 317 }; 318 319 extern const VMStateInfo vmstate_info_int8; 320 extern const VMStateInfo vmstate_info_int16; 321 extern const VMStateInfo vmstate_info_int32; 322 extern const VMStateInfo vmstate_info_int64; 323 324 extern const VMStateInfo vmstate_info_uint8_equal; 325 extern const VMStateInfo vmstate_info_int32_equal; 326 extern const VMStateInfo vmstate_info_int32_le; 327 328 extern const VMStateInfo vmstate_info_uint8; 329 extern const VMStateInfo vmstate_info_uint16; 330 extern const VMStateInfo vmstate_info_uint32; 331 extern const VMStateInfo vmstate_info_uint64; 332 333 extern const VMStateInfo vmstate_info_timer; 334 extern const VMStateInfo vmstate_info_ptimer; 335 extern const VMStateInfo vmstate_info_buffer; 336 337 #define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0) 338 #define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0) 339 340 #define VMSTATE_SINGLE(_field, _state, _version, _info, _type) { \ 341 .name = (stringify(_field)), \ 342 .version_id = (_version), \ 343 .size = sizeof(_type), \ 344 .info = &(_info), \ 345 .flags = VMS_SINGLE, \ 346 .offset = offsetof(_state, _field) \ 347 + type_check(_type,typeof_field(_state, _field)) \ 348 } 349 350 #define VMSTATE_SINGLE_TEST(_field, _state, _test, _info, _type) { \ 351 .name = (stringify(_field)), \ 352 .field_exists = (_test), \ 353 .size = sizeof(_type), \ 354 .info = &(_info), \ 355 .flags = VMS_SINGLE, \ 356 .offset = offsetof(_state, _field) \ 357 + type_check(_type,typeof_field(_state, _field)) \ 358 } 359 360 #define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \ 361 .name = (stringify(_field)), \ 362 .version_id = (_version), \ 363 .info = &(_info), \ 364 .size = sizeof(_type), \ 365 .flags = VMS_SINGLE|VMS_POINTER, \ 366 .offset = offsetof(_state, _field) \ 367 + type_check(_type,typeof_field(_state, _field)) \ 368 } 369 370 #define VMSTATE_ARRAY(_field, _state, _num, _version, _info, _type) {\ 371 .name = (stringify(_field)), \ 372 .version_id = (_version), \ 373 .num = (_num), \ 374 .info = &(_info), \ 375 .size = sizeof(_type), \ 376 .flags = VMS_ARRAY, \ 377 .offset = offsetof(_state, _field) \ 378 + type_check_array(_type,typeof_field(_state, _field),_num) \ 379 } 380 381 #define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\ 382 .name = (stringify(_field)), \ 383 .field_exists = (_test), \ 384 .num = (_num), \ 385 .info = &(_info), \ 386 .size = sizeof(_type), \ 387 .flags = VMS_ARRAY, \ 388 .offset = offsetof(_state, _field) \ 389 + type_check_array(_type,typeof_field(_state, _field),_num) \ 390 } 391 392 #define VMSTATE_VARRAY(_field, _state, _field_num, _version, _info, _type) {\ 393 .name = (stringify(_field)), \ 394 .version_id = (_version), \ 395 .num_offset = offsetof(_state, _field_num) \ 396 + type_check(int32_t,typeof_field(_state, _field_num)), \ 397 .info = &(_info), \ 398 .size = sizeof(_type), \ 399 .flags = VMS_VARRAY|VMS_POINTER, \ 400 .offset = offsetof(_state, _field) \ 401 + type_check_pointer(_type,typeof_field(_state, _field)) \ 402 } 403 404 #define VMSTATE_STRUCT(_field, _state, _version, _vmsd, _type) { \ 405 .name = (stringify(_field)), \ 406 .version_id = (_version), \ 407 .vmsd = &(_vmsd), \ 408 .size = sizeof(_type), \ 409 .flags = VMS_STRUCT, \ 410 .offset = offsetof(_state, _field) \ 411 + type_check(_type,typeof_field(_state, _field)) \ 412 } 413 414 #define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type) { \ 415 .name = (stringify(_field)), \ 416 .vmsd = &(_vmsd), \ 417 .size = sizeof(_type), \ 418 .flags = VMS_STRUCT|VMS_POINTER, \ 419 .offset = offsetof(_state, _field) \ 420 + type_check(_type,typeof_field(_state, _field)) \ 421 } 422 423 #define VMSTATE_ARRAY_OF_POINTER(_field, _state, _num, _version, _info, _type) {\ 424 .name = (stringify(_field)), \ 425 .version_id = (_version), \ 426 .num = (_num), \ 427 .info = &(_info), \ 428 .size = sizeof(_type), \ 429 .flags = VMS_ARRAY|VMS_ARRAY_OF_POINTER, \ 430 .offset = offsetof(_state, _field) \ 431 + type_check_array(_type,typeof_field(_state, _field),_num) \ 432 } 433 434 #define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _version, _vmsd, _type) { \ 435 .name = (stringify(_field)), \ 436 .num = (_num), \ 437 .version_id = (_version), \ 438 .vmsd = &(_vmsd), \ 439 .size = sizeof(_type), \ 440 .flags = VMS_STRUCT|VMS_ARRAY, \ 441 .offset = offsetof(_state, _field) \ 442 + type_check_array(_type,typeof_field(_state, _field),_num) \ 443 } 444 445 #define VMSTATE_STRUCT_ARRAY_SIZE_UINT8(_field, _state, _field__num, _version, _vmsd, _type) { \ 446 .name = (stringify(_field)), \ 447 .num_offset = offsetof(_state, _field_num) \ 448 + type_check(uint8_t,typeof_field(_state, _field_num)), \ 449 .version_id = (_version), \ 450 .vmsd = &(_vmsd), \ 451 .size = sizeof(_type), \ 452 .flags = VMS_STRUCT|VMS_ARRAY, \ 453 .offset = offsetof(_state, _field) \ 454 + type_check_array(_type,typeof_field(_state, _field),_num) \ 455 } 456 457 #define VMSTATE_STATIC_BUFFER(_field, _state, _version) { \ 458 .name = (stringify(_field)), \ 459 .version_id = (_version), \ 460 .size = sizeof(typeof_field(_state,_field)), \ 461 .info = &vmstate_info_buffer, \ 462 .flags = VMS_BUFFER, \ 463 .offset = offsetof(_state, _field) \ 464 + type_check_array(uint8_t,typeof_field(_state, _field),sizeof(typeof_field(_state,_field))) \ 465 } 466 467 #define VMSTATE_STATIC_BUFFER_TEST(_field, _state, _test) { \ 468 .name = (stringify(_field)), \ 469 .field_exists = (_test), \ 470 .size = sizeof(typeof_field(_state,_field)), \ 471 .info = &vmstate_info_buffer, \ 472 .flags = VMS_BUFFER, \ 473 .offset = offsetof(_state, _field) \ 474 + type_check_array(uint8_t,typeof_field(_state, _field),sizeof(typeof_field(_state,_field))) \ 475 } 476 477 #define VMSTATE_PARTIAL_BUFFER(_field, _state, _size) { \ 478 .name = (stringify(_field)), \ 479 .size = (_size), \ 480 .info = &vmstate_info_buffer, \ 481 .flags = VMS_BUFFER, \ 482 .offset = offsetof(_state, _field) \ 483 + type_check_array(uint8_t,typeof_field(_state, _field),sizeof(typeof_field(_state,_field))) \ 484 } 485 486 #define VMSTATE_BUFFER_START_MIDDLE(_field, _state, start) { \ 487 .name = (stringify(_field)), \ 488 .size = sizeof(typeof_field(_state,_field)) - start, \ 489 .info = &vmstate_info_buffer, \ 490 .flags = VMS_BUFFER, \ 491 .offset = offsetof(_state, _field) + start \ 492 + type_check_array(uint8_t,typeof_field(_state, _field),sizeof(typeof_field(_state,_field))) \ 493 } 494 495 extern const VMStateDescription vmstate_pci_device; 496 497 #define VMSTATE_PCI_DEVICE(_field, _state) { \ 498 .name = (stringify(_field)), \ 499 .size = sizeof(PCIDevice), \ 500 .vmsd = &vmstate_pci_device, \ 501 .flags = VMS_STRUCT, \ 502 .offset = offsetof(_state, _field) \ 503 + type_check(PCIDevice,typeof_field(_state, _field)) \ 504 } 505 506 extern const VMStateDescription vmstate_i2c_slave; 507 508 #define VMSTATE_I2C_SLAVE(_field, _state) { \ 509 .name = (stringify(_field)), \ 510 .size = sizeof(i2c_slave), \ 511 .vmsd = &vmstate_i2c_slave, \ 512 .flags = VMS_STRUCT, \ 513 .offset = offsetof(_state, _field) \ 514 + type_check(i2c_slave,typeof_field(_state, _field)) \ 515 } 516 517 /* _f : field name 518 _f_n : num of elements field_name 519 _n : num of elements 520 _s : struct state name 521 _v : version 522 */ 523 524 #define VMSTATE_INT8_V(_f, _s, _v) \ 525 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t) 526 #define VMSTATE_INT16_V(_f, _s, _v) \ 527 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int16, int16_t) 528 #define VMSTATE_INT32_V(_f, _s, _v) \ 529 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int32, int32_t) 530 #define VMSTATE_INT64_V(_f, _s, _v) \ 531 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int64, int64_t) 532 533 #define VMSTATE_UINT8_V(_f, _s, _v) \ 534 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint8, uint8_t) 535 #define VMSTATE_UINT16_V(_f, _s, _v) \ 536 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16, uint16_t) 537 #define VMSTATE_UINT32_V(_f, _s, _v) \ 538 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32, uint32_t) 539 #define VMSTATE_UINT64_V(_f, _s, _v) \ 540 VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t) 541 542 #define VMSTATE_INT8(_f, _s) \ 543 VMSTATE_INT8_V(_f, _s, 0) 544 #define VMSTATE_INT16(_f, _s) \ 545 VMSTATE_INT16_V(_f, _s, 0) 546 #define VMSTATE_INT32(_f, _s) \ 547 VMSTATE_INT32_V(_f, _s, 0) 548 #define VMSTATE_INT64(_f, _s) \ 549 VMSTATE_INT64_V(_f, _s, 0) 550 551 #define VMSTATE_UINT8(_f, _s) \ 552 VMSTATE_UINT8_V(_f, _s, 0) 553 #define VMSTATE_UINT16(_f, _s) \ 554 VMSTATE_UINT16_V(_f, _s, 0) 555 #define VMSTATE_UINT32(_f, _s) \ 556 VMSTATE_UINT32_V(_f, _s, 0) 557 #define VMSTATE_UINT64(_f, _s) \ 558 VMSTATE_UINT64_V(_f, _s, 0) 559 560 #define VMSTATE_UINT8_EQUAL(_f, _s) \ 561 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t) 562 563 #define VMSTATE_INT32_EQUAL(_f, _s) \ 564 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t) 565 566 #define VMSTATE_INT32_LE(_f, _s) \ 567 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t) 568 569 #define VMSTATE_UINT32_TEST(_f, _s, _t) \ 570 VMSTATE_SINGLE_TEST(_f, _s, _t, vmstate_info_uint32, uint32_t) 571 572 #define VMSTATE_TIMER_V(_f, _s, _v) \ 573 VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *) 574 575 #define VMSTATE_TIMER(_f, _s) \ 576 VMSTATE_TIMER_V(_f, _s, 0) 577 578 #define VMSTATE_TIMER_ARRAY(_f, _s, _n) \ 579 VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *) 580 581 #define VMSTATE_PTIMER_V(_f, _s, _v) \ 582 VMSTATE_POINTER(_f, _s, _v, vmstate_info_ptimer, ptimer_state *) 583 584 #define VMSTATE_PTIMER(_f, _s) \ 585 VMSTATE_PTIMER_V(_f, _s, 0) 586 587 #define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \ 588 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t) 589 590 #define VMSTATE_UINT16_ARRAY(_f, _s, _n) \ 591 VMSTATE_UINT16_ARRAY_V(_f, _s, _n, 0) 592 593 #define VMSTATE_UINT8_ARRAY_V(_f, _s, _n, _v) \ 594 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint8, uint8_t) 595 596 #define VMSTATE_UINT8_ARRAY(_f, _s, _n) \ 597 VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0) 598 599 #define VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) \ 600 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t) 601 602 #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \ 603 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0) 604 605 #define VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v) \ 606 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint64, uint64_t) 607 608 #define VMSTATE_UINT64_ARRAY(_f, _s, _n) \ 609 VMSTATE_UINT64_ARRAY_V(_f, _s, _n, 0) 610 611 #define VMSTATE_INT16_ARRAY_V(_f, _s, _n, _v) \ 612 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int16, int16_t) 613 614 #define VMSTATE_INT16_ARRAY(_f, _s, _n) \ 615 VMSTATE_INT16_ARRAY_V(_f, _s, _n, 0) 616 617 #define VMSTATE_INT32_ARRAY_V(_f, _s, _n, _v) \ 618 VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t) 619 620 #define VMSTATE_INT32_ARRAY(_f, _s, _n) \ 621 VMSTATE_INT32_ARRAY_V(_f, _s, _n, 0) 622 623 #define VMSTATE_INT32_VARRAY_V(_f, _s, _f_n, _v) \ 624 VMSTATE_VARRAY(_f, _s, _f_n, _v, vmstate_info_int32, int32_t) 625 626 #define VMSTATE_INT32_VARRAY(_f, _s, _f_n) \ 627 VMSTATE_INT32_VARRAY_V(_f, _s, _f_n, 0) 628 629 #define VMSTATE_BUFFER_V(_f, _s, _v) \ 630 VMSTATE_STATIC_BUFFER(_f, _s, _v) 631 632 #define VMSTATE_BUFFER(_f, _s) \ 633 VMSTATE_STATIC_BUFFER(_f, _s, 0) 634 635 #define VMSTATE_BUFFER_TEST(_f, _s, _t) \ 636 VMSTATE_STATIC_BUFFER_TEST(_f, _s, _t) 637 638 #ifdef NEED_CPU_H 639 #if TARGET_LONG_BITS == 64 640 #define VMSTATE_UINTTL_V(_f, _s, _v) \ 641 VMSTATE_UINT64_V(_f, _s, _v) 642 #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v) \ 643 VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v) 644 #else 645 #define VMSTATE_UINTTL_V(_f, _s, _v) \ 646 VMSTATE_UINT32_V(_f, _s, _v) 647 #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v) \ 648 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) 649 #endif 650 #define VMSTATE_UINTTL(_f, _s) \ 651 VMSTATE_UINTTL_V(_f, _s, 0) 652 #define VMSTATE_UINTTL_ARRAY(_f, _s, _n) \ 653 VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, 0) 654 655 #endif 656 657 #define VMSTATE_END_OF_LIST() \ 658 {} 659 660 extern int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, 661 void *opaque, int version_id); 662 extern void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, 663 void *opaque); 664 extern int vmstate_register(int instance_id, const VMStateDescription *vmsd, 665 void *base); 666 void vmstate_unregister(const VMStateDescription *vmsd, void *opaque); 667 #endif 668