From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9BeQ-0001U8-2v for qemu-devel@nongnu.org; Wed, 16 Dec 2015 07:57:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9BeM-0007MW-AK for qemu-devel@nongnu.org; Wed, 16 Dec 2015 07:57:49 -0500 Received: from demumfd001.nsn-inter.net ([93.183.12.32]:35351) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9BeL-0007MN-Vh for qemu-devel@nongnu.org; Wed, 16 Dec 2015 07:57:46 -0500 From: marcin.krzeminski@nokia.com Date: Wed, 16 Dec 2015 13:57:09 +0100 Message-Id: <1450270635-27080-7-git-send-email-marcin.krzeminski@nokia.com> In-Reply-To: <1450270635-27080-1-git-send-email-marcin.krzeminski@nokia.com> References: <1450270635-27080-1-git-send-email-marcin.krzeminski@nokia.com> Subject: [Qemu-devel] [PATCH 06/12] 4byte address mode support added. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pawel.lenkow@nokia.com, peter.crosthwaite@xilinx.com, marcin.krzeminski@nokia.com From: Marcin Krzeminski Signed-off-by: Marcin Krzeminski --- hw/block/m25p80.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index 1a547ae..6d5d90d 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -237,6 +237,9 @@ typedef enum { ERASE_32K = 0x52, ERASE_SECTOR = 0xd8, + EN_4BYTE_ADDR = 0xB7, + EX_4BYTE_ADDR = 0xE9, + RESET_ENABLE = 0x66, RESET_MEMORY = 0x99, @@ -267,6 +270,7 @@ typedef struct Flash { uint8_t cmd_in_progress; uint64_t cur_addr; bool write_enable; + bool four_bytes_address_mode; bool reset_enable; bool initialized; uint8_t reset_pin; @@ -405,11 +409,24 @@ void flash_write8(Flash *s, uint64_t addr, uint8_t data) s->dirty_page = page; } +static inline int is_4bytes(Flash *s) +{ + return s->four_bytes_address_mode; + } +} + static void complete_collecting_data(Flash *s) { - s->cur_addr = s->data[0] << 16; - s->cur_addr |= s->data[1] << 8; - s->cur_addr |= s->data[2]; + if (is_4bytes(s)) { + s->cur_addr = s->data[0] << 24; + s->cur_addr |= s->data[1] << 16; + s->cur_addr |= s->data[2] << 8; + s->cur_addr |= s->data[3]; + } else { + s->cur_addr = s->data[0] << 16; + s->cur_addr |= s->data[1] << 8; + s->cur_addr |= s->data[2]; + } s->state = STATE_IDLE; @@ -446,6 +463,7 @@ static void reset_memory(Flash *s) { s->cmd_in_progress = NOP; s->cur_addr = 0; + s->four_bytes_address_mode = false; s->len = 0; s->needed_bytes = 0; s->pos = 0; @@ -565,6 +583,12 @@ static void decode_new_cmd(Flash *s, uint32_t value) break; case NOP: break; + case EN_4BYTE_ADDR: + s->four_bytes_address_mode = true; + break; + case EX_4BYTE_ADDR: + s->four_bytes_address_mode = false; + break; case RESET_ENABLE: s->reset_enable = true; break; @@ -715,6 +739,7 @@ static const VMStateDescription vmstate_m25p80 = { VMSTATE_UINT8(cmd_in_progress, Flash), VMSTATE_UINT64(cur_addr, Flash), VMSTATE_BOOL(write_enable, Flash), + VMSTATE_BOOL(four_bytes_address_mode, Flash), VMSTATE_BOOL(reset_enable, Flash), VMSTATE_BOOL(initialized, Flash), VMSTATE_UINT8(reset_pin, Flash), -- 2.5.0