VMState: port all i2c devices
cover VMState: port all i2c devices
Hi
This patch is on top of my previous series:
[PATCH 00/26] VMState: port several pc devices to vmstate
This ports all i2c_devices to vmstate. Big changes:
- i2c->address now are uint8_t, my review of all uses is that they are always used as uint8_t (and that is the type that is passed on the value). If you know i2c, please check. Change 0002 looks big, but it is because as I was auditing the paths, I changed the types of the functios to reflect that they use uint8_t. Real part of the patch is changing the struct definitions.
- qdev: there was not support for uint8_t (the i2c addresses) in qdev, now it is I missed this change in my 1st pass (on mips_malta)
- qdev_prop_set_uint32(eeprom, "address", 0x50 + i);
+ qdev_prop_set_uint8(eeprom, "address", 0x50 + i);
And qdev complained during compilation. qdev++
- I had to fix lots of places where values of one type were sent with a different type. qemu_put_byte/qemu_put_be16/qemu_put_be32 should be just baned. Yesterday.
- tmp105: We have a winner, the 1st user of post_save(). Can anyone explain me what we need to do _anything_ after saving
s->faults = tmp105_faultq[(s->config >> 3) & 3]; /* F */
I can't see why saving have to change faults, and no, I don't understand what that line does.
- twl922230: here we go.
It pass all the fields of a struct tm (they are ints) as uint16_t. All solutions are bad (tm):
* marshalling the struct tm in a struct tm_16bits fields, and use normal vmstate
* up version and declare all previous versions baned. No forward migration for you.
* Do the hack that I did, new type:
vmstate_hack_int32_as_uint16
local to that function, and be done with it. It is a big hack, but the function were already abusing the format.
- lm832x: I got an unused command (0xff) to be send as an error. it was using an int, -1 means an error, and a small number meaned a command. As the numbers of commands is very limited, I think this is the best solution. Notice that we were doing this already when we saved/loaded the value. Name the constant instead of -1 to make things easier.
- vmstate arrays shortened the save/load code for this series _a lot_.
Comments? Test and reports from arm users are welcome (the only use of i2c in a pc is for smbus-eeprom, and it is a _very_ limited use).
Later, Juan.
Juan Quintela (20):
qdev: Add support for uint8_t
i2c: addresses are load/save as uint8_t values, change types to
reflect this
vmstate: port i2c_bus device
vmstate: port i2c_slave device
vmstate: add uint8 array
vmstate: create VMSTATE_I2C_SLAVE
vmstate: port wm8750 device
vmstate: port max7310 device
vmstate: create VMSTATE_STRUCT_POINTER
vmstate: port pxa2xx_i2c device
vmstate: port ssd0303 device
vmstate: create VMSTATE_INT16_ARRAY
tmp105: change len and alorm to uint8_t
vmstate: port wmp105 device
twl92230: change pwrbtn_state to uint8_t
vmstate: port twl92230 device
vmstate: add support for arrays of pointers
lm832x: make fields to have the same types that they are saved/loaded
vmstate: port lm832x device
vmstate: remove i2c_slave_load/save
hw/hw.h | 47 ++++++++++++ hw/i2c.c | 64 ++++++++++------ hw/i2c.h | 10 +-- hw/lm832x.c | 148 +++++++++++++++---------------------- hw/max7310.c | 51 +++++-------- hw/mips_malta.c | 2 +- hw/pc.c | 2 +- hw/pxa2xx.c | 54 +++++++------- hw/qdev-properties.c | 33 ++++++++ hw/qdev.h | 5 + hw/smbus.c | 18 ++-- hw/smbus.h | 18 ++-- hw/ssd0303.c | 65 ++++++----------- hw/tmp105.c | 60 +++++++-------- hw/twl92230.c | 200 ++++++++++++++++++++++---------------------------- hw/wm8750.c | 120 +++++++++++------------------- savevm.c | 3 + 17 files changed, 438 insertions(+), 462 deletions(-)
PATCH 1/20 qdev: Add support for uint8_t
--- hw/qdev-properties.c | 33 +++++++++++++++++++++++++++++++++ hw/qdev.h | 5 +++++ 2 files changed, 38 insertions(+), 0 deletions(-)
hw/qdev-properties.c +33 -0
@@ -8,6 +8,34 @@ void *qdev_get_prop_ptr(DeviceState *dev, Property *prop)return ptr; } +/* --- 8bit integer --- */ + +static int parse_uint8 (DeviceState *dev,Property *prop,const char *str) +{ +uint8_t *ptr =qdev_get_prop_ptr (dev, prop); +const char *fmt; + +/* accept both hex and decimal */ + fmt =strncasecmp (str,"0x" ,2 ) ==0 ?"%" PRIx8 :"%" PRIu8; +if (sscanf (str, fmt, ptr) !=1 ) +return -1 ; +return 0 ; +} + +static int print_uint8 (DeviceState *dev,Property *prop,char *dest,size_t len) +{ +uint8_t *ptr =qdev_get_prop_ptr (dev, prop); +return snprintf (dest, len,"%" PRIu8, *ptr); +} + +PropertyInfo qdev_prop_uint8 = { + .name ="uint8" , + .type =PROP_TYPE_UINT8 , + .size =sizeof (uint8_t ), + .parse = parse_uint8, + .print = print_uint8, +}; +/* --- 16bit integer --- */ static int parse_uint16 (DeviceState *dev,Property *prop,const char *str)
@@ -380,6 +408,11 @@ void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyTmemcpy (dst, src, prop->info->size); } +void qdev_prop_set_uint8 (DeviceState *dev,const char *name,uint8_t value) +{ +qdev_prop_set (dev, name, &value,PROP_TYPE_UINT8 ); +} +void qdev_prop_set_uint16 (DeviceState *dev,const char *name,uint16_t value) {qdev_prop_set (dev, name, &value,PROP_TYPE_UINT16 );
hw/qdev.h +5 -0
@@ -60,6 +60,7 @@ struct Property {enum PropertyType {PROP_TYPE_UNSPEC =0 , +PROP_TYPE_UINT8 ,PROP_TYPE_UINT16 ,PROP_TYPE_UINT32 ,PROP_TYPE_INT32 ,
@@ -155,6 +156,7 @@ void do_info_qdm(Monitor *mon);/*** qdev-properties.c ***/ +extern PropertyInfo qdev_prop_uint8;extern PropertyInfo qdev_prop_uint16;extern PropertyInfo qdev_prop_uint32;extern PropertyInfo qdev_prop_int32;
@@ -181,6 +183,8 @@ extern PropertyInfo qdev_prop_pci_devfn; .defval = (_type[]) { _defval }, \ } +#define DEFINE_PROP_UINT8 (_n, _s, _f, _d) \ + DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)#define DEFINE_PROP_UINT16 (_n, _s, _f, _d) \ DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint16, uint16_t)#define DEFINE_PROP_UINT32 (_n, _s, _f, _d) \
@@ -212,6 +216,7 @@ extern PropertyInfo qdev_prop_pci_devfn;void *qdev_get_prop_ptr (DeviceState *dev,Property *prop);int qdev_prop_parse (DeviceState *dev,const char *name,const char *value);void qdev_prop_set (DeviceState *dev,const char *name,void *src,enum PropertyType type); +void qdev_prop_set_uint8 (DeviceState *dev,const char *name,uint8_t value);void qdev_prop_set_uint16 (DeviceState *dev,const char *name,uint16_t value);void qdev_prop_set_uint32 (DeviceState *dev,const char *name,uint32_t value);void qdev_prop_set_int32 (DeviceState *dev,const char *name,int32_t value);
Signature · 1 line
1.6.2.5
PATCH 2/20 i2c: addresses are load/save as uint8_t values, change types to reflect this
In reply to Juan Quintela--- hw/i2c.c | 21 +++++++++++---------- hw/i2c.h | 8 ++++---- hw/mips_malta.c | 2 +- hw/pc.c | 2 +- hw/smbus.c | 18 +++++++++--------- hw/smbus.h | 18 +++++++++--------- 6 files changed, 35 insertions(+), 34 deletions(-)
hw/i2c.c +11 -10
@@ -14,14 +14,14 @@ struct i2c_busBusState qbus;i2c_slave *current_dev;i2c_slave *dev; -int saved_address; +uint8_t saved_address; };static struct BusInfo i2c_bus_info = { .name ="I2C" , .size =sizeof (i2c_bus), .props = (Property []) { - DEFINE_PROP_UINT32("address", struct i2c_slave, address, 0), + DEFINE_PROP_UINT8("address", struct i2c_slave, address, 0),DEFINE_PROP_END_OF_LIST (), } };
@@ -29,8 +29,9 @@ static struct BusInfo i2c_bus_info = {static void i2c_bus_save (QEMUFile *f,void *opaque) {i2c_bus *bus = (i2c_bus *)opaque; + bus->saved_address = bus->current_dev ? bus->current_dev->address :-1 ; -qemu_put_byte (f, bus->current_dev ? bus->current_dev->address :-1 ); +qemu_put_8s (f, &bus->saved_address); }static int i2c_bus_load (QEMUFile *f,void *opaque,int version_id)
@@ -42,7 +43,7 @@ static int i2c_bus_load(QEMUFile *f, void *opaque, int version_id)/* The bus is loaded before attached devices, so load and save the current device id. Devices will check themselves as loaded. */ - bus->saved_address = (int8_t )qemu_get_byte (f); +qemu_get_8s (f, &bus->saved_address); bus->current_dev =NULL ;return 0 ;
@@ -58,7 +59,7 @@ i2c_bus *i2c_init_bus(DeviceState *parent, const char *name)return bus; } -void i2c_set_slave_address (i2c_slave *dev,int address) +void i2c_set_slave_address (i2c_slave *dev,uint8_t address) { dev->address = address; }
@@ -71,7 +72,7 @@ int i2c_bus_busy(i2c_bus *bus)/* Returns non-zero if the address is not valid. */ /* TODO: Make this handle multiple masters. */ -int i2c_start_transfer (i2c_bus *bus,int address,int recv) +int i2c_start_transfer (i2c_bus *bus,uint8_t address,int recv) {DeviceState *qdev;i2c_slave *slave =NULL ;
@@ -136,14 +137,14 @@ void i2c_nack(i2c_bus *bus)void i2c_slave_save (QEMUFile *f,i2c_slave *dev) { -qemu_put_byte (f, dev->address); +qemu_put_8s (f, &dev->address); }void i2c_slave_load (QEMUFile *f,i2c_slave *dev) {i2c_bus *bus; bus =FROM_QBUS (i2c_bus,qdev_get_parent_bus (&dev->qdev)); - dev->address =qemu_get_byte (f); +qemu_get_8s (f, &dev->address);if (bus->saved_address == dev->address) { bus->current_dev = dev; }
@@ -167,12 +168,12 @@ void i2c_register_slave(I2CSlaveInfo *info)qdev_register (&info->qdev); } -DeviceState *i2c_create_slave (i2c_bus *bus,const char *name,int addr) +DeviceState *i2c_create_slave (i2c_bus *bus,const char *name,uint8_t addr) {DeviceState *dev; dev =qdev_create (&bus->qbus, name); -qdev_prop_set_uint32 (dev,"address" , addr); +qdev_prop_set_uint8 (dev,"address" , addr);qdev_init (dev);return dev; }
hw/i2c.h +4 -4
@@ -40,13 +40,13 @@ struct i2c_slaveI2CSlaveInfo *info;/* Remaining fields for internal use by the I2C code. */ -uint32_t address; +uint8_t address; };i2c_bus *i2c_init_bus (DeviceState *parent,const char *name); -void i2c_set_slave_address (i2c_slave *dev,int address); +void i2c_set_slave_address (i2c_slave *dev,uint8_t address);int i2c_bus_busy (i2c_bus *bus); -int i2c_start_transfer (i2c_bus *bus,int address,int recv); +int i2c_start_transfer (i2c_bus *bus,uint8_t address,int recv);void i2c_end_transfer (i2c_bus *bus);void i2c_nack (i2c_bus *bus);int i2c_send (i2c_bus *bus,uint8_t data);
@@ -59,7 +59,7 @@ void i2c_slave_load(QEMUFile *f, i2c_slave *dev);void i2c_register_slave (I2CSlaveInfo *type); -DeviceState *i2c_create_slave (i2c_bus *bus,const char *name,int addr); +DeviceState *i2c_create_slave (i2c_bus *bus,const char *name,uint8_t addr);/* max7310.c */ void max7310_reset (i2c_slave *i2c);
hw/mips_malta.c +1 -1
@@ -913,7 +913,7 @@ void mips_malta_init (ram_addr_t ram_size,/* TODO: Populate SPD eeprom data. */ DeviceState *eeprom; eeprom =qdev_create ((BusState *)smbus,"smbus-eeprom" ); -qdev_prop_set_uint32 (eeprom,"address" ,0x50 + i); +qdev_prop_set_uint8 (eeprom,"address" ,0x50 + i);qdev_prop_set_ptr (eeprom,"data" , eeprom_buf + (i *256 ));qdev_init (eeprom); }
hw/pc.c +1 -1
@@ -1401,7 +1401,7 @@ static void pc_init1(ram_addr_t ram_size,for (i =0 ; i <8 ; i++) {DeviceState *eeprom; eeprom =qdev_create ((BusState *)smbus,"smbus-eeprom" ); -qdev_prop_set_uint32 (eeprom,"address" ,0x50 + i); +qdev_prop_set_uint8 (eeprom,"address" ,0x50 + i);qdev_prop_set_ptr (eeprom,"data" , eeprom_buf + (i *256 ));qdev_init (eeprom); }
hw/smbus.c +9 -9
@@ -217,13 +217,13 @@ void smbus_register_device(SMBusDeviceInfo *info) }/* Master device commands. */ -void smbus_quick_command (i2c_bus *bus,int addr,int read) +void smbus_quick_command (i2c_bus *bus,uint8_t addr,int read) {i2c_start_transfer (bus, addr, read);i2c_end_transfer (bus); } -uint8_t smbus_receive_byte (i2c_bus *bus,int addr) +uint8_t smbus_receive_byte (i2c_bus *bus,uint8_t addr) {uint8_t data;
@@ -234,14 +234,14 @@ uint8_t smbus_receive_byte(i2c_bus *bus, int addr)return data; } -void smbus_send_byte (i2c_bus *bus,int addr,uint8_t data) +void smbus_send_byte (i2c_bus *bus,uint8_t addr,uint8_t data) {i2c_start_transfer (bus, addr,0 );i2c_send (bus, data);i2c_end_transfer (bus); } -uint8_t smbus_read_byte (i2c_bus *bus,int addr,uint8_t command) +uint8_t smbus_read_byte (i2c_bus *bus,uint8_t addr,uint8_t command) {uint8_t data;i2c_start_transfer (bus, addr,0 );
@@ -253,7 +253,7 @@ uint8_t smbus_read_byte(i2c_bus *bus, int addr, uint8_t command)return data; } -void smbus_write_byte (i2c_bus *bus,int addr,uint8_t command,uint8_t data) +void smbus_write_byte (i2c_bus *bus,uint8_t addr,uint8_t command,uint8_t data) {i2c_start_transfer (bus, addr,0 );i2c_send (bus, command);
@@ -261,7 +261,7 @@ void smbus_write_byte(i2c_bus *bus, int addr, uint8_t command, uint8_t data)i2c_end_transfer (bus); } -uint16_t smbus_read_word (i2c_bus *bus,int addr,uint8_t command) +uint16_t smbus_read_word (i2c_bus *bus,uint8_t addr,uint8_t command) {uint16_t data;i2c_start_transfer (bus, addr,0 );
@@ -274,7 +274,7 @@ uint16_t smbus_read_word(i2c_bus *bus, int addr, uint8_t command)return data; } -void smbus_write_word (i2c_bus *bus,int addr,uint8_t command,uint16_t data) +void smbus_write_word (i2c_bus *bus,uint8_t addr,uint8_t command,uint16_t data) {i2c_start_transfer (bus, addr,0 );i2c_send (bus, command);
@@ -283,7 +283,7 @@ void smbus_write_word(i2c_bus *bus, int addr, uint8_t command, uint16_t data)i2c_end_transfer (bus); } -int smbus_read_block (i2c_bus *bus,int addr,uint8_t command,uint8_t *data) +int smbus_read_block (i2c_bus *bus,uint8_t addr,uint8_t command,uint8_t *data) {int len;int i;
@@ -301,7 +301,7 @@ int smbus_read_block(i2c_bus *bus, int addr, uint8_t command, uint8_t *data)return len; } -void smbus_write_block (i2c_bus *bus,int addr,uint8_t command,uint8_t *data, +void smbus_write_block (i2c_bus *bus,uint8_t addr,uint8_t command,uint8_t *data,int len) {int i;
hw/smbus.h +9 -9
@@ -56,13 +56,13 @@ typedef struct {void smbus_register_device (SMBusDeviceInfo *info);/* Master device commands. */ -void smbus_quick_command (i2c_bus *bus,int addr,int read); -uint8_t smbus_receive_byte (i2c_bus *bus,int addr); -void smbus_send_byte (i2c_bus *bus,int addr,uint8_t data); -uint8_t smbus_read_byte (i2c_bus *bus,int addr,uint8_t command); -void smbus_write_byte (i2c_bus *bus,int addr,uint8_t command,uint8_t data); -uint16_t smbus_read_word (i2c_bus *bus,int addr,uint8_t command); -void smbus_write_word (i2c_bus *bus,int addr,uint8_t command,uint16_t data); -int smbus_read_block (i2c_bus *bus,int addr,uint8_t command,uint8_t *data); -void smbus_write_block (i2c_bus *bus,int addr,uint8_t command,uint8_t *data, +void smbus_quick_command (i2c_bus *bus,uint8_t addr,int read); +uint8_t smbus_receive_byte (i2c_bus *bus,uint8_t addr); +void smbus_send_byte (i2c_bus *bus,uint8_t addr,uint8_t data); +uint8_t smbus_read_byte (i2c_bus *bus,uint8_t addr,uint8_t command); +void smbus_write_byte (i2c_bus *bus,uint8_t addr,uint8_t command,uint8_t data); +uint16_t smbus_read_word (i2c_bus *bus,uint8_t addr,uint8_t command); +void smbus_write_word (i2c_bus *bus,uint8_t addr,uint8_t command,uint16_t data); +int smbus_read_block (i2c_bus *bus,uint8_t addr,uint8_t command,uint8_t *data); +void smbus_write_block (i2c_bus *bus,uint8_t addr,uint8_t command,uint8_t *data,int len);
Signature · 1 line
1.6.2.5
PATCH 3/20 vmstate: port i2c_bus device
In reply to Juan Quintela--- hw/i2c.c | 31 +++++++++++++++++++------------ 1 files changed, 19 insertions(+), 12 deletions(-)
hw/i2c.c +19 -12
@@ -26,36 +26,43 @@ static struct BusInfo i2c_bus_info = { } }; -static void i2c_bus_save (QEMUFile *f,void *opaque) +static void i2c_bus_pre_save (const void *opaque) { -i2c_bus *bus = (i2c_bus *)opaque; - bus->saved_address = bus->current_dev ? bus->current_dev->address :-1 ; +i2c_bus *bus = (void *)opaque; -qemu_put_8s (f, &bus->saved_address); + bus->saved_address = bus->current_dev ? bus->current_dev->address :-1 ; } -static int i2c_bus_load (QEMUFile *f,void *opaque,int version_id) +static int i2c_bus_post_load (void *opaque) { -i2c_bus *bus = (i2c_bus *)opaque; - -if (version_id !=1 ) -return -EINVAL ; +i2c_bus *bus = opaque;/* The bus is loaded before attached devices, so load and save the current device id. Devices will check themselves as loaded. */ -qemu_get_8s (f, &bus->saved_address); bus->current_dev =NULL ; -return 0 ; } +static const VMStateDescription vmstate_i2c_bus = { + .name ="i2c_bus" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .pre_save = i2c_bus_pre_save, + .post_load = i2c_bus_post_load, + .fields = (VMStateField []) { +VMSTATE_UINT8 (saved_address, i2c_bus), +VMSTATE_END_OF_LIST () + } +}; +/* Create a new I2C bus. */ i2c_bus *i2c_init_bus (DeviceState *parent,const char *name) {i2c_bus *bus; bus =FROM_QBUS (i2c_bus,qbus_create (&i2c_bus_info, parent, name)); -register_savevm ("i2c_bus" ,-1 ,1 , i2c_bus_save, i2c_bus_load, bus); +vmstate_register (-1 , &vmstate_i2c_bus, bus);return bus; }
Signature · 1 line
1.6.2.5
PATCH 4/20 vmstate: port i2c_slave device
In reply to Juan Quintela--- hw/i2c.c | 33 ++++++++++++++++++++++++++------- 1 files changed, 26 insertions(+), 7 deletions(-)
hw/i2c.c +26 -7
@@ -142,19 +142,38 @@ void i2c_nack(i2c_bus *bus) dev->info->event (dev,I2C_NACK ); } -void i2c_slave_save (QEMUFile *f,i2c_slave *dev) -{ -qemu_put_8s (f, &dev->address); -} - -void i2c_slave_load (QEMUFile *f,i2c_slave *dev) +static int i2c_slave_post_load (void *opaque) { +i2c_slave *dev = opaque;i2c_bus *bus; bus =FROM_QBUS (i2c_bus,qdev_get_parent_bus (&dev->qdev)); -qemu_get_8s (f, &dev->address);if (bus->saved_address == dev->address) { bus->current_dev = dev; } +return 0 ; +} + +static const VMStateDescription vmstate_i2c_slave = { + .name ="i2c_slave" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .post_load = i2c_slave_post_load, + .fields = (VMStateField []) { +VMSTATE_UINT8 (address, i2c_slave), +VMSTATE_END_OF_LIST () + } +}; + +void i2c_slave_save (QEMUFile *f,i2c_slave *dev) +{ +vmstate_save_state (f, &vmstate_i2c_slave, dev); +} + +void i2c_slave_load (QEMUFile *f,i2c_slave *dev) +{ +vmstate_load_state (f, &vmstate_i2c_slave, dev, + vmstate_i2c_slave.version_id); }static int i2c_slave_qdev_init (DeviceState *dev,DeviceInfo *base)
Signature · 1 line
1.6.2.5
PATCH 5/20 vmstate: add uint8 array
In reply to Juan Quintela--- hw/hw.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
hw/hw.h +6 -0
@@ -498,6 +498,12 @@ extern const VMStateDescription vmstate_pci_device;#define VMSTATE_UINT16_ARRAY (_f, _s, _n) \ VMSTATE_UINT16_ARRAY_V(_f, _s, _n, 0) +#define VMSTATE_UINT8_ARRAY_V (_f, _s, _n, _v) \ + VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint8, uint8_t) + +#define VMSTATE_UINT8_ARRAY (_f, _s, _n) \ + VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0) +#define VMSTATE_UINT32_ARRAY_V (_f, _s, _n, _v) \ VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t)
Signature · 1 line
1.6.2.5
PATCH 6/20 vmstate: create VMSTATE_I2C_SLAVE
In reply to Juan Quintela--- hw/hw.h | 11 +++++++++++ hw/i2c.c | 2 +- 2 files changed, 12 insertions(+), 1 deletions(-)
hw/hw.h +11 -0
@@ -428,6 +428,17 @@ extern const VMStateDescription vmstate_pci_device; + type_check(PCIDevice,typeof_field(_state, _field)) \ } +extern const VMStateDescription vmstate_i2c_slave; + +#define VMSTATE_I2C_SLAVE (_field, _state) { \ + .name = (stringify(_field)), \ + .size = sizeof(i2c_slave), \ + .vmsd = &vmstate_i2c_slave, \ + .flags = VMS_STRUCT, \ + .offset = offsetof(_state, _field) \ + + type_check(i2c_slave,typeof_field(_state, _field)) \ +} +/* _f : field name _f_n : num of elements field_name _n : num of elements
hw/i2c.c +1 -1
@@ -153,7 +153,7 @@ static int i2c_slave_post_load(void *opaque)return 0 ; } -static const VMStateDescription vmstate_i2c_slave = { +const VMStateDescription vmstate_i2c_slave = { .name ="i2c_slave" , .version_id =1 , .minimum_version_id =1 ,
Signature · 1 line
1.6.2.5
PATCH 7/20 vmstate: port wm8750 device
In reply to Juan Quintela--- hw/wm8750.c | 120 ++++++++++++++++++++++------------------------------------- 1 files changed, 45 insertions(+), 75 deletions(-)
hw/wm8750.c +45 -75
@@ -46,6 +46,7 @@ typedef struct {uint8_t diff[2 ], pol, ds, monomix[2 ], alc, mute;uint8_t path[4 ], mpath[2 ], power, format;const WMRate *rate; +uint8_t rate_vmstate;int adc_hz, dac_hz, ext_adc_hz, ext_dac_hz, master; } WM8750State;
@@ -564,87 +565,56 @@ static int wm8750_rx(i2c_slave *i2c)return 0x00 ; } -static void wm8750_save (QEMUFile *f,void *opaque) +static void wm8750_pre_save (const void *opaque) { -WM8750State *s = (WM8750State *) opaque; -int i; -qemu_put_8s (f, &s->i2c_data[0 ]); -qemu_put_8s (f, &s->i2c_data[1 ]); -qemu_put_be32 (f, s->i2c_len); -qemu_put_be32 (f, s->enable); -qemu_put_be32 (f, s->idx_in); -qemu_put_be32 (f, s->req_in); -qemu_put_be32 (f, s->idx_out); -qemu_put_be32 (f, s->req_out); - -for (i =0 ; i <7 ; i ++) -qemu_put_8s (f, &s->outvol[i]); -for (i =0 ; i <2 ; i ++) -qemu_put_8s (f, &s->outmute[i]); -for (i =0 ; i <4 ; i ++) -qemu_put_8s (f, &s->invol[i]); -for (i =0 ; i <2 ; i ++) -qemu_put_8s (f, &s->inmute[i]); - -for (i =0 ; i <2 ; i ++) -qemu_put_8s (f, &s->diff[i]); -qemu_put_8s (f, &s->pol); -qemu_put_8s (f, &s->ds); -for (i =0 ; i <2 ; i ++) -qemu_put_8s (f, &s->monomix[i]); -qemu_put_8s (f, &s->alc); -qemu_put_8s (f, &s->mute); -for (i =0 ; i <4 ; i ++) -qemu_put_8s (f, &s->path[i]); -for (i =0 ; i <2 ; i ++) -qemu_put_8s (f, &s->mpath[i]); -qemu_put_8s (f, &s->format); -qemu_put_8s (f, &s->power); -qemu_put_byte (f, (s->rate - wm_rate_table) /sizeof (*s->rate)); -i2c_slave_save (f, &s->i2c); +WM8750State *s = (void *)opaque; + + s->rate_vmstate = (s->rate - wm_rate_table) /sizeof (*s->rate); } -static int wm8750_load (QEMUFile *f,void *opaque,int version_id) +static int wm8750_post_load (void *opaque) { -WM8750State *s = (WM8750State *) opaque; -int i; -qemu_get_8s (f, &s->i2c_data[0 ]); -qemu_get_8s (f, &s->i2c_data[1 ]); - s->i2c_len =qemu_get_be32 (f); - s->enable =qemu_get_be32 (f); - s->idx_in =qemu_get_be32 (f); - s->req_in =qemu_get_be32 (f); - s->idx_out =qemu_get_be32 (f); - s->req_out =qemu_get_be32 (f); - -for (i =0 ; i <7 ; i ++) -qemu_get_8s (f, &s->outvol[i]); -for (i =0 ; i <2 ; i ++) -qemu_get_8s (f, &s->outmute[i]); -for (i =0 ; i <4 ; i ++) -qemu_get_8s (f, &s->invol[i]); -for (i =0 ; i <2 ; i ++) -qemu_get_8s (f, &s->inmute[i]); - -for (i =0 ; i <2 ; i ++) -qemu_get_8s (f, &s->diff[i]); -qemu_get_8s (f, &s->pol); -qemu_get_8s (f, &s->ds); -for (i =0 ; i <2 ; i ++) -qemu_get_8s (f, &s->monomix[i]); -qemu_get_8s (f, &s->alc); -qemu_get_8s (f, &s->mute); -for (i =0 ; i <4 ; i ++) -qemu_get_8s (f, &s->path[i]); -for (i =0 ; i <2 ; i ++) -qemu_get_8s (f, &s->mpath[i]); -qemu_get_8s (f, &s->format); -qemu_get_8s (f, &s->power); - s->rate = &wm_rate_table[(uint8_t )qemu_get_byte (f) &0x1f ]; -i2c_slave_load (f, &s->i2c); +WM8750State *s = opaque; + + s->rate = &wm_rate_table[s->rate_vmstate &0x1f ];return 0 ; } +static const VMStateDescription vmstate_wm8750 = { + .name =CODEC , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .pre_save = wm8750_pre_save, + .post_load = wm8750_post_load, + .fields = (VMStateField []) { +VMSTATE_UINT8_ARRAY (i2c_data, WM8750State,2 ), +VMSTATE_INT32 (i2c_len, WM8750State), +VMSTATE_INT32 (enable, WM8750State), +VMSTATE_INT32 (idx_in, WM8750State), +VMSTATE_INT32 (req_in, WM8750State), +VMSTATE_INT32 (idx_out, WM8750State), +VMSTATE_INT32 (req_out, WM8750State), +VMSTATE_UINT8_ARRAY (outvol, WM8750State,7 ), +VMSTATE_UINT8_ARRAY (outmute, WM8750State,2 ), +VMSTATE_UINT8_ARRAY (invol, WM8750State,4 ), +VMSTATE_UINT8_ARRAY (inmute, WM8750State,2 ), +VMSTATE_UINT8_ARRAY (diff, WM8750State,2 ), +VMSTATE_UINT8 (pol, WM8750State), +VMSTATE_UINT8 (ds, WM8750State), +VMSTATE_UINT8_ARRAY (monomix, WM8750State,2 ), +VMSTATE_UINT8 (alc, WM8750State), +VMSTATE_UINT8 (mute, WM8750State), +VMSTATE_UINT8_ARRAY (path, WM8750State,4 ), +VMSTATE_UINT8_ARRAY (mpath, WM8750State,2 ), +VMSTATE_UINT8 (format, WM8750State), +VMSTATE_UINT8 (power, WM8750State), +VMSTATE_UINT8 (rate_vmstate, WM8750State), +VMSTATE_I2C_SLAVE (i2c, WM8750State), +VMSTATE_END_OF_LIST () + } +}; +static int wm8750_init (i2c_slave *i2c) {WM8750State *s =FROM_I2C_SLAVE (WM8750State, i2c);
@@ -652,7 +622,7 @@ static int wm8750_init(i2c_slave *i2c)AUD_register_card (CODEC , &s->card);wm8750_reset (&s->i2c); -register_savevm (CODEC ,-1 ,0 , wm8750_save, wm8750_load, s); +vmstate_register (-1 , &vmstate_wm8750, s);return 0 ; }
Signature · 1 line
1.6.2.5
PATCH 8/20 vmstate: port max7310 device
In reply to Juan Quintela--- hw/max7310.c | 51 ++++++++++++++++++--------------------------------- 1 files changed, 18 insertions(+), 33 deletions(-)
hw/max7310.c +18 -33
@@ -143,38 +143,23 @@ static void max7310_event(i2c_slave *i2c, enum i2c_event event) } } -static void max7310_save (QEMUFile *f,void *opaque) -{ -MAX7310State *s = (MAX7310State *) opaque; - -qemu_put_be32 (f, s->i2c_command_byte); -qemu_put_be32 (f, s->len); - -qemu_put_8s (f, &s->level); -qemu_put_8s (f, &s->direction); -qemu_put_8s (f, &s->polarity); -qemu_put_8s (f, &s->status); -qemu_put_8s (f, &s->command); - -i2c_slave_save (f, &s->i2c); -} - -static int max7310_load (QEMUFile *f,void *opaque,int version_id) -{ -MAX7310State *s = (MAX7310State *) opaque; - - s->i2c_command_byte =qemu_get_be32 (f); - s->len =qemu_get_be32 (f); - -qemu_get_8s (f, &s->level); -qemu_get_8s (f, &s->direction); -qemu_get_8s (f, &s->polarity); -qemu_get_8s (f, &s->status); -qemu_get_8s (f, &s->command); - -i2c_slave_load (f, &s->i2c); -return 0 ; -} +static const VMStateDescription vmstate_max7310 = { + .name ="max7310" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { +VMSTATE_INT32 (i2c_command_byte, MAX7310State), +VMSTATE_INT32 (len, MAX7310State), +VMSTATE_UINT8 (level, MAX7310State), +VMSTATE_UINT8 (direction, MAX7310State), +VMSTATE_UINT8 (polarity, MAX7310State), +VMSTATE_UINT8 (status, MAX7310State), +VMSTATE_UINT8 (command, MAX7310State), +VMSTATE_I2C_SLAVE (i2c, MAX7310State), +VMSTATE_END_OF_LIST () + } +};static void max7310_gpio_set (void *opaque,int line,int level) {
@@ -199,7 +184,7 @@ static int max7310_init(i2c_slave *i2c)max7310_reset (&s->i2c); -register_savevm ("max7310" ,-1 ,0 , max7310_save, max7310_load, s); +vmstate_register (-1 , &vmstate_max7310, s);return 0 ; }
Signature · 1 line
1.6.2.5
PATCH 9/20 vmstate: create VMSTATE_STRUCT_POINTER
In reply to Juan Quintela--- hw/hw.h | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
hw/hw.h +9 -0
@@ -387,6 +387,15 @@ extern const VMStateInfo vmstate_info_buffer; + type_check(_type,typeof_field(_state, _field)) \ } +#define VMSTATE_STRUCT_POINTER (_field, _state, _vmsd, _type) { \ + .name = (stringify(_field)), \ + .vmsd = &(_vmsd), \ + .size = sizeof(_type), \ + .flags = VMS_STRUCT|VMS_POINTER, \ + .offset = offsetof(_state, _field) \ + + type_check(_type,typeof_field(_state, _field)) \ +} +#define VMSTATE_STRUCT_ARRAY (_field, _state, _num, _version, _vmsd, _type) { \ .name = (stringify(_field)), \ .num = (_num), \
Signature · 1 line
1.6.2.5
PATCH 10/20 vmstate: port pxa2xx_i2c device
In reply to Juan Quintela--- hw/pxa2xx.c | 54 ++++++++++++++++++++++++++---------------------------- 1 files changed, 26 insertions(+), 28 deletions(-)
hw/pxa2xx.c +26 -28
@@ -1452,33 +1452,32 @@ static CPUWriteMemoryFunc * const pxa2xx_i2c_writefn[] = { pxa2xx_i2c_write, }; -static void pxa2xx_i2c_save (QEMUFile *f,void *opaque) -{ -PXA2xxI2CState *s = (PXA2xxI2CState *) opaque; - -qemu_put_be16s (f, &s->control); -qemu_put_be16s (f, &s->status); -qemu_put_8s (f, &s->ibmr); -qemu_put_8s (f, &s->data); - -i2c_slave_save (f, &s->slave->i2c); -} - -static int pxa2xx_i2c_load (QEMUFile *f,void *opaque,int version_id) -{ -PXA2xxI2CState *s = (PXA2xxI2CState *) opaque; - -if (version_id !=1 ) -return -EINVAL ; - -qemu_get_be16s (f, &s->control); -qemu_get_be16s (f, &s->status); -qemu_get_8s (f, &s->ibmr); -qemu_get_8s (f, &s->data); +static const VMStateDescription vmstate_pxa2xx_i2c_slave = { + .name ="pxa2xx_i2c_slave" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_I2C_SLAVE (i2c, PXA2xxI2CSlaveState), +VMSTATE_END_OF_LIST () + } +}; -i2c_slave_load (f, &s->slave->i2c); -return 0 ; -} +static const VMStateDescription vmstate_pxa2xx_i2c = { + .name ="pxa2xx_i2c" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_UINT16 (control, PXA2xxI2CState), +VMSTATE_UINT16 (status, PXA2xxI2CState), +VMSTATE_UINT8 (ibmr, PXA2xxI2CState), +VMSTATE_UINT8 (data, PXA2xxI2CState), +VMSTATE_STRUCT_POINTER (slave, PXA2xxI2CState, + vmstate_pxa2xx_i2c, PXA2xxI2CSlaveState *), +VMSTATE_END_OF_LIST () + } +};static int pxa2xx_i2c_slave_init (i2c_slave *i2c) {
@@ -1516,8 +1515,7 @@ PXA2xxI2CState *pxa2xx_i2c_init(target_phys_addr_t base,cpu_register_physical_memory (base & ~region_size, region_size +1 , iomemtype); -register_savevm ("pxa2xx_i2c" , base,1 , - pxa2xx_i2c_save, pxa2xx_i2c_load, s); +vmstate_register (base, &vmstate_pxa2xx_i2c, s);return s; }
Signature · 1 line
1.6.2.5
PATCH 11/20 vmstate: port ssd0303 device
In reply to Juan Quintela--- hw/ssd0303.c | 65 +++++++++++++++++++-------------------------------------- 1 files changed, 22 insertions(+), 43 deletions(-)
hw/ssd0303.c +22 -43
@@ -261,48 +261,27 @@ static void ssd0303_invalidate_display(void * opaque) s->redraw =1 ; } -static void ssd0303_save (QEMUFile *f,void *opaque) -{ -ssd0303_state *s = (ssd0303_state *)opaque; - -qemu_put_be32 (f, s->row); -qemu_put_be32 (f, s->col); -qemu_put_be32 (f, s->start_line); -qemu_put_be32 (f, s->mirror); -qemu_put_be32 (f, s->flash); -qemu_put_be32 (f, s->enabled); -qemu_put_be32 (f, s->inverse); -qemu_put_be32 (f, s->redraw); -qemu_put_be32 (f, s->mode); -qemu_put_be32 (f, s->cmd_state); -qemu_put_buffer (f, s->framebuffer,sizeof (s->framebuffer)); - -i2c_slave_save (f, &s->i2c); -} - -static int ssd0303_load (QEMUFile *f,void *opaque,int version_id) -{ -ssd0303_state *s = (ssd0303_state *)opaque; - -if (version_id !=1 ) -return -EINVAL ; - - s->row =qemu_get_be32 (f); - s->col =qemu_get_be32 (f); - s->start_line =qemu_get_be32 (f); - s->mirror =qemu_get_be32 (f); - s->flash =qemu_get_be32 (f); - s->enabled =qemu_get_be32 (f); - s->inverse =qemu_get_be32 (f); - s->redraw =qemu_get_be32 (f); - s->mode =qemu_get_be32 (f); - s->cmd_state =qemu_get_be32 (f); -qemu_get_buffer (f, s->framebuffer,sizeof (s->framebuffer)); - -i2c_slave_load (f, &s->i2c); - -return 0 ; -} +static const VMStateDescription vmstate_ssd0303 = { + .name ="ssd0303_oled" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_INT32 (row, ssd0303_state), +VMSTATE_INT32 (col, ssd0303_state), +VMSTATE_INT32 (start_line, ssd0303_state), +VMSTATE_INT32 (mirror, ssd0303_state), +VMSTATE_INT32 (flash, ssd0303_state), +VMSTATE_INT32 (enabled, ssd0303_state), +VMSTATE_INT32 (inverse, ssd0303_state), +VMSTATE_INT32 (redraw, ssd0303_state), +VMSTATE_UINT32 (mode, ssd0303_state), +VMSTATE_UINT32 (cmd_state, ssd0303_state), +VMSTATE_BUFFER (framebuffer, ssd0303_state), +VMSTATE_I2C_SLAVE (i2c, ssd0303_state), +VMSTATE_END_OF_LIST () + } +};static int ssd0303_init (i2c_slave *i2c) {
@@ -312,7 +291,7 @@ static int ssd0303_init(i2c_slave *i2c) ssd0303_invalidate_display, NULL, NULL, s);qemu_console_resize (s->ds,96 *MAGNIFY ,16 *MAGNIFY ); -register_savevm ("ssd0303_oled" ,-1 ,1 , ssd0303_save, ssd0303_load, s); +vmstate_register (-1 , &vmstate_ssd0303, s);return 0 ; }
Signature · 1 line
1.6.2.5
PATCH 12/20 vmstate: create VMSTATE_INT16_ARRAY
In reply to Juan Quintela--- hw/hw.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
hw/hw.h +6 -0
@@ -536,6 +536,12 @@ extern const VMStateDescription vmstate_i2c_slave;#define VMSTATE_UINT64_ARRAY (_f, _s, _n) \ VMSTATE_UINT64_ARRAY_V(_f, _s, _n, 0) +#define VMSTATE_INT16_ARRAY_V (_f, _s, _n, _v) \ + VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int16, int16_t) + +#define VMSTATE_INT16_ARRAY (_f, _s, _n) \ + VMSTATE_INT16_ARRAY_V(_f, _s, _n, 0) +#define VMSTATE_INT32_ARRAY_V (_f, _s, _n, _v) \ VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t)
Signature · 1 line
1.6.2.5
PATCH 13/20 tmp105: change len and alorm to uint8_t
In reply to Juan QuintelaThey were using only with very small integers, and they are sent/read as bytes. They can't become negative as far as I can see
--- hw/tmp105.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
hw/tmp105.c +2 -2
@@ -23,7 +23,7 @@ typedef struct { i2c_slave i2c; - int len; + uint8_t len; uint8_t buf[2]; qemu_irq pin;
@@ -32,7 +32,7 @@ typedef struct {int16_t temperature;int16_t limit[2 ];int faults; -int alarm; +uint8_t alarm; } TMP105State;static void tmp105_interrupt_update (TMP105State *s)
Signature · 1 line
1.6.2.5
PATCH 14/20 vmstate: port wmp105 device
In reply to Juan Quintela--- hw/tmp105.c | 56 +++++++++++++++++++++++++------------------------------- 1 files changed, 25 insertions(+), 31 deletions(-)
hw/tmp105.c +25 -31
@@ -173,46 +173,40 @@ static void tmp105_event(i2c_slave *i2c, enum i2c_event event) s->len =0 ; } -static void tmp105_save (QEMUFile *f,void *opaque) +static void tmp105_post_save (const void *opaque) { -TMP105State *s = (TMP105State *) opaque; - -qemu_put_byte (f, s->len); -qemu_put_8s (f, &s->buf[0 ]); -qemu_put_8s (f, &s->buf[1 ]); - -qemu_put_8s (f, &s->pointer); -qemu_put_8s (f, &s->config); -qemu_put_sbe16s (f, &s->temperature); -qemu_put_sbe16s (f, &s->limit[0 ]); -qemu_put_sbe16s (f, &s->limit[1 ]); -qemu_put_byte (f, s->alarm); +TMP105State *s = (void *)opaque; s->faults = tmp105_faultq[(s->config >>3 ) &3 ];/* F */ - -i2c_slave_save (f, &s->i2c); } -static int tmp105_load (QEMUFile *f,void *opaque,int version_id) +static int tmp105_post_load (void *opaque) { -TMP105State *s = (TMP105State *) opaque; - - s->len =qemu_get_byte (f); -qemu_get_8s (f, &s->buf[0 ]); -qemu_get_8s (f, &s->buf[1 ]); - -qemu_get_8s (f, &s->pointer); -qemu_get_8s (f, &s->config); -qemu_get_sbe16s (f, &s->temperature); -qemu_get_sbe16s (f, &s->limit[0 ]); -qemu_get_sbe16s (f, &s->limit[1 ]); - s->alarm =qemu_get_byte (f); +TMP105State *s = opaque;tmp105_interrupt_update (s); - -i2c_slave_load (f, &s->i2c);return 0 ; } +static const VMStateDescription vmstate_tmp105 = { + .name ="TMP105" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .post_save = tmp105_post_save, + .post_load = tmp105_post_load, + .fields = (VMStateField []) { +VMSTATE_UINT8 (len, TMP105State), +VMSTATE_UINT8_ARRAY (buf, TMP105State,2 ), +VMSTATE_UINT8 (pointer, TMP105State), +VMSTATE_UINT8 (config, TMP105State), +VMSTATE_INT16 (temperature, TMP105State), +VMSTATE_INT16_ARRAY (limit, TMP105State,2 ), +VMSTATE_UINT8 (alarm, TMP105State), +VMSTATE_I2C_SLAVE (i2c, TMP105State), +VMSTATE_END_OF_LIST () + } +}; +static void tmp105_reset (i2c_slave *i2c) {TMP105State *s = (TMP105State *) i2c;
@@ -234,7 +228,7 @@ static int tmp105_init(i2c_slave *i2c)tmp105_reset (&s->i2c); -register_savevm ("TMP105" ,-1 ,0 , tmp105_save, tmp105_load, s); +vmstate_register (-1 , &vmstate_tmp105, s);return 0 ; }
Signature · 1 line
1.6.2.5
PATCH 15/20 twl92230: change pwrbtn_state to uint8_t
In reply to Juan Quintelaits value is always the level of an interrupt, 0 or 1
--- hw/twl92230.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/twl92230.c +1 -1
@@ -62,7 +62,7 @@ typedef struct { } rtc;qemu_irq out[4 ];qemu_irq *in; -int pwrbtn_state; +uint8_t pwrbtn_state;qemu_irq pwrbtn; } MenelausState;
Signature · 1 line
1.6.2.5
PATCH 16/20 vmstate: port twl92230 device
In reply to Juan QuintelaJust don't look. struct tm members are ints' and they are sent as uint16_t. VMState code complains as it should. Have to create hacky int32_as_uint16 type. Don't ever think about copying it
--- hw/twl92230.c | 198 +++++++++++++++++++++++++------------------------------- 1 files changed, 88 insertions(+), 110 deletions(-)
hw/twl92230.c +88 -110
@@ -60,6 +60,7 @@ typedef struct {int alm_sec;int next_comp; } rtc; +uint16_t rtc_next_vmstate;qemu_irq out[4 ];qemu_irq *in;uint8_t pwrbtn_state;
@@ -747,134 +748,111 @@ static int menelaus_rx(i2c_slave *i2c)return menelaus_read (s, s->reg ++); } -static void tm_put (QEMUFile *f,struct tm *tm) { -qemu_put_be16 (f, tm->tm_sec); -qemu_put_be16 (f, tm->tm_min); -qemu_put_be16 (f, tm->tm_hour); -qemu_put_be16 (f, tm->tm_mday); -qemu_put_be16 (f, tm->tm_min); -qemu_put_be16 (f, tm->tm_year); -} +/* Save restore 32 bit int as uint16_t +This is a Big hack, but it is how the old state did it. +Or we broke compatibility in the state, or we can't use struct tm +*/ -static void tm_get (QEMUFile *f,struct tm *tm) { - tm->tm_sec =qemu_get_be16 (f); - tm->tm_min =qemu_get_be16 (f); - tm->tm_hour =qemu_get_be16 (f); - tm->tm_mday =qemu_get_be16 (f); - tm->tm_min =qemu_get_be16 (f); - tm->tm_year =qemu_get_be16 (f); +static int get_int32_as_uint16 (QEMUFile *f,void *pv,size_t size) +{ +int *v = pv; + *v =qemu_get_be16 (f); +return 0 ; } -static void menelaus_save (QEMUFile *f,void *opaque) +static void put_int32_as_uint16 (QEMUFile *f,const void *pv,size_t size) { -MenelausState *s = (MenelausState *) opaque; +int *v = (void *)pv; +qemu_put_be16 (f, *v); +} -qemu_put_be32 (f, s->firstbyte); -qemu_put_8s (f, &s->reg); - -qemu_put_8s (f, &s->vcore[0 ]); -qemu_put_8s (f, &s->vcore[1 ]); -qemu_put_8s (f, &s->vcore[2 ]); -qemu_put_8s (f, &s->vcore[3 ]); -qemu_put_8s (f, &s->vcore[4 ]); -qemu_put_8s (f, &s->dcdc[0 ]); -qemu_put_8s (f, &s->dcdc[1 ]); -qemu_put_8s (f, &s->dcdc[2 ]); -qemu_put_8s (f, &s->ldo[0 ]); -qemu_put_8s (f, &s->ldo[1 ]); -qemu_put_8s (f, &s->ldo[2 ]); -qemu_put_8s (f, &s->ldo[3 ]); -qemu_put_8s (f, &s->ldo[4 ]); -qemu_put_8s (f, &s->ldo[5 ]); -qemu_put_8s (f, &s->ldo[6 ]); -qemu_put_8s (f, &s->ldo[7 ]); -qemu_put_8s (f, &s->sleep[0 ]); -qemu_put_8s (f, &s->sleep[1 ]); -qemu_put_8s (f, &s->osc); -qemu_put_8s (f, &s->detect); -qemu_put_be16s (f, &s->mask); -qemu_put_be16s (f, &s->status); -qemu_put_8s (f, &s->dir); -qemu_put_8s (f, &s->inputs); -qemu_put_8s (f, &s->outputs); -qemu_put_8s (f, &s->bbsms); -qemu_put_8s (f, &s->pull[0 ]); -qemu_put_8s (f, &s->pull[1 ]); -qemu_put_8s (f, &s->pull[2 ]); -qemu_put_8s (f, &s->pull[3 ]); -qemu_put_8s (f, &s->mmc_ctrl[0 ]); -qemu_put_8s (f, &s->mmc_ctrl[1 ]); -qemu_put_8s (f, &s->mmc_ctrl[2 ]); -qemu_put_8s (f, &s->mmc_debounce); -qemu_put_8s (f, &s->rtc.ctrl); -qemu_put_be16s (f, &s->rtc.comp); -/* Should be <= 1000 */ -qemu_put_be16 (f, s->rtc.next -qemu_get_clock (rt_clock)); -tm_put (f, &s->rtc.new); -tm_put (f, &s->rtc.alm); -qemu_put_byte (f, s->pwrbtn_state); +const VMStateInfo vmstate_hack_int32_as_uint16 = { + .name ="int32_as_uint16" , + .get = get_int32_as_uint16, + .put = put_int32_as_uint16, +}; -i2c_slave_save (f, &s->i2c); -} +#define VMSTATE_UINT16_HACK (_f, _s) \ + VMSTATE_SINGLE(_f, _s, 0, vmstate_hack_int32_as_uint16, int32_t) + + +static const VMStateDescription vmstate_menelaus_tm = { + .name ="menelaus_tm" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { + VMSTATE_UINT16_HACK(tm_sec, struct tm), + VMSTATE_UINT16_HACK(tm_min, struct tm), + VMSTATE_UINT16_HACK(tm_hour, struct tm), + VMSTATE_UINT16_HACK(tm_mday, struct tm), + VMSTATE_UINT16_HACK(tm_min, struct tm), + VMSTATE_UINT16_HACK(tm_year, struct tm), +VMSTATE_END_OF_LIST () + } +}; -static int menelaus_load (QEMUFile *f,void *opaque,int version_id) +static void menelaus_pre_save (const void *opaque) { -MenelausState *s = (MenelausState *) opaque; +MenelausState *s = (void *)opaque; +/* Should be <= 1000 */ + s->rtc_next_vmstate = s->rtc.next -qemu_get_clock (rt_clock); +} - s->firstbyte =qemu_get_be32 (f); -qemu_get_8s (f, &s->reg); +static int menelaus_post_load (void *opaque) +{ +MenelausState *s = opaque;if (s->rtc.ctrl &1 )/* RTC_EN */ menelaus_rtc_stop (s); -qemu_get_8s (f, &s->vcore[0 ]); -qemu_get_8s (f, &s->vcore[1 ]); -qemu_get_8s (f, &s->vcore[2 ]); -qemu_get_8s (f, &s->vcore[3 ]); -qemu_get_8s (f, &s->vcore[4 ]); -qemu_get_8s (f, &s->dcdc[0 ]); -qemu_get_8s (f, &s->dcdc[1 ]); -qemu_get_8s (f, &s->dcdc[2 ]); -qemu_get_8s (f, &s->ldo[0 ]); -qemu_get_8s (f, &s->ldo[1 ]); -qemu_get_8s (f, &s->ldo[2 ]); -qemu_get_8s (f, &s->ldo[3 ]); -qemu_get_8s (f, &s->ldo[4 ]); -qemu_get_8s (f, &s->ldo[5 ]); -qemu_get_8s (f, &s->ldo[6 ]); -qemu_get_8s (f, &s->ldo[7 ]); -qemu_get_8s (f, &s->sleep[0 ]); -qemu_get_8s (f, &s->sleep[1 ]); -qemu_get_8s (f, &s->osc); -qemu_get_8s (f, &s->detect); -qemu_get_be16s (f, &s->mask); -qemu_get_be16s (f, &s->status); -qemu_get_8s (f, &s->dir); -qemu_get_8s (f, &s->inputs); -qemu_get_8s (f, &s->outputs); -qemu_get_8s (f, &s->bbsms); -qemu_get_8s (f, &s->pull[0 ]); -qemu_get_8s (f, &s->pull[1 ]); -qemu_get_8s (f, &s->pull[2 ]); -qemu_get_8s (f, &s->pull[3 ]); -qemu_get_8s (f, &s->mmc_ctrl[0 ]); -qemu_get_8s (f, &s->mmc_ctrl[1 ]); -qemu_get_8s (f, &s->mmc_ctrl[2 ]); -qemu_get_8s (f, &s->mmc_debounce); -qemu_get_8s (f, &s->rtc.ctrl); -qemu_get_be16s (f, &s->rtc.comp); - s->rtc.next =qemu_get_be16 (f); -tm_get (f, &s->rtc.new); -tm_get (f, &s->rtc.alm); - s->pwrbtn_state =qemu_get_byte (f); + + s->rtc.next = s->rtc_next_vmstate; +menelaus_alm_update (s);menelaus_update (s);if (s->rtc.ctrl &1 )/* RTC_EN */ menelaus_rtc_start (s); - -i2c_slave_load (f, &s->i2c);return 0 ; } +static const VMStateDescription vmstate_menelaus = { + .name ="menelaus" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .pre_save = menelaus_pre_save, + .post_load = menelaus_post_load, + .fields = (VMStateField []) { +VMSTATE_INT32 (firstbyte, MenelausState), +VMSTATE_UINT8 (reg, MenelausState), +VMSTATE_UINT8_ARRAY (vcore, MenelausState,5 ), +VMSTATE_UINT8_ARRAY (dcdc, MenelausState,3 ), +VMSTATE_UINT8_ARRAY (ldo, MenelausState,8 ), +VMSTATE_UINT8_ARRAY (sleep, MenelausState,2 ), +VMSTATE_UINT8 (osc, MenelausState), +VMSTATE_UINT8 (detect, MenelausState), +VMSTATE_UINT16 (mask, MenelausState), +VMSTATE_UINT16 (status, MenelausState), +VMSTATE_UINT8 (dir, MenelausState), +VMSTATE_UINT8 (inputs, MenelausState), +VMSTATE_UINT8 (outputs, MenelausState), +VMSTATE_UINT8 (bbsms, MenelausState), +VMSTATE_UINT8_ARRAY (pull, MenelausState,4 ), +VMSTATE_UINT8_ARRAY (mmc_ctrl, MenelausState,3 ), +VMSTATE_UINT8 (mmc_debounce, MenelausState), +VMSTATE_UINT8 (rtc.ctrl, MenelausState), +VMSTATE_UINT16 (rtc.comp, MenelausState), +VMSTATE_UINT16 (rtc_next_vmstate, MenelausState), +VMSTATE_STRUCT (rtc.new, MenelausState,0 , vmstate_menelaus_tm, + struct tm), +VMSTATE_STRUCT (rtc.alm, MenelausState,0 , vmstate_menelaus_tm, + struct tm), +VMSTATE_UINT8 (pwrbtn_state, MenelausState), +VMSTATE_I2C_SLAVE (i2c, MenelausState), +VMSTATE_END_OF_LIST () + } +}; +static int twl92230_init (i2c_slave *i2c) {MenelausState *s =FROM_I2C_SLAVE (MenelausState, i2c);
@@ -887,7 +865,7 @@ static int twl92230_init(i2c_slave *i2c)menelaus_reset (&s->i2c); -register_savevm ("menelaus" ,-1 ,0 , menelaus_save, menelaus_load, s); +vmstate_register (-1 , &vmstate_menelaus, s);return 0 ; }
Signature · 1 line
1.6.2.5
PATCH 17/20 vmstate: add support for arrays of pointers
In reply to Juan QuintelaWe need this to send arrays of timers
--- hw/hw.h | 15 +++++++++++++++ savevm.c | 3 +++ 2 files changed, 18 insertions(+), 0 deletions(-)
hw/hw.h +15 -0
@@ -286,6 +286,7 @@ enum VMStateFlags {VMS_STRUCT =0x008 ,VMS_VARRAY =0x010 ,/* Array with size in another field */ VMS_BUFFER =0x020 ,/* static sized buffer */ + VMS_ARRAY_OF_POINTER = 0x040, }; typedef struct {
@@ -396,6 +397,17 @@ extern const VMStateInfo vmstate_info_buffer; + type_check(_type,typeof_field(_state, _field)) \ } +#define VMSTATE_ARRAY_OF_POINTER (_field, _state, _num, _version, _info, _type) {\ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .num = (_num), \ + .info = &(_info), \ + .size = sizeof(_type), \ + .flags = VMS_ARRAY|VMS_ARRAY_OF_POINTER, \ + .offset = offsetof(_state, _field) \ + + type_check_array(_type,typeof_field(_state, _field),_num) \ +} +#define VMSTATE_STRUCT_ARRAY (_field, _state, _num, _version, _vmsd, _type) { \ .name = (stringify(_field)), \ .num = (_num), \
@@ -506,6 +518,9 @@ extern const VMStateDescription vmstate_i2c_slave;#define VMSTATE_TIMER (_f, _s) \ VMSTATE_TIMER_V(_f, _s, 0) +#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 *)
savevm.c +3 -0
@@ -1069,6 +1069,9 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,for (i =0 ; i < n_elems; i++) {void *addr = base_addr + field->size * i; +if (field->flags &VMS_ARRAY_OF_POINTER ) { + addr = *(void **)addr; + }if (field->flags &VMS_STRUCT ) { ret =vmstate_load_state (f, field->vmsd, addr, field->vmsd->version_id); }else {
Signature · 1 line
1.6.2.5
Hi,
Quoted 5 lines · ext Juan Quintela
-
i2c->addressnow areuint8_t, my review of all uses is that they are always
used asuint8_t(and that is the type that is passed on the
value). If you know
i2c, please check. Change 0002 looks big, but it is because as I was
I would propose that the address has more than 8 bits to be more future-proof. After all, the bus addressing has already been extended to 10 bits: see http://www.i2c-bus.org/addressing/10-bit-addressing/
Regards,
Juha
Quoted 10 lines · <[email protected]> wrote:
Hi,
Quoted 5 lines · ext Juan Quintela
-
i2c->addressnow areuint8_t, my review of all uses is that they are always
used asuint8_t(and that is the type that is passed on the
value). If you know
i2c, please check. Change 0002 looks big, but it is because as I was
Quoted 3 lines
I would propose that the address has more than 8 bits to be more future-proof. After all, the bus addressing has already been extended to 10 bits: see http://www.i2c-bus.org/addressing/10-bit-addressing/
Then we have a field day, and make incompatible versions from now on. VMState use typechecking to make sure that what we save/load has the same type that the variable. And that was not the case for i2c addresses. how many users have old machines saved that they want to restore?
Later, Juan.
Quoted 3 lines
Regards,
Juha
Quoted 11 lines · ext Juan Quintela
Quoted 10 lines
Quoted 6 lines
-
i2c->addressnow areuint8_t, my review of all uses is that they are always
used asuint8_t(and that is the type that is passed on the value). If you know
i2c, please check. Change 0002 looks big, but it is because as I wasI would propose that the address has more than 8 bits to be more future-proof. After all, the bus addressing has already been extended to 10 bits: see http://www.i2c-bus.org/addressing/10-bit-addressing/
Quoted 5 lines
Then we have a field day, and make incompatible versions from now on. VMState use typechecking to make sure that what we save/load has the same type that the variable. And that was not the case for i2c addresses. how many users have old machines saved that they want to restore?
I'm sorry but why is it not possible to start using e.g. 16 bits for the address in the save states from now on and still keep the ability to read save states generated with previous versions? I'm okay with staying on 8 bit addresses only, I would just like to have some solid rationale behind that decision.
Juha
Quoted 19 lines · <[email protected]> wrote:
Quoted 11 lines · ext Juan Quintela
Quoted 10 lines
Quoted 6 lines
-
i2c->addressnow areuint8_t, my review of all uses is that they are always
used asuint8_t(and that is the type that is passed on the value). If you know
i2c, please check. Change 0002 looks big, but it is because as I wasI would propose that the address has more than 8 bits to be more future-proof. After all, the bus addressing has already been extended to 10 bits: see http://www.i2c-bus.org/addressing/10-bit-addressing/
Quoted 5 lines
Then we have a field day, and make incompatible versions from now on. VMState use typechecking to make sure that what we save/load has the same type that the variable. And that was not the case for i2c addresses. how many users have old machines saved that they want to restore?
Quoted 5 lines
I'm sorry but why is it not possible to start using e.g. 16 bits for the address in the save states from now on and still keep the ability to read save states generated with previous versions? I'm okay with staying on 8 bit addresses only, I would just like to have some solid rationale behind that decision.
It is possible in the Turing sense. It is not possible in the current VMSTate sense.
And it is not trivial to do it. Only thing that I can think of is passing version_id to all get functions to be able to decide if address is 8 bit or 16 bit address. This get ugly fast.
The other solution that I can think of is adding address_vmstate that is 8 bits (current code), and a new one that is 16 bit. I think this one is a bit better (althought not perfect for any means).
In post_load, we do the adjustments (i.e. for older versions, we copy the value to the new value.
It does'nt matter how we do it, fields changing size is never going to be pretty.
Is 16 bits enough, or it is going to be needed to get more bits (there are not so many address fields, getting them to 32bits shouldn't be such a big deal.
Later, Juan.
PATCH 18/20 lm832x: make fields to have the same types that they are saved/loaded
In reply to Juan QuintelaThey were saved as uint8_t already. To make things simpler, I just reg == -1 used to indicate an error, I create LM832x_GENERAL_ERROR with vale 0xff to represet it
--- hw/lm832x.c | 41 ++++++++++++++++++++++------------------- 1 files changed, 22 insertions(+), 19 deletions(-)
hw/lm832x.c +22 -19
@@ -25,9 +25,9 @@ typedef struct { i2c_slave i2c; - int i2c_dir; - int i2c_cycle; - int reg; + uint8_t i2c_dir; + uint8_t i2c_cycle; + uint8_t reg; qemu_irq nirq; uint16_t model;
@@ -54,8 +54,8 @@ typedef struct {struct {uint8_t dbnctime;uint8_t size; -int start; -int len; +uint8_t start; +uint8_t len;uint8_t fifo[16 ]; } kbd;
@@ -152,6 +152,9 @@ enum { LM832x_CMD_PWM_WRITE =0x95 ,/* Write PWM script. */ LM832x_CMD_PWM_START =0x96 ,/* Start PWM engine. */ LM832x_CMD_PWM_STOP =0x97 ,/* Stop PWM engine. */ + LM832x_GENERAL_ERROR = 0xff, /* There was one error. + Previously was represented by -1 + This is not a command */ };#define LM832x_MAX_KPX 8
@@ -257,7 +260,7 @@ static void lm_kbd_write(LM823KbdState *s, int reg, int byte, uint8_t value)lm_kbd_irq_update (s); s->kbd.len =0 ; s->kbd.start =0 ; - s->reg =-1 ; + s->reg = LM832x_GENERAL_ERROR;break ;case LM832x_CMD_RESET:
@@ -265,7 +268,7 @@ static void lm_kbd_write(LM823KbdState *s, int reg, int byte, uint8_t value)lm_kbd_reset (s); elselm_kbd_error (s ,ERR_BADPAR ); - s->reg =-1 ; + s->reg = LM832x_GENERAL_ERROR;break ;case LM823x_CMD_WRITE_PULL_DOWN:
@@ -274,7 +277,7 @@ static void lm_kbd_write(LM823KbdState *s, int reg, int byte, uint8_t value)else { s->gpio.pull |= value <<8 ;lm_kbd_gpio_update (s); - s->reg =-1 ; + s->reg = LM832x_GENERAL_ERROR; }break ;case LM832x_CMD_WRITE_PORT_SEL:
@@ -283,7 +286,7 @@ static void lm_kbd_write(LM823KbdState *s, int reg, int byte, uint8_t value)else { s->gpio.dir |= value <<8 ;lm_kbd_gpio_update (s); - s->reg =-1 ; + s->reg = LM832x_GENERAL_ERROR; }break ;case LM832x_CMD_WRITE_PORT_STATE:
@@ -292,25 +295,25 @@ static void lm_kbd_write(LM823KbdState *s, int reg, int byte, uint8_t value)else { s->gpio.mask |= value <<8 ;lm_kbd_gpio_update (s); - s->reg =-1 ; + s->reg = LM832x_GENERAL_ERROR; }break ;case LM832x_CMD_SET_ACTIVE: s->acttime = value; - s->reg =-1 ; + s->reg = LM832x_GENERAL_ERROR;break ;case LM832x_CMD_SET_DEBOUNCE: s->kbd.dbnctime = value; - s->reg =-1 ; + s->reg = LM832x_GENERAL_ERROR;if (!value)lm_kbd_error (s,ERR_BADPAR );break ;case LM832x_CMD_SET_KEY_SIZE: s->kbd.size = value; - s->reg =-1 ; + s->reg = LM832x_GENERAL_ERROR;if ( (value &0xf ) <3 || (value &0xf ) > LM832x_MAX_KPY || (value >>4 ) <3 || (value >>4 ) > LM832x_MAX_KPX)
@@ -319,7 +322,7 @@ static void lm_kbd_write(LM823KbdState *s, int reg, int byte, uint8_t value)case LM832x_CMD_WRITE_CLOCK: s->clock = value; - s->reg =-1 ; + s->reg = LM832x_GENERAL_ERROR;if ((value &3 ) && (value &3 ) !=3 ) {lm_kbd_error (s,ERR_BADPAR ); fprintf(stderr, "%s: invalid clock setting in RCPWM\n",
@@ -332,7 +335,7 @@ static void lm_kbd_write(LM823KbdState *s, int reg, int byte, uint8_t value)if (byte ==0 ) {if (!(value &3 ) || (value >>2 ) >59 ) {lm_kbd_error (s,ERR_BADPAR ); - s->reg =-1 ; + s->reg = LM832x_GENERAL_ERROR;break ; }
@@ -342,11 +345,11 @@ static void lm_kbd_write(LM823KbdState *s, int reg, int byte, uint8_t value) s->pwm.file[s->pwm.faddr] |= value <<8 ; }else if (byte ==2 ) { s->pwm.file[s->pwm.faddr] |= value <<0 ; - s->reg =-1 ; + s->reg = LM832x_GENERAL_ERROR; }break ;case LM832x_CMD_PWM_START: - s->reg =-1 ; + s->reg = LM832x_GENERAL_ERROR;if (!(value &3 ) || (value >>2 ) >59 ) {lm_kbd_error (s,ERR_BADPAR );break ;
@@ -356,7 +359,7 @@ static void lm_kbd_write(LM823KbdState *s, int reg, int byte, uint8_t value)lm_kbd_pwm_start (s, (value &3 ) -1 );break ;case LM832x_CMD_PWM_STOP: - s->reg =-1 ; + s->reg = LM832x_GENERAL_ERROR;if (!(value &3 )) {lm_kbd_error (s,ERR_BADPAR );break ;
@@ -365,7 +368,7 @@ static void lm_kbd_write(LM823KbdState *s, int reg, int byte, uint8_t value)qemu_del_timer (s->pwm.tm[(value &3 ) -1 ]);break ; -case -1 : +case LM832x_GENERAL_ERROR:lm_kbd_error (s,ERR_BADPAR );break ;default :
Signature · 1 line
1.6.2.5
PATCH 19/20 vmstate: port lm832x device
In reply to Juan Quintela--- hw/lm832x.c | 107 ++++++++++++++++++++-------------------------------------- 1 files changed, 37 insertions(+), 70 deletions(-)
hw/lm832x.c +37 -70
@@ -414,76 +414,9 @@ static int lm_i2c_tx(i2c_slave *i2c, uint8_t data)return 0 ; } -static void lm_kbd_save (QEMUFile *f,void *opaque) +static int lm_kbd_post_load (void *opaque) { -LM823KbdState *s = (LM823KbdState *) opaque; -int i; - -i2c_slave_save (f, &s->i2c); -qemu_put_byte (f, s->i2c_dir); -qemu_put_byte (f, s->i2c_cycle); -qemu_put_byte (f, (uint8_t ) s->reg); - -qemu_put_8s (f, &s->config); -qemu_put_8s (f, &s->status); -qemu_put_8s (f, &s->acttime); -qemu_put_8s (f, &s->error); -qemu_put_8s (f, &s->clock); - -qemu_put_be16s (f, &s->gpio.pull); -qemu_put_be16s (f, &s->gpio.mask); -qemu_put_be16s (f, &s->gpio.dir); -qemu_put_be16s (f, &s->gpio.level); - -qemu_put_byte (f, s->kbd.dbnctime); -qemu_put_byte (f, s->kbd.size); -qemu_put_byte (f, s->kbd.start); -qemu_put_byte (f, s->kbd.len); -qemu_put_buffer (f, s->kbd.fifo,sizeof (s->kbd.fifo)); - -for (i =0 ; i <sizeof (s->pwm.file); i ++) -qemu_put_be16s (f, &s->pwm.file[i]); -qemu_put_8s (f, &s->pwm.faddr); -qemu_put_buffer (f, s->pwm.addr,sizeof (s->pwm.addr)); -qemu_put_timer (f, s->pwm.tm[0 ]); -qemu_put_timer (f, s->pwm.tm[1 ]); -qemu_put_timer (f, s->pwm.tm[2 ]); -} - -static int lm_kbd_load (QEMUFile *f,void *opaque,int version_id) -{ -LM823KbdState *s = (LM823KbdState *) opaque; -int i; - -i2c_slave_load (f, &s->i2c); - s->i2c_dir =qemu_get_byte (f); - s->i2c_cycle =qemu_get_byte (f); - s->reg = (int8_t )qemu_get_byte (f); - -qemu_get_8s (f, &s->config); -qemu_get_8s (f, &s->status); -qemu_get_8s (f, &s->acttime); -qemu_get_8s (f, &s->error); -qemu_get_8s (f, &s->clock); - -qemu_get_be16s (f, &s->gpio.pull); -qemu_get_be16s (f, &s->gpio.mask); -qemu_get_be16s (f, &s->gpio.dir); -qemu_get_be16s (f, &s->gpio.level); - - s->kbd.dbnctime =qemu_get_byte (f); - s->kbd.size =qemu_get_byte (f); - s->kbd.start =qemu_get_byte (f); - s->kbd.len =qemu_get_byte (f); -qemu_get_buffer (f, s->kbd.fifo,sizeof (s->kbd.fifo)); - -for (i =0 ; i <sizeof (s->pwm.file); i ++) -qemu_get_be16s (f, &s->pwm.file[i]); -qemu_get_8s (f, &s->pwm.faddr); -qemu_get_buffer (f, s->pwm.addr,sizeof (s->pwm.addr)); -qemu_get_timer (f, s->pwm.tm[0 ]); -qemu_get_timer (f, s->pwm.tm[1 ]); -qemu_get_timer (f, s->pwm.tm[2 ]); +LM823KbdState *s = opaque;lm_kbd_irq_update (s);lm_kbd_gpio_update (s);
@@ -491,6 +424,40 @@ static int lm_kbd_load(QEMUFile *f, void *opaque, int version_id)return 0 ; } +static const VMStateDescription vmstate_lm_kbd = { + .name ="LM8323" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .post_load = lm_kbd_post_load, + .fields = (VMStateField []) { +VMSTATE_I2C_SLAVE (i2c, LM823KbdState), +VMSTATE_UINT8 (i2c_dir, LM823KbdState), +VMSTATE_UINT8 (i2c_cycle, LM823KbdState), +VMSTATE_UINT8 (reg, LM823KbdState), +VMSTATE_UINT8 (config, LM823KbdState), +VMSTATE_UINT8 (status, LM823KbdState), +VMSTATE_UINT8 (acttime, LM823KbdState), +VMSTATE_UINT8 (error, LM823KbdState), +VMSTATE_UINT8 (clock, LM823KbdState), +VMSTATE_UINT16 (gpio.pull, LM823KbdState), +VMSTATE_UINT16 (gpio.mask, LM823KbdState), +VMSTATE_UINT16 (gpio.dir, LM823KbdState), +VMSTATE_UINT16 (gpio.level, LM823KbdState), +VMSTATE_UINT8 (kbd.dbnctime, LM823KbdState), +VMSTATE_UINT8 (kbd.size, LM823KbdState), +VMSTATE_UINT8 (kbd.start, LM823KbdState), +VMSTATE_UINT8 (kbd.len, LM823KbdState), +VMSTATE_BUFFER (kbd.fifo, LM823KbdState), +VMSTATE_UINT16_ARRAY (pwm.file, LM823KbdState,256 ), +VMSTATE_UINT8 (pwm.faddr, LM823KbdState), +VMSTATE_BUFFER (pwm.addr, LM823KbdState), +VMSTATE_TIMER_ARRAY (pwm.tm, LM823KbdState,3 ), +VMSTATE_END_OF_LIST () + } +}; + +static int lm8323_init (i2c_slave *i2c) {LM823KbdState *s =FROM_I2C_SLAVE (LM823KbdState, i2c);
@@ -504,7 +471,7 @@ static int lm8323_init(i2c_slave *i2c)lm_kbd_reset (s);qemu_register_reset ((void *) lm_kbd_reset, s); -register_savevm ("LM8323" ,-1 ,0 , lm_kbd_save, lm_kbd_load, s); +vmstate_register (-1 , &vmstate_lm_kbd, s);return 0 ; }
Signature · 1 line
1.6.2.5
PATCH 20/20 vmstate: remove i2c_slave_load/save
In reply to Juan QuintelaAll its users moved to vmstate
--- hw/i2c.c | 11 ----------- hw/i2c.h | 2 -- 2 files changed, 0 insertions(+), 13 deletions(-)
hw/i2c.c +0 -11
@@ -165,17 +165,6 @@ const VMStateDescription vmstate_i2c_slave = { } }; -void i2c_slave_save (QEMUFile *f,i2c_slave *dev) -{ -vmstate_save_state (f, &vmstate_i2c_slave, dev); -} - -void i2c_slave_load (QEMUFile *f,i2c_slave *dev) -{ -vmstate_load_state (f, &vmstate_i2c_slave, dev, - vmstate_i2c_slave.version_id); -} -static int i2c_slave_qdev_init (DeviceState *dev,DeviceInfo *base) {I2CSlaveInfo *info =container_of (base, I2CSlaveInfo, qdev);
hw/i2c.h +0 -2
@@ -51,8 +51,6 @@ void i2c_end_transfer(i2c_bus *bus);void i2c_nack (i2c_bus *bus);int i2c_send (i2c_bus *bus,uint8_t data);int i2c_recv (i2c_bus *bus); -void i2c_slave_save (QEMUFile *f,i2c_slave *dev); -void i2c_slave_load (QEMUFile *f,i2c_slave *dev);#define I2C_SLAVE_FROM_QDEV (dev) DO_UPCAST(i2c_slave, qdev, dev)#define FROM_I2C_SLAVE (type, dev) DO_UPCAST(type, i2c, dev)
Signature · 1 line
1.6.2.5