Commit d4ae799cd164aa80a25e52ac09aceb7ff9732ac9

Authored by aurel32
1 parent e8afa065

hw/eeprom93xx.c: substitute structure dump with discrete dump in eeprom_save/load

The EEPROM 93xx device used to dump a C structure to the migration stream.
This structure includes mixed 8 and 16bit variables and is thus subject to
compiler dependent padding. Replace this with discrete dumps of each member
(and add a padding byte to ensure compatibility, a version update is
included in the following patch).

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6917 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 27 additions and 2 deletions
hw/eeprom93xx.c
... ... @@ -95,7 +95,19 @@ static void eeprom_save(QEMUFile *f, void *opaque)
95 95 /* Save EEPROM data. */
96 96 unsigned address;
97 97 eeprom_t *eeprom = (eeprom_t *)opaque;
98   - qemu_put_buffer(f, (uint8_t *)eeprom, sizeof(*eeprom) - 2);
  98 +
  99 + qemu_put_byte(f, eeprom->tick);
  100 + qemu_put_byte(f, eeprom->address);
  101 + qemu_put_byte(f, eeprom->command);
  102 + qemu_put_byte(f, eeprom->writeable);
  103 +
  104 + qemu_put_byte(f, eeprom->eecs);
  105 + qemu_put_byte(f, eeprom->eesk);
  106 + qemu_put_byte(f, eeprom->eedo);
  107 +
  108 + qemu_put_byte(f, eeprom->addrbits);
  109 + qemu_put_byte(f, eeprom->size);
  110 + qemu_put_byte(f, 0); /* padding for compatiblity */
99 111 qemu_put_be16(f, eeprom->data);
100 112 for (address = 0; address < eeprom->size; address++) {
101 113 qemu_put_be16(f, eeprom->contents[address]);
... ... @@ -111,7 +123,20 @@ static int eeprom_load(QEMUFile *f, void *opaque, int version_id)
111 123 if (version_id == eeprom_version) {
112 124 unsigned address;
113 125 uint8_t size = eeprom->size;
114   - qemu_get_buffer(f, (uint8_t *)eeprom, sizeof(*eeprom) - 2);
  126 +
  127 + eeprom->tick = qemu_get_byte(f);
  128 + eeprom->address = qemu_get_byte(f);
  129 + eeprom->command = qemu_get_byte(f);
  130 + eeprom->writeable = qemu_get_byte(f);
  131 +
  132 + eeprom->eecs = qemu_get_byte(f);
  133 + eeprom->eesk = qemu_get_byte(f);
  134 + eeprom->eedo = qemu_get_byte(f);
  135 +
  136 + eeprom->addrbits = qemu_get_byte(f);
  137 + eeprom->size = qemu_get_byte(f);
  138 + qemu_get_byte(f); /* skip padding byte */
  139 +
115 140 if (eeprom->size == size) {
116 141 eeprom->data = qemu_get_be16(f);
117 142 for (address = 0; address < eeprom->size; address++) {
... ...