From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aBRse-0000Oo-HI for qemu-devel@nongnu.org; Tue, 22 Dec 2015 13:41:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aBRsZ-0002Xv-GL for qemu-devel@nongnu.org; Tue, 22 Dec 2015 13:41:52 -0500 Received: from e06smtp12.uk.ibm.com ([195.75.94.108]:49010) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aBRsZ-0002Xc-6r for qemu-devel@nongnu.org; Tue, 22 Dec 2015 13:41:47 -0500 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 22 Dec 2015 18:41:43 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 20FA717D8056 for ; Tue, 22 Dec 2015 18:42:08 +0000 (GMT) Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [9.149.37.248]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tBMIfTnQ7930334 for ; Tue, 22 Dec 2015 18:41:29 GMT Received: from d06av07.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tBMIfTaW016883 for ; Tue, 22 Dec 2015 11:41:29 -0700 References: <1450270635-27080-1-git-send-email-marcin.krzeminski@nokia.com> <1450270635-27080-7-git-send-email-marcin.krzeminski@nokia.com> From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= Message-ID: <56799953.5090500@fr.ibm.com> Date: Tue, 22 Dec 2015 19:41:23 +0100 MIME-Version: 1.0 In-Reply-To: <1450270635-27080-7-git-send-email-marcin.krzeminski@nokia.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 06/12] 4byte address mode support added. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: marcin.krzeminski@nokia.com, qemu-devel@nongnu.org Cc: pawel.lenkow@nokia.com, peter.crosthwaite@xilinx.com Hello Marcin, On 12/16/2015 01:57 PM, marcin.krzeminski@nokia.com wrote: > 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; Don't we need to also change 'needed_bytes' in the decode_new_cmd() routine to increase the number of bytes expected by some commands ? If so, we could add a width attribute to 'struct Flash' and to something like : @@ -260,6 +263,7 @@ typedef struct Flash { uint8_t cmd_in_progress; uint64_t cur_addr; bool write_enable; + uint8_t width; int64_t dirty_page; @@ -401,6 +405,10 @@ static void complete_collecting_data(Fla s->cur_addr |= s->data[1] << 8; s->cur_addr |= s->data[2]; + if (s->width == 4) { + s->cur_addr = s->cur_addr << 8 | s->data[4]; + } + s->state = STATE_IDLE; switch (s->cmd_in_progress) { @@ -446,7 +454,7 @@ static void decode_new_cmd(Flash *s, uin case DPP: case QPP: case PP: - s->needed_bytes = 3; + s->needed_bytes = s->width; s->pos = 0; s->len = 0; s->state = STATE_COLLECTING_DATA; @@ -644,6 +658,7 @@ static int m25p80_init(SSISlave *ss) memset(s->storage, 0xFF, s->size); } + s->width = 3; return 0; } QOR, DIOR, QIOR command also need a check. I suppose an address and some number of dummy bytes are expected before the fast read command is done. I would need to check the datasheets. Cheers, C. > @@ -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), >