[U-Boot] [PATCH v11 5/9] nds32/lib: add generic funcs in NDS32 lib

Mike Frysinger vapier at gentoo.org
Tue Sep 6 23:15:25 CEST 2011


On Tuesday, September 06, 2011 02:41:47 馬克泡 wrote:
> 2011/9/1 Mike Frysinger <vapier at gentoo.org>:
> > On Thursday, September 01, 2011 01:52:46 Macpaul Lin wrote:
> >> +void board_init_f(ulong bootflag)
> >> +{
> >> ...
> >> +     /* Pointer is writable since we allocated a register for it */
> >> +     gd = (gd_t *) ((CONFIG_SYS_INIT_SP_ADDR) & ~0x07);
> >> +
> >> +     /* compiler optimization barrier needed for GCC >= 3.4 */
> >> +     __asm__ __volatile__("" : : : "memory");
> >> +
> >> +     memset((void *)gd, 0, sizeof(gd_t));
> > 
> > err, is that barrier really needed ?  sounds like a bug in your compiler.
> 
> I'm not sure if this is really a bug which has been fixed or this is
> still a common problem.
> I've found there are architectures x86, mips, m68k, nios2, powerpc
> have this code to do
> optimization barrier.
> I'll try to verify this with our toolchain department, but I think
> this might be a common problem.
> Could someone give a comment on this?

unless you know you need it, i'd refrain from copying warts from other people.  
might want to look at `git log` to see why the other arches actually have it.

> > as for the memset, it should be:
> > memset((void *)gd, 0, GENERATED_GBL_DATA_SIZE);
> 
> It's the similar case.
> Since we have generated header file for global data, this code might be
> good. However, there are other architecture remain the same code which do
> memset with sizeof(gd_t).
> Included m68k, sparc, arm, avr32 and powerpc.
> Do I miss something of the discussion before in the mailing list?
> Should these also be a clean up for other architectures, too?

i think it's a matter of those arches havent updated.  the generated header is 
a new feature compared to these arches.

> > also, did i miss something, or do you not zero out your board info ?
> 
> No, I didn't zero out the board info just like the implementation of
> other architecture.
> Dose this lead a problem?

i think it depends purely on the arch/board setup.  if the arch knows the 
board data is going to be coming from a zeroed location (like bss), or it 
knows it initializes all the members, then you can skip it.  otherwise, you 
should be calling memset() on it to make sure things are in a sane state.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110906/e8e4bdd6/attachment.pgp 


More information about the U-Boot mailing list