diff options
Diffstat (limited to 'hw')
78 files changed, 434 insertions, 1012 deletions
@@ -12,6 +12,9 @@ * If you received this file as part of a commercial VirtualBox * distribution, then only the terms of your commercial VirtualBox * license agreement apply instead of the previous paragraph. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "hw.h" @@ -14,6 +14,9 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/> + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "sysemu.h" #include "hw.h" diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c index d9075e6611..bdc55a1eaa 100644 --- a/hw/acpi_piix4.c +++ b/hw/acpi_piix4.c @@ -14,6 +14,9 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/> + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "hw.h" #include "pc.h" diff --git a/hw/ads7846.c b/hw/ads7846.c index 9c58a5f59f..de3f7af127 100644 --- a/hw/ads7846.c +++ b/hw/ads7846.c @@ -5,6 +5,9 @@ * Written by Andrzej Zaborowski <balrog@zabor.org> * * This code is licensed under the GNU GPL v2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "ssi.h" @@ -15,6 +15,9 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/> + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "apm.h" diff --git a/hw/arm-misc.h b/hw/arm-misc.h index af403a159a..6e8ae6b02e 100644 --- a/hw/arm-misc.h +++ b/hw/arm-misc.h @@ -31,6 +31,7 @@ struct arm_boot_info { const char *initrd_filename; target_phys_addr_t loader_start; target_phys_addr_t smp_loader_start; + target_phys_addr_t smp_bootreg_addr; target_phys_addr_t smp_priv_base; int nb_cpus; int board_id; diff --git a/hw/arm_boot.c b/hw/arm_boot.c index 215d5dec64..bf509a8eb9 100644 --- a/hw/arm_boot.c +++ b/hw/arm_boot.c @@ -31,17 +31,17 @@ static uint32_t bootloader[] = { /* Entry point for secondary CPUs. Enable interrupt controller and Issue WFI until start address is written to system controller. */ static uint32_t smpboot[] = { - 0xe59f0020, /* ldr r0, privbase */ - 0xe3a01001, /* mov r1, #1 */ - 0xe5801100, /* str r1, [r0, #0x100] */ - 0xe3a00201, /* mov r0, #0x10000000 */ - 0xe3800030, /* orr r0, #0x30 */ + 0xe59f201c, /* ldr r2, privbase */ + 0xe59f001c, /* ldr r0, startaddr */ + 0xe3a01001, /* mov r1, #1 */ + 0xe5821100, /* str r1, [r2, #256] */ 0xe320f003, /* wfi */ 0xe5901000, /* ldr r1, [r0] */ 0xe1110001, /* tst r1, r1 */ 0x0afffffb, /* beq <wfi> */ 0xe12fff11, /* bx r1 */ - 0 /* privbase: Private memory region base address. */ + 0, /* privbase: Private memory region base address. */ + 0 /* bootreg: Boot register address is held here */ }; #define WRITE_WORD(p, value) do { \ @@ -197,6 +197,7 @@ static void do_cpu_reset(void *opaque) info->loader_start); } } else { + stl_phys_notdirty(info->smp_bootreg_addr, 0); env->regs[15] = info->smp_loader_start; } } @@ -272,8 +273,9 @@ void arm_load_kernel(CPUState *env, struct arm_boot_info *info) rom_add_blob_fixed("bootloader", bootloader, sizeof(bootloader), info->loader_start); if (info->nb_cpus > 1) { - smpboot[10] = info->smp_priv_base; - for (n = 0; n < sizeof(smpboot) / 4; n++) { + smpboot[ARRAY_SIZE(smpboot) - 1] = info->smp_bootreg_addr; + smpboot[ARRAY_SIZE(smpboot) - 2] = info->smp_priv_base; + for (n = 0; n < ARRAY_SIZE(smpboot); n++) { smpboot[n] = tswap32(smpboot[n]); } rom_add_blob_fixed("smpboot", smpboot, sizeof(smpboot), diff --git a/hw/arm_timer.c b/hw/arm_timer.c index 60e1c63ab6..1902f1a7b9 100644 --- a/hw/arm_timer.c +++ b/hw/arm_timer.c @@ -11,6 +11,7 @@ #include "qemu-timer.h" #include "qemu-common.h" #include "qdev.h" +#include "ptimer.h" /* Common timer implementation. */ diff --git a/hw/bitbang_i2c.c b/hw/bitbang_i2c.c index 18df411ebc..93fb2ed2c8 100644 --- a/hw/bitbang_i2c.c +++ b/hw/bitbang_i2c.c @@ -5,6 +5,9 @@ * Copyright (c) 2008 Jan Kiszka * * This code is licensed under the GNU GPL v2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "hw.h" #include "bitbang_i2c.h" diff --git a/hw/bonito.c b/hw/bonito.c index 04d706aba3..f2c78377bb 100644 --- a/hw/bonito.c +++ b/hw/bonito.c @@ -5,6 +5,9 @@ * Copyright (c) 2010 Huacai Chen (zltjiangshi@gmail.com) * * This code is licensed under the GNU GPL v2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ /* diff --git a/hw/collie.c b/hw/collie.c index 8dd6e4ec7e..42f4310816 100644 --- a/hw/collie.c +++ b/hw/collie.c @@ -4,6 +4,9 @@ * Copyright (C) 2011 Dmitry Eremin-Solenikov * * This code is licensed under GNU GPL v2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "hw.h" #include "sysbus.h" diff --git a/hw/ds1338.c b/hw/ds1338.c index 3522af5b5a..f754cb7cea 100644 --- a/hw/ds1338.c +++ b/hw/ds1338.c @@ -5,6 +5,9 @@ * Written by Paul Brook * * This code is licensed under the GNU GPL v2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "i2c.h" @@ -6,6 +6,9 @@ * Written by Andrzej Zaborowski <balrog@zabor.org> * * This code is licensed under the GNU GPL v2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "hw.h" diff --git a/hw/etraxfs_timer.c b/hw/etraxfs_timer.c index 319cee130b..2dfdb3063e 100644 --- a/hw/etraxfs_timer.c +++ b/hw/etraxfs_timer.c @@ -24,6 +24,7 @@ #include "sysbus.h" #include "sysemu.h" #include "qemu-timer.h" +#include "ptimer.h" #define D(x) diff --git a/hw/framebuffer.c b/hw/framebuffer.c index b43bcdff40..6bf48dc046 100644 --- a/hw/framebuffer.c +++ b/hw/framebuffer.c @@ -5,6 +5,9 @@ * Written by Paul Brook <paul@codesourcery.com> * * This code is licensed under the GNU GPLv2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ /* TODO: diff --git a/hw/grlib_apbuart.c b/hw/grlib_apbuart.c index 62bdb03a9c..f8a64e1644 100644 --- a/hw/grlib_apbuart.c +++ b/hw/grlib_apbuart.c @@ -24,6 +24,7 @@ #include "sysbus.h" #include "qemu-char.h" +#include "ptimer.h" #include "trace.h" diff --git a/hw/grlib_gptimer.c b/hw/grlib_gptimer.c index 5645054c3c..9c98a830d7 100644 --- a/hw/grlib_gptimer.c +++ b/hw/grlib_gptimer.c @@ -24,6 +24,7 @@ #include "sysbus.h" #include "qemu-timer.h" +#include "ptimer.h" #include "trace.h" diff --git a/hw/gumstix.c b/hw/gumstix.c index 686a5ed86d..13a36ea5c5 100644 --- a/hw/gumstix.c +++ b/hw/gumstix.c @@ -6,6 +6,9 @@ * Code based on spitz platform by Andrzej Zaborowski <balrog@zabor.org> * * This code is licensed under the GNU GPL v2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ /* @@ -1,6 +1,8 @@ #ifndef QEMU_HID_H #define QEMU_HID_H +#include "vmstate.h" + #define HID_MOUSE 1 #define HID_TABLET 2 #define HID_KEYBOARD 3 @@ -56,4 +58,25 @@ int hid_pointer_poll(HIDState *hs, uint8_t *buf, int len); int hid_keyboard_poll(HIDState *hs, uint8_t *buf, int len); int hid_keyboard_write(HIDState *hs, uint8_t *buf, int len); +extern const VMStateDescription vmstate_hid_keyboard_device; + +#define VMSTATE_HID_KEYBOARD_DEVICE(_field, _state) { \ + .name = (stringify(_field)), \ + .size = sizeof(HIDState), \ + .vmsd = &vmstate_hid_keyboard_device, \ + .flags = VMS_STRUCT, \ + .offset = vmstate_offset_value(_state, _field, HIDState), \ +} + +extern const VMStateDescription vmstate_hid_ptr_device; + +#define VMSTATE_HID_POINTER_DEVICE(_field, _state) { \ + .name = (stringify(_field)), \ + .size = sizeof(HIDState), \ + .vmsd = &vmstate_hid_ptr_device, \ + .flags = VMS_STRUCT, \ + .offset = vmstate_offset_value(_state, _field, HIDState), \ +} + + #endif /* QEMU_HID_H */ @@ -10,215 +10,8 @@ #include "ioport.h" #include "irq.h" - -/* VM Load/Save */ - -/* This function writes a chunk of data to a file at the given position. - * The pos argument can be ignored if the file is only being used for - * streaming. The handler should try to write all of the data it can. - */ -typedef int (QEMUFilePutBufferFunc)(void *opaque, const uint8_t *buf, - int64_t pos, int size); - -/* Read a chunk of data from a file at the given position. The pos argument - * can be ignored if the file is only be used for streaming. The number of - * bytes actually read should be returned. - */ -typedef int (QEMUFileGetBufferFunc)(void *opaque, uint8_t *buf, - int64_t pos, int size); - -/* Close a file - * - * Return negative error number on error, 0 or positive value on success. - * - * The meaning of return value on success depends on the specific back-end being - * used. - */ -typedef int (QEMUFileCloseFunc)(void *opaque); - -/* Called to determine if the file has exceeded it's bandwidth allocation. The - * bandwidth capping is a soft limit, not a hard limit. - */ -typedef int (QEMUFileRateLimit)(void *opaque); - -/* Called to change the current bandwidth allocation. This function must return - * the new actual bandwidth. It should be new_rate if everything goes ok, and - * the old rate otherwise - */ -typedef int64_t (QEMUFileSetRateLimit)(void *opaque, int64_t new_rate); -typedef int64_t (QEMUFileGetRateLimit)(void *opaque); - -QEMUFile *qemu_fopen_ops(void *opaque, QEMUFilePutBufferFunc *put_buffer, - QEMUFileGetBufferFunc *get_buffer, - QEMUFileCloseFunc *close, - QEMUFileRateLimit *rate_limit, - QEMUFileSetRateLimit *set_rate_limit, - QEMUFileGetRateLimit *get_rate_limit); -QEMUFile *qemu_fopen(const char *filename, const char *mode); -QEMUFile *qemu_fdopen(int fd, const char *mode); -QEMUFile *qemu_fopen_socket(int fd); -QEMUFile *qemu_popen(FILE *popen_file, const char *mode); -QEMUFile *qemu_popen_cmd(const char *command, const char *mode); -int qemu_stdio_fd(QEMUFile *f); -void qemu_fflush(QEMUFile *f); -int qemu_fclose(QEMUFile *f); -void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size); -void qemu_put_byte(QEMUFile *f, int v); - -static inline void qemu_put_ubyte(QEMUFile *f, unsigned int v) -{ - qemu_put_byte(f, (int)v); -} - -#define qemu_put_sbyte qemu_put_byte - -void qemu_put_be16(QEMUFile *f, unsigned int v); -void qemu_put_be32(QEMUFile *f, unsigned int v); -void qemu_put_be64(QEMUFile *f, uint64_t v); -int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size); -int qemu_get_byte(QEMUFile *f); - -static inline unsigned int qemu_get_ubyte(QEMUFile *f) -{ - return (unsigned int)qemu_get_byte(f); -} - -#define qemu_get_sbyte qemu_get_byte - -unsigned int qemu_get_be16(QEMUFile *f); -unsigned int qemu_get_be32(QEMUFile *f); -uint64_t qemu_get_be64(QEMUFile *f); -int qemu_file_rate_limit(QEMUFile *f); -int64_t qemu_file_set_rate_limit(QEMUFile *f, int64_t new_rate); -int64_t qemu_file_get_rate_limit(QEMUFile *f); -int qemu_file_get_error(QEMUFile *f); -void qemu_file_set_error(QEMUFile *f, int error); - -/* Try to send any outstanding data. This function is useful when output is - * halted due to rate limiting or EAGAIN errors occur as it can be used to - * resume output. */ -void qemu_file_put_notify(QEMUFile *f); - -static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv) -{ - qemu_put_be64(f, *pv); -} - -static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv) -{ - qemu_put_be32(f, *pv); -} - -static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv) -{ - qemu_put_be16(f, *pv); -} - -static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv) -{ - qemu_put_byte(f, *pv); -} - -static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv) -{ - *pv = qemu_get_be64(f); -} - -static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv) -{ - *pv = qemu_get_be32(f); -} - -static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv) -{ - *pv = qemu_get_be16(f); -} - -static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv) -{ - *pv = qemu_get_byte(f); -} - -// Signed versions for type safety -static inline void qemu_put_sbuffer(QEMUFile *f, const int8_t *buf, int size) -{ - qemu_put_buffer(f, (const uint8_t *)buf, size); -} - -static inline void qemu_put_sbe16(QEMUFile *f, int v) -{ - qemu_put_be16(f, (unsigned int)v); -} - -static inline void qemu_put_sbe32(QEMUFile *f, int v) -{ - qemu_put_be32(f, (unsigned int)v); -} - -static inline void qemu_put_sbe64(QEMUFile *f, int64_t v) -{ - qemu_put_be64(f, (uint64_t)v); -} - -static inline size_t qemu_get_sbuffer(QEMUFile *f, int8_t *buf, int size) -{ - return qemu_get_buffer(f, (uint8_t *)buf, size); -} - -static inline int qemu_get_sbe16(QEMUFile *f) -{ - return (int)qemu_get_be16(f); -} - -static inline int qemu_get_sbe32(QEMUFile *f) -{ - return (int)qemu_get_be32(f); -} - -static inline int64_t qemu_get_sbe64(QEMUFile *f) -{ - return (int64_t)qemu_get_be64(f); -} - -static inline void qemu_put_s8s(QEMUFile *f, const int8_t *pv) -{ - qemu_put_8s(f, (const uint8_t *)pv); -} - -static inline void qemu_put_sbe16s(QEMUFile *f, const int16_t *pv) -{ - qemu_put_be16s(f, (const uint16_t *)pv); -} - -static inline void qemu_put_sbe32s(QEMUFile *f, const int32_t *pv) -{ - qemu_put_be32s(f, (const uint32_t *)pv); -} - -static inline void qemu_put_sbe64s(QEMUFile *f, const int64_t *pv) -{ - qemu_put_be64s(f, (const uint64_t *)pv); -} - -static inline void qemu_get_s8s(QEMUFile *f, int8_t *pv) -{ - qemu_get_8s(f, (uint8_t *)pv); -} - -static inline void qemu_get_sbe16s(QEMUFile *f, int16_t *pv) -{ - qemu_get_be16s(f, (uint16_t *)pv); -} - -static inline void qemu_get_sbe32s(QEMUFile *f, int32_t *pv) -{ - qemu_get_be32s(f, (uint32_t *)pv); -} - -static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv) -{ - qemu_get_be64s(f, (uint64_t *)pv); -} +#include "qemu-file.h" +#include "vmstate.h" #ifdef NEED_CPU_H #if TARGET_LONG_BITS == 64 @@ -242,37 +35,6 @@ static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv) #endif #endif -int64_t qemu_ftell(QEMUFile *f); -int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence); - -typedef void SaveSetParamsHandler(int blk_enable, int shared, void * opaque); -typedef void SaveStateHandler(QEMUFile *f, void *opaque); -typedef int SaveLiveStateHandler(Monitor *mon, QEMUFile *f, int stage, - void *opaque); -typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id); - -int register_savevm(DeviceState *dev, - const char *idstr, - int instance_id, - int version_id, - SaveStateHandler *save_state, - LoadStateHandler *load_state, - void *opaque); - -int register_savevm_live(DeviceState *dev, - const char *idstr, - int instance_id, - int version_id, - SaveSetParamsHandler *set_params, - SaveLiveStateHandler *save_live_state, - SaveStateHandler *save_state, - LoadStateHandler *load_state, - void *opaque); - -void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque); -void register_device_unmigratable(DeviceState *dev, const char *idstr, - void *opaque); - typedef void QEMUResetHandler(void *opaque); void qemu_register_reset(QEMUResetHandler *func, void *opaque); @@ -284,637 +46,6 @@ typedef int QEMUBootSetHandler(void *opaque, const char *boot_devices); void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque); int qemu_boot_set(const char *boot_devices); -typedef struct VMStateInfo VMStateInfo; -typedef struct VMStateDescription VMStateDescription; - -struct VMStateInfo { - const char *name; - int (*get)(QEMUFile *f, void *pv, size_t size); - void (*put)(QEMUFile *f, void *pv, size_t size); -}; - -enum VMStateFlags { - VMS_SINGLE = 0x001, - VMS_POINTER = 0x002, - VMS_ARRAY = 0x004, - VMS_STRUCT = 0x008, - VMS_VARRAY_INT32 = 0x010, /* Array with size in int32_t field*/ - VMS_BUFFER = 0x020, /* static sized buffer */ - VMS_ARRAY_OF_POINTER = 0x040, - VMS_VARRAY_UINT16 = 0x080, /* Array with size in uint16_t field */ - VMS_VBUFFER = 0x100, /* Buffer with size in int32_t field */ - VMS_MULTIPLY = 0x200, /* multiply "size" field by field_size */ - VMS_VARRAY_UINT8 = 0x400, /* Array with size in uint8_t field*/ - VMS_VARRAY_UINT32 = 0x800, /* Array with size in uint32_t field*/ -}; - -typedef struct { - const char *name; - size_t offset; - size_t size; - size_t start; - int num; - size_t num_offset; - size_t size_offset; - const VMStateInfo *info; - enum VMStateFlags flags; - const VMStateDescription *vmsd; - int version_id; - bool (*field_exists)(void *opaque, int version_id); -} VMStateField; - -typedef struct VMStateSubsection { - const VMStateDescription *vmsd; - bool (*needed)(void *opaque); -} VMStateSubsection; - -struct VMStateDescription { - const char *name; - int unmigratable; - int version_id; - int minimum_version_id; - int minimum_version_id_old; - LoadStateHandler *load_state_old; - int (*pre_load)(void *opaque); - int (*post_load)(void *opaque, int version_id); - void (*pre_save)(void *opaque); - VMStateField *fields; - const VMStateSubsection *subsections; -}; - -extern const VMStateInfo vmstate_info_bool; - -extern const VMStateInfo vmstate_info_int8; -extern const VMStateInfo vmstate_info_int16; -extern const VMStateInfo vmstate_info_int32; -extern const VMStateInfo vmstate_info_int64; - -extern const VMStateInfo vmstate_info_uint8_equal; -extern const VMStateInfo vmstate_info_uint16_equal; -extern const VMStateInfo vmstate_info_int32_equal; -extern const VMStateInfo vmstate_info_uint32_equal; -extern const VMStateInfo vmstate_info_int32_le; - -extern const VMStateInfo vmstate_info_uint8; -extern const VMStateInfo vmstate_info_uint16; -extern const VMStateInfo vmstate_info_uint32; -extern const VMStateInfo vmstate_info_uint64; - -extern const VMStateInfo vmstate_info_timer; -extern const VMStateInfo vmstate_info_ptimer; -extern const VMStateInfo vmstate_info_buffer; -extern const VMStateInfo vmstate_info_unused_buffer; - -#define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0) -#define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0) - -#define vmstate_offset_value(_state, _field, _type) \ - (offsetof(_state, _field) + \ - type_check(_type, typeof_field(_state, _field))) - -#define vmstate_offset_pointer(_state, _field, _type) \ - (offsetof(_state, _field) + \ - type_check_pointer(_type, typeof_field(_state, _field))) - -#define vmstate_offset_array(_state, _field, _type, _num) \ - (offsetof(_state, _field) + \ - type_check_array(_type, typeof_field(_state, _field), _num)) - -#define vmstate_offset_sub_array(_state, _field, _type, _start) \ - (offsetof(_state, _field[_start])) - -#define vmstate_offset_buffer(_state, _field) \ - vmstate_offset_array(_state, _field, uint8_t, \ - sizeof(typeof_field(_state, _field))) - -#define VMSTATE_SINGLE_TEST(_field, _state, _test, _version, _info, _type) { \ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .field_exists = (_test), \ - .size = sizeof(_type), \ - .info = &(_info), \ - .flags = VMS_SINGLE, \ - .offset = vmstate_offset_value(_state, _field, _type), \ -} - -#define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .info = &(_info), \ - .size = sizeof(_type), \ - .flags = VMS_SINGLE|VMS_POINTER, \ - .offset = vmstate_offset_value(_state, _field, _type), \ -} - -#define VMSTATE_POINTER_TEST(_field, _state, _test, _info, _type) { \ - .name = (stringify(_field)), \ - .info = &(_info), \ - .field_exists = (_test), \ - .size = sizeof(_type), \ - .flags = VMS_SINGLE|VMS_POINTER, \ - .offset = vmstate_offset_value(_state, _field, _type), \ -} - -#define VMSTATE_ARRAY(_field, _state, _num, _version, _info, _type) {\ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .num = (_num), \ - .info = &(_info), \ - .size = sizeof(_type), \ - .flags = VMS_ARRAY, \ - .offset = vmstate_offset_array(_state, _field, _type, _num), \ -} - -#define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\ - .name = (stringify(_field)), \ - .field_exists = (_test), \ - .num = (_num), \ - .info = &(_info), \ - .size = sizeof(_type), \ - .flags = VMS_ARRAY, \ - .offset = vmstate_offset_array(_state, _field, _type, _num),\ -} - -#define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .num = (_num), \ - .info = &(_info), \ - .size = sizeof(_type), \ - .flags = VMS_ARRAY, \ - .offset = vmstate_offset_sub_array(_state, _field, _type, _start), \ -} - -#define VMSTATE_ARRAY_INT32_UNSAFE(_field, _state, _field_num, _info, _type) {\ - .name = (stringify(_field)), \ - .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \ - .info = &(_info), \ - .size = sizeof(_type), \ - .flags = VMS_VARRAY_INT32, \ - .offset = offsetof(_state, _field), \ -} - -#define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, _type) {\ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \ - .info = &(_info), \ - .size = sizeof(_type), \ - .flags = VMS_VARRAY_INT32|VMS_POINTER, \ - .offset = vmstate_offset_pointer(_state, _field, _type), \ -} - -#define VMSTATE_VARRAY_UINT32(_field, _state, _field_num, _version, _info, _type) {\ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\ - .info = &(_info), \ - .size = sizeof(_type), \ - .flags = VMS_VARRAY_UINT32|VMS_POINTER, \ - .offset = vmstate_offset_pointer(_state, _field, _type), \ -} - -#define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version, _info, _type) {\ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\ - .info = &(_info), \ - .size = sizeof(_type), \ - .flags = VMS_VARRAY_UINT16, \ - .offset = offsetof(_state, _field), \ -} - -#define VMSTATE_STRUCT_TEST(_field, _state, _test, _version, _vmsd, _type) { \ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .field_exists = (_test), \ - .vmsd = &(_vmsd), \ - .size = sizeof(_type), \ - .flags = VMS_STRUCT, \ - .offset = vmstate_offset_value(_state, _field, _type), \ -} - -#define VMSTATE_STRUCT_POINTER_TEST(_field, _state, _test, _vmsd, _type) { \ - .name = (stringify(_field)), \ - .field_exists = (_test), \ - .vmsd = &(_vmsd), \ - .size = sizeof(_type), \ - .flags = VMS_STRUCT|VMS_POINTER, \ - .offset = vmstate_offset_value(_state, _field, _type), \ -} - -#define VMSTATE_ARRAY_OF_POINTER(_field, _state, _num, _version, _info, _type) {\ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .num = (_num), \ - .info = &(_info), \ - .size = sizeof(_type), \ - .flags = VMS_ARRAY|VMS_ARRAY_OF_POINTER, \ - .offset = vmstate_offset_array(_state, _field, _type, _num), \ -} - -#define VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, _test, _version, _vmsd, _type) { \ - .name = (stringify(_field)), \ - .num = (_num), \ - .field_exists = (_test), \ - .version_id = (_version), \ - .vmsd = &(_vmsd), \ - .size = sizeof(_type), \ - .flags = VMS_STRUCT|VMS_ARRAY, \ - .offset = vmstate_offset_array(_state, _field, _type, _num),\ -} - -#define VMSTATE_STRUCT_VARRAY_UINT8(_field, _state, _field_num, _version, _vmsd, _type) { \ - .name = (stringify(_field)), \ - .num_offset = vmstate_offset_value(_state, _field_num, uint8_t), \ - .version_id = (_version), \ - .vmsd = &(_vmsd), \ - .size = sizeof(_type), \ - .flags = VMS_STRUCT|VMS_VARRAY_UINT8, \ - .offset = offsetof(_state, _field), \ -} - -#define VMSTATE_STRUCT_VARRAY_POINTER_INT32(_field, _state, _field_num, _vmsd, _type) { \ - .name = (stringify(_field)), \ - .version_id = 0, \ - .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \ - .size = sizeof(_type), \ - .vmsd = &(_vmsd), \ - .flags = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \ - .offset = vmstate_offset_pointer(_state, _field, _type), \ -} - -#define VMSTATE_STRUCT_VARRAY_POINTER_UINT16(_field, _state, _field_num, _vmsd, _type) { \ - .name = (stringify(_field)), \ - .version_id = 0, \ - .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\ - .size = sizeof(_type), \ - .vmsd = &(_vmsd), \ - .flags = VMS_POINTER | VMS_VARRAY_UINT16 | VMS_STRUCT, \ - .offset = vmstate_offset_pointer(_state, _field, _type), \ -} - -#define VMSTATE_STRUCT_VARRAY_INT32(_field, _state, _field_num, _version, _vmsd, _type) { \ - .name = (stringify(_field)), \ - .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \ - .version_id = (_version), \ - .vmsd = &(_vmsd), \ - .size = sizeof(_type), \ - .flags = VMS_STRUCT|VMS_VARRAY_INT32, \ - .offset = offsetof(_state, _field), \ -} - -#define VMSTATE_STRUCT_VARRAY_UINT32(_field, _state, _field_num, _version, _vmsd, _type) { \ - .name = (stringify(_field)), \ - .num_offset = vmstate_offset_value(_state, _field_num, uint32_t), \ - .version_id = (_version), \ - .vmsd = &(_vmsd), \ - .size = sizeof(_type), \ - .flags = VMS_STRUCT|VMS_VARRAY_UINT32, \ - .offset = offsetof(_state, _field), \ -} - -#define VMSTATE_STATIC_BUFFER(_field, _state, _version, _test, _start, _size) { \ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .field_exists = (_test), \ - .size = (_size - _start), \ - .info = &vmstate_info_buffer, \ - .flags = VMS_BUFFER, \ - .offset = vmstate_offset_buffer(_state, _field) + _start, \ -} - -#define VMSTATE_BUFFER_MULTIPLY(_field, _state, _version, _test, _start, _field_size, _multiply) { \ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .field_exists = (_test), \ - .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\ - .size = (_multiply), \ - .info = &vmstate_info_buffer, \ - .flags = VMS_VBUFFER|VMS_MULTIPLY, \ - .offset = offsetof(_state, _field), \ - .start = (_start), \ -} - -#define VMSTATE_VBUFFER(_field, _state, _version, _test, _start, _field_size) { \ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .field_exists = (_test), \ - .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\ - .info = &vmstate_info_buffer, \ - .flags = VMS_VBUFFER|VMS_POINTER, \ - .offset = offsetof(_state, _field), \ - .start = (_start), \ -} - -#define VMSTATE_VBUFFER_UINT32(_field, _state, _version, _test, _start, _field_size) { \ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .field_exists = (_test), \ - .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\ - .info = &vmstate_info_buffer, \ - .flags = VMS_VBUFFER|VMS_POINTER, \ - .offset = offsetof(_state, _field), \ - .start = (_start), \ -} - -#define VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, _info, _size) { \ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .size = (_size), \ - .info = &(_info), \ - .flags = VMS_BUFFER, \ - .offset = offsetof(_state, _field), \ -} - -#define VMSTATE_UNUSED_BUFFER(_test, _version, _size) { \ - .name = "unused", \ - .field_exists = (_test), \ - .version_id = (_version), \ - .size = (_size), \ - .info = &vmstate_info_unused_buffer, \ - .flags = VMS_BUFFER, \ -} -extern const VMStateDescription vmstate_pci_device; - -#define VMSTATE_PCI_DEVICE(_field, _state) { \ - .name = (stringify(_field)), \ - .size = sizeof(PCIDevice), \ - .vmsd = &vmstate_pci_device, \ - .flags = VMS_STRUCT, \ - .offset = vmstate_offset_value(_state, _field, PCIDevice), \ -} - -#define VMSTATE_PCI_DEVICE_POINTER(_field, _state) { \ - .name = (stringify(_field)), \ - .size = sizeof(PCIDevice), \ - .vmsd = &vmstate_pci_device, \ - .flags = VMS_STRUCT|VMS_POINTER, \ - .offset = vmstate_offset_pointer(_state, _field, PCIDevice), \ -} - -extern const VMStateDescription vmstate_pcie_device; - -#define VMSTATE_PCIE_DEVICE(_field, _state) { \ - .name = (stringify(_field)), \ - .version_id = 2, \ - .size = sizeof(PCIDevice), \ - .vmsd = &vmstate_pcie_device, \ - .flags = VMS_STRUCT, \ - .offset = vmstate_offset_value(_state, _field, PCIDevice), \ -} - -extern const VMStateDescription vmstate_i2c_slave; - -#define VMSTATE_I2C_SLAVE(_field, _state) { \ - .name = (stringify(_field)), \ - .size = sizeof(i2c_slave), \ - .vmsd = &vmstate_i2c_slave, \ - .flags = VMS_STRUCT, \ - .offset = vmstate_offset_value(_state, _field, i2c_slave), \ -} - -extern const VMStateDescription vmstate_usb_device; - -#define VMSTATE_USB_DEVICE(_field, _state) { \ - .name = (stringify(_field)), \ - .size = sizeof(USBDevice), \ - .vmsd = &vmstate_usb_device, \ - .flags = VMS_STRUCT, \ - .offset = vmstate_offset_value(_state, _field, USBDevice), \ -} - -#define vmstate_offset_macaddr(_state, _field) \ - vmstate_offset_array(_state, _field.a, uint8_t, \ - sizeof(typeof_field(_state, _field))) - -#define VMSTATE_MACADDR(_field, _state) { \ - .name = (stringify(_field)), \ - .size = sizeof(MACAddr), \ - .info = &vmstate_info_buffer, \ - .flags = VMS_BUFFER, \ - .offset = vmstate_offset_macaddr(_state, _field), \ -} - -extern const VMStateDescription vmstate_ptimer; - -#define VMSTATE_PTIMER(_field, _state) { \ - .name = (stringify(_field)), \ - .version_id = (1), \ - .vmsd = &vmstate_ptimer, \ - .size = sizeof(ptimer_state *), \ - .flags = VMS_STRUCT|VMS_POINTER, \ - .offset = vmstate_offset_pointer(_state, _field, ptimer_state), \ -} - -extern const VMStateDescription vmstate_hid_keyboard_device; - -#define VMSTATE_HID_KEYBOARD_DEVICE(_field, _state) { \ - .name = (stringify(_field)), \ - .size = sizeof(HIDState), \ - .vmsd = &vmstate_hid_keyboard_device, \ - .flags = VMS_STRUCT, \ - .offset = vmstate_offset_value(_state, _field, HIDState), \ -} - -extern const VMStateDescription vmstate_hid_ptr_device; - -#define VMSTATE_HID_POINTER_DEVICE(_field, _state) { \ - .name = (stringify(_field)), \ - .size = sizeof(HIDState), \ - .vmsd = &vmstate_hid_ptr_device, \ - .flags = VMS_STRUCT, \ - .offset = vmstate_offset_value(_state, _field, HIDState), \ -} - -/* _f : field name - _f_n : num of elements field_name - _n : num of elements - _s : struct state name - _v : version -*/ - -#define VMSTATE_SINGLE(_field, _state, _version, _info, _type) \ - VMSTATE_SINGLE_TEST(_field, _state, NULL, _version, _info, _type) - -#define VMSTATE_STRUCT(_field, _state, _version, _vmsd, _type) \ - VMSTATE_STRUCT_TEST(_field, _state, NULL, _version, _vmsd, _type) - -#define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type) \ - VMSTATE_STRUCT_POINTER_TEST(_field, _state, NULL, _vmsd, _type) - -#define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _version, _vmsd, _type) \ - VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, NULL, _version, \ - _vmsd, _type) - -#define VMSTATE_BOOL_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_bool, bool) - -#define VMSTATE_INT8_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t) -#define VMSTATE_INT16_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int16, int16_t) -#define VMSTATE_INT32_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int32, int32_t) -#define VMSTATE_INT64_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int64, int64_t) - -#define VMSTATE_UINT8_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint8, uint8_t) -#define VMSTATE_UINT16_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16, uint16_t) -#define VMSTATE_UINT32_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32, uint32_t) -#define VMSTATE_UINT64_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t) - -#define VMSTATE_BOOL(_f, _s) \ - VMSTATE_BOOL_V(_f, _s, 0) - -#define VMSTATE_INT8(_f, _s) \ - VMSTATE_INT8_V(_f, _s, 0) -#define VMSTATE_INT16(_f, _s) \ - VMSTATE_INT16_V(_f, _s, 0) -#define VMSTATE_INT32(_f, _s) \ - VMSTATE_INT32_V(_f, _s, 0) -#define VMSTATE_INT64(_f, _s) \ - VMSTATE_INT64_V(_f, _s, 0) - -#define VMSTATE_UINT8(_f, _s) \ - VMSTATE_UINT8_V(_f, _s, 0) -#define VMSTATE_UINT16(_f, _s) \ - VMSTATE_UINT16_V(_f, _s, 0) -#define VMSTATE_UINT32(_f, _s) \ - VMSTATE_UINT32_V(_f, _s, 0) -#define VMSTATE_UINT64(_f, _s) \ - VMSTATE_UINT64_V(_f, _s, 0) - -#define VMSTATE_UINT8_EQUAL(_f, _s) \ - VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t) - -#define VMSTATE_UINT16_EQUAL(_f, _s) \ - VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint16_equal, uint16_t) - -#define VMSTATE_UINT16_EQUAL_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16_equal, uint16_t) - -#define VMSTATE_INT32_EQUAL(_f, _s) \ - VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t) - -#define VMSTATE_UINT32_EQUAL(_f, _s) \ - VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint32_equal, uint32_t) - -#define VMSTATE_INT32_LE(_f, _s) \ - VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t) - -#define VMSTATE_UINT8_TEST(_f, _s, _t) \ - VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint8, uint8_t) - -#define VMSTATE_UINT16_TEST(_f, _s, _t) \ - VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint16, uint16_t) - -#define VMSTATE_UINT32_TEST(_f, _s, _t) \ - VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t) - -#define VMSTATE_TIMER_TEST(_f, _s, _test) \ - VMSTATE_POINTER_TEST(_f, _s, _test, vmstate_info_timer, QEMUTimer *) - -#define VMSTATE_TIMER(_f, _s) \ - VMSTATE_TIMER_TEST(_f, _s, NULL) - -#define VMSTATE_TIMER_ARRAY(_f, _s, _n) \ - VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *) - -#define VMSTATE_BOOL_ARRAY_V(_f, _s, _n, _v) \ - VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_bool, bool) - -#define VMSTATE_BOOL_ARRAY(_f, _s, _n) \ - VMSTATE_BOOL_ARRAY_V(_f, _s, _n, 0) - -#define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \ - VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t) - -#define VMSTATE_UINT16_ARRAY(_f, _s, _n) \ - VMSTATE_UINT16_ARRAY_V(_f, _s, _n, 0) - -#define VMSTATE_UINT8_ARRAY_V(_f, _s, _n, _v) \ - VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint8, uint8_t) - -#define VMSTATE_UINT8_ARRAY(_f, _s, _n) \ - VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0) - -#define VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) \ - VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t) - -#define VMSTATE_UINT32_ARRAY(_f, _s, _n) \ - VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0) - -#define VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v) \ - VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint64, uint64_t) - -#define VMSTATE_UINT64_ARRAY(_f, _s, _n) \ - VMSTATE_UINT64_ARRAY_V(_f, _s, _n, 0) - -#define VMSTATE_INT16_ARRAY_V(_f, _s, _n, _v) \ - VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int16, int16_t) - -#define VMSTATE_INT16_ARRAY(_f, _s, _n) \ - VMSTATE_INT16_ARRAY_V(_f, _s, _n, 0) - -#define VMSTATE_INT32_ARRAY_V(_f, _s, _n, _v) \ - VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t) - -#define VMSTATE_INT32_ARRAY(_f, _s, _n) \ - VMSTATE_INT32_ARRAY_V(_f, _s, _n, 0) - -#define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num) \ - VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t) - -#define VMSTATE_UINT32_ARRAY(_f, _s, _n) \ - VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0) - -#define VMSTATE_INT64_ARRAY_V(_f, _s, _n, _v) \ - VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int64, int64_t) - -#define VMSTATE_INT64_ARRAY(_f, _s, _n) \ - VMSTATE_INT64_ARRAY_V(_f, _s, _n, 0) - -#define VMSTATE_BUFFER_V(_f, _s, _v) \ - VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f))) - -#define VMSTATE_BUFFER(_f, _s) \ - VMSTATE_BUFFER_V(_f, _s, 0) - -#define VMSTATE_PARTIAL_BUFFER(_f, _s, _size) \ - VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, 0, _size) - -#define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \ - VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, _start, sizeof(typeof_field(_s, _f))) - -#define VMSTATE_PARTIAL_VBUFFER(_f, _s, _size) \ - VMSTATE_VBUFFER(_f, _s, 0, NULL, 0, _size) - -#define VMSTATE_PARTIAL_VBUFFER_UINT32(_f, _s, _size) \ - VMSTATE_VBUFFER_UINT32(_f, _s, 0, NULL, 0, _size) - -#define VMSTATE_SUB_VBUFFER(_f, _s, _start, _size) \ - VMSTATE_VBUFFER(_f, _s, 0, NULL, _start, _size) - -#define VMSTATE_BUFFER_TEST(_f, _s, _test) \ - VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f))) - -#define VMSTATE_BUFFER_UNSAFE(_field, _state, _version, _size) \ - VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, vmstate_info_buffer, _size) - -#define VMSTATE_UNUSED_V(_v, _size) \ - VMSTATE_UNUSED_BUFFER(NULL, _v, _size) - -#define VMSTATE_UNUSED(_size) \ - VMSTATE_UNUSED_V(0, _size) - -#define VMSTATE_UNUSED_TEST(_test, _size) \ - VMSTATE_UNUSED_BUFFER(_test, 0, _size) - #ifdef NEED_CPU_H #if TARGET_LONG_BITS == 64 #define VMSTATE_UINTTL_V(_f, _s, _v) \ @@ -934,24 +65,4 @@ extern const VMStateDescription vmstate_hid_ptr_device; #endif -#define VMSTATE_END_OF_LIST() \ - {} - -int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, - void *opaque, int version_id); -void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, - void *opaque); -int vmstate_register(DeviceState *dev, int instance_id, - const VMStateDescription *vmsd, void *base); -int vmstate_register_with_alias_id(DeviceState *dev, int instance_id, - const VMStateDescription *vmsd, - void *base, int alias_id, - int required_for_version); -void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd, - void *opaque); -struct MemoryRegion; -void vmstate_register_ram(struct MemoryRegion *memory, DeviceState *dev); -void vmstate_unregister_ram(struct MemoryRegion *memory, DeviceState *dev); -void vmstate_register_ram_global(struct MemoryRegion *memory); - #endif @@ -74,4 +74,14 @@ void tmp105_set(i2c_slave *i2c, int temp); /* lm832x.c */ void lm832x_key_event(DeviceState *dev, int key, int state); +extern const VMStateDescription vmstate_i2c_slave; + +#define VMSTATE_I2C_SLAVE(_field, _state) { \ + .name = (stringify(_field)), \ + .size = sizeof(i2c_slave), \ + .vmsd = &vmstate_i2c_slave, \ + .flags = VMS_STRUCT, \ + .offset = vmstate_offset_value(_state, _field, i2c_slave), \ +} + #endif diff --git a/hw/ivshmem.c b/hw/ivshmem.c index 1aa9e3bfa1..bec2e0b8fe 100644 --- a/hw/ivshmem.c +++ b/hw/ivshmem.c @@ -12,6 +12,9 @@ * Copyright (c) 2006 Igor Kovalenko * * This code is licensed under the GNU GPL v2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "hw.h" #include "pc.h" diff --git a/hw/kvmclock.c b/hw/kvmclock.c index 5388bc489d..3b9fb20495 100644 --- a/hw/kvmclock.c +++ b/hw/kvmclock.c @@ -9,6 +9,8 @@ * This work is licensed under the terms of the GNU GPL version 2. * See the COPYING file in the top-level directory. * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "qemu-common.h" diff --git a/hw/lan9118.c b/hw/lan9118.c index 7e64c5dee3..8b83fe2198 100644 --- a/hw/lan9118.c +++ b/hw/lan9118.c @@ -5,12 +5,16 @@ * Written by Paul Brook * * This code is licensed under the GNU GPL v2 + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "sysbus.h" #include "net.h" #include "devices.h" #include "sysemu.h" +#include "ptimer.h" /* For crc32 */ #include <zlib.h> diff --git a/hw/leon3.c b/hw/leon3.c index e25bb046a7..71d79a65a7 100644 --- a/hw/leon3.c +++ b/hw/leon3.c @@ -23,6 +23,7 @@ */ #include "hw.h" #include "qemu-timer.h" +#include "ptimer.h" #include "qemu-char.h" #include "sysemu.h" #include "boards.h" diff --git a/hw/lm32_timer.c b/hw/lm32_timer.c index 445847f1ce..115e1e968f 100644 --- a/hw/lm32_timer.c +++ b/hw/lm32_timer.c @@ -25,6 +25,7 @@ #include "sysbus.h" #include "trace.h" #include "qemu-timer.h" +#include "ptimer.h" #include "qemu-error.h" #define DEFAULT_FREQUENCY (50*1000000) diff --git a/hw/mainstone.c b/hw/mainstone.c index c914a4ef7d..27f59009f6 100644 --- a/hw/mainstone.c +++ b/hw/mainstone.c @@ -7,6 +7,9 @@ * Code based on spitz platform by Andrzej Zaborowski <balrog@zabor.org> * * This code is licensed under the GNU GPL v2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "hw.h" #include "pxa.h" diff --git a/hw/marvell_88w8618_audio.c b/hw/marvell_88w8618_audio.c index 855b792b9d..0cd8410622 100644 --- a/hw/marvell_88w8618_audio.c +++ b/hw/marvell_88w8618_audio.c @@ -5,6 +5,9 @@ * Copyright (c) 2008 Jan Kiszka * * This code is licensed under the GNU GPL v2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "sysbus.h" #include "hw.h" diff --git a/hw/max111x.c b/hw/max111x.c index 70cd1af24f..fc79814bf8 100644 --- a/hw/max111x.c +++ b/hw/max111x.c @@ -5,6 +5,9 @@ * Written by Andrzej Zaborowski <balrog@zabor.org> * * This code is licensed under the GNU GPLv2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "ssi.h" diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c index 9cbd052694..657fa10d6d 100644 --- a/hw/mc146818rtc.c +++ b/hw/mc146818rtc.c @@ -179,8 +179,9 @@ static void rtc_periodic_timer(void *opaque) RTCState *s = opaque; rtc_timer_update(s, s->next_periodic_time); + s->cmos_data[RTC_REG_C] |= REG_C_PF; if (s->cmos_data[RTC_REG_B] & REG_B_PIE) { - s->cmos_data[RTC_REG_C] |= 0xc0; + s->cmos_data[RTC_REG_C] |= REG_C_IRQF; #ifdef TARGET_I386 if(rtc_td_hack) { if (s->irq_reinject_on_ack_count >= RTC_REINJECT_ON_ACK_COUNT) @@ -296,9 +297,11 @@ static void rtc_set_time(RTCState *s) tm->tm_sec = rtc_from_bcd(s, s->cmos_data[RTC_SECONDS]); tm->tm_min = rtc_from_bcd(s, s->cmos_data[RTC_MINUTES]); tm->tm_hour = rtc_from_bcd(s, s->cmos_data[RTC_HOURS] & 0x7f); - if (!(s->cmos_data[RTC_REG_B] & REG_B_24H) && - (s->cmos_data[RTC_HOURS] & 0x80)) { - tm->tm_hour += 12; + if (!(s->cmos_data[RTC_REG_B] & REG_B_24H)) { + tm->tm_hour %= 12; + if (s->cmos_data[RTC_HOURS] & 0x80) { + tm->tm_hour += 12; + } } tm->tm_wday = rtc_from_bcd(s, s->cmos_data[RTC_DAY_OF_WEEK]) - 1; tm->tm_mday = rtc_from_bcd(s, s->cmos_data[RTC_DAY_OF_MONTH]); @@ -320,7 +323,8 @@ static void rtc_copy_date(RTCState *s) s->cmos_data[RTC_HOURS] = rtc_to_bcd(s, tm->tm_hour); } else { /* 12 hour format */ - s->cmos_data[RTC_HOURS] = rtc_to_bcd(s, tm->tm_hour % 12); + int h = (tm->tm_hour % 12) ? tm->tm_hour % 12 : 12; + s->cmos_data[RTC_HOURS] = rtc_to_bcd(s, h); if (tm->tm_hour >= 12) s->cmos_data[RTC_HOURS] |= 0x80; } @@ -422,16 +426,17 @@ static void rtc_update_second2(void *opaque) } /* check alarm */ - if (s->cmos_data[RTC_REG_B] & REG_B_AIE) { - if (((s->cmos_data[RTC_SECONDS_ALARM] & 0xc0) == 0xc0 || - rtc_from_bcd(s, s->cmos_data[RTC_SECONDS_ALARM]) == s->current_tm.tm_sec) && - ((s->cmos_data[RTC_MINUTES_ALARM] & 0xc0) == 0xc0 || - rtc_from_bcd(s, s->cmos_data[RTC_MINUTES_ALARM]) == s->current_tm.tm_min) && - ((s->cmos_data[RTC_HOURS_ALARM] & 0xc0) == 0xc0 || - rtc_from_bcd(s, s->cmos_data[RTC_HOURS_ALARM]) == s->current_tm.tm_hour)) { - - s->cmos_data[RTC_REG_C] |= 0xa0; + if (((s->cmos_data[RTC_SECONDS_ALARM] & 0xc0) == 0xc0 || + rtc_from_bcd(s, s->cmos_data[RTC_SECONDS_ALARM]) == s->current_tm.tm_sec) && + ((s->cmos_data[RTC_MINUTES_ALARM] & 0xc0) == 0xc0 || + rtc_from_bcd(s, s->cmos_data[RTC_MINUTES_ALARM]) == s->current_tm.tm_min) && + ((s->cmos_data[RTC_HOURS_ALARM] & 0xc0) == 0xc0 || + rtc_from_bcd(s, s->cmos_data[RTC_HOURS_ALARM]) == s->current_tm.tm_hour)) { + + s->cmos_data[RTC_REG_C] |= REG_C_AF; + if (s->cmos_data[RTC_REG_B] & REG_B_AIE) { qemu_irq_raise(s->irq); + s->cmos_data[RTC_REG_C] |= REG_C_IRQF; } } @@ -472,10 +477,13 @@ static uint32_t cmos_ioport_read(void *opaque, uint32_t addr) case RTC_REG_C: ret = s->cmos_data[s->cmos_index]; qemu_irq_lower(s->irq); + s->cmos_data[RTC_REG_C] = 0x00; #ifdef TARGET_I386 if(s->irq_coalesced && + (s->cmos_data[RTC_REG_B] & REG_B_PIE) && s->irq_reinject_on_ack_count < RTC_REINJECT_ON_ACK_COUNT) { s->irq_reinject_on_ack_count++; + s->cmos_data[RTC_REG_C] |= REG_C_IRQF | REG_C_PF; apic_reset_irq_delivered(); DPRINTF_C("cmos: injecting on ack\n"); qemu_irq_raise(s->irq); @@ -484,11 +492,8 @@ static uint32_t cmos_ioport_read(void *opaque, uint32_t addr) DPRINTF_C("cmos: coalesced irqs decreased to %d\n", s->irq_coalesced); } - break; } #endif - - s->cmos_data[RTC_REG_C] = 0x00; break; default: ret = s->cmos_data[s->cmos_index]; diff --git a/hw/mcf5206.c b/hw/mcf5206.c index 7b6d501447..5110d833af 100644 --- a/hw/mcf5206.c +++ b/hw/mcf5206.c @@ -8,6 +8,7 @@ #include "hw.h" #include "mcf.h" #include "qemu-timer.h" +#include "ptimer.h" #include "sysemu.h" #include "exec-memory.h" diff --git a/hw/mcf5208.c b/hw/mcf5208.c index 3b0636dc2f..aa11a755cc 100644 --- a/hw/mcf5208.c +++ b/hw/mcf5208.c @@ -8,6 +8,7 @@ #include "hw.h" #include "mcf.h" #include "qemu-timer.h" +#include "ptimer.h" #include "sysemu.h" #include "net.h" #include "boards.h" diff --git a/hw/milkymist-sysctl.c b/hw/milkymist-sysctl.c index 6326b70abb..bd2a298d2e 100644 --- a/hw/milkymist-sysctl.c +++ b/hw/milkymist-sysctl.c @@ -26,6 +26,7 @@ #include "sysemu.h" #include "trace.h" #include "qemu-timer.h" +#include "ptimer.h" #include "qemu-error.h" enum { diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c index 94ef1dfd37..163a668533 100644 --- a/hw/mips_fulong2e.c +++ b/hw/mips_fulong2e.c @@ -5,6 +5,9 @@ * Copyright (c) 2009 chenming (chenming@rdc.faw.com.cn) * Copyright (c) 2010 Huacai Chen (zltjiangshi@gmail.com) * This code is licensed under the GNU GPL v2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ /* @@ -9,6 +9,9 @@ * * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "hw.h" diff --git a/hw/mst_fpga.c b/hw/mst_fpga.c index 93247022b9..8bfa5dda37 100644 --- a/hw/mst_fpga.c +++ b/hw/mst_fpga.c @@ -6,6 +6,9 @@ * <akuster@mvista.com> * * This code is licensed under the GNU GPL v2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "hw.h" #include "sysbus.h" diff --git a/hw/musicpal.c b/hw/musicpal.c index a01e3d2d92..977ffb6e50 100644 --- a/hw/musicpal.c +++ b/hw/musicpal.c @@ -4,6 +4,9 @@ * Copyright (c) 2008 Jan Kiszka * * This code is licensed under the GNU GPL v2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "sysbus.h" @@ -14,6 +17,7 @@ #include "boards.h" #include "pc.h" #include "qemu-timer.h" +#include "ptimer.h" #include "block.h" #include "flash.h" #include "console.h" @@ -11,6 +11,9 @@ * from ST Microelectronics. * * This code is licensed under the GNU GPL v2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #ifndef NAND_IO diff --git a/hw/omap_dss.c b/hw/omap_dss.c index ede640b92e..86ed6ea5d9 100644 --- a/hw/omap_dss.c +++ b/hw/omap_dss.c @@ -793,7 +793,7 @@ static void omap_rfbi_write(void *opaque, target_phys_addr_t addr, if ((s->rfbi.control & (1 << 2)) && s->rfbi.chip[0]) s->rfbi.rxbuf = s->rfbi.chip[0]->read(s->rfbi.chip[0]->opaque, 1); else if ((s->rfbi.control & (1 << 3)) && s->rfbi.chip[1]) - s->rfbi.rxbuf = s->rfbi.chip[0]->read(s->rfbi.chip[0]->opaque, 1); + s->rfbi.rxbuf = s->rfbi.chip[1]->read(s->rfbi.chip[1]->opaque, 1); if (!-- s->rfbi.pixels) omap_rfbi_transfer_stop(s); break; @@ -802,7 +802,7 @@ static void omap_rfbi_write(void *opaque, target_phys_addr_t addr, if ((s->rfbi.control & (1 << 2)) && s->rfbi.chip[0]) s->rfbi.rxbuf = s->rfbi.chip[0]->read(s->rfbi.chip[0]->opaque, 0); else if ((s->rfbi.control & (1 << 3)) && s->rfbi.chip[1]) - s->rfbi.rxbuf = s->rfbi.chip[0]->read(s->rfbi.chip[0]->opaque, 0); + s->rfbi.rxbuf = s->rfbi.chip[1]->read(s->rfbi.chip[1]->opaque, 0); if (!-- s->rfbi.pixels) omap_rfbi_transfer_stop(s); break; diff --git a/hw/pc_piix.c b/hw/pc_piix.c index b70431fe87..3aea3cc9de 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -201,6 +201,17 @@ static void pc_init1(MemoryRegion *system_memory, } idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0"); idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1"); + + /* FIXME there's some major spaghetti here. Somehow we create the + * devices on the PIIX before we actually create it. We create the + * PIIX3 deep in the recess of the i440fx creation too and then lose + * the DeviceState. + * + * For now, let's "fix" this by making judicious use of paths. This + * is not generally the right way to do this. + */ + qdev_property_add_child(qdev_resolve_path("/i440fx/piix3", NULL), + "rtc", (DeviceState *)rtc_state, NULL); } else { for(i = 0; i < MAX_IDE_BUS; i++) { ISADevice *dev; @@ -211,17 +222,6 @@ static void pc_init1(MemoryRegion *system_memory, } } - /* FIXME there's some major spaghetti here. Somehow we create the devices - * on the PIIX before we actually create it. We create the PIIX3 deep in - * the recess of the i440fx creation too and then lose the DeviceState. - * - * For now, let's "fix" this by making judicious use of paths. This is not - * generally the right way to do this. - */ - - qdev_property_add_child(qdev_resolve_path("/i440fx/piix3", NULL), - "rtc", (DeviceState *)rtc_state, NULL); - audio_init(isa_bus, pci_enabled ? pci_bus : NULL); pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device, @@ -552,4 +552,22 @@ static inline void pci_dma_sglist_init(QEMUSGList *qsg, PCIDevice *dev, qemu_sglist_init(qsg, alloc_hint); } +extern const VMStateDescription vmstate_pci_device; + +#define VMSTATE_PCI_DEVICE(_field, _state) { \ + .name = (stringify(_field)), \ + .size = sizeof(PCIDevice), \ + .vmsd = &vmstate_pci_device, \ + .flags = VMS_STRUCT, \ + .offset = vmstate_offset_value(_state, _field, PCIDevice), \ +} + +#define VMSTATE_PCI_DEVICE_POINTER(_field, _state) { \ + .name = (stringify(_field)), \ + .size = sizeof(PCIDevice), \ + .vmsd = &vmstate_pci_device, \ + .flags = VMS_STRUCT|VMS_POINTER, \ + .offset = vmstate_offset_pointer(_state, _field, PCIDevice), \ +} + #endif @@ -129,4 +129,15 @@ void pcie_add_capability(PCIDevice *dev, void pcie_ari_init(PCIDevice *dev, uint16_t offset, uint16_t nextfn); +extern const VMStateDescription vmstate_pcie_device; + +#define VMSTATE_PCIE_DEVICE(_field, _state) { \ + .name = (stringify(_field)), \ + .version_id = 2, \ + .size = sizeof(PCIDevice), \ + .vmsd = &vmstate_pcie_device, \ + .flags = VMS_STRUCT, \ + .offset = vmstate_offset_value(_state, _field, PCIDevice), \ +} + #endif /* QEMU_PCIE_H */ diff --git a/hw/pcnet.c b/hw/pcnet.c index cba253ba7b..306dc6ed7e 100644 --- a/hw/pcnet.c +++ b/hw/pcnet.c @@ -1505,6 +1505,7 @@ static void pcnet_bcr_writew(PCNetState *s, uint32_t rap, uint32_t val) #ifdef PCNET_DEBUG printf("BCR_SWS=0x%04x\n", val); #endif + /* fall through */ case BCR_LNKST: case BCR_LED1: case BCR_LED2: diff --git a/hw/pl031.c b/hw/pl031.c index a007ff0ff2..2fb0c8ef24 100644 --- a/hw/pl031.c +++ b/hw/pl031.c @@ -7,6 +7,8 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "sysbus.h" diff --git a/hw/ptimer.c b/hw/ptimer.c index b6cabd5b7d..de7d6643ad 100644 --- a/hw/ptimer.c +++ b/hw/ptimer.c @@ -7,6 +7,7 @@ */ #include "hw.h" #include "qemu-timer.h" +#include "ptimer.h" #include "host-utils.h" struct ptimer_state diff --git a/hw/ptimer.h b/hw/ptimer.h new file mode 100644 index 0000000000..6638f61322 --- /dev/null +++ b/hw/ptimer.h @@ -0,0 +1,39 @@ +/* + * General purpose implementation of a simple periodic countdown timer. + * + * Copyright (c) 2007 CodeSourcery. + * + * This code is licensed under the GNU LGPL. + */ +#ifndef PTIMER_H +#define PTIMER_H + +#include "qemu-common.h" +#include "qemu-timer.h" +#include "vmstate.h" + +/* ptimer.c */ +typedef struct ptimer_state ptimer_state; +typedef void (*ptimer_cb)(void *opaque); + +ptimer_state *ptimer_init(QEMUBH *bh); +void ptimer_set_period(ptimer_state *s, int64_t period); +void ptimer_set_freq(ptimer_state *s, uint32_t freq); +void ptimer_set_limit(ptimer_state *s, uint64_t limit, int reload); +uint64_t ptimer_get_count(ptimer_state *s); +void ptimer_set_count(ptimer_state *s, uint64_t count); +void ptimer_run(ptimer_state *s, int oneshot); +void ptimer_stop(ptimer_state *s); + +extern const VMStateDescription vmstate_ptimer; + +#define VMSTATE_PTIMER(_field, _state) { \ + .name = (stringify(_field)), \ + .version_id = (1), \ + .vmsd = &vmstate_ptimer, \ + .size = sizeof(ptimer_state *), \ + .flags = VMS_STRUCT|VMS_POINTER, \ + .offset = vmstate_offset_pointer(_state, _field, ptimer_state), \ +} + +#endif diff --git a/hw/pxa2xx_keypad.c b/hw/pxa2xx_keypad.c index f86323fecf..59db02584e 100644 --- a/hw/pxa2xx_keypad.c +++ b/hw/pxa2xx_keypad.c @@ -6,6 +6,9 @@ * or <Akuster@mvista.com> * * This code is licensed under the GPLv2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "hw.h" @@ -126,48 +129,45 @@ static void pxa27x_keyboard_event (PXA2xxKeyPadState *kp, int keycode) if(!(kp->kpc & KPC_ME)) /* skip if not enabled */ return; - if(kp->kpc & KPC_AS || kp->kpc & KPC_ASACT) { - if(kp->kpc & KPC_AS) - kp->kpc &= ~(KPC_AS); - - rel = (keycode & 0x80) ? 1 : 0; /* key release from qemu */ - keycode &= ~(0x80); /* strip qemu key release bit */ - if (kp->alt_code) { - keycode |= 0x80; - kp->alt_code = 0; - } + rel = (keycode & 0x80) ? 1 : 0; /* key release from qemu */ + keycode &= ~0x80; /* strip qemu key release bit */ + if (kp->alt_code) { + keycode |= 0x80; + kp->alt_code = 0; + } - row = kp->map[keycode].row; - col = kp->map[keycode].column; - if(row == -1 || col == -1) - return; + row = kp->map[keycode].row; + col = kp->map[keycode].column; + if (row == -1 || col == -1) { + return; + } - val = KPASMKPx_MKC(row, col); - if (rel) { - if (kp->kpasmkp[col / 2] & val) { - kp->kpasmkp[col / 2] &= ~val; - kp->pressed_cnt--; - assert_irq = 1; - } - } else { - if (!(kp->kpasmkp[col / 2] & val)) { - kp->kpasmkp[col / 2] |= val; - kp->pressed_cnt++; - assert_irq = 1; - } + val = KPASMKPx_MKC(row, col); + if (rel) { + if (kp->kpasmkp[col / 2] & val) { + kp->kpasmkp[col / 2] &= ~val; + kp->pressed_cnt--; + assert_irq = 1; } - kp->kpas = ((kp->pressed_cnt & 0x1f) << 26) | (0xf << 4) | 0xf; - if (kp->pressed_cnt == 1) { - kp->kpas &= ~((0xf << 4) | 0xf); - if (rel) - pxa27x_keypad_find_pressed_key(kp, &row, &col); - kp->kpas |= ((row & 0xf) << 4) | (col & 0xf); + } else { + if (!(kp->kpasmkp[col / 2] & val)) { + kp->kpasmkp[col / 2] |= val; + kp->pressed_cnt++; + assert_irq = 1; } - goto out; } - return; + kp->kpas = ((kp->pressed_cnt & 0x1f) << 26) | (0xf << 4) | 0xf; + if (kp->pressed_cnt == 1) { + kp->kpas &= ~((0xf << 4) | 0xf); + if (rel) { + pxa27x_keypad_find_pressed_key(kp, &row, &col); + } + kp->kpas |= ((row & 0xf) << 4) | (col & 0xf); + } + + if (!(kp->kpc & (KPC_AS | KPC_ASACT))) + assert_irq = 0; -out: if (assert_irq && (kp->kpc & KPC_MIE)) { kp->kpc |= KPC_MI; qemu_irq_raise(kp->irq); @@ -245,6 +245,9 @@ static void pxa2xx_keypad_write(void *opaque, target_phys_addr_t offset, switch (offset) { case KPC: s->kpc = value; + if (s->kpc & KPC_AS) { + s->kpc &= ~(KPC_AS); + } break; case KPDK: s->kpdk = value; diff --git a/hw/pxa2xx_lcd.c b/hw/pxa2xx_lcd.c index 5dd4ef06d6..4e9f7b48ac 100644 --- a/hw/pxa2xx_lcd.c +++ b/hw/pxa2xx_lcd.c @@ -5,6 +5,9 @@ * Written by Andrzej Zaborowski <balrog@zabor.org> * * This code is licensed under the GPLv2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "hw.h" @@ -574,7 +577,8 @@ static const MemoryRegionOps pxa2xx_lcdc_ops = { static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp) { int i, n, format, r, g, b, alpha; - uint32_t *dest, *src; + uint32_t *dest; + uint8_t *src; s->pal_for = LCCR4_PALFOR(s->control[4]); format = s->pal_for; @@ -593,7 +597,7 @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp) return; } - src = (uint32_t *) s->dma_ch[ch].pbuffer; + src = (uint8_t *) s->dma_ch[ch].pbuffer; dest = (uint32_t *) s->dma_ch[ch].palette; alpha = r = g = b = 0; @@ -601,43 +605,48 @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp) switch (format) { case 0: /* 16 bpp, no transparency */ alpha = 0; - if (s->control[0] & LCCR0_CMS) - r = g = b = *src & 0xff; + if (s->control[0] & LCCR0_CMS) { + r = g = b = *(uint16_t *) src & 0xff; + } else { - r = (*src & 0xf800) >> 8; - g = (*src & 0x07e0) >> 3; - b = (*src & 0x001f) << 3; + r = (*(uint16_t *) src & 0xf800) >> 8; + g = (*(uint16_t *) src & 0x07e0) >> 3; + b = (*(uint16_t *) src & 0x001f) << 3; } + src += 2; break; case 1: /* 16 bpp plus transparency */ - alpha = *src & (1 << 24); + alpha = *(uint16_t *) src & (1 << 24); if (s->control[0] & LCCR0_CMS) - r = g = b = *src & 0xff; + r = g = b = *(uint16_t *) src & 0xff; else { - r = (*src & 0xf800) >> 8; - g = (*src & 0x07e0) >> 3; - b = (*src & 0x001f) << 3; + r = (*(uint16_t *) src & 0xf800) >> 8; + g = (*(uint16_t *) src & 0x07e0) >> 3; + b = (*(uint16_t *) src & 0x001f) << 3; } + src += 2; break; case 2: /* 18 bpp plus transparency */ - alpha = *src & (1 << 24); + alpha = *(uint32_t *) src & (1 << 24); if (s->control[0] & LCCR0_CMS) - r = g = b = *src & 0xff; + r = g = b = *(uint32_t *) src & 0xff; else { - r = (*src & 0xf80000) >> 16; - g = (*src & 0x00fc00) >> 8; - b = (*src & 0x0000f8); + r = (*(uint32_t *) src & 0xf80000) >> 16; + g = (*(uint32_t *) src & 0x00fc00) >> 8; + b = (*(uint32_t *) src & 0x0000f8); } + src += 4; break; case 3: /* 24 bpp plus transparency */ - alpha = *src & (1 << 24); + alpha = *(uint32_t *) src & (1 << 24); if (s->control[0] & LCCR0_CMS) - r = g = b = *src & 0xff; + r = g = b = *(uint32_t *) src & 0xff; else { - r = (*src & 0xff0000) >> 16; - g = (*src & 0x00ff00) >> 8; - b = (*src & 0x0000ff); + r = (*(uint32_t *) src & 0xff0000) >> 16; + g = (*(uint32_t *) src & 0x00ff00) >> 8; + b = (*(uint32_t *) src & 0x0000ff); } + src += 4; break; } switch (ds_get_bits_per_pixel(s->ds)) { @@ -657,7 +666,6 @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp) *dest = rgb_to_pixel32(r, g, b) | alpha; break; } - src ++; dest ++; } } diff --git a/hw/pxa2xx_mmci.c b/hw/pxa2xx_mmci.c index f47c79ca4a..b505a4cc98 100644 --- a/hw/pxa2xx_mmci.c +++ b/hw/pxa2xx_mmci.c @@ -5,6 +5,9 @@ * Written by Andrzej Zaborowski <balrog@zabor.org> * * This code is licensed under the GPLv2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "hw.h" diff --git a/hw/pxa2xx_pcmcia.c b/hw/pxa2xx_pcmcia.c index dc522dcf43..b15872a9d9 100644 --- a/hw/pxa2xx_pcmcia.c +++ b/hw/pxa2xx_pcmcia.c @@ -5,6 +5,9 @@ * Written by Andrzej Zaborowski <balrog@zabor.org> * * This code is licensed under the GPLv2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "hw.h" diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 663c2a0a19..02f0dae0bc 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -680,6 +680,16 @@ static int parse_chr(DeviceState *dev, Property *prop, const char *str) return 0; } +static void free_chr(DeviceState *dev, Property *prop) +{ + CharDriverState **ptr = qdev_get_prop_ptr(dev, prop); + + if (*ptr) { + qemu_chr_add_handlers(*ptr, NULL, NULL, NULL, NULL); + } +} + + static int print_chr(DeviceState *dev, Property *prop, char *dest, size_t len) { CharDriverState **ptr = qdev_get_prop_ptr(dev, prop); @@ -699,6 +709,7 @@ PropertyInfo qdev_prop_chr = { .print = print_chr, .get = get_generic, .set = set_generic, + .free = free_chr, }; /* --- netdev device --- */ @@ -376,11 +376,6 @@ int qdev_unplug(DeviceState *dev) } assert(dev->info->unplug != NULL); - if (dev->ref != 0) { - qerror_report(QERR_DEVICE_IN_USE, dev->id?:""); - return -1; - } - qdev_hot_removed = true; return dev->info->unplug(dev); @@ -465,6 +460,29 @@ static void qdev_property_del_all(DeviceState *dev) } } +static void qdev_property_del_child(DeviceState *dev, DeviceState *child, Error **errp) +{ + DeviceProperty *prop; + + QTAILQ_FOREACH(prop, &dev->properties, node) { + if (strstart(prop->type, "child<", NULL) && prop->opaque == child) { + break; + } + } + + g_assert(prop != NULL); + + QTAILQ_REMOVE(&dev->properties, prop, node); + + if (prop->release) { + prop->release(dev, prop->name, prop->opaque); + } + + g_free(prop->name); + g_free(prop->type); + g_free(prop); +} + /* Unlink device from bus and free the structure. */ void qdev_free(DeviceState *dev) { @@ -491,6 +509,12 @@ void qdev_free(DeviceState *dev) prop->info->free(dev, prop); } } + if (dev->parent) { + qdev_property_del_child(dev->parent, dev, NULL); + } + if (dev->ref != 0) { + qerror_report(QERR_DEVICE_IN_USE, dev->id?:""); + } g_free(dev); } @@ -1239,6 +1263,14 @@ static void qdev_get_child_property(DeviceState *dev, Visitor *v, void *opaque, g_free(path); } +static void qdev_release_child_property(DeviceState *dev, const char *name, + void *opaque) +{ + DeviceState *child = opaque; + + qdev_unref(child); +} + void qdev_property_add_child(DeviceState *dev, const char *name, DeviceState *child, Error **errp) { @@ -1247,7 +1279,8 @@ void qdev_property_add_child(DeviceState *dev, const char *name, type = g_strdup_printf("child<%s>", child->info->name); qdev_property_add(dev, name, type, qdev_get_child_property, - NULL, NULL, child, errp); + NULL, qdev_release_child_property, + child, errp); qdev_ref(child); g_assert(child->parent == NULL); diff --git a/hw/realview.c b/hw/realview.c index d4191e91c8..3f35118f21 100644 --- a/hw/realview.c +++ b/hw/realview.c @@ -21,6 +21,7 @@ #include "exec-memory.h" #define SMP_BOOT_ADDR 0xe0000000 +#define SMP_BOOTREG_ADDR 0x10000030 typedef struct { SysBusDevice busdev; @@ -96,6 +97,7 @@ static void realview_register_devices(void) static struct arm_boot_info realview_binfo = { .smp_loader_start = SMP_BOOT_ADDR, + .smp_bootreg_addr = SMP_BOOTREG_ADDR, }; /* The following two lists must be consistent. */ diff --git a/hw/sh_timer.c b/hw/sh_timer.c index d2c0cec835..64bf604ba4 100644 --- a/hw/sh_timer.c +++ b/hw/sh_timer.c @@ -12,6 +12,7 @@ #include "sh.h" #include "qemu-timer.h" #include "exec-memory.h" +#include "ptimer.h" //#define DEBUG_TIMER diff --git a/hw/slavio_timer.c b/hw/slavio_timer.c index 2353c43bda..44b500a5fa 100644 --- a/hw/slavio_timer.c +++ b/hw/slavio_timer.c @@ -24,6 +24,7 @@ #include "sun4m.h" #include "qemu-timer.h" +#include "ptimer.h" #include "sysbus.h" #include "trace.h" diff --git a/hw/smbios.c b/hw/smbios.c index c9ba43e8d0..c57237d279 100644 --- a/hw/smbios.c +++ b/hw/smbios.c @@ -9,6 +9,8 @@ * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "sysemu.h" diff --git a/hw/spitz.c b/hw/spitz.c index 82a133dfa8..9d129c22b9 100644 --- a/hw/spitz.c +++ b/hw/spitz.c @@ -5,6 +5,9 @@ * Written by Andrzej Zaborowski <balrog@zabor.org> * * This code is licensed under the GNU GPL v2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "hw.h" diff --git a/hw/ssi-sd.c b/hw/ssi-sd.c index 18dabd64a6..2d89cfe522 100644 --- a/hw/ssi-sd.c +++ b/hw/ssi-sd.c @@ -5,6 +5,9 @@ * Written by Paul Brook * * This code is licensed under the GNU GPL v2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "blockdev.h" @@ -5,6 +5,9 @@ * Written by Paul Brook * * This code is licensed under the GNU GPL v2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "ssi.h" diff --git a/hw/strongarm.c b/hw/strongarm.c index 69c117906c..fe63fd7ab7 100644 --- a/hw/strongarm.c +++ b/hw/strongarm.c @@ -22,6 +22,9 @@ * * You should have received a copy of the GNU General Public License along * with this program; if not, see <http://www.gnu.org/licenses/>. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "sysbus.h" #include "strongarm.h" diff --git a/hw/sysbus.h b/hw/sysbus.h index 899756bf7f..7b8ca236bf 100644 --- a/hw/sysbus.h +++ b/hw/sysbus.h @@ -8,7 +8,7 @@ #define QDEV_MAX_MMIO 32 #define QDEV_MAX_PIO 32 -#define QDEV_MAX_IRQ 256 +#define QDEV_MAX_IRQ 512 typedef struct SysBusDevice SysBusDevice; diff --git a/hw/tc6393xb.c b/hw/tc6393xb.c index b75fa603cf..420925ccb3 100644 --- a/hw/tc6393xb.c +++ b/hw/tc6393xb.c @@ -6,6 +6,9 @@ * Most features are currently unsupported!!! * * This code is licensed under the GNU GPL v2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "hw.h" #include "devices.h" @@ -6,6 +6,9 @@ * * Code based on spitz platform by Andrzej Zaborowski <balrog@zabor.org> * This code is licensed under the GNU GPL v2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "hw.h" @@ -434,3 +434,15 @@ static inline USBBus *usb_bus_from_device(USBDevice *d) { return DO_UPCAST(USBBus, qbus, d->qdev.parent_bus); } + +extern const VMStateDescription vmstate_usb_device; + +#define VMSTATE_USB_DEVICE(_field, _state) { \ + .name = (stringify(_field)), \ + .size = sizeof(USBDevice), \ + .vmsd = &vmstate_usb_device, \ + .flags = VMS_STRUCT, \ + .offset = vmstate_offset_value(_state, _field, USBDevice), \ +} + + diff --git a/hw/vexpress.c b/hw/vexpress.c index c9ca43c89b..71115564e0 100644 --- a/hw/vexpress.c +++ b/hw/vexpress.c @@ -16,6 +16,9 @@ * * You should have received a copy of the GNU General Public License along * with this program; if not, see <http://www.gnu.org/licenses/>. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "sysbus.h" @@ -28,11 +31,13 @@ #include "exec-memory.h" #define SMP_BOOT_ADDR 0xe0000000 +#define SMP_BOOTREG_ADDR 0x10000030 #define VEXPRESS_BOARD_ID 0x8e0 static struct arm_boot_info vexpress_binfo = { .smp_loader_start = SMP_BOOT_ADDR, + .smp_bootreg_addr = SMP_BOOTREG_ADDR, }; static void vexpress_a9_init(ram_addr_t ram_size, diff --git a/hw/vhost.c b/hw/vhost.c index 19a7b5c820..4778521102 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -8,6 +8,9 @@ * * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include <sys/ioctl.h> diff --git a/hw/vhost_net.c b/hw/vhost_net.c index 950a6b8d99..f672e9dafd 100644 --- a/hw/vhost_net.c +++ b/hw/vhost_net.c @@ -8,6 +8,9 @@ * * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "net.h" diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index 5e81f53e14..5b416c36ee 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -153,6 +153,12 @@ static void virtio_blk_handle_scsi(VirtIOBlockReq *req) int status; int i; + if ((req->dev->vdev.guest_features & (1 << VIRTIO_BLK_F_SCSI)) == 0) { + virtio_blk_req_complete(req, VIRTIO_BLK_S_UNSUPP); + g_free(req); + return; + } + /* * We require at least one output segment each for the virtio_blk_outhdr * and the SCSI command block. diff --git a/hw/virtio-console.c b/hw/virtio-console.c index 73d866a52d..0b28a30b8c 100644 --- a/hw/virtio-console.c +++ b/hw/virtio-console.c @@ -125,27 +125,11 @@ static int virtconsole_initfn(VirtIOSerialPort *port) return 0; } -static int virtconsole_exitfn(VirtIOSerialPort *port) -{ - VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port); - - if (vcon->chr) { - /* - * Instead of closing the chardev, free it so it can be used - * for other purposes. - */ - qemu_chr_add_handlers(vcon->chr, NULL, NULL, NULL, NULL); - } - - return 0; -} - static VirtIOSerialPortInfo virtconsole_info = { .qdev.name = "virtconsole", .qdev.size = sizeof(VirtConsole), .is_console = true, .init = virtconsole_initfn, - .exit = virtconsole_exitfn, .have_data = flush_buf, .guest_open = guest_open, .guest_close = guest_close, @@ -165,7 +149,6 @@ static VirtIOSerialPortInfo virtserialport_info = { .qdev.name = "virtserialport", .qdev.size = sizeof(VirtConsole), .init = virtconsole_initfn, - .exit = virtconsole_exitfn, .have_data = flush_buf, .guest_open = guest_open, .guest_close = guest_close, diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 77b75bcd9a..caff0aa2eb 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -11,6 +11,8 @@ * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include <inttypes.h> diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c index 3a9004a9b8..32e46e98cb 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -13,6 +13,9 @@ * * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "iov.h" diff --git a/hw/vt82c686.c b/hw/vt82c686.c index 038128b84c..7fb88a53bf 100644 --- a/hw/vt82c686.c +++ b/hw/vt82c686.c @@ -5,6 +5,9 @@ * Copyright (c) 2009 chenming (chenming@rdc.faw.com.cn) * Copyright (c) 2010 Huacai Chen (zltjiangshi@gmail.com) * This code is licensed under the GNU GPL v2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "hw.h" diff --git a/hw/xen_backend.c b/hw/xen_backend.c index d876cabb12..2673ace185 100644 --- a/hw/xen_backend.c +++ b/hw/xen_backend.c @@ -13,6 +13,9 @@ * * You should have received a copy of the GNU General Public License along * with this program; if not, see <http://www.gnu.org/licenses/>. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ /* diff --git a/hw/xen_disk.c b/hw/xen_disk.c index 192e81746f..68fa36a1cf 100644 --- a/hw/xen_disk.c +++ b/hw/xen_disk.c @@ -14,6 +14,9 @@ * * You should have received a copy of the GNU General Public License along * with this program; if not, see <http://www.gnu.org/licenses/>. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include <stdio.h> diff --git a/hw/xen_nic.c b/hw/xen_nic.c index ef2a2d6997..9a59bdad6e 100644 --- a/hw/xen_nic.c +++ b/hw/xen_nic.c @@ -14,6 +14,9 @@ * * You should have received a copy of the GNU General Public License along * with this program; if not, see <http://www.gnu.org/licenses/>. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include <stdio.h> diff --git a/hw/xilinx_axidma.c b/hw/xilinx_axidma.c index 596ec0ed68..0da20d9565 100644 --- a/hw/xilinx_axidma.c +++ b/hw/xilinx_axidma.c @@ -25,6 +25,7 @@ #include "sysbus.h" #include "qemu-char.h" #include "qemu-timer.h" +#include "ptimer.h" #include "qemu-log.h" #include "qdev-addr.h" diff --git a/hw/xilinx_timer.c b/hw/xilinx_timer.c index 0b2f32a3af..adca53b98c 100644 --- a/hw/xilinx_timer.c +++ b/hw/xilinx_timer.c @@ -24,6 +24,7 @@ #include "sysbus.h" #include "qemu-timer.h" +#include "ptimer.h" #define D(x) @@ -6,6 +6,9 @@ * Code is based on mainstone platform. * * This code is licensed under the GNU GPL v2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #include "hw.h" |