[U-Boot] [PATCH] cfi_flash: Make all flash access functions weak
Stefan Roese
sr at denx.de
Mon Nov 17 10:34:03 CET 2008
On Monday 17 November 2008, Haavard Skinnemoen wrote:
> Stefan Roese <sr at denx.de> wrote:
> > Old version without weak aliases:
> > text data bss dec hex filename
> > 280964 20232 50788 351984 55ef0 ./u-boot
> >
> > New version with weak aliases:
> > text data bss dec hex filename
> > 280520 20232 50788 351540 55d34 ./u-boot
> >
> > So the difference is 444 bytes (with gcc 4.2.2). I have to admit that
> > this is more than I thought. If necessary I could make this weak change
> > conditionally of course. I just didn't want to "pollute" to the source
> > with more #ifdef's.
>
> Looks like it's 444 bytes _smaller_ with weak functions...that's a bit
> surprising. From you comment, it sounds like it's really 444 bytes
> larger. Did you mix up the numbers?
Yes.
> If it's really 444 bytes larger, I think that's a bit much for
> something as simple as memory accessors. Ideally, they should boil down
> to a single instruction each.
>
> Perhaps you could allow overriding them in the board header by doing
> something like
>
> #ifndef flash_write8
> # #define flash_write8(value, addr) __raw_writeb(value, addr)
> ...
>
> in cfi_flash.c?
I could do it this way, sure. But how about this version:
static void __flash_write8(u8 value, void *addr)
{
__raw_writeb(value, addr);
}
...
#ifdef CONFIG_CFI_FLASH_USE_WEAK_ACCESSORS
void flash_write8(u8 value, void *addr)__attribute__((weak, alias("__flash_write8")));
...
#else
#define flash_read8 __flash_read8
...
#endif
We would still have the original accessor functions this way. And the
resulting source code looks a little "better" to me (less #ifdef's).
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
=====================================================================
More information about the U-Boot
mailing list