[U-Boot] Struct SoC access

Scott Wood scottwood at freescale.com
Mon Aug 16 22:21:28 CEST 2010


On Sun, Aug 15, 2010 at 12:15:29AM +0200, Reinhard Meyer wrote:
> >> Would the toolchain "gulp" when one defines the whole 4 GB that way?
> > 
> > Why not?
> 
> Since the AT91s have no base address registers at all, the memory layout
> is completely fixed. Even chip selects have a fixed address and fixed
> size of 256MB each. Therefore it _might_ make sense to completely
> define the 4GB in the soc struct.
> Then assign struct soc *soc = (struct soc *)0;

One snag you might hit is that dereferencing a NULL pointer is undefined,
and some versions of GCC assume you won't do this when optimizing.  Not sure
if this simple usage would be affected (it seems to mainly be an issue when
comparing a pointer to NULL after dereferencing), and
-fno-delete-null-pointer-checks may help.

> Did you read Mike's comment of hardware dependent direct usage of
> struct members to access hardware? I thought that was generally
> discouraged for several reasons (cache and access sequencing)?
> 
> Whats a IOCCC?

The International Obfuscated C Code Contest, possibly a more appropriate
venue for code that defines a 4GB struct. :-)

-Scott



More information about the U-Boot mailing list