diff options
author | aurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162> | 2009-03-28 23:14:52 +0000 |
---|---|---|
committer | aurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162> | 2009-03-28 23:14:52 +0000 |
commit | 7ab2589cbb91e07f6eadde0b5435602d75a5a72a (patch) | |
tree | 92fefdf74fc8eecff42e5fc0e99fb7599f5fda8a /hw | |
parent | d4ae799cd164aa80a25e52ac09aceb7ff9732ac9 (diff) | |
download | qemu-7ab2589cbb91e07f6eadde0b5435602d75a5a72a.zip qemu-7ab2589cbb91e07f6eadde0b5435602d75a5a72a.tar.gz qemu-7ab2589cbb91e07f6eadde0b5435602d75a5a72a.tar.bz2 |
hw/eeprom93xx.c: support 93xx EEPROMs with more than 255 words
In the head of eeprom93xx.c we promise to support chips with 256 words,
but store the size in an unsigned byte. This patch replaces this with an
16 bit variable and changes the load/store code accordingly (introducing a
new version).
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@6918 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw')
-rw-r--r-- | hw/eeprom93xx.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/hw/eeprom93xx.c b/hw/eeprom93xx.c index 1d546e2..ae15a7f 100644 --- a/hw/eeprom93xx.c +++ b/hw/eeprom93xx.c @@ -49,8 +49,9 @@ #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 { @@ -83,7 +84,7 @@ struct _eeprom_t { uint8_t eedo; uint8_t addrbits; - uint8_t size; + uint16_t size; uint16_t data; uint16_t contents[0]; }; @@ -106,8 +107,7 @@ static void eeprom_save(QEMUFile *f, void *opaque) 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]); @@ -120,9 +120,9 @@ static int eeprom_load(QEMUFile *f, void *opaque, int version_id) 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); @@ -134,8 +134,12 @@ static int eeprom_load(QEMUFile *f, void *opaque, int version_id) 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); @@ -317,7 +321,7 @@ eeprom_t *eeprom93xx_new(uint16_t nwords) /* 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; } |