VMState: Port several non-pc devices
PATCH 55/58 piix4: create PIIX4State
In reply to Juan QuintelaIt only contains a PCIDevice by know, but it makes easy to use migration code
--- hw/piix4.c | 29 +++++++++++++++++------------ 1 files changed, 17 insertions(+), 12 deletions(-)
hw/piix4.c +17 -12
@@ -30,10 +30,14 @@PCIDevice *piix4_dev; +typedef struct PIIX4State { +PCIDevice dev; +}PIIX4State ; +static void piix4_reset (void *opaque) { -PCIDevice *d = opaque; -uint8_t *pci_conf = d->config; +PIIX4State *d = opaque; +uint8_t *pci_conf = d->dev.config; pci_conf[0x04 ] =0x07 ;// master, memory and I/O pci_conf[0x05 ] =0x00 ;
@@ -70,31 +74,32 @@ static void piix4_reset(void *opaque)static void piix_save (QEMUFile * f,void *opaque) { -PCIDevice *d = opaque; -pci_device_save (d, f); +PIIX4State *d = opaque; +pci_device_save (&d->dev, f); }static int piix_load (QEMUFile * f,void *opaque,int version_id) { -PCIDevice *d = opaque; +PIIX4State *d = opaque;if (version_id !=2 )return -EINVAL ; -return pci_device_load (d, f); +return pci_device_load (&d->dev, f); } -static int piix4_initfn (PCIDevice *d) +static int piix4_initfn (PCIDevice *dev) { +PIIX4State *d =DO_UPCAST (PIIX4State, dev, dev);uint8_t *pci_conf; -isa_bus_new (&d->qdev); -register_savevm (&d->qdev,"PIIX4" ,0 ,2 , piix_save, piix_load, d); +isa_bus_new (&d->dev.qdev); +register_savevm (&d->dev.qdev,"PIIX4" ,0 ,2 , piix_save, piix_load, d); - pci_conf = d->config; + pci_conf = d->dev.config;pci_config_set_vendor_id (pci_conf,PCI_VENDOR_ID_INTEL );pci_config_set_device_id (pci_conf,PCI_DEVICE_ID_INTEL_82371AB_0 );// 82371AB/EB/MB PIIX4 PCI-to-ISA bridge pci_config_set_class (pci_conf,PCI_CLASS_BRIDGE_ISA ); - piix4_dev = d; + piix4_dev = &d->dev;qemu_register_reset (piix4_reset, d);return 0 ; }
@@ -111,7 +116,7 @@ static PCIDeviceInfo piix4_info[] = { { .qdev.name = "PIIX4", .qdev.desc = "ISA bridge", - .qdev.size = sizeof(PCIDevice), + .qdev.size = sizeof(PIIX4State), .qdev.no_user = 1, .no_hotplug = 1, .init = piix4_initfn,
Signature · 1 line
1.7.4
PATCH 56/58 vmstate: port piix4
In reply to Juan Quintela--- hw/piix4.c | 25 +++++++++++-------------- 1 files changed, 11 insertions(+), 14 deletions(-)
hw/piix4.c +11 -14
@@ -72,19 +72,16 @@ static void piix4_reset(void *opaque) pci_conf[0xae ] =0x00 ; } -static void piix_save (QEMUFile * f,void *opaque) -{ -PIIX4State *d = opaque; -pci_device_save (&d->dev, f); -} - -static int piix_load (QEMUFile * f,void *opaque,int version_id) -{ -PIIX4State *d = opaque; -if (version_id !=2 ) -return -EINVAL ; -return pci_device_load (&d->dev, f); -} +static const VMStateDescription vmstate_piix4 = { + .name ="PIIX4" , + .version_id =2 , + .minimum_version_id =2 , + .minimum_version_id_old =2 , + .fields = (VMStateField []) { +VMSTATE_PCI_DEVICE (dev, PIIX4State), +VMSTATE_END_OF_LIST () + } +};static int piix4_initfn (PCIDevice *dev) {
@@ -92,7 +89,6 @@ static int piix4_initfn(PCIDevice *dev)uint8_t *pci_conf;isa_bus_new (&d->dev.qdev); -register_savevm (&d->dev.qdev,"PIIX4" ,0 ,2 , piix_save, piix_load, d); pci_conf = d->dev.config;pci_config_set_vendor_id (pci_conf,PCI_VENDOR_ID_INTEL );
@@ -117,6 +113,7 @@ static PCIDeviceInfo piix4_info[] = { .qdev.name = "PIIX4", .qdev.desc = "ISA bridge", .qdev.size = sizeof(PIIX4State), + .qdev.vmsd = &vmstate_piix4, .qdev.no_user = 1, .no_hotplug = 1, .init = piix4_initfn,
Signature · 1 line
1.7.4
PATCH 57/58 mac_dbdma: create DBDMAState instead of passing one array around
In reply to Juan Quintela--- hw/mac_dbdma.c | 45 +++++++++++++++++++++++++++------------------ 1 files changed, 27 insertions(+), 18 deletions(-)
hw/mac_dbdma.c +27 -18
@@ -165,6 +165,10 @@ typedef struct DBDMA_channel {int processing; } DBDMA_channel; +typedef struct { +DBDMA_channel channels[DBDMA_CHANNELS ]; +}DBDMAState ; +#ifdef DEBUG_DBDMA static void dump_dbdma_cmd (dbdma_cmd *cmd) {
@@ -617,31 +621,34 @@ static void channel_run(DBDMA_channel *ch) } } -static void DBDMA_run (DBDMA_channel *ch) +static void DBDMA_run (DBDMAState *s) {int channel; -for (channel =0 ; channel <DBDMA_CHANNELS ; channel++, ch++) { -uint32_t status = ch->regs[DBDMA_STATUS ]; -if (!ch->processing && (status &RUN ) && (status &ACTIVE )) -channel_run (ch); +for (channel =0 ; channel <DBDMA_CHANNELS ; channel++) { +DBDMA_channel *ch = &s->channels[channel]; +uint32_t status = ch->regs[DBDMA_STATUS ]; +if (!ch->processing && (status &RUN ) && (status &ACTIVE )) { +channel_run (ch); + } } }static void DBDMA_run_bh (void *opaque) { -DBDMA_channel *ch = opaque; +DBDMAState *s = opaque;DBDMA_DPRINTF ("DBDMA_run_bh\n" ); -DBDMA_run (ch); +DBDMA_run (s); }void DBDMA_register_channel (void *dbdma,int nchan,qemu_irq irq,DBDMA_rw rw,DBDMA_flush flush,void *opaque) { -DBDMA_channel *ch = (DBDMA_channel *)dbdma + nchan; +DBDMAState *s = dbdma; +DBDMA_channel *ch = &s->channels[nchan];DBDMA_DPRINTF ("DBDMA_register_channel 0x%x\n" , nchan);
@@ -700,7 +707,8 @@ static void dbdma_writel (void *opaque, target_phys_addr_t addr, uint32_t value) { int channel = addr >> DBDMA_CHANNEL_SHIFT; -DBDMA_channel *ch = (DBDMA_channel *)opaque + channel; +DBDMAState *s = opaque; +DBDMA_channel *ch = &s->channels[channel];int reg = (addr - (channel <<DBDMA_CHANNEL_SHIFT )) >>2 ;DBDMA_DPRINTF ("writel 0x" TARGET_FMT_plx" <= 0x%08x\n" , addr, value);
@@ -749,7 +757,8 @@ static uint32_t dbdma_readl (void *opaque, target_phys_addr_t addr) {uint32_t value;int channel = addr >>DBDMA_CHANNEL_SHIFT ; -DBDMA_channel *ch = (DBDMA_channel *)opaque + channel; +DBDMAState *s = opaque; +DBDMA_channel *ch = &s->channels[channel];int reg = (addr - (channel <<DBDMA_CHANNEL_SHIFT )) >>2 ; value = ch->regs[reg];
@@ -803,17 +812,17 @@ static CPUReadMemoryFunc * const dbdma_read[] = {static void dbdma_save (QEMUFile *f,void *opaque) { -DBDMA_channel *s = opaque; +DBDMAState *s = opaque;unsigned int i, j;for (i =0 ; i <DBDMA_CHANNELS ; i++)for (j =0 ; j <DBDMA_REGS ; j++) -qemu_put_be32s (f, &s[i].regs[j]); +qemu_put_be32s (f, &s->channels[i].regs[j]); }static int dbdma_load (QEMUFile *f,void *opaque,int version_id) { -DBDMA_channel *s = opaque; +DBDMAState *s = opaque;unsigned int i, j;if (version_id !=2 )
@@ -821,25 +830,25 @@ static int dbdma_load(QEMUFile *f, void *opaque, int version_id)for (i =0 ; i <DBDMA_CHANNELS ; i++)for (j =0 ; j <DBDMA_REGS ; j++) -qemu_get_be32s (f, &s[i].regs[j]); +qemu_get_be32s (f, &s->channels[i].regs[j]);return 0 ; }static void dbdma_reset (void *opaque) { -DBDMA_channel *s = opaque; +DBDMAState *s = opaque;int i;for (i =0 ; i <DBDMA_CHANNELS ; i++) -memset (s[i].regs,0 ,DBDMA_SIZE ); +memset (s->channels[i].regs,0 ,DBDMA_SIZE ); }void *DBDMA_init (int *dbdma_mem_index) { -DBDMA_channel *s; +DBDMAState *s; - s =qemu_mallocz (sizeof (DBDMA_channel) *DBDMA_CHANNELS ); + s =qemu_mallocz (sizeof (DBDMAState)); *dbdma_mem_index =cpu_register_io_memory (dbdma_read, dbdma_write, s,DEVICE_LITTLE_ENDIAN );
Signature · 1 line
1.7.4
PATCH 58/58 vmstate: port mac_dbdma
In reply to Juan Quintela--- hw/mac_dbdma.c | 46 ++++++++++++++++++++++------------------------ 1 files changed, 22 insertions(+), 24 deletions(-)
hw/mac_dbdma.c +22 -24
@@ -810,30 +810,28 @@ static CPUReadMemoryFunc * const dbdma_read[] = { dbdma_readl, }; -static void dbdma_save (QEMUFile *f,void *opaque) -{ -DBDMAState *s = opaque; -unsigned int i, j; - -for (i =0 ; i <DBDMA_CHANNELS ; i++) -for (j =0 ; j <DBDMA_REGS ; j++) -qemu_put_be32s (f, &s->channels[i].regs[j]); -} - -static int dbdma_load (QEMUFile *f,void *opaque,int version_id) -{ -DBDMAState *s = opaque; -unsigned int i, j; - -if (version_id !=2 ) -return -EINVAL ; - -for (i =0 ; i <DBDMA_CHANNELS ; i++) -for (j =0 ; j <DBDMA_REGS ; j++) -qemu_get_be32s (f, &s->channels[i].regs[j]); +static const VMStateDescription vmstate_dbdma_channel = { + .name ="dbdma_channel" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { + VMSTATE_UINT32_ARRAY(regs, struct DBDMA_channel, DBDMA_REGS), +VMSTATE_END_OF_LIST () + } +}; -return 0 ; -} +static const VMStateDescription vmstate_dbdma = { + .name ="dbdma" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_STRUCT_ARRAY (channels, DBDMAState,DBDMA_CHANNELS ,1 , + vmstate_dbdma_channel, DBDMA_channel), +VMSTATE_END_OF_LIST () + } +};static void dbdma_reset (void *opaque) {
@@ -852,7 +850,7 @@ void* DBDMA_init (int *dbdma_mem_index) *dbdma_mem_index =cpu_register_io_memory (dbdma_read, dbdma_write, s,DEVICE_LITTLE_ENDIAN ); -register_savevm (NULL ,"dbdma" ,-1 ,1 , dbdma_save, dbdma_load, s); +vmstate_register (NULL ,-1 , &vmstate_dbdma, s);qemu_register_reset (dbdma_reset, s); dbdma_bh =qemu_bh_new (DBDMA_run_bh, s);
Signature · 1 line
1.7.4
PATCH 6/58 vmstate: add VMSTATE_STRUCT_VARRAY_UINT32
In reply to Juan Quintela--- hw/hw.h | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
hw/hw.h +10 -0
@@ -519,6 +519,16 @@ extern const VMStateInfo vmstate_info_unused_buffer; .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), \
Signature · 1 line
1.7.4
PATCH 4/58 vmstate: add VMSTATE_STRUCT_VARRAY_INT32
In reply to Juan Quintela--- hw/hw.h | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
hw/hw.h +11 -0
@@ -508,6 +508,17 @@ extern const VMStateInfo vmstate_info_unused_buffer; .offset = offsetof(_state, _field), \ } + +#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_STATIC_BUFFER (_field, _state, _version, _test, _start, _size) { \ .name = (stringify(_field)), \ .version_id = (_version), \
Signature · 1 line
1.7.4
PATCH 13/58 vmstate: port m48t59
In reply to Juan Quintela--- hw/m48t59.c | 36 +++++++++++++----------------------- 1 files changed, 13 insertions(+), 23 deletions(-)
hw/m48t59.c +13 -23
@@ -585,28 +585,18 @@ static CPUReadMemoryFunc * const nvram_read[] = { &nvram_readl, }; -static void m48t59_save (QEMUFile *f,void *opaque) -{ -M48t59State *s = opaque; - -qemu_put_8s (f, &s->lock); -qemu_put_be16s (f, &s->addr); -qemu_put_buffer (f, s->buffer, s->size); -} - -static int m48t59_load (QEMUFile *f,void *opaque,int version_id) -{ -M48t59State *s = opaque; - -if (version_id !=1 ) -return -EINVAL ; - -qemu_get_8s (f, &s->lock); -qemu_get_be16s (f, &s->addr); -qemu_get_buffer (f, s->buffer, s->size); - -return 0 ; -} +static const VMStateDescription vmstate_m48t59 = { + .name ="m48t59" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_UINT8 (lock, M48t59State), +VMSTATE_UINT16 (addr, M48t59State), +VMSTATE_VBUFFER_UINT32 (buffer, M48t59State,0 ,NULL ,0 , size), +VMSTATE_END_OF_LIST () + } +};static void m48t59_reset_common (M48t59State *NVRAM ) {
@@ -696,7 +686,7 @@ static void m48t59_init_common(M48t59State *s) }qemu_get_timedate (&s->alarm,0 ); -register_savevm (NULL ,"m48t59" ,-1 ,1 , m48t59_save, m48t59_load, s); +vmstate_register (NULL ,-1 , &vmstate_m48t59, s); }static int m48t59_init_isa1 (ISADevice *dev)
Signature · 1 line
1.7.4
PATCH 25/58 vmstate: port stellaris ssi bus
In reply to Juan Quintela--- hw/stellaris.c | 31 +++++++++++-------------------- 1 files changed, 11 insertions(+), 20 deletions(-)
hw/stellaris.c +11 -20
@@ -1219,24 +1219,16 @@ static uint32_t stellaris_ssi_bus_transfer(SSISlave *dev, uint32_t val)return ssi_transfer (s->bus[s->current_dev], val); } -static void stellaris_ssi_bus_save (QEMUFile *f,void *opaque) -{ -stellaris_ssi_bus_state *s = (stellaris_ssi_bus_state *)opaque; - -qemu_put_be32 (f, s->current_dev); -} - -static int stellaris_ssi_bus_load (QEMUFile *f,void *opaque,int version_id) -{ -stellaris_ssi_bus_state *s = (stellaris_ssi_bus_state *)opaque; - -if (version_id !=1 ) -return -EINVAL ; - - s->current_dev =qemu_get_be32 (f); - -return 0 ; -} +static const VMStateDescription vmstate_stellaris_ssi_bus = { + .name ="stellaris_ssi_bus" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_INT32 (current_dev, stellaris_ssi_bus_state), +VMSTATE_END_OF_LIST () + } +};static int stellaris_ssi_bus_init (SSISlave *dev) {
@@ -1246,8 +1238,7 @@ static int stellaris_ssi_bus_init(SSISlave *dev) s->bus[1 ] =ssi_create_bus (&dev->qdev,"ssi1" );qdev_init_gpio_in (&dev->qdev, stellaris_ssi_bus_select,1 ); -register_savevm (&dev->qdev,"stellaris_ssi_bus" ,-1 ,1 , - stellaris_ssi_bus_save, stellaris_ssi_bus_load, s); +vmstate_register (&dev->qdev,-1 , &vmstate_stellaris_ssi_bus, s);return 0 ; }
Signature · 1 line
1.7.4
PATCH 10/58 vmstate: port adb_kbd
In reply to Juan Quintela--- hw/adb.c | 40 ++++++++++++++-------------------------- 1 files changed, 14 insertions(+), 26 deletions(-)
hw/adb.c +14 -26
@@ -261,30 +261,19 @@ static int adb_kbd_request(ADBDevice *d, uint8_t *obuf,return olen; } -static void adb_kbd_save (QEMUFile *f,void *opaque) -{ -KBDState *s = (KBDState *)opaque; - -qemu_put_buffer (f, s->data,sizeof (s->data)); -qemu_put_sbe32s (f, &s->rptr); -qemu_put_sbe32s (f, &s->wptr); -qemu_put_sbe32s (f, &s->count); -} - -static int adb_kbd_load (QEMUFile *f,void *opaque,int version_id) -{ -KBDState *s = (KBDState *)opaque; - -if (version_id !=1 ) -return -EINVAL ; - -qemu_get_buffer (f, s->data,sizeof (s->data)); -qemu_get_sbe32s (f, &s->rptr); -qemu_get_sbe32s (f, &s->wptr); -qemu_get_sbe32s (f, &s->count); - -return 0 ; -} +static const VMStateDescription vmstate_adb_kbd = { + .name ="adb_kbd" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_BUFFER (data, KBDState), +VMSTATE_INT32 (rptr, KBDState), +VMSTATE_INT32 (wptr, KBDState), +VMSTATE_INT32 (count, KBDState), +VMSTATE_END_OF_LIST () + } +};static int adb_kbd_reset (ADBDevice *d) {
@@ -305,8 +294,7 @@ void adb_kbd_init(ADBBusState *bus) d =adb_register_device (bus,ADB_KEYBOARD , adb_kbd_request, adb_kbd_reset, s);qemu_add_kbd_event_handler (adb_kbd_put_keycode, d); -register_savevm (NULL ,"adb_kbd" ,-1 ,1 , adb_kbd_save, - adb_kbd_load, s); +vmstate_register (NULL ,-1 , &vmstate_adb_kbd, s); }/***************************************************************/
Signature · 1 line
1.7.4
PATCH 17/58 vmstate: port sysborg_timer
In reply to Juan Quintela--- hw/syborg_timer.c | 46 ++++++++++++++++------------------------------ 1 files changed, 16 insertions(+), 30 deletions(-)
hw/syborg_timer.c +16 -30
@@ -174,34 +174,21 @@ static CPUWriteMemoryFunc * const syborg_timer_writefn[] = { syborg_timer_write }; -static void syborg_timer_save (QEMUFile *f,void *opaque) -{ -SyborgTimerState *s = opaque; - -qemu_put_be32 (f, s->running); -qemu_put_be32 (f, s->oneshot); -qemu_put_be32 (f, s->limit); -qemu_put_be32 (f, s->int_level); -qemu_put_be32 (f, s->int_enabled); -qemu_put_ptimer (f, s->timer); -} - -static int syborg_timer_load (QEMUFile *f,void *opaque,int version_id) -{ -SyborgTimerState *s = opaque; - -if (version_id !=1 ) -return -EINVAL ; - - s->running =qemu_get_be32 (f); - s->oneshot =qemu_get_be32 (f); - s->limit =qemu_get_be32 (f); - s->int_level =qemu_get_be32 (f); - s->int_enabled =qemu_get_be32 (f); -qemu_get_ptimer (f, s->timer); - -return 0 ; -} +static const VMStateDescription vmstate_syborg_timer = { + .name ="syborg_timer" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_INT32 (running, SyborgTimerState), +VMSTATE_INT32 (oneshot, SyborgTimerState), +VMSTATE_UINT32 (limit, SyborgTimerState), +VMSTATE_UINT32 (int_level, SyborgTimerState), +VMSTATE_UINT32 (int_enabled, SyborgTimerState), +VMSTATE_PTIMER (timer, SyborgTimerState), +VMSTATE_END_OF_LIST () + } +};static int syborg_timer_init (SysBusDevice *dev) {
@@ -222,8 +209,7 @@ static int syborg_timer_init(SysBusDevice *dev) bh =qemu_bh_new (syborg_timer_tick, s); s->timer =ptimer_init (bh);ptimer_set_freq (s->timer, s->freq); -register_savevm (&dev->qdev,"syborg_timer" ,-1 ,1 , - syborg_timer_save, syborg_timer_load, s); +vmstate_register (&dev->qdev,-1 , &vmstate_syborg_timer, s);return 0 ; }
Signature · 1 line
1.7.4
PATCH 34/58 vmstate: port pxa2xx_pm
In reply to Juan Quintela--- hw/pxa2xx.c | 33 ++++++++++++--------------------- 1 files changed, 12 insertions(+), 21 deletions(-)
hw/pxa2xx.c +12 -21
@@ -147,25 +147,16 @@ static CPUWriteMemoryFunc * const pxa2xx_pm_writefn[] = { pxa2xx_pm_write, }; -static void pxa2xx_pm_save (QEMUFile *f,void *opaque) -{ -PXA2xxState *s = (PXA2xxState *) opaque; -int i; - -for (i =0 ; i <0x40 ; i ++) -qemu_put_be32s (f, &s->pm_regs[i]); -} - -static int pxa2xx_pm_load (QEMUFile *f,void *opaque,int version_id) -{ -PXA2xxState *s = (PXA2xxState *) opaque; -int i; - -for (i =0 ; i <0x40 ; i ++) -qemu_get_be32s (f, &s->pm_regs[i]); - -return 0 ; -} +static const VMStateDescription vmstate_pxa2xx_pm = { + .name ="pxa2xx_pm" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { +VMSTATE_UINT32_ARRAY (pm_regs, PXA2xxState,0x40 ), +VMSTATE_END_OF_LIST () + } +};#define CCCR 0x00/* Core Clock Configuration register */ #define CKEN 0x04/* Clock Enable register */
@@ -2115,7 +2106,7 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision) iomemtype =cpu_register_io_memory (pxa2xx_pm_readfn, pxa2xx_pm_writefn, s,DEVICE_NATIVE_ENDIAN );cpu_register_physical_memory (s->pm_base,0x100 , iomemtype); -register_savevm (NULL ,"pxa2xx_pm" ,0 ,0 , pxa2xx_pm_save, pxa2xx_pm_load, s); +vmstate_register (NULL ,0 , &vmstate_pxa2xx_pm, s);for (i =0 ; pxa27x_ssp[i].io_base; i ++); s->ssp = (SSIBus **)qemu_mallocz (sizeof (SSIBus *) * i);
@@ -2238,7 +2229,7 @@ PXA2xxState *pxa255_init(unsigned int sdram_size) iomemtype =cpu_register_io_memory (pxa2xx_pm_readfn, pxa2xx_pm_writefn, s,DEVICE_NATIVE_ENDIAN );cpu_register_physical_memory (s->pm_base,0x100 , iomemtype); -register_savevm (NULL ,"pxa2xx_pm" ,0 ,0 , pxa2xx_pm_save, pxa2xx_pm_load, s); +vmstate_register (NULL ,0 , &vmstate_pxa2xx_pm, s);for (i =0 ; pxa255_ssp[i].io_base; i ++); s->ssp = (SSIBus **)qemu_mallocz (sizeof (SSIBus *) * i);
Signature · 1 line
1.7.4
PATCH 50/58 vmstate: port max111x
In reply to Juan Quintela--- hw/max111x.c | 49 +++++++++++++++++-------------------------------- 1 files changed, 17 insertions(+), 32 deletions(-)
hw/max111x.c +17 -32
@@ -94,36 +94,22 @@ static uint32_t max111x_transfer(SSISlave *dev, uint32_t value)return max111x_read (s); } -static void max111x_save (QEMUFile *f,void *opaque) -{ -MAX111xState *s = (MAX111xState *) opaque; -int i; - -qemu_put_8s (f, &s->tb1); -qemu_put_8s (f, &s->rb2); -qemu_put_8s (f, &s->rb3); -qemu_put_be32 (f, s->inputs); -qemu_put_be32 (f, s->com); -for (i =0 ; i < s->inputs; i ++) -qemu_put_byte (f, s->input[i]); -} - -static int max111x_load (QEMUFile *f,void *opaque,int version_id) -{ -MAX111xState *s = (MAX111xState *) opaque; -int i; - -qemu_get_8s (f, &s->tb1); -qemu_get_8s (f, &s->rb2); -qemu_get_8s (f, &s->rb3); -if (s->inputs !=qemu_get_be32 (f)) -return -EINVAL ; - s->com =qemu_get_be32 (f); -for (i =0 ; i < s->inputs; i ++) - s->input[i] =qemu_get_byte (f); - -return 0 ; -} +static const VMStateDescription vmstate_max111x = { + .name ="max111x" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { +VMSTATE_UINT8 (tb1, MAX111xState), +VMSTATE_UINT8 (rb2, MAX111xState), +VMSTATE_UINT8 (rb3, MAX111xState), +VMSTATE_INT32 (inputs, MAX111xState), +VMSTATE_INT32 (com, MAX111xState), +VMSTATE_ARRAY_INT32_UNSAFE (input, MAX111xState, inputs, + vmstate_info_uint8, uint8_t), +VMSTATE_END_OF_LIST () + } +};static int max111x_init (SSISlave *dev,int inputs) {
@@ -143,8 +129,7 @@ static int max111x_init(SSISlave *dev, int inputs) s->input[7 ] =0x80 ; s->com =0 ; -register_savevm (&dev->qdev,"max111x" ,-1 ,0 , - max111x_save, max111x_load, s); +vmstate_register (&dev->qdev,-1 , &vmstate_max111x, s);return 0 ; }
Signature · 1 line
1.7.4
PATCH 40/58 vmstate: port syborg_serial
In reply to Juan Quintela--- hw/syborg_serial.c | 60 +++++++++++++++------------------------------------ 1 files changed, 18 insertions(+), 42 deletions(-)
hw/syborg_serial.c +18 -42
@@ -273,47 +273,24 @@ static CPUWriteMemoryFunc * const syborg_serial_writefn[] = { syborg_serial_write }; -static void syborg_serial_save (QEMUFile *f,void *opaque) -{ -SyborgSerialState *s = opaque; -int i; - -qemu_put_be32 (f, s->fifo_size); -qemu_put_be32 (f, s->int_enable); -qemu_put_be32 (f, s->read_pos); -qemu_put_be32 (f, s->read_count); -qemu_put_be32 (f, s->dma_tx_ptr); -qemu_put_be32 (f, s->dma_rx_ptr); -qemu_put_be32 (f, s->dma_rx_size); -for (i =0 ; i < s->fifo_size; i++) { -qemu_put_be32 (f, s->read_fifo[i]); - } -} - -static int syborg_serial_load (QEMUFile *f,void *opaque,int version_id) -{ -SyborgSerialState *s = opaque; -int i; - -if (version_id !=1 ) -return -EINVAL ; - - i =qemu_get_be32 (f); -if (s->fifo_size != i) -return -EINVAL ; - - s->int_enable =qemu_get_be32 (f); - s->read_pos =qemu_get_be32 (f); - s->read_count =qemu_get_be32 (f); - s->dma_tx_ptr =qemu_get_be32 (f); - s->dma_rx_ptr =qemu_get_be32 (f); - s->dma_rx_size =qemu_get_be32 (f); -for (i =0 ; i < s->fifo_size; i++) { - s->read_fifo[i] =qemu_get_be32 (f); +static const VMStateDescription vmstate_syborg_serial = { + .name ="syborg_serial" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_UINT32_EQUAL (fifo_size, SyborgSerialState), +VMSTATE_UINT32 (int_enable, SyborgSerialState), +VMSTATE_INT32 (read_pos, SyborgSerialState), +VMSTATE_INT32 (read_count, SyborgSerialState), +VMSTATE_UINT32 (dma_tx_ptr, SyborgSerialState), +VMSTATE_UINT32 (dma_rx_ptr, SyborgSerialState), +VMSTATE_UINT32 (dma_rx_size, SyborgSerialState), +VMSTATE_VARRAY_UINT32 (read_fifo, SyborgSerialState, fifo_size,1 , + vmstate_info_uint32, uint32), +VMSTATE_END_OF_LIST () } - -return 0 ; -} +};static int syborg_serial_init (SysBusDevice *dev) {
@@ -336,8 +313,6 @@ static int syborg_serial_init(SysBusDevice *dev) } s->read_fifo =qemu_mallocz (s->fifo_size *sizeof (s->read_fifo[0 ])); -register_savevm (&dev->qdev,"syborg_serial" ,-1 ,1 , - syborg_serial_save, syborg_serial_load, s);return 0 ; }
@@ -345,6 +320,7 @@ static SysBusDeviceInfo syborg_serial_info = { .init = syborg_serial_init, .qdev.name = "syborg,serial", .qdev.size = sizeof(SyborgSerialState), + .qdev.vmsd = &vmstate_syborg_serial, .qdev.props = (Property []) {DEFINE_PROP_UINT32 ("fifo-size" , SyborgSerialState, fifo_size,16 ),DEFINE_PROP_END_OF_LIST (),
Signature · 1 line
1.7.4
PATCH 19/58 vmstate: port syborg_rtc
In reply to Juan Quintela--- hw/syborg_rtc.c | 34 ++++++++++++---------------------- 1 files changed, 12 insertions(+), 22 deletions(-)
hw/syborg_rtc.c +12 -22
@@ -102,26 +102,17 @@ static CPUWriteMemoryFunc * const syborg_rtc_writefn[] = { syborg_rtc_write }; -static void syborg_rtc_save (QEMUFile *f,void *opaque) -{ -SyborgRTCState *s = opaque; - -qemu_put_be64 (f, s->offset); -qemu_put_be64 (f, s->data); -} - -static int syborg_rtc_load (QEMUFile *f,void *opaque,int version_id) -{ -SyborgRTCState *s = opaque; - -if (version_id !=1 ) -return -EINVAL ; - - s->offset =qemu_get_be64 (f); - s->data =qemu_get_be64 (f); - -return 0 ; -} +static const VMStateDescription vmstate_syborg_rtc = { + .name ="syborg_keyboard" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_INT64 (offset, SyborgRTCState), +VMSTATE_INT64 (data, SyborgRTCState), +VMSTATE_END_OF_LIST () + } +};static int syborg_rtc_init (SysBusDevice *dev) {
@@ -137,8 +128,7 @@ static int syborg_rtc_init(SysBusDevice *dev)qemu_get_timedate (&tm,0 ); s->offset = (uint64_t )mktime (&tm) *1000000000 ; -register_savevm (&dev->qdev,"syborg_rtc" ,-1 ,1 , - syborg_rtc_save, syborg_rtc_load, s); +vmstate_register (&dev->qdev,-1 , &vmstate_syborg_rtc, s);return 0 ; }
Signature · 1 line
1.7.4
PATCH 38/58 vmstate: port syborg_pointer
In reply to Juan Quintela--- hw/syborg_pointer.c | 73 +++++++++++++++++++------------------------------- 1 files changed, 28 insertions(+), 45 deletions(-)
hw/syborg_pointer.c +28 -45
@@ -152,52 +152,36 @@ static void syborg_pointer_event(void *opaque, int dx, int dy, int dz,syborg_pointer_update (s); } -static void syborg_pointer_save (QEMUFile *f,void *opaque) -{ -SyborgPointerState *s = (SyborgPointerState *)opaque; -int i; - -qemu_put_be32 (f, s->fifo_size); -qemu_put_be32 (f, s->absolute); -qemu_put_be32 (f, s->int_enabled); -qemu_put_be32 (f, s->read_pos); -qemu_put_be32 (f, s->read_count); -for (i =0 ; i < s->fifo_size; i++) { -qemu_put_be32 (f, s->event_fifo[i].x); -qemu_put_be32 (f, s->event_fifo[i].y); -qemu_put_be32 (f, s->event_fifo[i].z); -qemu_put_be32 (f, s->event_fifo[i].pointer_buttons); +static const VMStateDescription vmstate_event_data = { + .name ="dbma_channel" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { +VMSTATE_INT32 (x, event_data), +VMSTATE_INT32 (y, event_data), +VMSTATE_INT32 (z, event_data), +VMSTATE_INT32 (pointer_buttons, event_data), +VMSTATE_END_OF_LIST () } -} +}; -static int syborg_pointer_load (QEMUFile *f,void *opaque,int version_id) -{ -SyborgPointerState *s = (SyborgPointerState *)opaque; -uint32_t val; -int i; - -if (version_id !=1 ) -return -EINVAL ; - - val =qemu_get_be32 (f); -if (val != s->fifo_size) -return -EINVAL ; - - val =qemu_get_be32 (f); -if (val != s->absolute) -return -EINVAL ; - - s->int_enabled =qemu_get_be32 (f); - s->read_pos =qemu_get_be32 (f); - s->read_count =qemu_get_be32 (f); -for (i =0 ; i < s->fifo_size; i++) { - s->event_fifo[i].x =qemu_get_be32 (f); - s->event_fifo[i].y =qemu_get_be32 (f); - s->event_fifo[i].z =qemu_get_be32 (f); - s->event_fifo[i].pointer_buttons =qemu_get_be32 (f); +static const VMStateDescription vmstate_syborg_pointer = { + .name ="syborg_pointer" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_UINT32_EQUAL (fifo_size, SyborgPointerState), +VMSTATE_UINT32_EQUAL (absolute, SyborgPointerState), +VMSTATE_INT32 (int_enabled, SyborgPointerState), +VMSTATE_INT32 (read_pos, SyborgPointerState), +VMSTATE_INT32 (read_count, SyborgPointerState), +VMSTATE_STRUCT_VARRAY_UINT32 (event_fifo, SyborgPointerState, fifo_size, +1 , vmstate_event_data, event_data), +VMSTATE_END_OF_LIST () } -return 0 ; -} +};static int syborg_pointer_init (SysBusDevice *dev) {
@@ -219,8 +203,7 @@ static int syborg_pointer_init(SysBusDevice *dev)qemu_add_mouse_event_handler (syborg_pointer_event, s, s->absolute,"Syborg Pointer" ); -register_savevm (&dev->qdev,"syborg_pointer" ,-1 ,1 , - syborg_pointer_save, syborg_pointer_load, s); +vmstate_register (&dev->qdev,-1 , &vmstate_syborg_pointer, s);return 0 ; }
Signature · 1 line
1.7.4
PATCH 37/58 vmstate: port ppc4xx_pci
In reply to Juan Quintela--- hw/ppc4xx_pci.c | 80 ++++++++++++++++++++++++++---------------------------- 1 files changed, 39 insertions(+), 41 deletions(-)
hw/ppc4xx_pci.c +39 -41
@@ -285,50 +285,48 @@ static void ppc4xx_pci_set_irq(void *opaque, int irq_num, int level)qemu_set_irq (pci_irqs[irq_num], level); } -static void ppc4xx_pci_save (QEMUFile *f,void *opaque) -{ -PPC4xxPCIState *controller = opaque; -int i; - -pci_device_save (controller->pci_dev, f); - -for (i =0 ; i < PPC4xx_PCI_NR_PMMS; i++) { -qemu_put_be32s (f, &controller->pmm[i].la); -qemu_put_be32s (f, &controller->pmm[i].ma); -qemu_put_be32s (f, &controller->pmm[i].pcila); -qemu_put_be32s (f, &controller->pmm[i].pciha); - } - -for (i =0 ; i < PPC4xx_PCI_NR_PTMS; i++) { -qemu_put_be32s (f, &controller->ptm[i].ms); -qemu_put_be32s (f, &controller->ptm[i].la); +static const VMStateDescription vmstate_pci_master_map = { + .name ="pci_master_map" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { + VMSTATE_UINT32(la, struct PCIMasterMap), + VMSTATE_UINT32(ma, struct PCIMasterMap), + VMSTATE_UINT32(pcila, struct PCIMasterMap), + VMSTATE_UINT32(pciha, struct PCIMasterMap), +VMSTATE_END_OF_LIST () } -} - -static int ppc4xx_pci_load (QEMUFile *f,void *opaque,int version_id) -{ -PPC4xxPCIState *controller = opaque; -int i; - -if (version_id !=1 ) -return -EINVAL ; - -pci_device_load (controller->pci_dev, f); +}; -for (i =0 ; i < PPC4xx_PCI_NR_PMMS; i++) { -qemu_get_be32s (f, &controller->pmm[i].la); -qemu_get_be32s (f, &controller->pmm[i].ma); -qemu_get_be32s (f, &controller->pmm[i].pcila); -qemu_get_be32s (f, &controller->pmm[i].pciha); +static const VMStateDescription vmstate_pci_target_map = { + .name ="pci_target_map" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { + VMSTATE_UINT32(ms, struct PCITargetMap), + VMSTATE_UINT32(la, struct PCITargetMap), +VMSTATE_END_OF_LIST () } +}; -for (i =0 ; i < PPC4xx_PCI_NR_PTMS; i++) { -qemu_get_be32s (f, &controller->ptm[i].ms); -qemu_get_be32s (f, &controller->ptm[i].la); +static const VMStateDescription vmstate_ppc4xx_pci = { + .name ="ppc4xx_pci" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_PCI_DEVICE_POINTER (pci_dev, PPC4xxPCIState), +VMSTATE_STRUCT_ARRAY (pmm, PPC4xxPCIState, PPC4xx_PCI_NR_PMMS,1 , + vmstate_pci_master_map, + struct PCIMasterMap), +VMSTATE_STRUCT_ARRAY (ptm, PPC4xxPCIState, PPC4xx_PCI_NR_PTMS,1 , + vmstate_pci_target_map, + struct PCITargetMap), +VMSTATE_END_OF_LIST () } - -return 0 ; -} +};/* XXX Interrupt acknowledge cycles not supported. */ PCIBus *ppc4xx_pci_init(CPUState *env, qemu_irq pci_irqs[4],
@@ -381,8 +379,8 @@ PCIBus *ppc4xx_pci_init(CPUState *env, qemu_irq pci_irqs[4],qemu_register_reset (ppc4xx_pci_reset, controller);/* XXX load/save code not tested. */ -register_savevm (&controller->pci_dev->qdev,"ppc4xx_pci" , ppc4xx_pci_id++, -1 , ppc4xx_pci_save, ppc4xx_pci_load, controller); +vmstate_register (&controller->pci_dev->qdev, ppc4xx_pci_id++, + &vmstate_ppc4xx_pci, controller);return controller->pci_state.bus;
Signature · 1 line
1.7.4
PATCH 36/58 vmstate: port ppce500_pci
In reply to Juan Quintela--- hw/ppce500_pci.c | 87 +++++++++++++++++++++++++----------------------------- 1 files changed, 40 insertions(+), 47 deletions(-)
hw/ppce500_pci.c +40 -47
@@ -216,56 +216,49 @@ static void mpc85xx_pci_set_irq(void *opaque, int irq_num, int level)qemu_set_irq (pic[irq_num], level); } -static void ppce500_pci_save (QEMUFile *f,void *opaque) -{ -PPCE500PCIState *controller = opaque; -int i; - -pci_device_save (controller->pci_dev, f); - -for (i =0 ; i <PPCE500_PCI_NR_POBS ; i++) { -qemu_put_be32s (f, &controller->pob[i].potar); -qemu_put_be32s (f, &controller->pob[i].potear); -qemu_put_be32s (f, &controller->pob[i].powbar); -qemu_put_be32s (f, &controller->pob[i].powar); - } - -for (i =0 ; i <PPCE500_PCI_NR_PIBS ; i++) { -qemu_put_be32s (f, &controller->pib[i].pitar); -qemu_put_be32s (f, &controller->pib[i].piwbar); -qemu_put_be32s (f, &controller->pib[i].piwbear); -qemu_put_be32s (f, &controller->pib[i].piwar); +static const VMStateDescription vmstate_pci_outbound = { + .name ="pci_outbound" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { + VMSTATE_UINT32(potar, struct pci_outbound), + VMSTATE_UINT32(potear, struct pci_outbound), + VMSTATE_UINT32(powbar, struct pci_outbound), + VMSTATE_UINT32(powar, struct pci_outbound), +VMSTATE_END_OF_LIST () } -qemu_put_be32s (f, &controller->gasket_time); -} - -static int ppce500_pci_load (QEMUFile *f,void *opaque,int version_id) -{ -PPCE500PCIState *controller = opaque; -int i; - -if (version_id !=1 ) -return -EINVAL ; - -pci_device_load (controller->pci_dev, f); +}; -for (i =0 ; i <PPCE500_PCI_NR_POBS ; i++) { -qemu_get_be32s (f, &controller->pob[i].potar); -qemu_get_be32s (f, &controller->pob[i].potear); -qemu_get_be32s (f, &controller->pob[i].powbar); -qemu_get_be32s (f, &controller->pob[i].powar); +static const VMStateDescription vmstate_pci_inbound = { + .name ="pci_inbound" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { + VMSTATE_UINT32(pitar, struct pci_inbound), + VMSTATE_UINT32(piwbar, struct pci_inbound), + VMSTATE_UINT32(piwbear, struct pci_inbound), + VMSTATE_UINT32(piwar, struct pci_inbound), +VMSTATE_END_OF_LIST () } +}; -for (i =0 ; i <PPCE500_PCI_NR_PIBS ; i++) { -qemu_get_be32s (f, &controller->pib[i].pitar); -qemu_get_be32s (f, &controller->pib[i].piwbar); -qemu_get_be32s (f, &controller->pib[i].piwbear); -qemu_get_be32s (f, &controller->pib[i].piwar); +static const VMStateDescription vmstate_ppce500_pci = { + .name ="ppce500_pci" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_PCI_DEVICE_POINTER (pci_dev, PPCE500PCIState), +VMSTATE_STRUCT_ARRAY (pob, PPCE500PCIState,PPCE500_PCI_NR_POBS ,1 , + vmstate_pci_outbound, struct pci_outbound), +VMSTATE_STRUCT_ARRAY (pib, PPCE500PCIState,PPCE500_PCI_NR_PIBS ,1 , + vmstate_pci_outbound, struct pci_inbound), +VMSTATE_UINT32 (gasket_time, PPCE500PCIState), +VMSTATE_END_OF_LIST () } -qemu_get_be32s (f, &controller->gasket_time); - -return 0 ; -} +};PCIBus *ppce500_pci_init (qemu_irq pci_irqs[4 ],target_phys_addr_t registers) {
@@ -314,8 +307,8 @@ PCIBus *ppce500_pci_init(qemu_irq pci_irqs[4], target_phys_addr_t registers) PCIE500_REG_SIZE, index);/* XXX load/save code not tested. */ -register_savevm (&d->qdev,"ppce500_pci" , ppce500_pci_id++, -1 , ppce500_pci_save, ppce500_pci_load, controller); +vmstate_register (&d->qdev, ppce500_pci_id++, &vmstate_ppce500_pci, + controller);return controller->pci_state.bus;
Signature · 1 line
1.7.4
PATCH 52/58 vmstate: port nand
In reply to Juan Quintela--- hw/nand.c | 73 ++++++++++++++++++++++++++++++++---------------------------- 1 files changed, 39 insertions(+), 34 deletions(-)
hw/nand.c +39 -34
@@ -66,6 +66,8 @@ struct NANDFlashState {void (*blk_write)(NANDFlashState *s);void (*blk_erase)(NANDFlashState *s);void (*blk_load)(NANDFlashState *s,uint32_t addr,int offset); + +uint32_t ioaddr_vmstate; };# define NAND_NO_AUTOINCR 0x00000001
@@ -281,48 +283,51 @@ static void nand_command(NANDFlashState *s) } } -static void nand_save (QEMUFile *f,void *opaque) +static void nand_pre_save (void *opaque) { -NANDFlashState *s = (NANDFlashState *) opaque; -qemu_put_byte (f, s->cle); -qemu_put_byte (f, s->ale); -qemu_put_byte (f, s->ce); -qemu_put_byte (f, s->wp); -qemu_put_byte (f, s->gnd); -qemu_put_buffer (f, s->io,sizeof (s->io)); -qemu_put_be32 (f, s->ioaddr - s->io); -qemu_put_be32 (f, s->iolen); - -qemu_put_be32s (f, &s->cmd); -qemu_put_be32s (f, &s->addr); -qemu_put_be32 (f, s->addrlen); -qemu_put_be32 (f, s->status); -qemu_put_be32 (f, s->offset); -/* XXX: do we want to save s->storage too? */ +NANDFlashState *s = opaque; + + s->ioaddr_vmstate = s->ioaddr - s->io; } -static int nand_load (QEMUFile *f,void *opaque,int version_id) +static int nand_post_load (void *opaque,int version_id) { -NANDFlashState *s = (NANDFlashState *) opaque; - s->cle =qemu_get_byte (f); - s->ale =qemu_get_byte (f); - s->ce =qemu_get_byte (f); - s->wp =qemu_get_byte (f); - s->gnd =qemu_get_byte (f); -qemu_get_buffer (f, s->io,sizeof (s->io)); - s->ioaddr = s->io +qemu_get_be32 (f); - s->iolen =qemu_get_be32 (f); -if (s->ioaddr >= s->io +sizeof (s->io) || s->ioaddr < s->io) +NANDFlashState *s = opaque; + +if (s->ioaddr_vmstate >sizeof (s->io)) {return -EINVAL ; + } + s->ioaddr = s->io + s->ioaddr_vmstate; -qemu_get_be32s (f, &s->cmd); -qemu_get_be32s (f, &s->addr); - s->addrlen =qemu_get_be32 (f); - s->status =qemu_get_be32 (f); - s->offset =qemu_get_be32 (f);return 0 ; } +static const VMStateDescription vmstate_nand = { + .name ="nand" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .pre_save = nand_pre_save, + .post_load = nand_post_load, + .fields = (VMStateField []) { +VMSTATE_UINT8 (cle, NANDFlashState), +VMSTATE_UINT8 (ale, NANDFlashState), +VMSTATE_UINT8 (ce, NANDFlashState), +VMSTATE_UINT8 (wp, NANDFlashState), +VMSTATE_UINT8 (gnd, NANDFlashState), +VMSTATE_BUFFER (io, NANDFlashState), +VMSTATE_UINT32 (ioaddr_vmstate, NANDFlashState), +VMSTATE_INT32 (iolen, NANDFlashState), +VMSTATE_UINT32 (cmd, NANDFlashState), +VMSTATE_UINT32 (addr, NANDFlashState), +VMSTATE_INT32 (addrlen, NANDFlashState), +VMSTATE_INT32 (status, NANDFlashState), +VMSTATE_INT32 (offset, NANDFlashState), +/* XXX: do we want to save s->storage too? */ +VMSTATE_END_OF_LIST () + } +}; +/* * Chip inputs are CLE, ALE, CE, WP, GND and eight I/O pins. Chip * outputs are R/B and eight I/O pins.
@@ -502,7 +507,7 @@ NANDFlashState *nand_init(int manf_id, int chip_id)is used. */ s->ioaddr = s->io; -register_savevm (NULL ,"nand" ,-1 ,0 , nand_save, nand_load, s); +vmstate_register (NULL ,-1 , &vmstate_nand, s);return s; }
Signature · 1 line
1.7.4
PATCH 18/58 vmstate: port pmtimer
In reply to Juan QuintelaIt was a half conversion. Finish it.
enabled can only get values of 0, 1 or 2, was declared as an int but sent as an unint8_t, change its type.
--- hw/hw.h | 17 ++++++++++----- hw/ptimer.c | 59 +++++++++++++++------------------------------------------ qemu-timer.h | 2 - 3 files changed, 27 insertions(+), 51 deletions(-)
hw/hw.h +11 -6
@@ -669,6 +669,17 @@ extern const VMStateDescription vmstate_usb_device; .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), \ +} +/* _f : field name _f_n : num of elements field_name _n : num of elements
@@ -760,12 +771,6 @@ extern const VMStateDescription vmstate_usb_device;#define VMSTATE_TIMER_ARRAY (_f, _s, _n) \ VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *) -#define VMSTATE_PTIMER_V (_f, _s, _v) \ - VMSTATE_POINTER(_f, _s, _v, vmstate_info_ptimer, ptimer_state *) - -#define VMSTATE_PTIMER (_f, _s) \ - VMSTATE_PTIMER_V(_f, _s, 0) -#define VMSTATE_BOOL_ARRAY_V (_f, _s, _n, _v) \ VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_bool, bool)
hw/ptimer.c +16 -43
72 lines not on this page · raw message
qemu-timer.h +0 -2
@@ -118,8 +118,6 @@ 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); -void qemu_put_ptimer (QEMUFile *f,ptimer_state *s); -void qemu_get_ptimer (QEMUFile *f,ptimer_state *s);/* icount */ int64_t qemu_icount_round (int64_t count);
Signature · 1 line
1.7.4
PATCH 45/58 vmstate: port pxa2xx_dma
In reply to Juan Quintela--- hw/pxa2xx_dma.c | 90 ++++++++++++++++++++++--------------------------------- 1 files changed, 36 insertions(+), 54 deletions(-)
hw/pxa2xx_dma.c +36 -54
@@ -428,60 +428,42 @@ static CPUWriteMemoryFunc * const pxa2xx_dma_writefn[] = {pxa2xx_dma_write }; -static void pxa2xx_dma_save (QEMUFile *f,void *opaque) -{ -PXA2xxDMAState *s = (PXA2xxDMAState *) opaque; -int i; - -qemu_put_be32 (f, s->channels); - -qemu_put_be32s (f, &s->stopintr); -qemu_put_be32s (f, &s->eorintr); -qemu_put_be32s (f, &s->rasintr); -qemu_put_be32s (f, &s->startintr); -qemu_put_be32s (f, &s->endintr); -qemu_put_be32s (f, &s->align); -qemu_put_be32s (f, &s->pio); - -qemu_put_buffer (f, s->req,PXA2XX_DMA_NUM_REQUESTS ); -for (i =0 ; i < s->channels; i ++) { -qemu_put_betl (f, s->chan[i].descr); -qemu_put_betl (f, s->chan[i].src); -qemu_put_betl (f, s->chan[i].dest); -qemu_put_be32s (f, &s->chan[i].cmd); -qemu_put_be32s (f, &s->chan[i].state); -qemu_put_be32 (f, s->chan[i].request); - }; -} +static const VMStateDescription vmstate_dma_channel = { + .name ="PXA2xxDMAChannel" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { +VMSTATE_UINTTL (descr, PXA2xxDMAChannel), +VMSTATE_UINTTL (src, PXA2xxDMAChannel), +VMSTATE_UINTTL (dest, PXA2xxDMAChannel), +VMSTATE_UINT32 (cmd, PXA2xxDMAChannel), +VMSTATE_UINT32 (state, PXA2xxDMAChannel), +VMSTATE_INT32 (request, PXA2xxDMAChannel), +VMSTATE_END_OF_LIST () + } +}; -static int pxa2xx_dma_load (QEMUFile *f,void *opaque,int version_id) -{ -PXA2xxDMAState *s = (PXA2xxDMAState *) opaque; -int i; - -if (qemu_get_be32 (f) != s->channels) -return -EINVAL ; - -qemu_get_be32s (f, &s->stopintr); -qemu_get_be32s (f, &s->eorintr); -qemu_get_be32s (f, &s->rasintr); -qemu_get_be32s (f, &s->startintr); -qemu_get_be32s (f, &s->endintr); -qemu_get_be32s (f, &s->align); -qemu_get_be32s (f, &s->pio); - -qemu_get_buffer (f, s->req,PXA2XX_DMA_NUM_REQUESTS ); -for (i =0 ; i < s->channels; i ++) { - s->chan[i].descr =qemu_get_betl (f); - s->chan[i].src =qemu_get_betl (f); - s->chan[i].dest =qemu_get_betl (f); -qemu_get_be32s (f, &s->chan[i].cmd); -qemu_get_be32s (f, &s->chan[i].state); - s->chan[i].request =qemu_get_be32 (f); - }; - -return 0 ; -} +static const VMStateDescription vmstate_pxa2xx_dma = { + .name ="pxa2xx_dma" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { +VMSTATE_INT32 (channels, PXA2xxDMAState), +VMSTATE_UINT32 (stopintr, PXA2xxDMAState), +VMSTATE_UINT32 (eorintr, PXA2xxDMAState), +VMSTATE_UINT32 (rasintr, PXA2xxDMAState), +VMSTATE_UINT32 (startintr, PXA2xxDMAState), +VMSTATE_UINT32 (endintr, PXA2xxDMAState), +VMSTATE_UINT32 (align, PXA2xxDMAState), +VMSTATE_UINT32 (pio, PXA2xxDMAState), +VMSTATE_BUFFER (req, PXA2xxDMAState), +VMSTATE_STRUCT_VARRAY_INT32 (chan, PXA2xxDMAState, channels,0 , + vmstate_dma_channel, PXA2xxDMAChannel), +VMSTATE_END_OF_LIST () + } +};static PXA2xxDMAState *pxa2xx_dma_init (target_phys_addr_t base,qemu_irq irq,int channels)
@@ -506,7 +488,7 @@ static PXA2xxDMAState *pxa2xx_dma_init(target_phys_addr_t base, pxa2xx_dma_writefn, s, DEVICE_NATIVE_ENDIAN);cpu_register_physical_memory (base,0x00010000 , iomemtype); -register_savevm (NULL ,"pxa2xx_dma" ,0 ,0 , pxa2xx_dma_save, pxa2xx_dma_load, s); +vmstate_register (NULL ,0 , &vmstate_pxa2xx_dma, s);return s; }
Signature · 1 line
1.7.4
PATCH 49/58 max111x: input field is only used as uint8_t
In reply to Juan Quintela--- hw/max111x.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/max111x.c +1 -1
@@ -15,7 +15,7 @@ typedef struct {uint8_t tb1, rb2, rb3;int cycle; -int input[8 ]; +uint8_t input[8 ];int inputs, com; } MAX111xState;
Signature · 1 line
1.7.4
PATCH 5/58 vmstate: add VMSTATE_INT64_ARRAY
In reply to Juan Quintela--- hw/hw.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
hw/hw.h +6 -0
@@ -778,6 +778,12 @@ extern const VMStateDescription vmstate_usb_device;#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)))
Signature · 1 line
1.7.4
PATCH 43/58 vmstate: stellaris use unused for placeholder entries
In reply to Juan Quintela--- hw/stellaris.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
hw/stellaris.c +1 -2
@@ -291,8 +291,7 @@ static const VMStateDescription vmstate_stellaris_gptm = {VMSTATE_UINT32 (control, gptm_state),VMSTATE_UINT32 (state, gptm_state),VMSTATE_UINT32 (mask, gptm_state), -VMSTATE_UINT32 (mode[0 ], gptm_state), -VMSTATE_UINT32 (mode[0 ], gptm_state), +VMSTATE_UNUSED (8 ),VMSTATE_UINT32_ARRAY (load, gptm_state,2 ),VMSTATE_UINT32_ARRAY (match, gptm_state,2 ), VMSTATE_UINT32_ARRAY(prescale, gptm_state, 2),
Signature · 1 line
1.7.4
PATCH 8/58 vmstate: be able to store/save a pci device from a pointer
In reply to Juan Quintela--- hw/hw.h | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
hw/hw.h +8 -0
@@ -609,6 +609,14 @@ extern const VMStateDescription vmstate_pci_device; .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) { \
Signature · 1 line
1.7.4
PATCH 16/58 vmstate: port arm_timer
In reply to Juan Quintela--- hw/arm_timer.c | 37 ++++++++++++++----------------------- 1 files changed, 14 insertions(+), 23 deletions(-)
hw/arm_timer.c +14 -23
@@ -140,28 +140,19 @@ static void arm_timer_tick(void *opaque)arm_timer_update (s); } -static void arm_timer_save (QEMUFile *f,void *opaque) -{ -arm_timer_state *s = (arm_timer_state *)opaque; -qemu_put_be32 (f, s->control); -qemu_put_be32 (f, s->limit); -qemu_put_be32 (f, s->int_level); -qemu_put_ptimer (f, s->timer); -} - -static int arm_timer_load (QEMUFile *f,void *opaque,int version_id) -{ -arm_timer_state *s = (arm_timer_state *)opaque; - -if (version_id !=1 ) -return -EINVAL ; - - s->control =qemu_get_be32 (f); - s->limit =qemu_get_be32 (f); - s->int_level =qemu_get_be32 (f); -qemu_get_ptimer (f, s->timer); -return 0 ; -} +static const VMStateDescription vmstate_arm_timer = { + .name ="arm_timer" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_UINT32 (control, arm_timer_state), +VMSTATE_UINT32 (limit, arm_timer_state), +VMSTATE_INT32 (int_level, arm_timer_state), +VMSTATE_PTIMER (timer, arm_timer_state), +VMSTATE_END_OF_LIST () + } +};static arm_timer_state *arm_timer_init (uint32_t freq) {
@@ -174,7 +165,7 @@ static arm_timer_state *arm_timer_init(uint32_t freq) bh =qemu_bh_new (arm_timer_tick, s); s->timer =ptimer_init (bh); -register_savevm (NULL ,"arm_timer" ,-1 ,1 , arm_timer_save, arm_timer_load, s); +vmstate_register (NULL ,-1 , &vmstate_arm_timer, s);return s; }
Signature · 1 line
1.7.4
PATCH 12/58 vmstate: port ads7846
In reply to Juan Quintela--- hw/ads7846.c | 41 ++++++++++++++++++----------------------- 1 files changed, 18 insertions(+), 23 deletions(-)
hw/ads7846.c +18 -23
@@ -105,35 +105,30 @@ static void ads7846_ts_event(void *opaque, } } -static void ads7846_save (QEMUFile *f,void *opaque) +static int ads7856_post_load (void *opaque,int version_id) { -ADS7846State *s = (ADS7846State *) opaque; -int i; - -for (i =0 ; i <8 ; i ++) -qemu_put_be32 (f, s->input[i]); -qemu_put_be32 (f, s->noise); -qemu_put_be32 (f, s->cycle); -qemu_put_be32 (f, s->output); -} - -static int ads7846_load (QEMUFile *f,void *opaque,int version_id) -{ -ADS7846State *s = (ADS7846State *) opaque; -int i; - -for (i =0 ; i <8 ; i ++) - s->input[i] =qemu_get_be32 (f); - s->noise =qemu_get_be32 (f); - s->cycle =qemu_get_be32 (f); - s->output =qemu_get_be32 (f); +ADS7846State *s = opaque; s->pressure =0 ;ads7846_int_update (s); -return 0 ; } +static const VMStateDescription vmstate_ads7846 = { + .name ="ads7846" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .post_load = ads7856_post_load, + .fields = (VMStateField []) { +VMSTATE_INT32_ARRAY (input, ADS7846State,8 ), +VMSTATE_INT32 (noise, ADS7846State), +VMSTATE_INT32 (cycle, ADS7846State), +VMSTATE_INT32 (output, ADS7846State), +VMSTATE_END_OF_LIST () + } +}; +static int ads7846_init (SSISlave *dev) {ADS7846State *s =FROM_SSI_SLAVE (ADS7846State, dev);
@@ -151,7 +146,7 @@ static int ads7846_init(SSISlave *dev)ads7846_int_update (s); -register_savevm (NULL ,"ads7846" ,-1 ,0 , ads7846_save, ads7846_load, s); +vmstate_register (NULL ,-1 , &vmstate_ads7846, s);return 0 ; }
Signature · 1 line
1.7.4
PATCH 14/58 vmstate: port mipsnet
In reply to Juan Quintela--- hw/mipsnet.c | 53 +++++++++++++++++++---------------------------------- 1 files changed, 19 insertions(+), 34 deletions(-)
hw/mipsnet.c +19 -34
@@ -202,44 +202,29 @@ static void mipsnet_ioport_write(void *opaque, uint32_t addr, uint32_t val) } } -static void mipsnet_save (QEMUFile *f,void *opaque) -{ -MIPSnetState *s = opaque; - -qemu_put_be32s (f, &s->busy); -qemu_put_be32s (f, &s->rx_count); -qemu_put_be32s (f, &s->rx_read); -qemu_put_be32s (f, &s->tx_count); -qemu_put_be32s (f, &s->tx_written); -qemu_put_be32s (f, &s->intctl); -qemu_put_buffer (f, s->rx_buffer,MAX_ETH_FRAME_SIZE ); -qemu_put_buffer (f, s->tx_buffer,MAX_ETH_FRAME_SIZE ); -} - -static int mipsnet_load (QEMUFile *f,void *opaque,int version_id) -{ -MIPSnetState *s = opaque; - -if (version_id >0 ) -return -EINVAL ; - -qemu_get_be32s (f, &s->busy); -qemu_get_be32s (f, &s->rx_count); -qemu_get_be32s (f, &s->rx_read); -qemu_get_be32s (f, &s->tx_count); -qemu_get_be32s (f, &s->tx_written); -qemu_get_be32s (f, &s->intctl); -qemu_get_buffer (f, s->rx_buffer,MAX_ETH_FRAME_SIZE ); -qemu_get_buffer (f, s->tx_buffer,MAX_ETH_FRAME_SIZE ); - -return 0 ; -} +static const VMStateDescription vmstate_mipsnet = { + .name ="mipsnet" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { +VMSTATE_UINT32 (busy, MIPSnetState), +VMSTATE_UINT32 (rx_count, MIPSnetState), +VMSTATE_UINT32 (rx_read, MIPSnetState), +VMSTATE_UINT32 (tx_count, MIPSnetState), +VMSTATE_UINT32 (tx_written, MIPSnetState), +VMSTATE_UINT32 (intctl, MIPSnetState), +VMSTATE_BUFFER (rx_buffer, MIPSnetState), +VMSTATE_BUFFER (tx_buffer, MIPSnetState), +VMSTATE_END_OF_LIST () + } +};static void mipsnet_cleanup (VLANClientState *nc) {MIPSnetState *s =DO_UPCAST (NICState, nc, nc)->opaque; -unregister_savevm (NULL ,"mipsnet" , s); +vmstate_unregister (NULL , &vmstate_mipsnet, s);isa_unassign_ioport (s->io_base,36 );
@@ -284,5 +269,5 @@ void mipsnet_init (int base, qemu_irq irq, NICInfo *nd) }mipsnet_reset (s); -register_savevm (NULL ,"mipsnet" ,0 ,0 , mipsnet_save, mipsnet_load, s); +vmstate_register (NULL ,0 , &vmstate_mipsnet, s); }
Signature · 1 line
1.7.4
PATCH 31/58 vmstate: port pxa2xx_i2s
In reply to Juan Quintela--- hw/pxa2xx.c | 53 ++++++++++++++++++----------------------------------- 1 files changed, 18 insertions(+), 35 deletions(-)
hw/pxa2xx.c +18 -35
@@ -1710,39 +1710,23 @@ static CPUWriteMemoryFunc * const pxa2xx_i2s_writefn[] = { pxa2xx_i2s_write, }; -static void pxa2xx_i2s_save (QEMUFile *f,void *opaque) -{ -PXA2xxI2SState *s = (PXA2xxI2SState *) opaque; - -qemu_put_be32s (f, &s->control[0 ]); -qemu_put_be32s (f, &s->control[1 ]); -qemu_put_be32s (f, &s->status); -qemu_put_be32s (f, &s->mask); -qemu_put_be32s (f, &s->clk); - -qemu_put_be32 (f, s->enable); -qemu_put_be32 (f, s->rx_len); -qemu_put_be32 (f, s->tx_len); -qemu_put_be32 (f, s->fifo_len); -} - -static int pxa2xx_i2s_load (QEMUFile *f,void *opaque,int version_id) -{ -PXA2xxI2SState *s = (PXA2xxI2SState *) opaque; - -qemu_get_be32s (f, &s->control[0 ]); -qemu_get_be32s (f, &s->control[1 ]); -qemu_get_be32s (f, &s->status); -qemu_get_be32s (f, &s->mask); -qemu_get_be32s (f, &s->clk); - - s->enable =qemu_get_be32 (f); - s->rx_len =qemu_get_be32 (f); - s->tx_len =qemu_get_be32 (f); - s->fifo_len =qemu_get_be32 (f); - -return 0 ; -} +static const VMStateDescription vmstate_pxa2xx_i2s = { + .name ="pxa2xx_i2s" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { +VMSTATE_UINT32_ARRAY (control, PXA2xxI2SState,2 ), +VMSTATE_UINT32 (status, PXA2xxI2SState), +VMSTATE_UINT32 (mask, PXA2xxI2SState), +VMSTATE_UINT32 (clk, PXA2xxI2SState), +VMSTATE_INT32 (enable, PXA2xxI2SState), +VMSTATE_INT32 (rx_len, PXA2xxI2SState), +VMSTATE_INT32 (tx_len, PXA2xxI2SState), +VMSTATE_INT32 (fifo_len, PXA2xxI2SState), +VMSTATE_END_OF_LIST () + } +};static void pxa2xx_i2s_data_req (void *opaque,int tx,int rx) {
@@ -1783,8 +1767,7 @@ static PXA2xxI2SState *pxa2xx_i2s_init(target_phys_addr_t base, pxa2xx_i2s_writefn, s, DEVICE_NATIVE_ENDIAN);cpu_register_physical_memory (base,0x100000 , iomemtype); -register_savevm (NULL ,"pxa2xx_i2s" , base,0 , - pxa2xx_i2s_save, pxa2xx_i2s_load, s); +vmstate_register (NULL , base, &vmstate_pxa2xx_i2s, s);return s; }
Signature · 1 line
1.7.4
PATCH 28/58 vmstate: port heathrow_pic
In reply to Juan Quintela--- hw/heathrow_pic.c | 62 +++++++++++++++++++++------------------------------- 1 files changed, 25 insertions(+), 37 deletions(-)
hw/heathrow_pic.c +25 -37
@@ -159,42 +159,31 @@ static void heathrow_pic_set_irq(void *opaque, int num, int level)heathrow_pic_update (s); } -static void heathrow_pic_save_one (QEMUFile *f,HeathrowPIC *s) -{ -qemu_put_be32s (f, &s->events); -qemu_put_be32s (f, &s->mask); -qemu_put_be32s (f, &s->levels); -qemu_put_be32s (f, &s->level_triggered); -} - -static void heathrow_pic_save (QEMUFile *f,void *opaque) -{ -HeathrowPICS *s = (HeathrowPICS *)opaque; - -heathrow_pic_save_one (f, &s->pics[0 ]); -heathrow_pic_save_one (f, &s->pics[1 ]); -} - -static void heathrow_pic_load_one (QEMUFile *f,HeathrowPIC *s) -{ -qemu_get_be32s (f, &s->events); -qemu_get_be32s (f, &s->mask); -qemu_get_be32s (f, &s->levels); -qemu_get_be32s (f, &s->level_triggered); -} - -static int heathrow_pic_load (QEMUFile *f,void *opaque,int version_id) -{ -HeathrowPICS *s = (HeathrowPICS *)opaque; - -if (version_id !=1 ) -return -EINVAL ; - -heathrow_pic_load_one (f, &s->pics[0 ]); -heathrow_pic_load_one (f, &s->pics[1 ]); +static const VMStateDescription vmstate_heathrow_pic_one = { + .name ="heathrow_pic_one" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { +VMSTATE_UINT32 (events, HeathrowPIC), +VMSTATE_UINT32 (mask, HeathrowPIC), +VMSTATE_UINT32 (levels, HeathrowPIC), +VMSTATE_UINT32 (level_triggered, HeathrowPIC), +VMSTATE_END_OF_LIST () + } +}; -return 0 ; -} +static const VMStateDescription vmstate_heathrow_pic = { + .name ="heathrow_pic" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_STRUCT_ARRAY (pics, HeathrowPICS,2 ,1 , + vmstate_heathrow_pic_one, HeathrowPIC), +VMSTATE_END_OF_LIST () + } +};static void heathrow_pic_reset_one (HeathrowPIC *s) {
@@ -223,8 +212,7 @@ qemu_irq *heathrow_pic_init(int *pmem_index, *pmem_index =cpu_register_io_memory (pic_read, pic_write, s,DEVICE_LITTLE_ENDIAN ); -register_savevm (NULL ,"heathrow_pic" ,-1 ,1 , heathrow_pic_save, - heathrow_pic_load, s); +vmstate_register (NULL ,-1 , &vmstate_heathrow_pic, s);qemu_register_reset (heathrow_pic_reset, s);return qemu_allocate_irqs (heathrow_pic_set_irq, s,64 ); }
Signature · 1 line
1.7.4
PATCH 48/58 vmstate: port pxa2xx_lcdc
In reply to Juan Quintela--- hw/pxa2xx_lcd.c | 110 +++++++++++++++++++++--------------------------------- 1 files changed, 43 insertions(+), 67 deletions(-)
hw/pxa2xx_lcd.c +43 -67
@@ -833,74 +833,26 @@ static void pxa2xx_lcdc_orientation(void *opaque, int angle)pxa2xx_lcdc_resize (s); } -static void pxa2xx_lcdc_save (QEMUFile *f,void *opaque) -{ -PXA2xxLCDState *s = (PXA2xxLCDState *) opaque; -int i; - -qemu_put_be32 (f, s->irqlevel); -qemu_put_be32 (f, s->transp); - -for (i =0 ; i <6 ; i ++) -qemu_put_be32s (f, &s->control[i]); -for (i =0 ; i <2 ; i ++) -qemu_put_be32s (f, &s->status[i]); -for (i =0 ; i <2 ; i ++) -qemu_put_be32s (f, &s->ovl1c[i]); -for (i =0 ; i <2 ; i ++) -qemu_put_be32s (f, &s->ovl2c[i]); -qemu_put_be32s (f, &s->ccr); -qemu_put_be32s (f, &s->cmdcr); -qemu_put_be32s (f, &s->trgbr); -qemu_put_be32s (f, &s->tcr); -qemu_put_be32s (f, &s->liidr); -qemu_put_8s (f, &s->bscntr); - -for (i =0 ; i <7 ; i ++) { -qemu_put_betl (f, s->dma_ch[i].branch); -qemu_put_byte (f, s->dma_ch[i].up); -qemu_put_buffer (f, s->dma_ch[i].pbuffer,sizeof (s->dma_ch[i].pbuffer)); - -qemu_put_betl (f, s->dma_ch[i].descriptor); -qemu_put_betl (f, s->dma_ch[i].source); -qemu_put_be32s (f, &s->dma_ch[i].id); -qemu_put_be32s (f, &s->dma_ch[i].command); +static const VMStateDescription vmstate_dma_channel = { + .name ="dma_channel" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { + VMSTATE_UINTTL(branch, struct dma_channel), + VMSTATE_UINT8(up, struct dma_channel), + VMSTATE_BUFFER(pbuffer, struct dma_channel), + VMSTATE_UINTTL(descriptor, struct dma_channel), + VMSTATE_UINTTL(source, struct dma_channel), + VMSTATE_UINT32(id, struct dma_channel), + VMSTATE_UINT32(command, struct dma_channel), +VMSTATE_END_OF_LIST () } -} +}; -static int pxa2xx_lcdc_load (QEMUFile *f,void *opaque,int version_id) +static int pxa2xx_lcdc_post_load (void *opaque,int version_id) { -PXA2xxLCDState *s = (PXA2xxLCDState *) opaque; -int i; - - s->irqlevel =qemu_get_be32 (f); - s->transp =qemu_get_be32 (f); - -for (i =0 ; i <6 ; i ++) -qemu_get_be32s (f, &s->control[i]); -for (i =0 ; i <2 ; i ++) -qemu_get_be32s (f, &s->status[i]); -for (i =0 ; i <2 ; i ++) -qemu_get_be32s (f, &s->ovl1c[i]); -for (i =0 ; i <2 ; i ++) -qemu_get_be32s (f, &s->ovl2c[i]); -qemu_get_be32s (f, &s->ccr); -qemu_get_be32s (f, &s->cmdcr); -qemu_get_be32s (f, &s->trgbr); -qemu_get_be32s (f, &s->tcr); -qemu_get_be32s (f, &s->liidr); -qemu_get_8s (f, &s->bscntr); - -for (i =0 ; i <7 ; i ++) { - s->dma_ch[i].branch =qemu_get_betl (f); - s->dma_ch[i].up =qemu_get_byte (f); -qemu_get_buffer (f, s->dma_ch[i].pbuffer,sizeof (s->dma_ch[i].pbuffer)); - - s->dma_ch[i].descriptor =qemu_get_betl (f); - s->dma_ch[i].source =qemu_get_betl (f); -qemu_get_be32s (f, &s->dma_ch[i].id); -qemu_get_be32s (f, &s->dma_ch[i].command); - } +PXA2xxLCDState *s = opaque; s->bpp =LCCR3_BPP (s->control[3 ]); s->xres = s->yres = s->pal_for =-1 ;
@@ -908,6 +860,31 @@ static int pxa2xx_lcdc_load(QEMUFile *f, void *opaque, int version_id)return 0 ; } +static const VMStateDescription vmstate_pxa2xx_lcdc = { + .name ="pxa2xx_lcdc" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .post_load = pxa2xx_lcdc_post_load, + .fields = (VMStateField []) { +VMSTATE_INT32 (irqlevel, PXA2xxLCDState), +VMSTATE_INT32 (transp, PXA2xxLCDState), +VMSTATE_UINT32_ARRAY (control, PXA2xxLCDState,6 ), +VMSTATE_UINT32_ARRAY (status, PXA2xxLCDState,2 ), +VMSTATE_UINT32_ARRAY (ovl1c, PXA2xxLCDState,2 ), +VMSTATE_UINT32_ARRAY (ovl2c, PXA2xxLCDState,2 ), +VMSTATE_UINT32 (ccr, PXA2xxLCDState), +VMSTATE_UINT32 (cmdcr, PXA2xxLCDState), +VMSTATE_UINT32 (trgbr, PXA2xxLCDState), +VMSTATE_UINT32 (tcr, PXA2xxLCDState), +VMSTATE_UINT32 (liidr, PXA2xxLCDState), +VMSTATE_UINT8 (bscntr, PXA2xxLCDState), +VMSTATE_STRUCT_ARRAY (dma_ch, PXA2xxLCDState,7 ,0 , + vmstate_dma_channel, struct dma_channel), +VMSTATE_END_OF_LIST () + } +}; +#define BITS 8#include "pxa2xx_template.h" #define BITS 15
@@ -972,8 +949,7 @@ PXA2xxLCDState *pxa2xx_lcdc_init(target_phys_addr_t base, qemu_irq irq)exit (1 ); } -register_savevm (NULL ,"pxa2xx_lcdc" ,0 ,0 , - pxa2xx_lcdc_save, pxa2xx_lcdc_load, s); +vmstate_register (NULL ,0 , &vmstate_pxa2xx_lcdc, s);return s; }
Signature · 1 line
1.7.4
PATCH 1/58 vmstate: add VMSTATE_UINT32_EQUAL
In reply to Juan Quintela--- hw/hw.h | 4 ++++ savevm.c | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 0 deletions(-)
hw/hw.h +4 -0
@@ -343,6 +343,7 @@ 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;
@@ -679,6 +680,9 @@ extern const VMStateDescription vmstate_usb_device;#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)
savevm.c +21 -0
@@ -882,6 +882,27 @@ const VMStateInfo vmstate_info_uint32 = { .put = put_uint32, }; +/* 32 bit uint. See that the received value is the same than the one +in the field */ + +static int get_uint32_equal (QEMUFile *f,void *pv,size_t size) +{ +uint32_t *v = pv; +uint32_t v2; +qemu_get_be32s (f, &v2); + +if (*v == v2) { +return 0 ; + } +return -EINVAL ; +} + +const VMStateInfo vmstate_info_uint32_equal = { + .name ="uint32 equal" , + .get = get_uint32_equal, + .put = put_uint32, +}; +/* 64 bit unsigned int */ static int get_uint64 (QEMUFile *f,void *pv,size_t size)
Signature · 1 line
1.7.4
PATCH 47/58 pxa2xx_lcd: up field is used as a bool and migrated as an uint8_t
In reply to Juan Quintela--- hw/pxa2xx_lcd.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/pxa2xx_lcd.c +1 -1
@@ -17,7 +17,7 @@struct dma_channel {target_phys_addr_t branch; -int up; +uint8_t up;uint8_t palette[1024 ];uint8_t pbuffer[1024 ]; void (*redraw)(PXA2xxLCDState *s, target_phys_addr_t addr,
Signature · 1 line
1.7.4
PATCH 11/58 vmstate: port adb_mouse
In reply to Juan Quintela--- hw/adb.c | 43 +++++++++++++++---------------------------- 1 files changed, 15 insertions(+), 28 deletions(-)
hw/adb.c +15 -28
@@ -427,32 +427,20 @@ static int adb_mouse_reset(ADBDevice *d)return 0 ; } -static void adb_mouse_save (QEMUFile *f,void *opaque) -{ -MouseState *s = (MouseState *)opaque; - -qemu_put_sbe32s (f, &s->buttons_state); -qemu_put_sbe32s (f, &s->last_buttons_state); -qemu_put_sbe32s (f, &s->dx); -qemu_put_sbe32s (f, &s->dy); -qemu_put_sbe32s (f, &s->dz); -} - -static int adb_mouse_load (QEMUFile *f,void *opaque,int version_id) -{ -MouseState *s = (MouseState *)opaque; - -if (version_id !=1 ) -return -EINVAL ; - -qemu_get_sbe32s (f, &s->buttons_state); -qemu_get_sbe32s (f, &s->last_buttons_state); -qemu_get_sbe32s (f, &s->dx); -qemu_get_sbe32s (f, &s->dy); -qemu_get_sbe32s (f, &s->dz); - -return 0 ; -} +static const VMStateDescription vmstate_adb_mouse = { + .name ="adb_mouse" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_INT32 (buttons_state, MouseState), +VMSTATE_INT32 (last_buttons_state, MouseState), +VMSTATE_INT32 (dx, MouseState), +VMSTATE_INT32 (dy, MouseState), +VMSTATE_INT32 (dz, MouseState), +VMSTATE_END_OF_LIST () + } +};void adb_mouse_init (ADBBusState *bus) {
@@ -463,6 +451,5 @@ void adb_mouse_init(ADBBusState *bus) d =adb_register_device (bus,ADB_MOUSE , adb_mouse_request, adb_mouse_reset, s);qemu_add_mouse_event_handler (adb_mouse_event, d,0 ,"QEMU ADB Mouse" ); -register_savevm (NULL ,"adb_mouse" ,-1 ,1 , adb_mouse_save, - adb_mouse_load, s); +vmstate_register (NULL ,-1 , &vmstate_adb_mouse, s); }
Signature · 1 line
1.7.4
PATCH 23/58 vmstate: port armv7m nvic
In reply to Juan Quintela--- hw/armv7m_nvic.c | 39 ++++++++++++++------------------------- 1 files changed, 14 insertions(+), 25 deletions(-)
hw/armv7m_nvic.c +14 -25
@@ -365,30 +365,19 @@ static void nvic_writel(void *opaque, uint32_t offset, uint32_t value) } } -static void nvic_save (QEMUFile *f,void *opaque) -{ -nvic_state *s = (nvic_state *)opaque; - -qemu_put_be32 (f, s->systick.control); -qemu_put_be32 (f, s->systick.reload); -qemu_put_be64 (f, s->systick.tick); -qemu_put_timer (f, s->systick.timer); -} - -static int nvic_load (QEMUFile *f,void *opaque,int version_id) -{ -nvic_state *s = (nvic_state *)opaque; - -if (version_id !=1 ) -return -EINVAL ; - - s->systick.control =qemu_get_be32 (f); - s->systick.reload =qemu_get_be32 (f); - s->systick.tick =qemu_get_be64 (f); -qemu_get_timer (f, s->systick.timer); - -return 0 ; -} +static const VMStateDescription vmstate_nvic = { + .name ="armv7m_nvic" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_UINT32 (systick.control, nvic_state), +VMSTATE_UINT32 (systick.reload, nvic_state), +VMSTATE_INT64 (systick.tick, nvic_state), +VMSTATE_TIMER (systick.timer, nvic_state), +VMSTATE_END_OF_LIST () + } +};static int armv7m_nvic_init (SysBusDevice *dev) {
@@ -397,7 +386,7 @@ static int armv7m_nvic_init(SysBusDevice *dev)gic_init (&s->gic);cpu_register_physical_memory (0xe000e000 ,0x1000 , s->gic.iomemtype); s->systick.timer =qemu_new_timer (vm_clock, systick_timer_tick, s); -register_savevm (&dev->qdev,"armv7m_nvic" ,-1 ,1 , nvic_save, nvic_load, s); +vmstate_register (&dev->qdev,-1 , &vmstate_nvic, s);return 0 ; }
Signature · 1 line
1.7.4
PATCH 9/58 vmstate: move timers to use test instead of version
In reply to Juan Quintela--- hw/hw.h | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-)
hw/hw.h +12 -3
@@ -399,6 +399,15 @@ extern const VMStateInfo vmstate_info_unused_buffer; .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), \
@@ -742,11 +751,11 @@ extern const VMStateDescription vmstate_usb_device;#define VMSTATE_UINT32_TEST (_f, _s, _t) \ VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t) -#define VMSTATE_TIMER_V (_f, _s, _v) \ - VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *) +#define VMSTATE_TIMER_TEST (_f, _s, _test) \ + VMSTATE_POINTER_TEST(_f, _s, _test, vmstate_info_timer, QEMUTimer *)#define VMSTATE_TIMER (_f, _s) \ - VMSTATE_TIMER_V(_f, _s, 0) + 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 *)
Signature · 1 line
1.7.4
PATCH 7/58 vmstate: Add a way to send a partial array
In reply to Juan Quintela--- hw/hw.h | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
hw/hw.h +9 -0
@@ -429,6 +429,15 @@ extern const VMStateInfo vmstate_info_unused_buffer; .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), \
Signature · 1 line
1.7.4
PATCH 53/58 mac_nvram: size is a size, no need to be a target dependent type
In reply to Juan Quintela--- hw/mac_nvram.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/mac_nvram.c +1 -1
@@ -38,7 +38,7 @@#endif struct MacIONVRAMState { -target_phys_addr_t size; +uint32_t size;int mem_index;unsigned int it_shift;uint8_t *data;
Signature · 1 line
1.7.4
PATCH 15/58 vmstate: port arm sp804
In reply to Juan Quintela--- hw/arm_timer.c | 29 +++++++++++------------------ 1 files changed, 11 insertions(+), 18 deletions(-)
hw/arm_timer.c +11 -18
@@ -235,24 +235,17 @@ static CPUWriteMemoryFunc * const sp804_writefn[] = { sp804_write }; -static void sp804_save (QEMUFile *f,void *opaque) -{ -sp804_state *s = (sp804_state *)opaque; -qemu_put_be32 (f, s->level[0 ]); -qemu_put_be32 (f, s->level[1 ]); -} -static int sp804_load (QEMUFile *f,void *opaque,int version_id) -{ -sp804_state *s = (sp804_state *)opaque; - -if (version_id !=1 ) -return -EINVAL ; - - s->level[0 ] =qemu_get_be32 (f); - s->level[1 ] =qemu_get_be32 (f); -return 0 ; -} +static const VMStateDescription vmstate_sp804 = { + .name ="sp804" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_INT32_ARRAY (level, sp804_state,2 ), +VMSTATE_END_OF_LIST () + } +};static int sp804_init (SysBusDevice *dev) {
@@ -271,7 +264,7 @@ static int sp804_init(SysBusDevice *dev) iomemtype =cpu_register_io_memory (sp804_readfn, sp804_writefn, s,DEVICE_NATIVE_ENDIAN );sysbus_init_mmio (dev,0x1000 , iomemtype); -register_savevm (&dev->qdev,"sp804" ,-1 ,1 , sp804_save, sp804_load, s); +vmstate_register (&dev->qdev,-1 , &vmstate_sp804, s);return 0 ; }
Signature · 1 line
1.7.4
PATCH 46/58 pxa2xx_lcd: name anonymous struct
In reply to Juan Quintela--- hw/pxa2xx_lcd.c | 28 +++++++++++++++------------- 1 files changed, 15 insertions(+), 13 deletions(-)
hw/pxa2xx_lcd.c +15 -13
@@ -15,6 +15,20 @@#include "sysemu.h" #include "framebuffer.h" +struct dma_channel { +target_phys_addr_t branch; +int up; +uint8_t palette[1024 ]; +uint8_t pbuffer[1024 ]; +void (*redraw)(PXA2xxLCDState *s,target_phys_addr_t addr, +int *miny,int *maxy); + +target_phys_addr_t descriptor; +target_phys_addr_t source; +uint32_t id; +uint32_t command; +}; +struct PXA2xxLCDState {qemu_irq irq;int irqlevel;
@@ -50,19 +64,7 @@ struct PXA2xxLCDState {uint32_t liidr;uint8_t bscntr; -struct { -target_phys_addr_t branch; -int up; -uint8_t palette[1024 ]; -uint8_t pbuffer[1024 ]; -void (*redraw)(PXA2xxLCDState *s,target_phys_addr_t addr, -int *miny,int *maxy); - -target_phys_addr_t descriptor; -target_phys_addr_t source; -uint32_t id; -uint32_t command; - } dma_ch[7 ]; +struct dma_channel dma_ch[7 ];qemu_irq vsync_cb;int orientation;
Signature · 1 line
1.7.4
PATCH 51/58 nand: pin values are uint8_t
In reply to Juan Quintela--- hw/flash.h | 4 ++-- hw/nand.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
hw/flash.h +2 -2
@@ -21,8 +21,8 @@ pflash_t *pflash_cfi02_register(target_phys_addr_t base, ram_addr_t off,typedef struct NANDFlashState NANDFlashState ;NANDFlashState *nand_init (int manf_id,int chip_id);void nand_done (NANDFlashState *s); -void nand_setpins (NANDFlashState *s, -int cle,int ale,int ce,int wp,int gnd); +void nand_setpins (NANDFlashState *s,uint8_t cle,uint8_t ale, +uint8_t ce,uint8_t wp,uint8_t gnd);void nand_getpins (NANDFlashState *s,int *rb);void nand_setio (NANDFlashState *s,uint8_t value);uint8_t nand_getio (NANDFlashState *s);
hw/nand.c +3 -3
@@ -52,7 +52,7 @@ struct NANDFlashState {BlockDriverState *bdrv;int mem_oob; -int cle, ale, ce, wp, gnd; +uint8_t cle, ale, ce, wp, gnd;uint8_t io[MAX_PAGE +MAX_OOB +0x400 ];uint8_t *ioaddr;
@@ -329,8 +329,8 @@ static int nand_load(QEMUFile *f, void *opaque, int version_id)* * CE, WP and R/B are active low. */ -void nand_setpins (NANDFlashState *s, -int cle,int ale,int ce,int wp,int gnd) +void nand_setpins (NANDFlashState *s,uint8_t cle,uint8_t ale, +uint8_t ce,uint8_t wp,uint8_t gnd) { s->cle = cle; s->ale = ale;
Signature · 1 line
1.7.4
PATCH 44/58 pxa2xx_dma: make req array static
In reply to Juan QuintelaWe know its size, and it is always allocated
--- hw/pxa2xx_dma.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
hw/pxa2xx_dma.c +3 -4
@@ -23,6 +23,8 @@ typedef struct {/* Allow the DMA to be used as a PIC. */ typedef void (*pxa2xx_dma_handler_t )(void *opaque,int irq,int level); +#define PXA2XX_DMA_NUM_REQUESTS 75 +struct PXA2xxDMAState {pxa2xx_dma_handler_t handler;qemu_irq irq;
@@ -39,7 +41,7 @@ struct PXA2xxDMAState {int channels;PXA2xxDMAChannel *chan; -uint8_t *req; +uint8_t req[PXA2XX_DMA_NUM_REQUESTS ];/* Flag to avoid recursive DMA invocations. */ int running;
@@ -48,8 +50,6 @@ struct PXA2xxDMAState {#define PXA255_DMA_NUM_CHANNELS 16#define PXA27X_DMA_NUM_CHANNELS 32 -#define PXA2XX_DMA_NUM_REQUESTS 75 -#define DCSR0 0x0000/* DMA Control / Status register for Channel 0 */ #define DCSR31 0x007c/* DMA Control / Status register for Channel 31 */ #define DALGN 0x00a0/* DMA Alignment register */
@@ -495,7 +495,6 @@ static PXA2xxDMAState *pxa2xx_dma_init(target_phys_addr_t base, s->chan =qemu_mallocz (sizeof (PXA2xxDMAChannel) * s->channels); s->irq = irq; s->handler = (pxa2xx_dma_handler_t ) pxa2xx_dma_request; - s->req =qemu_mallocz (sizeof (uint8_t ) *PXA2XX_DMA_NUM_REQUESTS );memset (s->chan,0 ,sizeof (PXA2xxDMAChannel) * s->channels);for (i =0 ; i < s->channels; i ++)
Signature · 1 line
1.7.4
PATCH 54/58 vmstate: port mac_nvram
In reply to Juan Quintela--- hw/mac_nvram.c | 30 +++++++++++------------------- 1 files changed, 11 insertions(+), 19 deletions(-)
hw/mac_nvram.c +11 -19
@@ -105,24 +105,17 @@ static CPUReadMemoryFunc * const nvram_read[] = { &macio_nvram_readb, }; -static void macio_nvram_save (QEMUFile *f,void *opaque) -{ -MacIONVRAMState *s = (MacIONVRAMState *)opaque; - -qemu_put_buffer (f, s->data, s->size); -} - -static int macio_nvram_load (QEMUFile *f,void *opaque,int version_id) -{ -MacIONVRAMState *s = (MacIONVRAMState *)opaque; - -if (version_id !=1 ) -return -EINVAL ; - -qemu_get_buffer (f, s->data, s->size); +static const VMStateDescription vmstate_macio_nvram = { + .name ="macio_nvram" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_VBUFFER_UINT32 (data, MacIONVRAMState,0 ,NULL ,0 , size), +VMSTATE_END_OF_LIST () + } +}; -return 0 ; -}static void macio_nvram_reset (void *opaque) {
@@ -141,8 +134,7 @@ MacIONVRAMState *macio_nvram_init (int *mem_index, target_phys_addr_t size, s->mem_index =cpu_register_io_memory (nvram_read, nvram_write, s,DEVICE_NATIVE_ENDIAN ); *mem_index = s->mem_index; -register_savevm (NULL ,"macio_nvram" ,-1 ,1 , macio_nvram_save, - macio_nvram_load, s); +vmstate_register (NULL ,-1 , &vmstate_macio_nvram, s);qemu_register_reset (macio_nvram_reset, s);return s;
Signature · 1 line
1.7.4
PATCH 2/58 vmstate: Fix varrays with uint8 indexes
In reply to Juan Quintela--- hw/hw.h | 5 +++-- savevm.c | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-)
hw/hw.h +3 -2
@@ -298,6 +298,7 @@ enum VMStateFlags {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*/ }; typedef struct {
@@ -488,11 +489,11 @@ extern const VMStateInfo vmstate_info_unused_buffer;#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), \ + .num_offset = vmstate_offset_value(_state, _field_num, uint8_t), \ .version_id = (_version), \ .vmsd = &(_vmsd), \ .size = sizeof(_type), \ - .flags = VMS_STRUCT|VMS_VARRAY_INT32, \ + .flags = VMS_STRUCT|VMS_VARRAY_UINT8, \ .offset = offsetof(_state, _field), \ }
savevm.c +2 -0
@@ -1331,6 +1331,8 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, n_elems = *(int32_t *)(opaque+field->num_offset); }else if (field->flags &VMS_VARRAY_UINT16 ) { n_elems = *(uint16_t *)(opaque+field->num_offset); + }else if (field->flags &VMS_VARRAY_UINT8 ) { + n_elems = *(uint8_t *)(opaque+field->num_offset); }if (field->flags &VMS_POINTER ) { base_addr = *(void **)base_addr + field->start;
Signature · 1 line
1.7.4
PATCH 33/58 vmstate: port pxa2xx_mm
In reply to Juan Quintela--- hw/pxa2xx.c | 33 ++++++++++++--------------------- 1 files changed, 12 insertions(+), 21 deletions(-)
hw/pxa2xx.c +12 -21
@@ -517,25 +517,16 @@ static CPUWriteMemoryFunc * const pxa2xx_mm_writefn[] = { pxa2xx_mm_write, }; -static void pxa2xx_mm_save (QEMUFile *f,void *opaque) -{ -PXA2xxState *s = (PXA2xxState *) opaque; -int i; - -for (i =0 ; i <0x1a ; i ++) -qemu_put_be32s (f, &s->mm_regs[i]); -} - -static int pxa2xx_mm_load (QEMUFile *f,void *opaque,int version_id) -{ -PXA2xxState *s = (PXA2xxState *) opaque; -int i; - -for (i =0 ; i <0x1a ; i ++) -qemu_get_be32s (f, &s->mm_regs[i]); - -return 0 ; -} +static const VMStateDescription vmstate_pxa2xx_mm = { + .name ="pxa2xx_mm" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { +VMSTATE_UINT32_ARRAY (mm_regs, PXA2xxState,0x1a ), +VMSTATE_END_OF_LIST () + } +};/* Synchronous Serial Ports */ typedef struct {
@@ -2118,7 +2109,7 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision) iomemtype =cpu_register_io_memory (pxa2xx_mm_readfn, pxa2xx_mm_writefn, s,DEVICE_NATIVE_ENDIAN );cpu_register_physical_memory (s->mm_base,0x1000 , iomemtype); -register_savevm (NULL ,"pxa2xx_mm" ,0 ,0 , pxa2xx_mm_save, pxa2xx_mm_load, s); +vmstate_register (NULL ,0 , &vmstate_pxa2xx_mm, s); s->pm_base =0x40f00000 ; iomemtype = cpu_register_io_memory(pxa2xx_pm_readfn,
@@ -2241,7 +2232,7 @@ PXA2xxState *pxa255_init(unsigned int sdram_size) iomemtype =cpu_register_io_memory (pxa2xx_mm_readfn, pxa2xx_mm_writefn, s,DEVICE_NATIVE_ENDIAN );cpu_register_physical_memory (s->mm_base,0x1000 , iomemtype); -register_savevm (NULL ,"pxa2xx_mm" ,0 ,0 , pxa2xx_mm_save, pxa2xx_mm_load, s); +vmstate_register (NULL ,0 , &vmstate_pxa2xx_mm, s); s->pm_base =0x40f00000 ; iomemtype = cpu_register_io_memory(pxa2xx_pm_readfn,
Signature · 1 line
1.7.4
PATCH 21/58 vmstate: port pxa2xx_keypad
In reply to Juan Quintela--- hw/pxa2xx_keypad.c | 53 ++++++++++++++++----------------------------------- 1 files changed, 17 insertions(+), 36 deletions(-)
hw/pxa2xx_keypad.c +17 -36
@@ -289,40 +289,22 @@ static CPUWriteMemoryFunc * const pxa2xx_keypad_writefn[] = { pxa2xx_keypad_write }; -static void pxa2xx_keypad_save (QEMUFile *f,void *opaque) -{ -PXA2xxKeyPadState *s = (PXA2xxKeyPadState *) opaque; - -qemu_put_be32s (f, &s->kpc); -qemu_put_be32s (f, &s->kpdk); -qemu_put_be32s (f, &s->kprec); -qemu_put_be32s (f, &s->kpmk); -qemu_put_be32s (f, &s->kpas); -qemu_put_be32s (f, &s->kpasmkp[0 ]); -qemu_put_be32s (f, &s->kpasmkp[1 ]); -qemu_put_be32s (f, &s->kpasmkp[2 ]); -qemu_put_be32s (f, &s->kpasmkp[3 ]); -qemu_put_be32s (f, &s->kpkdi); - -} - -static int pxa2xx_keypad_load (QEMUFile *f,void *opaque,int version_id) -{ -PXA2xxKeyPadState *s = (PXA2xxKeyPadState *) opaque; - -qemu_get_be32s (f, &s->kpc); -qemu_get_be32s (f, &s->kpdk); -qemu_get_be32s (f, &s->kprec); -qemu_get_be32s (f, &s->kpmk); -qemu_get_be32s (f, &s->kpas); -qemu_get_be32s (f, &s->kpasmkp[0 ]); -qemu_get_be32s (f, &s->kpasmkp[1 ]); -qemu_get_be32s (f, &s->kpasmkp[2 ]); -qemu_get_be32s (f, &s->kpasmkp[3 ]); -qemu_get_be32s (f, &s->kpkdi); - -return 0 ; -} +static const VMStateDescription vmstate_pxa2xx_keypad = { + .name ="pxa2xx_keypad" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { +VMSTATE_UINT32 (kpc, PXA2xxKeyPadState), +VMSTATE_UINT32 (kpdk, PXA2xxKeyPadState), +VMSTATE_UINT32 (kprec, PXA2xxKeyPadState), +VMSTATE_UINT32 (kpmk, PXA2xxKeyPadState), +VMSTATE_UINT32 (kpas, PXA2xxKeyPadState), +VMSTATE_UINT32_ARRAY (kpasmkp, PXA2xxKeyPadState,4 ), +VMSTATE_UINT32 (kpkdi, PXA2xxKeyPadState), +VMSTATE_END_OF_LIST () + } +};PXA2xxKeyPadState *pxa27x_keypad_init (target_phys_addr_t base,qemu_irq irq)
@@ -337,8 +319,7 @@ PXA2xxKeyPadState *pxa27x_keypad_init(target_phys_addr_t base, pxa2xx_keypad_writefn, s, DEVICE_NATIVE_ENDIAN);cpu_register_physical_memory (base,0x00100000 , iomemtype); -register_savevm (NULL ,"pxa2xx_keypad" ,0 ,0 , - pxa2xx_keypad_save, pxa2xx_keypad_load, s); +vmstate_register (NULL ,0 , &vmstate_pxa2xx_keypad, s);return s; }
Signature · 1 line
1.7.4
PATCH 20/58 vmstate: port pxa2xx_pic
In reply to Juan Quintela--- hw/pxa2xx_pic.c | 52 ++++++++++++++++++++-------------------------------- 1 files changed, 20 insertions(+), 32 deletions(-)
hw/pxa2xx_pic.c +20 -32
@@ -241,41 +241,30 @@ static CPUWriteMemoryFunc * const pxa2xx_pic_writefn[] = { pxa2xx_pic_mem_write, }; -static void pxa2xx_pic_save (QEMUFile *f,void *opaque) +static int pxa2xx_pic_post_load (void *opaque,int version_id) { -PXA2xxPICState *s = (PXA2xxPICState *) opaque; -int i; - -for (i =0 ; i <2 ; i ++) -qemu_put_be32s (f, &s->int_enabled[i]); -for (i =0 ; i <2 ; i ++) -qemu_put_be32s (f, &s->int_pending[i]); -for (i =0 ; i <2 ; i ++) -qemu_put_be32s (f, &s->is_fiq[i]); -qemu_put_be32s (f, &s->int_idle); -for (i =0 ; i <PXA2XX_PIC_SRCS ; i ++) -qemu_put_be32s (f, &s->priority[i]); -} - -static int pxa2xx_pic_load (QEMUFile *f,void *opaque,int version_id) -{ -PXA2xxPICState *s = (PXA2xxPICState *) opaque; -int i; - -for (i =0 ; i <2 ; i ++) -qemu_get_be32s (f, &s->int_enabled[i]); -for (i =0 ; i <2 ; i ++) -qemu_get_be32s (f, &s->int_pending[i]); -for (i =0 ; i <2 ; i ++) -qemu_get_be32s (f, &s->is_fiq[i]); -qemu_get_be32s (f, &s->int_idle); -for (i =0 ; i <PXA2XX_PIC_SRCS ; i ++) -qemu_get_be32s (f, &s->priority[i]); +PXA2xxPICState *s = opaque; -pxa2xx_pic_update (opaque); +pxa2xx_pic_update (s);return 0 ; } +static const VMStateDescription vmstate_pxa2xx_pic = { + .name ="pxa2xx_mmci" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .post_load = pxa2xx_pic_post_load, + .fields = (VMStateField []) { +VMSTATE_UINT32_ARRAY (int_enabled, PXA2xxPICState,2 ), +VMSTATE_UINT32_ARRAY (int_pending, PXA2xxPICState,2 ), +VMSTATE_UINT32_ARRAY (is_fiq, PXA2xxPICState,2 ), +VMSTATE_UINT32 (int_idle, PXA2xxPICState), +VMSTATE_UINT32_ARRAY (priority, PXA2xxPICState,PXA2XX_PIC_SRCS ), +VMSTATE_END_OF_LIST () + } +}; +qemu_irq *pxa2xx_pic_init (target_phys_addr_t base,CPUState *env) {PXA2xxPICState *s;
@@ -306,8 +295,7 @@ qemu_irq *pxa2xx_pic_init(target_phys_addr_t base, CPUState *env)/* Enable IC coprocessor access. */ cpu_arm_set_cp_io (env,6 , pxa2xx_pic_cp_read, pxa2xx_pic_cp_write, s); -register_savevm (NULL ,"pxa2xx_pic" ,0 ,0 , pxa2xx_pic_save, - pxa2xx_pic_load, s); +vmstate_register (NULL ,0 , &vmstate_pxa2xx_pic, s);return qi; }
Signature · 1 line
1.7.4
PATCH 22/58 vmstate: port pl011
In reply to Juan Quintela--- hw/pl011.c | 76 +++++++++++++++++++---------------------------------------- 1 files changed, 25 insertions(+), 51 deletions(-)
hw/pl011.c +25 -51
@@ -235,56 +235,30 @@ static CPUWriteMemoryFunc * const pl011_writefn[] = {pl011_write }; -static void pl011_save (QEMUFile *f,void *opaque) -{ -pl011_state *s = (pl011_state *)opaque; -int i; - -qemu_put_be32 (f, s->readbuff); -qemu_put_be32 (f, s->flags); -qemu_put_be32 (f, s->lcr); -qemu_put_be32 (f, s->cr); -qemu_put_be32 (f, s->dmacr); -qemu_put_be32 (f, s->int_enabled); -qemu_put_be32 (f, s->int_level); -for (i =0 ; i <16 ; i++) -qemu_put_be32 (f, s->read_fifo[i]); -qemu_put_be32 (f, s->ilpr); -qemu_put_be32 (f, s->ibrd); -qemu_put_be32 (f, s->fbrd); -qemu_put_be32 (f, s->ifl); -qemu_put_be32 (f, s->read_pos); -qemu_put_be32 (f, s->read_count); -qemu_put_be32 (f, s->read_trigger); -} - -static int pl011_load (QEMUFile *f,void *opaque,int version_id) -{ -pl011_state *s = (pl011_state *)opaque; -int i; - -if (version_id !=1 ) -return -EINVAL ; - - s->readbuff =qemu_get_be32 (f); - s->flags =qemu_get_be32 (f); - s->lcr =qemu_get_be32 (f); - s->cr =qemu_get_be32 (f); - s->dmacr =qemu_get_be32 (f); - s->int_enabled =qemu_get_be32 (f); - s->int_level =qemu_get_be32 (f); -for (i =0 ; i <16 ; i++) - s->read_fifo[i] =qemu_get_be32 (f); - s->ilpr =qemu_get_be32 (f); - s->ibrd =qemu_get_be32 (f); - s->fbrd =qemu_get_be32 (f); - s->ifl =qemu_get_be32 (f); - s->read_pos =qemu_get_be32 (f); - s->read_count =qemu_get_be32 (f); - s->read_trigger =qemu_get_be32 (f); - -return 0 ; -} +static const VMStateDescription vmstate_pl011 = { + .name ="pl011" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_UINT32 (readbuff, pl011_state), +VMSTATE_UINT32 (flags, pl011_state), +VMSTATE_UINT32 (lcr, pl011_state), +VMSTATE_UINT32 (cr, pl011_state), +VMSTATE_UINT32 (dmacr, pl011_state), +VMSTATE_UINT32 (int_enabled, pl011_state), +VMSTATE_UINT32 (int_level, pl011_state), +VMSTATE_UINT32_ARRAY (read_fifo, pl011_state,16 ), +VMSTATE_UINT32 (ilpr, pl011_state), +VMSTATE_UINT32 (ibrd, pl011_state), +VMSTATE_UINT32 (fbrd, pl011_state), +VMSTATE_UINT32 (ifl, pl011_state), +VMSTATE_INT32 (read_pos, pl011_state), +VMSTATE_INT32 (read_count, pl011_state), +VMSTATE_INT32 (read_trigger, pl011_state), +VMSTATE_END_OF_LIST () + } +};static int pl011_init (SysBusDevice *dev,const unsigned char *id) {
@@ -307,7 +281,7 @@ static int pl011_init(SysBusDevice *dev, const unsigned char *id)qemu_chr_add_handlers (s->chr, pl011_can_receive, pl011_receive, pl011_event, s); } -register_savevm (&dev->qdev,"pl011_uart" ,-1 ,1 , pl011_save, pl011_load, s); +vmstate_register (&dev->qdev,-1 , &vmstate_pl011, s);return 0 ; }
Signature · 1 line
1.7.4
PATCH 26/58 vmstate: port stellaris sys
In reply to Juan Quintela--- hw/stellaris.c | 71 +++++++++++++++++++------------------------------------ 1 files changed, 25 insertions(+), 46 deletions(-)
hw/stellaris.c +25 -46
@@ -605,58 +605,37 @@ static void ssys_reset(void *opaque) s->dcgc[0 ] =1 ; } -static void ssys_save (QEMUFile *f,void *opaque) +static int stellaris_sys_post_load (void *opaque,int version_id) { -ssys_state *s = (ssys_state *)opaque; - -qemu_put_be32 (f, s->pborctl); -qemu_put_be32 (f, s->ldopctl); -qemu_put_be32 (f, s->int_mask); -qemu_put_be32 (f, s->int_status); -qemu_put_be32 (f, s->resc); -qemu_put_be32 (f, s->rcc); -qemu_put_be32 (f, s->rcgc[0 ]); -qemu_put_be32 (f, s->rcgc[1 ]); -qemu_put_be32 (f, s->rcgc[2 ]); -qemu_put_be32 (f, s->scgc[0 ]); -qemu_put_be32 (f, s->scgc[1 ]); -qemu_put_be32 (f, s->scgc[2 ]); -qemu_put_be32 (f, s->dcgc[0 ]); -qemu_put_be32 (f, s->dcgc[1 ]); -qemu_put_be32 (f, s->dcgc[2 ]); -qemu_put_be32 (f, s->clkvclr); -qemu_put_be32 (f, s->ldoarst); -} - -static int ssys_load (QEMUFile *f,void *opaque,int version_id) -{ -ssys_state *s = (ssys_state *)opaque; - -if (version_id !=1 ) -return -EINVAL ; +ssys_state *s = opaque; - s->pborctl =qemu_get_be32 (f); - s->ldopctl =qemu_get_be32 (f); - s->int_mask =qemu_get_be32 (f); - s->int_status =qemu_get_be32 (f); - s->resc =qemu_get_be32 (f); - s->rcc =qemu_get_be32 (f); - s->rcgc[0 ] =qemu_get_be32 (f); - s->rcgc[1 ] =qemu_get_be32 (f); - s->rcgc[2 ] =qemu_get_be32 (f); - s->scgc[0 ] =qemu_get_be32 (f); - s->scgc[1 ] =qemu_get_be32 (f); - s->scgc[2 ] =qemu_get_be32 (f); - s->dcgc[0 ] =qemu_get_be32 (f); - s->dcgc[1 ] =qemu_get_be32 (f); - s->dcgc[2 ] =qemu_get_be32 (f); - s->clkvclr =qemu_get_be32 (f); - s->ldoarst =qemu_get_be32 (f);ssys_calculate_system_clock (s);return 0 ; } +static const VMStateDescription vmstate_stellaris_sys = { + .name ="stellaris_sys" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .post_load = stellaris_sys_post_load, + .fields = (VMStateField []) { +VMSTATE_UINT32 (pborctl, ssys_state), +VMSTATE_UINT32 (ldopctl, ssys_state), +VMSTATE_UINT32 (int_mask, ssys_state), +VMSTATE_UINT32 (int_status, ssys_state), +VMSTATE_UINT32 (resc, ssys_state), +VMSTATE_UINT32 (rcc, ssys_state), +VMSTATE_UINT32_ARRAY (rcgc, ssys_state,3 ), +VMSTATE_UINT32_ARRAY (scgc, ssys_state,3 ), +VMSTATE_UINT32_ARRAY (dcgc, ssys_state,3 ), +VMSTATE_UINT32 (clkvclr, ssys_state), +VMSTATE_UINT32 (ldoarst, ssys_state), +VMSTATE_END_OF_LIST () + } +}; +static int stellaris_sys_init (uint32_t base,qemu_irq irq,stellaris_board_info * board,uint8_t *macaddr)
@@ -676,7 +655,7 @@ static int stellaris_sys_init(uint32_t base, qemu_irq irq, DEVICE_NATIVE_ENDIAN);cpu_register_physical_memory (base,0x00001000 , iomemtype);ssys_reset (s); -register_savevm (NULL ,"stellaris_sys" ,-1 ,1 , ssys_save, ssys_load, s); +vmstate_register (NULL ,-1 , &vmstate_stellaris_sys, s);return 0 ; }
Signature · 1 line
1.7.4
PATCH 27/58 vmstate: port pl022 ssp
In reply to Juan Quintela--- hw/pl022.c | 84 +++++++++++++++++++++++++---------------------------------- 1 files changed, 36 insertions(+), 48 deletions(-)
hw/pl022.c +36 -48
@@ -239,54 +239,42 @@ static CPUWriteMemoryFunc * const pl022_writefn[] = {pl022_write }; -static void pl022_save (QEMUFile *f,void *opaque) -{ -pl022_state *s = (pl022_state *)opaque; -int i; - -qemu_put_be32 (f, s->cr0); -qemu_put_be32 (f, s->cr1); -qemu_put_be32 (f, s->bitmask); -qemu_put_be32 (f, s->sr); -qemu_put_be32 (f, s->cpsr); -qemu_put_be32 (f, s->is); -qemu_put_be32 (f, s->im); -qemu_put_be32 (f, s->tx_fifo_head); -qemu_put_be32 (f, s->rx_fifo_head); -qemu_put_be32 (f, s->tx_fifo_len); -qemu_put_be32 (f, s->rx_fifo_len); -for (i =0 ; i <8 ; i++) { -qemu_put_be16 (f, s->tx_fifo[i]); -qemu_put_be16 (f, s->rx_fifo[i]); - } -} - -static int pl022_load (QEMUFile *f,void *opaque,int version_id) -{ -pl022_state *s = (pl022_state *)opaque; -int i; - -if (version_id !=1 ) -return -EINVAL ; - - s->cr0 =qemu_get_be32 (f); - s->cr1 =qemu_get_be32 (f); - s->bitmask =qemu_get_be32 (f); - s->sr =qemu_get_be32 (f); - s->cpsr =qemu_get_be32 (f); - s->is =qemu_get_be32 (f); - s->im =qemu_get_be32 (f); - s->tx_fifo_head =qemu_get_be32 (f); - s->rx_fifo_head =qemu_get_be32 (f); - s->tx_fifo_len =qemu_get_be32 (f); - s->rx_fifo_len =qemu_get_be32 (f); -for (i =0 ; i <8 ; i++) { - s->tx_fifo[i] =qemu_get_be16 (f); - s->rx_fifo[i] =qemu_get_be16 (f); +static const VMStateDescription vmstate_pl022 = { + .name ="pl022_ssp" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_UINT32 (cr0, pl022_state), +VMSTATE_UINT32 (cr1, pl022_state), +VMSTATE_UINT32 (bitmask, pl022_state), +VMSTATE_UINT32 (sr, pl022_state), +VMSTATE_UINT32 (cpsr, pl022_state), +VMSTATE_UINT32 (is, pl022_state), +VMSTATE_UINT32 (im, pl022_state), +VMSTATE_INT32 (tx_fifo_head, pl022_state), +VMSTATE_INT32 (rx_fifo_head, pl022_state), +VMSTATE_INT32 (tx_fifo_len, pl022_state), +VMSTATE_INT32 (rx_fifo_len, pl022_state), +VMSTATE_UINT16 (tx_fifo[0 ], pl022_state), +VMSTATE_UINT16 (rx_fifo[0 ], pl022_state), +VMSTATE_UINT16 (tx_fifo[1 ], pl022_state), +VMSTATE_UINT16 (rx_fifo[1 ], pl022_state), +VMSTATE_UINT16 (tx_fifo[2 ], pl022_state), +VMSTATE_UINT16 (rx_fifo[2 ], pl022_state), +VMSTATE_UINT16 (tx_fifo[3 ], pl022_state), +VMSTATE_UINT16 (rx_fifo[3 ], pl022_state), +VMSTATE_UINT16 (tx_fifo[4 ], pl022_state), +VMSTATE_UINT16 (rx_fifo[4 ], pl022_state), +VMSTATE_UINT16 (tx_fifo[5 ], pl022_state), +VMSTATE_UINT16 (rx_fifo[5 ], pl022_state), +VMSTATE_UINT16 (tx_fifo[6 ], pl022_state), +VMSTATE_UINT16 (rx_fifo[6 ], pl022_state), +VMSTATE_UINT16 (tx_fifo[7 ], pl022_state), +VMSTATE_UINT16 (rx_fifo[7 ], pl022_state), +VMSTATE_END_OF_LIST () } - -return 0 ; -} +};static int pl022_init (SysBusDevice *dev) {
@@ -300,7 +288,7 @@ static int pl022_init(SysBusDevice *dev)sysbus_init_irq (dev, &s->irq); s->ssi =ssi_create_bus (&dev->qdev,"ssi" );pl022_reset (s); -register_savevm (&dev->qdev,"pl022_ssp" ,-1 ,1 , pl022_save, pl022_load, s); +vmstate_register (&dev->qdev,-1 , &vmstate_pl022, s);return 0 ; }
Signature · 1 line
1.7.4
PATCH 30/58 vmstate: port stellaris gptm
In reply to Juan Quintela--- hw/stellaris.c | 84 ++++++++++++++++---------------------------------------- 1 files changed, 24 insertions(+), 60 deletions(-)
hw/stellaris.c +24 -60
@@ -280,64 +280,29 @@ static CPUWriteMemoryFunc * const gptm_writefn[] = {gptm_write }; -static void gptm_save (QEMUFile *f,void *opaque) -{ -gptm_state *s = (gptm_state *)opaque; - -qemu_put_be32 (f, s->config); -qemu_put_be32 (f, s->mode[0 ]); -qemu_put_be32 (f, s->mode[1 ]); -qemu_put_be32 (f, s->control); -qemu_put_be32 (f, s->state); -qemu_put_be32 (f, s->mask); -qemu_put_be32 (f, s->mode[0 ]); -qemu_put_be32 (f, s->mode[0 ]); -qemu_put_be32 (f, s->load[0 ]); -qemu_put_be32 (f, s->load[1 ]); -qemu_put_be32 (f, s->match[0 ]); -qemu_put_be32 (f, s->match[1 ]); -qemu_put_be32 (f, s->prescale[0 ]); -qemu_put_be32 (f, s->prescale[1 ]); -qemu_put_be32 (f, s->match_prescale[0 ]); -qemu_put_be32 (f, s->match_prescale[1 ]); -qemu_put_be32 (f, s->rtc); -qemu_put_be64 (f, s->tick[0 ]); -qemu_put_be64 (f, s->tick[1 ]); -qemu_put_timer (f, s->timer[0 ]); -qemu_put_timer (f, s->timer[1 ]); -} - -static int gptm_load (QEMUFile *f,void *opaque,int version_id) -{ -gptm_state *s = (gptm_state *)opaque; - -if (version_id !=1 ) -return -EINVAL ; - - s->config =qemu_get_be32 (f); - s->mode[0 ] =qemu_get_be32 (f); - s->mode[1 ] =qemu_get_be32 (f); - s->control =qemu_get_be32 (f); - s->state =qemu_get_be32 (f); - s->mask =qemu_get_be32 (f); - s->mode[0 ] =qemu_get_be32 (f); - s->mode[0 ] =qemu_get_be32 (f); - s->load[0 ] =qemu_get_be32 (f); - s->load[1 ] =qemu_get_be32 (f); - s->match[0 ] =qemu_get_be32 (f); - s->match[1 ] =qemu_get_be32 (f); - s->prescale[0 ] =qemu_get_be32 (f); - s->prescale[1 ] =qemu_get_be32 (f); - s->match_prescale[0 ] =qemu_get_be32 (f); - s->match_prescale[1 ] =qemu_get_be32 (f); - s->rtc =qemu_get_be32 (f); - s->tick[0 ] =qemu_get_be64 (f); - s->tick[1 ] =qemu_get_be64 (f); -qemu_get_timer (f, s->timer[0 ]); -qemu_get_timer (f, s->timer[1 ]); - -return 0 ; -} +static const VMStateDescription vmstate_stellaris_gptm = { + .name ="stellaris_gptm" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_UINT32 (config, gptm_state), +VMSTATE_UINT32_ARRAY (mode, gptm_state,2 ), +VMSTATE_UINT32 (control, gptm_state), +VMSTATE_UINT32 (state, gptm_state), +VMSTATE_UINT32 (mask, gptm_state), +VMSTATE_UINT32 (mode[0 ], gptm_state), +VMSTATE_UINT32 (mode[0 ], gptm_state), +VMSTATE_UINT32_ARRAY (load, gptm_state,2 ), +VMSTATE_UINT32_ARRAY (match, gptm_state,2 ), +VMSTATE_UINT32_ARRAY (prescale, gptm_state,2 ), +VMSTATE_UINT32_ARRAY (match_prescale, gptm_state,2 ), +VMSTATE_UINT32 (rtc, gptm_state), +VMSTATE_INT64_ARRAY (tick, gptm_state,2 ), +VMSTATE_TIMER_ARRAY (timer, gptm_state,2 ), +VMSTATE_END_OF_LIST () + } +};static int stellaris_gptm_init (SysBusDevice *dev) {
@@ -355,8 +320,7 @@ static int stellaris_gptm_init(SysBusDevice *dev) s->opaque[0 ] = s->opaque[1 ] = s; s->timer[0 ] =qemu_new_timer (vm_clock, gptm_tick, &s->opaque[0 ]); s->timer[1 ] =qemu_new_timer (vm_clock, gptm_tick, &s->opaque[1 ]); -register_savevm (&dev->qdev,"stellaris_gptm" ,-1 ,1 , - gptm_save, gptm_load, s); +vmstate_register (&dev->qdev,-1 , &vmstate_stellaris_gptm, s);return 0 ; }
Signature · 1 line
1.7.4
cover VMState: Port several non-pc devices
Hi
This series are split in three parts:
- All VMState changes/fixes are together at the beggining (patches 1-9)
- Devices whose port is trivial: (patches 10-40)
- Devices whose port needs some change in types, or introduce a new struct to include all the device state: rest of patches.
There are three warnings and one error for checpatch. The Last one is a bug on checpatch, as there is no need to put spaces there (and putting params makes the preprecessor choke).
And the other three, we can use worse arguments names or having longer than 80 chars macro definitions.
I think that all are ok.
#31: FILE: hw/hw.h:442:
+#define VMSTATE_VARRAY_UINT32(_field, _state, _field_num, _version, _info, _type) {\
WARNING: line over 80 characters
#23: FILE: hw/hw.h:512:
+#define VMSTATE_STRUCT_VARRAY_INT32(_field, _state, _field_num, _version, _vmsd, _type) { \
#22: FILE: hw/hw.h:522:
+#define VMSTATE_STRUCT_VARRAY_UINT32(_field, _state, _field_num, _version, _vmsd, _type) { \
#41: FILE: hw/hw.h:755:
+ VMSTATE_POINTER_TEST(_f, _s, _test, vmstate_info_timer, QEMUTimer *)
^
None of the patches should be difficult to review/accept.
Please review. Anthony, apply the VMState ones the early possible, as it makes easier to work on other devices.
Later, Juan.
Juan Quintela (58):
vmstate: add VMSTATE_UINT32_EQUAL
vmstate: Fix varrays with uint8 indexes
vmstate: add UINT32 VARRAYS
vmstate: add VMSTATE_STRUCT_VARRAY_INT32
vmstate: add VMSTATE_INT64_ARRAY
vmstate: add VMSTATE_STRUCT_VARRAY_UINT32
vmstate: Add a way to send a partial array
vmstate: be able to store/save a pci device from a pointer
vmstate: move timers to use test instead of version
vmstate: port adb_kbd
vmstate: port adb_mouse
vmstate: port ads7846
vmstate: port m48t59
vmstate: port mipsnet
vmstate: port arm sp804
vmstate: port arm_timer
vmstate: port sysborg_timer
vmstate: port pmtimer
vmstate: port syborg_rtc
vmstate: port pxa2xx_pic
vmstate: port pxa2xx_keypad
vmstate: port pl011
vmstate: port armv7m nvic
vmstate: port stellaris i2c
vmstate: port stellaris ssi bus
vmstate: port stellaris sys
vmstate: port pl022 ssp
vmstate: port heathrow_pic
vmstate: port cuda
vmstate: port stellaris gptm
vmstate: port pxa2xx_i2s
vmstate: port pxa2xx_cm
vmstate: port pxa2xx_mm
vmstate: port pxa2xx_pm
vmstate: port pxa2xx_rtc
vmstate: port ppce500_pci
vmstate: port ppc4xx_pci
vmstate: port syborg_pointer
vmstate: port stellaris_adc
vmstate: port syborg_serial
vmstate: port syborg_keyboard
vmstate: port stellaris gamepad
vmstate: stellaris use unused for placeholder entries
pxa2xx_dma: make req array static
vmstate: port pxa2xx_dma
pxa2xx_lcd: name anonymous struct
pxa2xx_lcd: up field is used as a bool and migrated as an uint8_t
vmstate: port pxa2xx_lcdc
max111x: input field is only used as uint8_t
vmstate: port max111x
nand: pin values are uint8_t
vmstate: port nand
mac_nvram: size is a size, no need to be a target dependent type
vmstate: port mac_nvram
piix4: create PIIX4State
vmstate: port piix4
mac_dbdma: create DBDMAState instead of passing one array around
vmstate: port mac_dbdma
hw/adb.c | 83 +++++--------- hw/ads7846.c | 41 +++---- hw/arm_timer.c | 66 ++++------- hw/armv7m_nvic.c | 39 ++---- hw/cuda.c | 116 +++++++----------- hw/flash.h | 4 +- hw/heathrow_pic.c | 62 ++++------ hw/hw.h | 94 +++++++++++++-- hw/m48t59.c | 36 ++---- hw/mac_dbdma.c | 83 +++++++------ hw/mac_nvram.c | 32 ++--- hw/max111x.c | 51 +++----- hw/mipsnet.c | 53 +++------ hw/nand.c | 79 +++++++------ hw/piix4.c | 44 ++++---- hw/pl011.c | 76 ++++-------- hw/pl022.c | 84 ++++++-------- hw/ppc4xx_pci.c | 80 ++++++------- hw/ppce500_pci.c | 87 ++++++-------- hw/ptimer.c | 59 +++------- hw/pxa2xx.c | 243 +++++++++++++++----------------------- hw/pxa2xx_dma.c | 97 ++++++--------- hw/pxa2xx_keypad.c | 53 +++------ hw/pxa2xx_lcd.c | 138 +++++++++------------- hw/pxa2xx_pic.c | 52 +++----- hw/stellaris.c | 323 +++++++++++++++++--------------------------------- hw/stellaris_input.c | 50 ++++---- hw/syborg_keyboard.c | 57 +++------ hw/syborg_pointer.c | 73 +++++------- hw/syborg_rtc.c | 34 ++---- hw/syborg_serial.c | 60 +++------- hw/syborg_timer.c | 46 +++----- qemu-timer.h | 2 - savevm.c | 25 ++++ 34 files changed, 1048 insertions(+), 1474 deletions(-)
Signature · 1 line
1.7.4
PATCH 3/58 vmstate: add UINT32 VARRAYS
--- hw/hw.h | 11 +++++++++++ savevm.c | 2 ++ 2 files changed, 13 insertions(+), 0 deletions(-)
hw/hw.h +11 -0
@@ -299,6 +299,7 @@ enum VMStateFlags {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 {
@@ -438,6 +439,16 @@ extern const VMStateInfo vmstate_info_unused_buffer; .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), \
savevm.c +2 -0
@@ -1329,6 +1329,8 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, n_elems = field->num; }else if (field->flags &VMS_VARRAY_INT32 ) { n_elems = *(int32_t *)(opaque+field->num_offset); + }else if (field->flags &VMS_VARRAY_UINT32 ) { + n_elems = *(uint32_t *)(opaque+field->num_offset); }else if (field->flags &VMS_VARRAY_UINT16 ) { n_elems = *(uint16_t *)(opaque+field->num_offset); }else if (field->flags &VMS_VARRAY_UINT8 ) {
Signature · 1 line
1.7.4
PATCH 32/58 vmstate: port pxa2xx_cm
In reply to Juan Quintela--- hw/pxa2xx.c | 39 ++++++++++++++------------------------- 1 files changed, 14 insertions(+), 25 deletions(-)
hw/pxa2xx.c +14 -25
@@ -228,29 +228,18 @@ static CPUWriteMemoryFunc * const pxa2xx_cm_writefn[] = { pxa2xx_cm_write, }; -static void pxa2xx_cm_save (QEMUFile *f,void *opaque) -{ -PXA2xxState *s = (PXA2xxState *) opaque; -int i; - -for (i =0 ; i <4 ; i ++) -qemu_put_be32s (f, &s->cm_regs[i]); -qemu_put_be32s (f, &s->clkcfg); -qemu_put_be32s (f, &s->pmnc); -} - -static int pxa2xx_cm_load (QEMUFile *f,void *opaque,int version_id) -{ -PXA2xxState *s = (PXA2xxState *) opaque; -int i; - -for (i =0 ; i <4 ; i ++) -qemu_get_be32s (f, &s->cm_regs[i]); -qemu_get_be32s (f, &s->clkcfg); -qemu_get_be32s (f, &s->pmnc); - -return 0 ; -} +static const VMStateDescription vmstate_pxa2xx_cm = { + .name ="pxa2xx_cm" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { +VMSTATE_UINT32_ARRAY (cm_regs, PXA2xxState,4 ), +VMSTATE_UINT32 (clkcfg, PXA2xxState), +VMSTATE_UINT32 (pmnc, PXA2xxState), +VMSTATE_END_OF_LIST () + } +};static uint32_t pxa2xx_clkpwr_read (void *opaque,int op2,int reg,int crm) {
@@ -2118,7 +2107,7 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision) iomemtype =cpu_register_io_memory (pxa2xx_cm_readfn, pxa2xx_cm_writefn, s,DEVICE_NATIVE_ENDIAN );cpu_register_physical_memory (s->cm_base,0x1000 , iomemtype); -register_savevm (NULL ,"pxa2xx_cm" ,0 ,0 , pxa2xx_cm_save, pxa2xx_cm_load, s); +vmstate_register (NULL ,0 , &vmstate_pxa2xx_cm, s);cpu_arm_set_cp_io (s->env,14 , pxa2xx_cp14_read, pxa2xx_cp14_write, s);
@@ -2241,7 +2230,7 @@ PXA2xxState *pxa255_init(unsigned int sdram_size) iomemtype =cpu_register_io_memory (pxa2xx_cm_readfn, pxa2xx_cm_writefn, s,DEVICE_NATIVE_ENDIAN );cpu_register_physical_memory (s->cm_base,0x1000 , iomemtype); -register_savevm (NULL ,"pxa2xx_cm" ,0 ,0 , pxa2xx_cm_save, pxa2xx_cm_load, s); +vmstate_register (NULL ,0 , &vmstate_pxa2xx_cm, s);cpu_arm_set_cp_io (s->env,14 , pxa2xx_cp14_read, pxa2xx_cp14_write, s);
Signature · 1 line
1.7.4
PATCH 42/58 vmstate: port stellaris gamepad
In reply to Juan Quintela--- hw/stellaris_input.c | 50 ++++++++++++++++++++++++-------------------------- 1 files changed, 24 insertions(+), 26 deletions(-)
hw/stellaris_input.c +24 -26
@@ -13,7 +13,7 @@typedef struct {qemu_irq irq;int keycode; -int pressed; +uint8_t pressed; }gamepad_button ; typedef struct {
@@ -47,30 +47,29 @@ static void stellaris_gamepad_put_key(void * opaque, int keycode) s->extension =0 ; } -static void stellaris_gamepad_save (QEMUFile *f,void *opaque) -{ -gamepad_state *s = (gamepad_state *)opaque; -int i; - -qemu_put_be32 (f, s->extension); -for (i =0 ; i < s->num_buttons; i++) -qemu_put_byte (f, s->buttons[i].pressed); -} - -static int stellaris_gamepad_load (QEMUFile *f,void *opaque,int version_id) -{ -gamepad_state *s = (gamepad_state *)opaque; -int i; - -if (version_id !=1 ) -return -EINVAL ; - - s->extension =qemu_get_be32 (f); -for (i =0 ; i < s->num_buttons; i++) - s->buttons[i].pressed =qemu_get_byte (f); +static const VMStateDescription vmstate_stellaris_button = { + .name ="stellaris_button" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_UINT8 (pressed, gamepad_button), +VMSTATE_END_OF_LIST () + } +}; -return 0 ; -} +static const VMStateDescription vmstate_stellaris_gamepad = { + .name ="stellaris_gamepad" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_INT32 (extension, gamepad_state), +VMSTATE_STRUCT_VARRAY_INT32 (buttons, gamepad_state, num_buttons,0 , + vmstate_stellaris_button, gamepad_button), +VMSTATE_END_OF_LIST () + } +};/* Returns an array 5 ouput slots. */ void stellaris_gamepad_init (int n,qemu_irq *irq,const int *keycode)
@@ -86,6 +85,5 @@ void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode) } s->num_buttons = n;qemu_add_kbd_event_handler (stellaris_gamepad_put_key, s); -register_savevm (NULL ,"stellaris_gamepad" ,-1 ,1 , - stellaris_gamepad_save, stellaris_gamepad_load, s); +vmstate_register (NULL ,-1 , &vmstate_stellaris_gamepad, s); }
Signature · 1 line
1.7.4
PATCH 41/58 vmstate: port syborg_keyboard
In reply to Juan Quintela--- hw/syborg_keyboard.c | 57 +++++++++++++++----------------------------------- 1 files changed, 17 insertions(+), 40 deletions(-)
hw/syborg_keyboard.c +17 -40
@@ -51,11 +51,11 @@ enum {typedef struct {SysBusDevice busdev; -int int_enabled; +uint32_t int_enabled;int extension_bit;uint32_t fifo_size;uint32_t *key_fifo; -int read_pos, read_count; +uint32_t read_pos, read_count;qemu_irq irq; }SyborgKeyboardState ;
@@ -165,43 +165,21 @@ static void syborg_keyboard_event(void *opaque, int keycode)syborg_keyboard_update (s); } -static void syborg_keyboard_save (QEMUFile *f,void *opaque) -{ -SyborgKeyboardState *s = (SyborgKeyboardState *)opaque; -int i; - -qemu_put_be32 (f, s->fifo_size); -qemu_put_be32 (f, s->int_enabled); -qemu_put_be32 (f, s->extension_bit); -qemu_put_be32 (f, s->read_pos); -qemu_put_be32 (f, s->read_count); -for (i =0 ; i < s->fifo_size; i++) { -qemu_put_be32 (f, s->key_fifo[i]); - } -} - -static int syborg_keyboard_load (QEMUFile *f,void *opaque,int version_id) -{ -SyborgKeyboardState *s = (SyborgKeyboardState *)opaque; -uint32_t val; -int i; - -if (version_id !=1 ) -return -EINVAL ; - - val =qemu_get_be32 (f); -if (val != s->fifo_size) -return -EINVAL ; - - s->int_enabled =qemu_get_be32 (f); - s->extension_bit =qemu_get_be32 (f); - s->read_pos =qemu_get_be32 (f); - s->read_count =qemu_get_be32 (f); -for (i =0 ; i < s->fifo_size; i++) { - s->key_fifo[i] =qemu_get_be32 (f); +static const VMStateDescription vmstate_syborg_keyboard = { + .name ="syborg_keyboard" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_UINT32_EQUAL (fifo_size, SyborgKeyboardState), +VMSTATE_UINT32 (int_enabled, SyborgKeyboardState), +VMSTATE_UINT32 (read_pos, SyborgKeyboardState), +VMSTATE_UINT32 (read_count, SyborgKeyboardState), +VMSTATE_VARRAY_UINT32 (key_fifo, SyborgKeyboardState, fifo_size,1 , + vmstate_info_uint32, uint32), +VMSTATE_END_OF_LIST () } -return 0 ; -} +};static int syborg_keyboard_init (SysBusDevice *dev) {
@@ -221,8 +199,7 @@ static int syborg_keyboard_init(SysBusDevice *dev)qemu_add_kbd_event_handler (syborg_keyboard_event, s); -register_savevm (&dev->qdev,"syborg_keyboard" ,-1 ,1 , - syborg_keyboard_save, syborg_keyboard_load, s); +vmstate_register (&dev->qdev,-1 , &vmstate_syborg_keyboard, s);return 0 ; }
Signature · 1 line
1.7.4
PATCH 24/58 vmstate: port stellaris i2c
In reply to Juan Quintela--- hw/stellaris.c | 49 +++++++++++++++++-------------------------------- 1 files changed, 17 insertions(+), 32 deletions(-)
hw/stellaris.c +17 -32
@@ -844,36 +844,22 @@ static CPUWriteMemoryFunc * const stellaris_i2c_writefn[] = { stellaris_i2c_write }; -static void stellaris_i2c_save (QEMUFile *f,void *opaque) -{ -stellaris_i2c_state *s = (stellaris_i2c_state *)opaque; - -qemu_put_be32 (f, s->msa); -qemu_put_be32 (f, s->mcs); -qemu_put_be32 (f, s->mdr); -qemu_put_be32 (f, s->mtpr); -qemu_put_be32 (f, s->mimr); -qemu_put_be32 (f, s->mris); -qemu_put_be32 (f, s->mcr); -} - -static int stellaris_i2c_load (QEMUFile *f,void *opaque,int version_id) -{ -stellaris_i2c_state *s = (stellaris_i2c_state *)opaque; - -if (version_id !=1 ) -return -EINVAL ; - - s->msa =qemu_get_be32 (f); - s->mcs =qemu_get_be32 (f); - s->mdr =qemu_get_be32 (f); - s->mtpr =qemu_get_be32 (f); - s->mimr =qemu_get_be32 (f); - s->mris =qemu_get_be32 (f); - s->mcr =qemu_get_be32 (f); - -return 0 ; -} +static const VMStateDescription vmstate_stellaris_i2c = { + .name ="stellaris_i2c" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_UINT32 (msa, stellaris_i2c_state), +VMSTATE_UINT32 (mcs, stellaris_i2c_state), +VMSTATE_UINT32 (mdr, stellaris_i2c_state), +VMSTATE_UINT32 (mtpr, stellaris_i2c_state), +VMSTATE_UINT32 (mimr, stellaris_i2c_state), +VMSTATE_UINT32 (mris, stellaris_i2c_state), +VMSTATE_UINT32 (mcr, stellaris_i2c_state), +VMSTATE_END_OF_LIST () + } +};static int stellaris_i2c_init (SysBusDevice * dev) {
@@ -891,8 +877,7 @@ static int stellaris_i2c_init(SysBusDevice * dev)sysbus_init_mmio (dev,0x1000 , iomemtype);/* ??? For now we only implement the master interface. */ stellaris_i2c_reset (s); -register_savevm (&dev->qdev,"stellaris_i2c" ,-1 ,1 , - stellaris_i2c_save, stellaris_i2c_load, s); +vmstate_register (&dev->qdev,-1 , &vmstate_stellaris_i2c, s);return 0 ; }
Signature · 1 line
1.7.4
PATCH 29/58 vmstate: port cuda
In reply to Juan Quintela--- hw/cuda.c | 116 ++++++++++++++++++++++++------------------------------------- 1 files changed, 46 insertions(+), 70 deletions(-)
hw/cuda.c +46 -70
@@ -644,80 +644,56 @@ static CPUReadMemoryFunc * const cuda_read[] = { &cuda_readl, }; -static void cuda_save_timer (QEMUFile *f,CUDATimer *s) +static bool cuda_timer_exist (void *opaque,int version_id) { -qemu_put_be16s (f, &s->latch); -qemu_put_be16s (f, &s->counter_value); -qemu_put_sbe64s (f, &s->load_time); -qemu_put_sbe64s (f, &s->next_irq_time); -if (s->timer) -qemu_put_timer (f, s->timer); -} - -static void cuda_save (QEMUFile *f,void *opaque) -{ -CUDAState *s = (CUDAState *)opaque; - -qemu_put_ubyte (f, s->b); -qemu_put_ubyte (f, s->a); -qemu_put_ubyte (f, s->dirb); -qemu_put_ubyte (f, s->dira); -qemu_put_ubyte (f, s->sr); -qemu_put_ubyte (f, s->acr); -qemu_put_ubyte (f, s->pcr); -qemu_put_ubyte (f, s->ifr); -qemu_put_ubyte (f, s->ier); -qemu_put_ubyte (f, s->anh); -qemu_put_sbe32s (f, &s->data_in_size); -qemu_put_sbe32s (f, &s->data_in_index); -qemu_put_sbe32s (f, &s->data_out_index); -qemu_put_ubyte (f, s->autopoll); -qemu_put_buffer (f, s->data_in,sizeof (s->data_in)); -qemu_put_buffer (f, s->data_out,sizeof (s->data_out)); -qemu_put_be32s (f, &s->tick_offset); -cuda_save_timer (f, &s->timers[0 ]); -cuda_save_timer (f, &s->timers[1 ]); -} +CUDATimer *s = opaque; -static void cuda_load_timer (QEMUFile *f,CUDATimer *s) -{ -qemu_get_be16s (f, &s->latch); -qemu_get_be16s (f, &s->counter_value); -qemu_get_sbe64s (f, &s->load_time); -qemu_get_sbe64s (f, &s->next_irq_time); -if (s->timer) -qemu_get_timer (f, s->timer); +return s->timer !=NULL ; } -static int cuda_load (QEMUFile *f,void *opaque,int version_id) -{ -CUDAState *s = (CUDAState *)opaque; - -if (version_id !=1 ) -return -EINVAL ; - - s->b =qemu_get_ubyte (f); - s->a =qemu_get_ubyte (f); - s->dirb =qemu_get_ubyte (f); - s->dira =qemu_get_ubyte (f); - s->sr =qemu_get_ubyte (f); - s->acr =qemu_get_ubyte (f); - s->pcr =qemu_get_ubyte (f); - s->ifr =qemu_get_ubyte (f); - s->ier =qemu_get_ubyte (f); - s->anh =qemu_get_ubyte (f); -qemu_get_sbe32s (f, &s->data_in_size); -qemu_get_sbe32s (f, &s->data_in_index); -qemu_get_sbe32s (f, &s->data_out_index); - s->autopoll =qemu_get_ubyte (f); -qemu_get_buffer (f, s->data_in,sizeof (s->data_in)); -qemu_get_buffer (f, s->data_out,sizeof (s->data_out)); -qemu_get_be32s (f, &s->tick_offset); -cuda_load_timer (f, &s->timers[0 ]); -cuda_load_timer (f, &s->timers[1 ]); +static const VMStateDescription vmstate_cuda_timer = { + .name ="cuda_timer" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { +VMSTATE_UINT16 (latch, CUDATimer), +VMSTATE_UINT16 (counter_value, CUDATimer), +VMSTATE_INT64 (load_time, CUDATimer), +VMSTATE_INT64 (next_irq_time, CUDATimer), +VMSTATE_TIMER_TEST (timer, CUDATimer, cuda_timer_exist), +VMSTATE_END_OF_LIST () + } +}; -return 0 ; -} +static const VMStateDescription vmstate_cuda = { + .name ="cuda" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_UINT8 (a, CUDAState), +VMSTATE_UINT8 (b, CUDAState), +VMSTATE_UINT8 (dira, CUDAState), +VMSTATE_UINT8 (dirb, CUDAState), +VMSTATE_UINT8 (sr, CUDAState), +VMSTATE_UINT8 (acr, CUDAState), +VMSTATE_UINT8 (pcr, CUDAState), +VMSTATE_UINT8 (ifr, CUDAState), +VMSTATE_UINT8 (ier, CUDAState), +VMSTATE_UINT8 (anh, CUDAState), +VMSTATE_INT32 (data_in_size, CUDAState), +VMSTATE_INT32 (data_in_index, CUDAState), +VMSTATE_INT32 (data_out_index, CUDAState), +VMSTATE_UINT8 (autopoll, CUDAState), +VMSTATE_BUFFER (data_in, CUDAState), +VMSTATE_BUFFER (data_out, CUDAState), +VMSTATE_UINT32 (tick_offset, CUDAState), +VMSTATE_STRUCT_ARRAY (timers, CUDAState,2 ,1 , + vmstate_cuda_timer, CUDATimer), +VMSTATE_END_OF_LIST () + } +};static void cuda_reset (void *opaque) {
@@ -764,6 +740,6 @@ void cuda_init (int *cuda_mem_index, qemu_irq irq) s->adb_poll_timer =qemu_new_timer (vm_clock, cuda_adb_poll, s); *cuda_mem_index =cpu_register_io_memory (cuda_read, cuda_write, s,DEVICE_NATIVE_ENDIAN ); -register_savevm (NULL ,"cuda" ,-1 ,1 , cuda_save, cuda_load, s); +vmstate_register (NULL ,-1 , &vmstate_cuda, s);qemu_register_reset (cuda_reset, s); }
Signature · 1 line
1.7.4
PATCH 39/58 vmstate: port stellaris_adc
In reply to Juan Quintela--- hw/stellaris.c | 89 +++++++++++++++++++++---------------------------------- 1 files changed, 34 insertions(+), 55 deletions(-)
hw/stellaris.c +34 -55
@@ -1058,60 +1058,40 @@ static CPUWriteMemoryFunc * const stellaris_adc_writefn[] = {stellaris_adc_write }; -static void stellaris_adc_save (QEMUFile *f,void *opaque) -{ -stellaris_adc_state *s = (stellaris_adc_state *)opaque; -int i; -int j; - -qemu_put_be32 (f, s->actss); -qemu_put_be32 (f, s->ris); -qemu_put_be32 (f, s->im); -qemu_put_be32 (f, s->emux); -qemu_put_be32 (f, s->ostat); -qemu_put_be32 (f, s->ustat); -qemu_put_be32 (f, s->sspri); -qemu_put_be32 (f, s->sac); -for (i =0 ; i <4 ; i++) { -qemu_put_be32 (f, s->fifo[i].state); -for (j =0 ; j <16 ; j++) { -qemu_put_be32 (f, s->fifo[i].data[j]); - } -qemu_put_be32 (f, s->ssmux[i]); -qemu_put_be32 (f, s->ssctl[i]); - } -qemu_put_be32 (f, s->noise); -} - -static int stellaris_adc_load (QEMUFile *f,void *opaque,int version_id) -{ -stellaris_adc_state *s = (stellaris_adc_state *)opaque; -int i; -int j; - -if (version_id !=1 ) -return -EINVAL ; - - s->actss =qemu_get_be32 (f); - s->ris =qemu_get_be32 (f); - s->im =qemu_get_be32 (f); - s->emux =qemu_get_be32 (f); - s->ostat =qemu_get_be32 (f); - s->ustat =qemu_get_be32 (f); - s->sspri =qemu_get_be32 (f); - s->sac =qemu_get_be32 (f); -for (i =0 ; i <4 ; i++) { - s->fifo[i].state =qemu_get_be32 (f); -for (j =0 ; j <16 ; j++) { - s->fifo[i].data[j] =qemu_get_be32 (f); - } - s->ssmux[i] =qemu_get_be32 (f); - s->ssctl[i] =qemu_get_be32 (f); +static const VMStateDescription vmstate_stellaris_adc = { + .name ="stellaris_adc" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_UINT32 (actss, stellaris_adc_state), +VMSTATE_UINT32 (ris, stellaris_adc_state), +VMSTATE_UINT32 (im, stellaris_adc_state), +VMSTATE_UINT32 (emux, stellaris_adc_state), +VMSTATE_UINT32 (ostat, stellaris_adc_state), +VMSTATE_UINT32 (ustat, stellaris_adc_state), +VMSTATE_UINT32 (sspri, stellaris_adc_state), +VMSTATE_UINT32 (sac, stellaris_adc_state), +VMSTATE_UINT32 (fifo[0 ].state, stellaris_adc_state), +VMSTATE_UINT32_ARRAY (fifo[0 ].data, stellaris_adc_state,16 ), +VMSTATE_UINT32 (ssmux[0 ], stellaris_adc_state), +VMSTATE_UINT32 (ssctl[0 ], stellaris_adc_state), +VMSTATE_UINT32 (fifo[1 ].state, stellaris_adc_state), +VMSTATE_UINT32_ARRAY (fifo[1 ].data, stellaris_adc_state,16 ), +VMSTATE_UINT32 (ssmux[1 ], stellaris_adc_state), +VMSTATE_UINT32 (ssctl[1 ], stellaris_adc_state), +VMSTATE_UINT32 (fifo[2 ].state, stellaris_adc_state), +VMSTATE_UINT32_ARRAY (fifo[2 ].data, stellaris_adc_state,16 ), +VMSTATE_UINT32 (ssmux[2 ], stellaris_adc_state), +VMSTATE_UINT32 (ssctl[2 ], stellaris_adc_state), +VMSTATE_UINT32 (fifo[3 ].state, stellaris_adc_state), +VMSTATE_UINT32_ARRAY (fifo[3 ].data, stellaris_adc_state,16 ), +VMSTATE_UINT32 (ssmux[3 ], stellaris_adc_state), +VMSTATE_UINT32 (ssctl[3 ], stellaris_adc_state), +VMSTATE_UINT32 (noise, stellaris_adc_state), +VMSTATE_END_OF_LIST () } - s->noise =qemu_get_be32 (f); - -return 0 ; -} +};static int stellaris_adc_init (SysBusDevice *dev) {
@@ -1129,8 +1109,7 @@ static int stellaris_adc_init(SysBusDevice *dev)sysbus_init_mmio (dev,0x1000 , iomemtype);stellaris_adc_reset (s);qdev_init_gpio_in (&dev->qdev, stellaris_adc_trigger,1 ); -register_savevm (&dev->qdev,"stellaris_adc" ,-1 ,1 , - stellaris_adc_save, stellaris_adc_load, s); +vmstate_register (&dev->qdev,-1 , &vmstate_stellaris_adc, s);return 0 ; }
Signature · 1 line
1.7.4
PATCH 35/58 vmstate: port pxa2xx_rtc
In reply to Juan Quintela--- hw/pxa2xx.c | 85 +++++++++++++++++++++++++--------------------------------- 1 files changed, 37 insertions(+), 48 deletions(-)
hw/pxa2xx.c +37 -48
@@ -1170,62 +1170,53 @@ static void pxa2xx_rtc_init(PXA2xxState *s) s->rtc_pi =qemu_new_timer (rt_clock, pxa2xx_rtc_pi_tick, s); } -static void pxa2xx_rtc_save (QEMUFile *f,void *opaque) +static void pxa2xx_rtc_pre_save (void *opaque) { -PXA2xxState *s = (PXA2xxState *) opaque; +PXA2xxState *s = opaque;pxa2xx_rtc_hzupdate (s);pxa2xx_rtc_piupdate (s);pxa2xx_rtc_swupdate (s); +} -qemu_put_be32s (f, &s->rttr); -qemu_put_be32s (f, &s->rtsr); -qemu_put_be32s (f, &s->rtar); -qemu_put_be32s (f, &s->rdar1); -qemu_put_be32s (f, &s->rdar2); -qemu_put_be32s (f, &s->ryar1); -qemu_put_be32s (f, &s->ryar2); -qemu_put_be32s (f, &s->swar1); -qemu_put_be32s (f, &s->swar2); -qemu_put_be32s (f, &s->piar); -qemu_put_be32s (f, &s->last_rcnr); -qemu_put_be32s (f, &s->last_rdcr); -qemu_put_be32s (f, &s->last_rycr); -qemu_put_be32s (f, &s->last_swcr); -qemu_put_be32s (f, &s->last_rtcpicr); -qemu_put_sbe64s (f, &s->last_hz); -qemu_put_sbe64s (f, &s->last_sw); -qemu_put_sbe64s (f, &s->last_pi); -} - -static int pxa2xx_rtc_load (QEMUFile *f,void *opaque,int version_id) +static int pxa2xx_rtc_post_load (void *opaque,int version_id) { -PXA2xxState *s = (PXA2xxState *) opaque; - -qemu_get_be32s (f, &s->rttr); -qemu_get_be32s (f, &s->rtsr); -qemu_get_be32s (f, &s->rtar); -qemu_get_be32s (f, &s->rdar1); -qemu_get_be32s (f, &s->rdar2); -qemu_get_be32s (f, &s->ryar1); -qemu_get_be32s (f, &s->ryar2); -qemu_get_be32s (f, &s->swar1); -qemu_get_be32s (f, &s->swar2); -qemu_get_be32s (f, &s->piar); -qemu_get_be32s (f, &s->last_rcnr); -qemu_get_be32s (f, &s->last_rdcr); -qemu_get_be32s (f, &s->last_rycr); -qemu_get_be32s (f, &s->last_swcr); -qemu_get_be32s (f, &s->last_rtcpicr); -qemu_get_sbe64s (f, &s->last_hz); -qemu_get_sbe64s (f, &s->last_sw); -qemu_get_sbe64s (f, &s->last_pi); +PXA2xxState *s = opaque;pxa2xx_rtc_alarm_update (s, s->rtsr); -return 0 ; } +static const VMStateDescription vmstate_pxa2xx_rtc = { + .name ="pxa2xx_rtc" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .pre_save = pxa2xx_rtc_pre_save, + .post_load = pxa2xx_rtc_post_load, + .fields = (VMStateField []) { +VMSTATE_UINT32 (rttr, PXA2xxState), +VMSTATE_UINT32 (rtsr, PXA2xxState), +VMSTATE_UINT32 (rtar, PXA2xxState), +VMSTATE_UINT32 (rdar1, PXA2xxState), +VMSTATE_UINT32 (rdar2, PXA2xxState), +VMSTATE_UINT32 (ryar1, PXA2xxState), +VMSTATE_UINT32 (ryar2, PXA2xxState), +VMSTATE_UINT32 (swar1, PXA2xxState), +VMSTATE_UINT32 (swar2, PXA2xxState), +VMSTATE_UINT32 (piar, PXA2xxState), +VMSTATE_UINT32 (last_rcnr, PXA2xxState), +VMSTATE_UINT32 (last_rdcr, PXA2xxState), +VMSTATE_UINT32 (last_rycr, PXA2xxState), +VMSTATE_UINT32 (last_swcr, PXA2xxState), +VMSTATE_UINT32 (last_rtcpicr, PXA2xxState), +VMSTATE_INT64 (last_hz, PXA2xxState), +VMSTATE_INT64 (last_sw, PXA2xxState), +VMSTATE_INT64 (last_pi, PXA2xxState), +VMSTATE_END_OF_LIST () + } +}; +/* I2C Interface */ typedef struct { i2c_slave i2c;
@@ -2130,8 +2121,7 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision) pxa2xx_rtc_writefn, s, DEVICE_NATIVE_ENDIAN);cpu_register_physical_memory (s->rtc_base,0x1000 , iomemtype);pxa2xx_rtc_init (s); -register_savevm (NULL ,"pxa2xx_rtc" ,0 ,0 , pxa2xx_rtc_save, - pxa2xx_rtc_load, s); +vmstate_register (NULL ,0 , &vmstate_pxa2xx_rtc, s); s->i2c[0 ] =pxa2xx_i2c_init (0x40301600 , s->pic[PXA2XX_PIC_I2C ],0xffff ); s->i2c[1 ] =pxa2xx_i2c_init (0x40f00100 , s->pic[PXA2XX_PIC_PWRI2C ],0xff );
@@ -2253,8 +2243,7 @@ PXA2xxState *pxa255_init(unsigned int sdram_size) pxa2xx_rtc_writefn, s, DEVICE_NATIVE_ENDIAN);cpu_register_physical_memory (s->rtc_base,0x1000 , iomemtype);pxa2xx_rtc_init (s); -register_savevm (NULL ,"pxa2xx_rtc" ,0 ,0 , pxa2xx_rtc_save, - pxa2xx_rtc_load, s); +vmstate_register (NULL ,0 , &vmstate_pxa2xx_rtc, s); s->i2c[0 ] =pxa2xx_i2c_init (0x40301600 , s->pic[PXA2XX_PIC_I2C ],0xffff ); s->i2c[1 ] =pxa2xx_i2c_init (0x40f00100 , s->pic[PXA2XX_PIC_PWRI2C ],0xff );
Signature · 1 line
1.7.4
Re: [Qemu-devel] [PATCH 08/58] vmstate: be able to store/save a pci device from a pointer
In reply to Juan QuintelaQuoted 26 lines · Juan Quintela
Signed-off-by Juan Quintela <[email protected]>--- hw/hw.h | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)hw/hw.h +8
-0@@ -609,6 +609,14 @@ extern const VMStateDescription vmstate_pci_device; .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) { \Signature · 1 line
1.7.4
There are only two users and it would be better to embedded PCIDevice Something like this. I did only compile test.
thanks,
hw/ppc4xx_pci.c +13 -13
@@ -48,11 +48,11 @@ struct PCITargetMap {#define PPC4xx_PCI_NR_PTMS 2struct PPC4xxPCIState { +PCIDevice pci_dev;struct PCIMasterMap pmm[PPC4xx_PCI_NR_PMMS];struct PCITargetMap ptm[PPC4xx_PCI_NR_PTMS];PCIHostState pci_state; -PCIDevice *pci_dev; };typedef struct PPC4xxPCIState PPC4xxPCIState ;
@@ -290,7 +290,7 @@ static void ppc4xx_pci_save(QEMUFile *f, void *opaque)PPC4xxPCIState *controller = opaque;int i; -pci_device_save (controller->pci_dev, f); +pci_device_save (&controller->pci_dev, f);for (i =0 ; i < PPC4xx_PCI_NR_PMMS; i++) {qemu_put_be32s (f, &controller->pmm[i].la);
@@ -313,7 +313,7 @@ static int ppc4xx_pci_load(QEMUFile *f, void *opaque, int version_id)if (version_id !=1 )return -EINVAL ; -pci_device_load (controller->pci_dev, f); +pci_device_load (&controller->pci_dev, f);for (i =0 ; i < PPC4xx_PCI_NR_PMMS; i++) {qemu_get_be32s (f, &controller->pmm[i].la);
@@ -337,22 +337,22 @@ PCIBus *ppc4xx_pci_init(CPUState *env, qemu_irq pci_irqs[4], target_phys_addr_t special_cycle, target_phys_addr_t registers) { +PCIBus *pci_bus; +PCIDevice *pci_dev;PPC4xxPCIState *controller;int index;static int ppc4xx_pci_id;uint8_t *pci_conf; - controller =qemu_mallocz (sizeof (PPC4xxPCIState)); + pci_bus =pci_register_bus (NULL ,"pci" , + ppc4xx_pci_set_irq, ppc4xx_pci_map_irq, + pci_irqs,0 ,4 ); - controller->pci_state.bus =pci_register_bus (NULL ,"pci" , - ppc4xx_pci_set_irq, - ppc4xx_pci_map_irq, - pci_irqs,0 ,4 ); + pci_dev =pci_register_device (pci_bus,"host bridge" , +sizeof (PPC4xxPCIState),0 ,NULL ,NULL ); + controller =DO_UPCAST (PPC4xxPCIState, pci_dev, pci_dev); - controller->pci_dev =pci_register_device (controller->pci_state.bus, -"host bridge" ,sizeof (PCIDevice), -0 ,NULL ,NULL ); - pci_conf = controller->pci_dev->config; + pci_conf = controller->pci_dev.config;pci_config_set_vendor_id (pci_conf,PCI_VENDOR_ID_IBM );pci_config_set_device_id (pci_conf,PCI_DEVICE_ID_IBM_440GX );pci_config_set_class (pci_conf,PCI_CLASS_BRIDGE_OTHER );
@@ -381,7 +381,7 @@ PCIBus *ppc4xx_pci_init(CPUState *env, qemu_irq pci_irqs[4],qemu_register_reset (ppc4xx_pci_reset, controller);/* XXX load/save code not tested. */ -register_savevm (&controller->pci_dev->qdev,"ppc4xx_pci" , ppc4xx_pci_id++, +register_savevm (&controller->pci_dev.qdev,"ppc4xx_pci" , ppc4xx_pci_id++,1 , ppc4xx_pci_save, ppc4xx_pci_load, controller);return controller->pci_state.bus;
hw/ppce500_pci.c +10 -14
@@ -73,11 +73,11 @@ struct pci_inbound { };struct PPCE500PCIState { +PCIDevice pci_dev;struct pci_outbound pob[PPCE500_PCI_NR_POBS ];struct pci_inbound pib[PPCE500_PCI_NR_PIBS ];uint32_t gasket_time;PCIHostState pci_state; -PCIDevice *pci_dev; };typedef struct PPCE500PCIState PPCE500PCIState ;
@@ -221,7 +221,7 @@ static void ppce500_pci_save(QEMUFile *f, void *opaque)PPCE500PCIState *controller = opaque;int i; -pci_device_save (controller->pci_dev, f); +pci_device_save (&controller->pci_dev, f);for (i =0 ; i <PPCE500_PCI_NR_POBS ; i++) {qemu_put_be32s (f, &controller->pob[i].potar);
@@ -247,7 +247,7 @@ static int ppce500_pci_load(QEMUFile *f, void *opaque, int version_id)if (version_id !=1 )return -EINVAL ; -pci_device_load (controller->pci_dev, f); +pci_device_load (&controller->pci_dev, f);for (i =0 ; i <PPCE500_PCI_NR_POBS ; i++) {qemu_get_be32s (f, &controller->pob[i].potar);
@@ -269,28 +269,24 @@ static int ppce500_pci_load(QEMUFile *f, void *opaque, int version_id)PCIBus *ppce500_pci_init (qemu_irq pci_irqs[4 ],target_phys_addr_t registers) { +PCIBus *pci_bus;PPCE500PCIState *controller;PCIDevice *d;int index;static int ppce500_pci_id; - controller =qemu_mallocz (sizeof (PPCE500PCIState)); - - controller->pci_state.bus =pci_register_bus (NULL ,"pci" , - mpc85xx_pci_set_irq, - mpc85xx_pci_map_irq, - pci_irqs,PCI_DEVFN (0x11 ,0 ), -4 ); - d =pci_register_device (controller->pci_state.bus, -"host bridge" ,sizeof (PCIDevice), + pci_bus =pci_register_bus (NULL ,"pci" , + mpc85xx_pci_set_irq, mpc85xx_pci_map_irq, + pci_irqs,PCI_DEVFN (0x11 ,0 ),4 ); + d =pci_register_device (pci_bus,"host bridge" ,sizeof (PPCE500PCIState),0 ,NULL ,NULL ); + controller =DO_UPCAST (PPCE500PCIState, pci_dev, d); + controller->pci_state.bus = pci_bus;pci_config_set_vendor_id (d->config,PCI_VENDOR_ID_FREESCALE );pci_config_set_device_id (d->config,PCI_DEVICE_ID_MPC8533E );pci_config_set_class (d->config,PCI_CLASS_PROCESSOR_POWERPC ); - controller->pci_dev = d; -/* CFGADDR */ index =pci_host_conf_register_mmio (&controller->pci_state,DEVICE_BIG_ENDIAN );
Signature · 1 line
yamahata
Re: [Qemu-devel] [PATCH 58/58] vmstate: port mac_dbdma
In reply to Juan QuintelaQuoted 20 lines · Juan Quintela
Signed-off-by Juan Quintela <[email protected]>---
hw/mac_dbdma.c | 46 ++++++++++++++++++++++------------------------1 files changed, 22 insertions(+), 24 deletions(-)hw/mac_dbdma.c +0
-7@@ -810,30 +810,28 @@ static CPUReadMemoryFunc * const dbdma_read[] = { dbdma_readl, }; -static void dbdma_save (QEMUFile *f,void *opaque) -{ - DBDMAState *s = opaque; - unsigned int i, j; - - for (i = 0; i < DBDMA_CHANNELS; i++) - for (j = 0; j < DBDMA_REGS; j++)
hw/mac_dbdma.c static CPUReadMemoryFunc * const dbdma_read[] = { · line 829
Quoted 10 lines
hw/mac_dbdma.c +0
-10- qemu_put_be32s(f, &s->channels[i].regs[j]); -} - -static int dbdma_load (QEMUFile *f,void *opaque,int version_id) -{ - DBDMAState *s = opaque; - unsigned int i, j; - - if (version_id != 2) - return -EINVAL;
Here the version ID was expected to be 2...
Quoted 10 lines
hw/mac_dbdma.c +6
-4- - for (i = 0; i < DBDMA_CHANNELS; i++) - for (j = 0; j < DBDMA_REGS; j++) - qemu_get_be32s(f, &s->channels[i].regs[j]); +static const VMStateDescription vmstate_dbdma_channel = { + .name = "dbdma_channel", + .version_id = 0, + .minimum_version_id = 0, + .minimum_version_id_old = 0, + .fields = (VMStateField[]) {
hw/mac_dbdma.c static CPUReadMemoryFunc * const dbdma_read[] = { · line 826
Quoted 10 lines
hw/mac_dbdma.c +7
-2+ VMSTATE_UINT32_ARRAY(regs, struct DBDMA_channel, DBDMA_REGS), + VMSTATE_END_OF_LIST() + } +}; - return 0; -} +static const VMStateDescription vmstate_dbdma = { + .name = "dbdma", + .version_id = 1,
... while you now have 1 ...
Quoted 12 lines
hw/mac_dbdma.c +8
-0+ .minimum_version_id = 1, + .minimum_version_id_old = 1, + .fields = (VMStateField[]) { + VMSTATE_STRUCT_ARRAY(channels, DBDMAState, DBDMA_CHANNELS, 1, + vmstate_dbdma_channel, DBDMA_channel), + VMSTATE_END_OF_LIST() + } +}; static void dbdma_reset(void *opaque) {
hw/mac_dbdma.c void* DBDMA_init (int *dbdma_mem_index) · line 855
Quoted 4 lines
hw/mac_dbdma.c +0
-1@@ -852,7 +850,7 @@ void* DBDMA_init (int *dbdma_mem_index) *dbdma_mem_index = cpu_register_io_memory(dbdma_read, dbdma_write, s, DEVICE_LITTLE_ENDIAN); - register_savevm(NULL, "dbdma", -1, 1, dbdma_save, dbdma_load, s);
... and here it was 1, which probably didn't work.
I'd still use 2.
Re: [Qemu-devel] [PATCH 46/58] pxa2xx_lcd: name anonymous struct
In reply to Juan QuintelaQuoted 10 lines · Juan Quintela
Signed-off-by Juan Quintela <[email protected]>---
hw/pxa2xx_lcd.c | 28 +++++++++++++++-------------1 files changed, 15 insertions(+), 13 deletions(-)hw/pxa2xx_lcd.c +0
-0
hw/pxa2xx_lcd.c line 18
Quoted 4 lines
hw/pxa2xx_lcd.c +1
-0@@ -15,6 +15,20 @@ #include "sysemu.h" #include "framebuffer.h" +struct dma_channel {
DMAChannel
Re: [Qemu-devel] [PATCH 50/58] vmstate: port max111x
In reply to Juan QuintelaQuoted 43 lines · Juan Quintela
Signed-off-by Juan Quintela <[email protected]>---
hw/max111x.c | 49 +++++++++++++++++--------------------------------1 files changed, 17 insertions(+), 32 deletions(-)hw/max111x.c +0
-30@@ -94,36 +94,22 @@ static uint32_t max111x_transfer(SSISlave *dev, uint32_t value) return max111x_read(s); } -static void max111x_save (QEMUFile *f,void *opaque) -{ - MAX111xState *s = (MAX111xState *) opaque; - int i; - - qemu_put_8s(f, &s->tb1); - qemu_put_8s(f, &s->rb2); - qemu_put_8s(f, &s->rb3); - qemu_put_be32(f, s->inputs); - qemu_put_be32(f, s->com); - for (i = 0; i < s->inputs; i ++) - qemu_put_byte(f, s->input[i]); -} - -static int max111x_load (QEMUFile *f,void *opaque,int version_id) -{ - MAX111xState *s = (MAX111xState *) opaque; - int i; - - qemu_get_8s(f, &s->tb1); - qemu_get_8s(f, &s->rb2); - qemu_get_8s(f, &s->rb3); - if (s->inputs != qemu_get_be32(f)) - return -EINVAL; - s->com = qemu_get_be32(f); - for (i = 0; i < s->inputs; i ++) - s->input[i] = qemu_get_byte(f); - - return 0; -}
hw/max111x.c static uint32_t max111x_transfer(SSISlave *dev, uint32_t value) · line 106
Quoted 10 lines
hw/max111x.c +10
-0+static const VMStateDescription vmstate_max111x = { + .name = "max111x", + .version_id = 0, + .minimum_version_id = 0, + .minimum_version_id_old = 0, + .fields = (VMStateField[]) { + VMSTATE_UINT8(tb1, MAX111xState), + VMSTATE_UINT8(rb2, MAX111xState), + VMSTATE_UINT8(rb3, MAX111xState), + VMSTATE_INT32(inputs, MAX111xState),
Shouldn't this be VMSTATE_EQUAL_INT32(inputs, MAX111xState)?
Re: [Qemu-devel] [PATCH 42/58] vmstate: port stellaris gamepad
In reply to Juan QuintelaQuoted 38 lines · Juan Quintela
Signed-off-by Juan Quintela <[email protected]>---
hw/stellaris_input.c | 50 ++++++++++++++++++++++++--------------------------1 files changed, 24 insertions(+), 26 deletions(-)hw/stellaris_input.c +1
-17@@ -13,7 +13,7 @@ typedef struct { qemu_irq irq; int keycode; - int pressed; + uint8_t pressed; } gamepad_button; typedef struct {@@ -47,30 +47,29 @@ static void stellaris_gamepad_put_key(void * opaque, int keycode) s->extension = 0; } -static void stellaris_gamepad_save (QEMUFile *f,void *opaque) -{ - gamepad_state *s = (gamepad_state *)opaque; - int i; - - qemu_put_be32(f, s->extension); - for (i = 0; i < s->num_buttons; i++) - qemu_put_byte(f, s->buttons[i].pressed); -} - -static int stellaris_gamepad_load (QEMUFile *f,void *opaque,int version_id) -{ - gamepad_state *s = (gamepad_state *)opaque; - int i; - - if (version_id != 1)
hw/stellaris_input.c static void stellaris_gamepad_put_key(void * opaque, int keycode) · line 54
Quoted 10 lines
hw/stellaris_input.c +5
-5- return -EINVAL; - - s->extension = qemu_get_be32(f); - for (i = 0; i < s->num_buttons; i++) - s->buttons[i].pressed = qemu_get_byte(f); +static const VMStateDescription vmstate_stellaris_button = { + .name = "stellaris_button", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1,
For consistency with other structures, these version fields should be 0.
Quoted 32 lines · Juan Quintela
Hi
This series are split in three parts:
- All VMState changes/fixes are together at the beggining (patches 1-9)
- Devices whose port is trivial: (patches 10-40)
- Devices whose port needs some change in types, or introduce a new struct to include all the device state: rest of patches.There are three warnings and one error for checpatch. The Last one is a bug on checpatch, as there is no need to put spaces there (and putting params makes the preprecessor choke).
And the other three, we can use worse arguments names or having longer than 80 chars macro definitions.
I think that all are ok.
#31: FILE:
hw/hw.h:442:
+#defineVMSTATE_VARRAY_UINT32(_field, _state, _field_num, _version, _info, _type){\WARNING: line over 80 characters
#23: FILE:hw/hw.h:512:
+#defineVMSTATE_STRUCT_VARRAY_INT32(_field, _state, _field_num, _version, _vmsd, _type){ \#22: FILE:
hw/hw.h:522:
+#defineVMSTATE_STRUCT_VARRAY_UINT32(_field, _state, _field_num, _version, _vmsd, _type){ \#41: FILE:
hw/hw.h:755:
+ VMSTATE_POINTER_TEST(_f, _s,_test,vmstate_info_timer, QEMUTimer *) ^
Quoted 4 lines
None of the patches should be difficult to review/accept.
Please review. Anthony, apply the VMState ones the early possible, as it makes easier to work on other devices.
Very nice work! I had some minor comments, but otherwise for the whole series:
[Qemu-devel] Re: [PATCH 42/58] vmstate: port stellaris gamepad
In reply to Blue SwirlQuoted 10 lines · Blue Swirl
Quoted 5 lines · Juan Quintela
+static const VMStateDescription
vmstate_stellaris_button= {
+ .name = "stellaris_button",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .minimum_version_id_old = 1,For consistency with other structures, these version fields should be 0.
From the part that you didn't posted.
@@ -86,6 +85,5 @@ void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode)
}
s->num_buttons = n;
qemu_add_kbd_event_handler(stellaris_gamepad_put_key, s);- register_savevm(NULL, "stellaris_gamepad", -1, 1,
- stellaris_gamepad_save, stellaris_gamepad_load, s);
+ vmstate_register(NULL, -1, &vmstate_stellaris_gamepad, s);
}
Signature · 8 lines
1.7.4 Version is already at ' (4th argument of register_savevm). I just used the version that was there. I agree that some devices had started at version 0 and others at version 1, but that is independent of this series. Later, Juan.
[Qemu-devel] Re: [PATCH 42/58] vmstate: port stellaris gamepad
Quoted 24 lines · Juan Quintela
Quoted 8 lines · Blue Swirl
Quoted 5 lines · Juan Quintela
+static const VMStateDescription
vmstate_stellaris_button= {
+ .name = "stellaris_button",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .minimum_version_id_old = 1,For consistency with other structures, these version fields should be 0.
From the part that you didn't posted.
hw/stellaris_input.c +1
-3@@ -86,6 +85,5 @@ void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode) } s->num_buttons = n; qemu_add_kbd_event_handler(stellaris_gamepad_put_key, s); - register_savevm(NULL, "stellaris_gamepad", -1, 1, - stellaris_gamepad_save, stellaris_gamepad_load, s); + vmstate_register(NULL, -1, &vmstate_stellaris_gamepad, s); } --1.7.4
Quoted 3 lines
Version is already at ' (4th argument of
register_savevm). I just used the version that was there. I agree that some devices had started at version 0 and others at version 1, but that is independent of this series.
The patch introduces two VMState structures, main VMState for the whole gamepad and a secondary VMState for button structures. The version for main VMState is OK at 1, but I was talking about the button substructure VMState version, which is 0 in other patches.
Re: [Qemu-devel] [PATCH 20/58] vmstate: port pxa2xx_pic
In reply to Juan QuintelaQuoted 4 lines · Juan Quintela
Signed-off-by Juan Quintela <[email protected]>---
hw/pxa2xx_pic.c | 52 ++++++++++++++++++++--------------------------------1 files changed, 20 insertions(+), 32 deletions(-)
Hi Juan,
I pushed an earlier patch from Dmitry Eremin-Solenikov that converted this device, so this patch can be skipped. Unfortunately some of your other patches may need rebasing now.
Cheers
[Qemu-devel] Re: [PATCH 20/58] vmstate: port pxa2xx_pic
Quoted 7 lines · andrzej zaborowski
Quoted 4 lines · Juan Quintela
Signed-off-by Juan Quintela <[email protected]>---
hw/pxa2xx_pic.c | 52 ++++++++++++++++++++--------------------------------1 files changed, 20 insertions(+), 32 deletions(-)Hi Juan,
Hi andrzej
Quoted 3 lines
I pushed an earlier patch from Dmitry Eremin-Solenikov that converted this device, so this patch can be skipped. Unfortunately some of your other patches may need rebasing now.
Remove from my tree. Please take a look at the other pxa2xx* patches if you are planning to port the other devices.
Later, Juan.
[Qemu-devel] Re: [PATCH 20/58] vmstate: port pxa2xx_pic
Quoted 7 lines · Juan Quintela
Quoted 3 lines · andrzej zaborowski
I pushed an earlier patch from Dmitry Eremin-Solenikov that converted this device, so this patch can be skipped. Unfortunately some of your other patches may need rebasing now.
Remove from my tree. Please take a look at the other pxa2xx* patches if you are planning to port the other devices.
All of the other patches I looked at, looked good to me.
Cheers