From: Aurelien Jarno <aurelien@aurel32.net>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [6918] hw/eeprom93xx.c: support 93xx EEPROMs with more than 255 words
Date: Sat, 28 Mar 2009 23:14:53 +0000 [thread overview]
Message-ID: <E1Lnhjp-0005rJ-AY@cvs.savannah.gnu.org> (raw)
Revision: 6918
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6918
Author: aurel32
Date: 2009-03-28 23:14:52 +0000 (Sat, 28 Mar 2009)
Log Message:
-----------
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>
Modified Paths:
--------------
trunk/hw/eeprom93xx.c
Modified: trunk/hw/eeprom93xx.c
===================================================================
--- trunk/hw/eeprom93xx.c 2009-03-28 23:14:41 UTC (rev 6917)
+++ trunk/hw/eeprom93xx.c 2009-03-28 23:14:52 UTC (rev 6918)
@@ -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 @@
uint8_t eedo;
uint8_t addrbits;
- uint8_t size;
+ uint16_t size;
uint16_t data;
uint16_t contents[0];
};
@@ -106,8 +107,7 @@
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 @@
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 @@
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 @@
/* 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;
}
reply other threads:[~2009-03-28 23:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1Lnhjp-0005rJ-AY@cvs.savannah.gnu.org \
--to=aurelien@aurel32.net \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).