qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@fr.ibm.com>
To: marcin.krzeminski@nokia.com, qemu-devel@nongnu.org
Cc: pawel.lenkow@nokia.com, peter.crosthwaite@xilinx.com
Subject: Re: [Qemu-devel] [PATCH 06/12] 4byte address mode support added.
Date: Tue, 22 Dec 2015 19:41:23 +0100	[thread overview]
Message-ID: <56799953.5090500@fr.ibm.com> (raw)
In-Reply-To: <1450270635-27080-7-git-send-email-marcin.krzeminski@nokia.com>

Hello Marcin,


On 12/16/2015 01:57 PM, marcin.krzeminski@nokia.com wrote:
> From: Marcin Krzeminski <marcin.krzeminski@nokia.com>
> 
> Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
> ---
>  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),
> 

  parent reply	other threads:[~2015-12-22 18:41 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-16 12:57 [Qemu-devel] [PATCH 00/12] Support for new flash devices/4bytes commands marcin.krzeminski
2015-12-16 12:57 ` [Qemu-devel] [PATCH 01/12] Removed unused variable marcin.krzeminski
2015-12-21 10:20   ` Peter Crosthwaite
2015-12-16 12:57 ` [Qemu-devel] [PATCH 02/12] Added reset-pin emulation in model marcin.krzeminski
2015-12-21 11:04   ` Peter Crosthwaite
2015-12-21 13:39     ` [Qemu-devel] ODP: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2016-02-01 18:29       ` [Qemu-devel] " Peter Crosthwaite
2016-02-02  7:15         ` Krzeminski, Marcin (Nokia - PL/Wroclaw)
2015-12-16 12:57 ` [Qemu-devel] [PATCH 03/12] Reset enable and reset memory commands support marcin.krzeminski
2015-12-21 11:18   ` Peter Crosthwaite
2015-12-21 13:42     ` [Qemu-devel] ODP: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2015-12-16 12:57 ` [Qemu-devel] [PATCH 04/12] Changed variable type to allow serial eeprom emulation (changing 0->1) marcin.krzeminski
2015-12-21 11:23   ` Peter Crosthwaite
2015-12-21 13:46     ` [Qemu-devel] ODP: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2015-12-16 12:57 ` [Qemu-devel] [PATCH 05/12] Added support for serial eeproms - AT25128A/AT25256A marcin.krzeminski
2015-12-21 11:28   ` Peter Crosthwaite
2015-12-21 13:49     ` [Qemu-devel] ODP: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2015-12-16 12:57 ` [Qemu-devel] [PATCH 06/12] 4byte address mode support added marcin.krzeminski
2015-12-21 11:35   ` Peter Crosthwaite
     [not found]     ` <CA0E6F9BA6AED7458C23277BD87075E51017D30D@DEMUMBX005.nsn-intra.net>
2015-12-21 13:53       ` [Qemu-devel] ODP: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2015-12-22 18:41   ` Cédric Le Goater [this message]
2015-12-22 21:28     ` [Qemu-devel] " Peter Crosthwaite
2016-02-04 11:58       ` Krzeminski, Marcin (Nokia - PL/Wroclaw)
2015-12-16 12:57 ` [Qemu-devel] [PATCH 07/12] Added support for extend address mode commands marcin.krzeminski
2015-12-21 11:41   ` Peter Crosthwaite
2015-12-21 13:56     ` [Qemu-devel] ODP: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2015-12-16 12:57 ` [Qemu-devel] [PATCH 08/12] Support for N25Q256A/N25Q512A marcin.krzeminski
2015-12-21 10:29   ` Peter Crosthwaite
2015-12-21 13:57     ` [Qemu-devel] ODP: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2015-12-16 12:57 ` [Qemu-devel] [PATCH 09/12] Support for 6Bytes jdec marcin.krzeminski
2015-12-21 10:47   ` Peter Crosthwaite
2015-12-21 14:10     ` [Qemu-devel] ODP: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2015-12-16 12:57 ` [Qemu-devel] [PATCH 10/12] Support for quad commands marcin.krzeminski
2015-12-21 11:52   ` Peter Crosthwaite
2015-12-21 14:29     ` [Qemu-devel] ODP: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2015-12-22 21:40   ` [Qemu-devel] " Peter Crosthwaite
2015-12-23  2:25     ` Peter Crosthwaite
2015-12-29 14:21       ` Lenkow, Pawel (Nokia - PL/Wroclaw)
2015-12-16 12:57 ` [Qemu-devel] [PATCH 11/12] Support for mx66u51235 and s25fl512s marcin.krzeminski
2015-12-16 12:57 ` [Qemu-devel] [PATCH 12/12] Read flag status register command support added marcin.krzeminski
2015-12-21 11:54   ` Peter Crosthwaite
2015-12-21 14:36     ` [Qemu-devel] ODP: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2015-12-16 13:01 ` [Qemu-devel] [PATCH 00/12] Support for new flash devices/4bytes commands Krzeminski, Marcin (Nokia - PL/Wroclaw)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56799953.5090500@fr.ibm.com \
    --to=clg@fr.ibm.com \
    --cc=marcin.krzeminski@nokia.com \
    --cc=pawel.lenkow@nokia.com \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).