[U-Boot] [PATCH 3/3] microblaze: Fix bdiinfo pointer
Wolfgang Denk
wd at denx.de
Tue Dec 21 22:15:49 CET 2010
Dear Michal Simek,
In message <4D1111CF.5090002 at monstr.eu> you wrote:
>
> >> @@ -91,15 +91,16 @@ void board_init (void)
> >> bd_t *bd;
> >> init_fnc_t **init_fnc_ptr;
> >> gd = (gd_t *) CONFIG_SYS_GBL_DATA_OFFSET;
> >> + bd = (bd_t *) CONFIG_SYS_GBL_DATA_OFFSET - GENERATED_BD_INFO_SIZE;
> >
> > This is actually wrong.
> >
> > You are using CONFIG_SYS_GBL_DATA_OFFSET as if it were
> > CONFIG_SYS_GBL_DATA_ADDR, but it ain't so: it is an _offset_, and NOT
> > and address.
>
> I agree. BTW: Maybe nios2 and sparc use it too.
I see - I put the custodians on Cc:.
> >> - memset ((void *)gd, 0, GENERATED_GBL_DATA_SIZE);
> >> - gd->bd = (bd_t *) (gd + 1); /* At end of global data */
> >> + memset ((void *)bd, 0, GENERATED_GBL_DATA_SIZE
> >> + + GENERATED_BD_INFO_SIZE);
> >
> > Don't do this. Instead, use two separate memset() calls, one for gd
> > and another one for bd. The stucts may be in a contiguous area now,
> > but you would probably run into nasty bugs if this gets changed one
> > day.
>
> I just wanted to save some instructions and no problem to separate it.
Yes, I understand this, but it's a dangerous thing to so, and
robust and maintainable code is more important than a few bytes.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Never call a man a fool. Borrow from him.
More information about the U-Boot
mailing list