From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L9IsG-0004wc-R3 for qemu-devel@nongnu.org; Sun, 07 Dec 2008 07:36:36 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L9IsE-0004vR-J7 for qemu-devel@nongnu.org; Sun, 07 Dec 2008 07:36:35 -0500 Received: from [199.232.76.173] (port=59834 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L9IsE-0004vA-86 for qemu-devel@nongnu.org; Sun, 07 Dec 2008 07:36:34 -0500 Received: from savannah.gnu.org ([199.232.41.3]:47850 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L9IsD-0008OB-LC for qemu-devel@nongnu.org; Sun, 07 Dec 2008 07:36:34 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1L9IsC-0003uA-PD for qemu-devel@nongnu.org; Sun, 07 Dec 2008 12:36:32 +0000 Received: from balrog by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1L9IsB-0003u6-QY for qemu-devel@nongnu.org; Sun, 07 Dec 2008 12:36:32 +0000 MIME-Version: 1.0 Errors-To: balrog Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Andrzej Zaborowski Message-Id: Date: Sun, 07 Dec 2008 12:36:31 +0000 Subject: [Qemu-devel] [5904] pflash_cfi01: add Single Byte Program ( Jean-Christophe PLAGNIOL-VILLARD). 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 Revision: 5904 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5904 Author: balrog Date: 2008-12-07 12:36:28 +0000 (Sun, 07 Dec 2008) Log Message: ----------- pflash_cfi01: add Single Byte Program (Jean-Christophe PLAGNIOL-VILLARD). Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Signed-off-by: Andrzej Zaborowski Modified Paths: -------------- trunk/hw/pflash_cfi01.c Modified: trunk/hw/pflash_cfi01.c =================================================================== --- trunk/hw/pflash_cfi01.c 2008-12-07 03:12:54 UTC (rev 5903) +++ trunk/hw/pflash_cfi01.c 2008-12-07 12:36:28 UTC (rev 5904) @@ -194,6 +194,47 @@ } } +static void inline pflash_data_write(pflash_t *pfl, target_ulong offset, + uint32_t value, int width) +{ + uint8_t *p = pfl->storage; + + DPRINTF("%s: block write offset " TARGET_FMT_lx + " value %x counter " TARGET_FMT_lx "\n", + __func__, offset, value, pfl->counter); + switch (width) { + case 1: + p[offset] = value; + pflash_update(pfl, offset, 1); + break; + case 2: +#if defined(TARGET_WORDS_BIGENDIAN) + p[offset] = value >> 8; + p[offset + 1] = value; +#else + p[offset] = value; + p[offset + 1] = value >> 8; +#endif + pflash_update(pfl, offset, 2); + break; + case 4: +#if defined(TARGET_WORDS_BIGENDIAN) + p[offset] = value >> 24; + p[offset + 1] = value >> 16; + p[offset + 2] = value >> 8; + p[offset + 3] = value; +#else + p[offset] = value; + p[offset + 1] = value >> 8; + p[offset + 2] = value >> 16; + p[offset + 3] = value >> 24; +#endif + pflash_update(pfl, offset, 4); + break; + } + +} + static void pflash_write (pflash_t *pfl, target_ulong offset, uint32_t value, int width) { @@ -221,6 +262,10 @@ switch (cmd) { case 0x00: /* ??? */ goto reset_flash; + case 0x10: /* Single Byte Program */ + case 0x40: /* Single Byte Program */ + DPRINTF(stderr, "%s: Single Byte Program\n", __func__); + break; case 0x20: /* Block erase */ p = pfl->storage; offset &= ~(pfl->sector_len - 1); @@ -262,6 +307,13 @@ return; case 1: switch (pfl->cmd) { + case 0x10: /* Single Byte Program */ + case 0x40: /* Single Byte Program */ + DPRINTF("%s: Single Byte Program\n", __func__); + pflash_data_write(pfl, offset, value, width); + pfl->status |= 0x80; /* Ready! */ + pfl->wcycle = 0; + break; case 0x20: /* Block erase */ case 0x28: if (cmd == 0xd0) { /* confirm */ @@ -306,40 +358,7 @@ case 2: switch (pfl->cmd) { case 0xe8: /* Block write */ - p = pfl->storage; - DPRINTF("%s: block write offset " TARGET_FMT_lx - " value %x counter " TARGET_FMT_lx "\n", - __func__, offset, value, pfl->counter); - switch (width) { - case 1: - p[offset] = value; - pflash_update(pfl, offset, 1); - break; - case 2: -#if defined(TARGET_WORDS_BIGENDIAN) - p[offset] = value >> 8; - p[offset + 1] = value; -#else - p[offset] = value; - p[offset + 1] = value >> 8; -#endif - pflash_update(pfl, offset, 2); - break; - case 4: -#if defined(TARGET_WORDS_BIGENDIAN) - p[offset] = value >> 24; - p[offset + 1] = value >> 16; - p[offset + 2] = value >> 8; - p[offset + 3] = value; -#else - p[offset] = value; - p[offset + 1] = value >> 8; - p[offset + 2] = value >> 16; - p[offset + 3] = value >> 24; -#endif - pflash_update(pfl, offset, 4); - break; - } + pflash_data_write(pfl, offset, value, width); pfl->status |= 0x80;