#define logout(fmt, args...) ((void)0)
#endif
-static int eeprom_instance = 0;
-static const int eeprom_version = 20061112;
+#define EEPROM_INSTANCE 0
+#define OLD_EEPROM_VERSION 20061112
+#define EEPROM_VERSION (OLD_EEPROM_VERSION + 1)
#if 0
typedef enum {
uint8_t eedo;
uint8_t addrbits;
- uint8_t size;
+ uint16_t size;
uint16_t data;
uint16_t contents[0];
};
qemu_put_byte(f, eeprom->eedo);
qemu_put_byte(f, eeprom->addrbits);
- qemu_put_byte(f, eeprom->size);
- qemu_put_byte(f, 0); /* padding for compatiblity */
+ qemu_put_be16(f, eeprom->size);
qemu_put_be16(f, eeprom->data);
for (address = 0; address < eeprom->size; address++) {
qemu_put_be16(f, eeprom->contents[address]);
of data and current EEPROM are identical. */
eeprom_t *eeprom = (eeprom_t *)opaque;
int result = -EINVAL;
- if (version_id == eeprom_version) {
+ if (version_id >= OLD_EEPROM_VERSION) {
unsigned address;
- uint8_t size = eeprom->size;
+ int size = eeprom->size;
eeprom->tick = qemu_get_byte(f);
eeprom->address = qemu_get_byte(f);
eeprom->eedo = qemu_get_byte(f);
eeprom->addrbits = qemu_get_byte(f);
- eeprom->size = qemu_get_byte(f);
- qemu_get_byte(f); /* skip padding byte */
+ if (version_id == OLD_EEPROM_VERSION) {
+ eeprom->size = qemu_get_byte(f);
+ qemu_get_byte(f);
+ } else {
+ eeprom->size = qemu_get_be16(f);
+ }
if (eeprom->size == size) {
eeprom->data = qemu_get_be16(f);
/* Output DO is tristate, read results in 1. */
eeprom->eedo = 1;
logout("eeprom = 0x%p, nwords = %u\n", eeprom, nwords);
- register_savevm("eeprom", eeprom_instance, eeprom_version,
+ register_savevm("eeprom", EEPROM_INSTANCE, EEPROM_VERSION,
eeprom_save, eeprom_load, eeprom);
return eeprom;
}