From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LbNLY-0007hm-Up for qemu-devel@nongnu.org; Sun, 22 Feb 2009 18:02:52 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LbNLV-0007gq-8d for qemu-devel@nongnu.org; Sun, 22 Feb 2009 18:02:52 -0500 Received: from [199.232.76.173] (port=37988 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LbNLV-0007gn-62 for qemu-devel@nongnu.org; Sun, 22 Feb 2009 18:02:49 -0500 Received: from outbound-sin.frontbridge.com ([207.46.51.80]:11243 helo=SG2EHSOBE003.bigfish.com) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_MD5:16) (Exim 4.60) (envelope-from ) id 1LbNLU-00044B-D2 for qemu-devel@nongnu.org; Sun, 22 Feb 2009 18:02:48 -0500 Received: from mail91-sin (localhost.localdomain [127.0.0.1]) by mail91-sin-R.bigfish.com (Postfix) with ESMTP id 892E6178013C for ; Sun, 22 Feb 2009 23:02:44 +0000 (UTC) Received: from ausb3extmailp01.amd.com (unknown [163.181.251.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail91-sin.bigfish.com (Postfix) with ESMTP id A3E3D1C6804E for ; Sun, 22 Feb 2009 23:02:40 +0000 (UTC) Received: from ausb3twp01.amd.com ([163.181.250.37]) by ausb3extmailp01.amd.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id n1MN2W11016902 for ; Sun, 22 Feb 2009 17:02:35 -0600 Received: from sausexbh1.amd.com (sausexbh1.amd.com [163.181.22.101]) by ausb3twp01.amd.com (Tumbleweed MailGate 3.5.1) with ESMTP id 2C06A1944D8 for ; Sun, 22 Feb 2009 17:02:22 -0600 (CST) From: Andre Przywara Date: Mon, 23 Feb 2009 00:02:12 +0100 Message-ID: <1235343732985-git-send-email-andre.przywara@amd.com> In-Reply-To: <12353435271060-git-send-email-andre.przywara@amd.com> References: <12353435271060-git-send-email-andre.przywara@amd.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH] support 93xx EEPROMs with more than 255 words Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Andre Przywara 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 --- hw/eeprom93xx.c | 24 ++++++++++++++---------- 1 files changed, 14 insertions(+), 10 deletions(-) diff --git a/hw/eeprom93xx.c b/hw/eeprom93xx.c index 527fdf7..e791894 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); + dummy = 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; } -- 1.5.2.2