From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] Add support for boards where the NOR FLASH is not memory-mapped
Date: Thu, 11 Dec 2008 12:01:11 +0100 [thread overview]
Message-ID: <200812111201.12242.sr@denx.de> (raw)
In-Reply-To: <20081210175658.GA19779@ld0162-tx32.am.freescale.net>
On Wednesday 10 December 2008, Scott Wood wrote:
> On Wed, Dec 10, 2008 at 11:41:11AM +0100, Stefan Roese wrote:
> > +void *board_flash_read_memcpy(void *__to, __const__ void *__from, int
> > n); +
> > +#if defined(CONFIG_FLASH_NOT_MEM_MAPPED)
> > +static inline int flash_read(void *__to, __const__ void *__from, int n)
>
> __const__? The other underscores seem gratuitous as well.
Not sure where I copied this from. I'll remove the underscores in the next
version.
> > +{
> > +#if defined(CONFIG_HAS_DATAFLASH)
> > + return read_dataflash(__from, n, __to);
> > +#elif defined(CONFIG_FLASH_NOT_MEM_MAPPED)
> > + if ((addr2info((u32)__from) != NULL))
> > + board_flash_read_memcpy(__to, __from, n);
> > + else
> > + memcpy(__to, __from, n);
> > + return OK;
> > +#endif
> > +}
>
> What if a board has dataflash *and* NOR flash?
You probably mean a board with dataflash *and* NOR FLASH that can't be
accessed memory-mapped. We currently don't have such a board. The upcoming
VCT board port is the first with such an (cumbersome) local bus interface.
And I hope it will be the last.
> > diff --git a/common/env_flash.c b/common/env_flash.c
> > index 75ee8dd..ee7c4d7 100644
> > --- a/common/env_flash.c
> > +++ b/common/env_flash.c
> > @@ -85,9 +85,50 @@ static ulong end_addr_new = CONFIG_ENV_ADDR_REDUND +
> > CONFIG_ENV_SECT_SIZE - 1; extern uchar default_environment[];
> > extern int default_environment_size;
> >
> > +void *board_flash_read_memcpy(void *__to, __const__ void *__from, int
> > n); +u8 flash_read8(void *addr);
> > +u32 flash_read32(void *addr);
>
> Should go in a header file.
OK.
> > +#if defined(CONFIG_FLASH_NOT_MEM_MAPPED)
> > +#define FLASH_READ_MEMCPY(d, s, n) board_flash_read_memcpy(d, s, n)
> > +#else
> > +#define FLASH_READ_MEMCPY(d, s, n) memcpy(d, s, n);
> > +#endif /* CONFIG_FLASH_NOT_MEM_MAPPED */
>
> No semicolon after memcpy, or FLASH_READ_MEMCPY won't behave like a
> function call in certain contexts (if/else, for loops, etc).
Right. Thanks for spotting.
> > +#define DO1(buf) \
> > + do { \
> > + if (((u32)buf >= CONFIG_FLASH_BASE) && \
> > + ((u32)buf < CONFIG_FLASH_END)) { \
> > + crc = crc_table[ ((int)crc ^ \
> > + (flash_read8((void *)buf++))) & 0xff] ^ \
> > + (crc >> 8); \
> > + } else { \
> > + crc = crc_table[((int)crc ^ \
> > + (*buf++)) & 0xff] ^ (crc >> 8); \
> > + } \
> > + } while (0)
>
> Maybe make this an inline function?
That would be a bigger change since this macro changes "buf" and "crc" without
having those parameters passed to it. I didn't want to make this bigger
change if not really necessary.
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
prev parent reply other threads:[~2008-12-11 11:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-10 10:41 [U-Boot] [PATCH v2] Add support for boards where the NOR FLASH is not memory-mapped Stefan Roese
2008-12-10 17:56 ` Scott Wood
2008-12-11 11:01 ` Stefan Roese [this message]
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=200812111201.12242.sr@denx.de \
--to=sr@denx.de \
--cc=u-boot@lists.denx.de \
/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