Revision 7ab2589c hw/eeprom93xx.c
b/hw/eeprom93xx.c | ||
---|---|---|
49 | 49 |
#define logout(fmt, args...) ((void)0) |
50 | 50 |
#endif |
51 | 51 |
|
52 |
static int eeprom_instance = 0; |
|
53 |
static const int eeprom_version = 20061112; |
|
52 |
#define EEPROM_INSTANCE 0 |
|
53 |
#define OLD_EEPROM_VERSION 20061112 |
|
54 |
#define EEPROM_VERSION (OLD_EEPROM_VERSION + 1) |
|
54 | 55 |
|
55 | 56 |
#if 0 |
56 | 57 |
typedef enum { |
... | ... | |
83 | 84 |
uint8_t eedo; |
84 | 85 |
|
85 | 86 |
uint8_t addrbits; |
86 |
uint8_t size;
|
|
87 |
uint16_t size;
|
|
87 | 88 |
uint16_t data; |
88 | 89 |
uint16_t contents[0]; |
89 | 90 |
}; |
... | ... | |
106 | 107 |
qemu_put_byte(f, eeprom->eedo); |
107 | 108 |
|
108 | 109 |
qemu_put_byte(f, eeprom->addrbits); |
109 |
qemu_put_byte(f, eeprom->size); |
|
110 |
qemu_put_byte(f, 0); /* padding for compatiblity */ |
|
110 |
qemu_put_be16(f, eeprom->size); |
|
111 | 111 |
qemu_put_be16(f, eeprom->data); |
112 | 112 |
for (address = 0; address < eeprom->size; address++) { |
113 | 113 |
qemu_put_be16(f, eeprom->contents[address]); |
... | ... | |
120 | 120 |
of data and current EEPROM are identical. */ |
121 | 121 |
eeprom_t *eeprom = (eeprom_t *)opaque; |
122 | 122 |
int result = -EINVAL; |
123 |
if (version_id == eeprom_version) {
|
|
123 |
if (version_id >= OLD_EEPROM_VERSION) {
|
|
124 | 124 |
unsigned address; |
125 |
uint8_t size = eeprom->size;
|
|
125 |
int size = eeprom->size;
|
|
126 | 126 |
|
127 | 127 |
eeprom->tick = qemu_get_byte(f); |
128 | 128 |
eeprom->address = qemu_get_byte(f); |
... | ... | |
134 | 134 |
eeprom->eedo = qemu_get_byte(f); |
135 | 135 |
|
136 | 136 |
eeprom->addrbits = qemu_get_byte(f); |
137 |
eeprom->size = qemu_get_byte(f); |
|
138 |
qemu_get_byte(f); /* skip padding byte */ |
|
137 |
if (version_id == OLD_EEPROM_VERSION) { |
|
138 |
eeprom->size = qemu_get_byte(f); |
|
139 |
qemu_get_byte(f); |
|
140 |
} else { |
|
141 |
eeprom->size = qemu_get_be16(f); |
|
142 |
} |
|
139 | 143 |
|
140 | 144 |
if (eeprom->size == size) { |
141 | 145 |
eeprom->data = qemu_get_be16(f); |
... | ... | |
317 | 321 |
/* Output DO is tristate, read results in 1. */ |
318 | 322 |
eeprom->eedo = 1; |
319 | 323 |
logout("eeprom = 0x%p, nwords = %u\n", eeprom, nwords); |
320 |
register_savevm("eeprom", eeprom_instance, eeprom_version,
|
|
324 |
register_savevm("eeprom", EEPROM_INSTANCE, EEPROM_VERSION,
|
|
321 | 325 |
eeprom_save, eeprom_load, eeprom); |
322 | 326 |
return eeprom; |
323 | 327 |
} |
Also available in: Unified diff