From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L1p5m-0000vF-Gb for qemu-devel@nongnu.org; Sun, 16 Nov 2008 16:23:38 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L1p5k-0000uL-Fg for qemu-devel@nongnu.org; Sun, 16 Nov 2008 16:23:38 -0500 Received: from [199.232.76.173] (port=34599 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L1p5k-0000uI-9N for qemu-devel@nongnu.org; Sun, 16 Nov 2008 16:23:36 -0500 Received: from 42.mail-out.ovh.net ([213.251.189.42]:45943) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1L1p5j-0005bv-QI for qemu-devel@nongnu.org; Sun, 16 Nov 2008 16:23:36 -0500 From: Jean-Christophe PLAGNIOL-VILLARD Date: Sun, 16 Nov 2008 22:18:55 +0100 Message-Id: <1226870338-31165-1-git-send-email-plagnioj@jcrosoft.com> In-Reply-To: <20081116211702.GA9160@game.jcrosoft.org> References: <20081116211702.GA9160@game.jcrosoft.org> Subject: [Qemu-devel] [PATCH 1/4] pflash_cfi01: add Single Byte Program 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: Jean-Christophe PLAGNIOL-VILLARD Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- hw/pflash_cfi01.c | 87 ++++++++++++++++++++++++++++++++-------------------- 1 files changed, 53 insertions(+), 34 deletions(-) diff --git a/hw/pflash_cfi01.c b/hw/pflash_cfi01.c index 28abc16..f26684e 100644 --- a/hw/pflash_cfi01.c +++ b/hw/pflash_cfi01.c @@ -195,6 +195,47 @@ static void pflash_update(pflash_t *pfl, int offset, } } +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) { @@ -223,6 +264,10 @@ static void pflash_write (pflash_t *pfl, target_ulong offset, uint32_t value, 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); @@ -264,6 +309,13 @@ static void pflash_write (pflash_t *pfl, target_ulong offset, uint32_t value, 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 */ @@ -308,40 +360,7 @@ static void pflash_write (pflash_t *pfl, target_ulong offset, uint32_t value, 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; -- 1.5.6.5