public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/3] microblaze: Fix bdiinfo pointer
Date: Tue, 21 Dec 2010 20:01:52 +0100	[thread overview]
Message-ID: <20101221190153.04CF1126EB1A@gemini.denx.de> (raw)
In-Reply-To: <1292955178-13018-3-git-send-email-monstr@monstr.eu>

Dear Michal Simek,

In message <1292955178-13018-3-git-send-email-monstr@monstr.eu> you wrote:
> Patch "Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value"
> (sha1: 25ddd1fb0a2281b182529afbc8fda5de2dc16d96)
> introduce GENERATED_GBL_DATA_SIZE which is sizeof aligned gd_t
> (currently 0x40).
> Microblaze configs used 0x40(128) because this place also contained
> board info structure which lies on the top of ram.

In the Subject: s/bdiinfo/bd_info/

> index eeef579..8232cf0 100644
> --- a/arch/microblaze/lib/board.c
> +++ b/arch/microblaze/lib/board.c
> @@ -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.

> -	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.

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
I usually tell my classes "if you are using @ and [] together in this
class, you will almost certainly NOT get what you want. That's  going
down  the wrong tunnel. There's no cheese at the end of that tunnel."
         -- Randal L. Schwartz in <8czptuomey.fsf@gadget.cscaper.com>

  reply	other threads:[~2010-12-21 19:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-21 18:12 [U-Boot] [PATCH 1/3] lib/asm-offsets.c: Clean coding style Michal Simek
2010-12-21 18:12 ` [U-Boot] [PATCH 2/3] Autogenerate GENERATED_BD_INFO_SIZE Michal Simek
2010-12-21 18:12   ` [U-Boot] [PATCH 3/3] microblaze: Fix bdiinfo pointer Michal Simek
2010-12-21 19:01     ` Wolfgang Denk [this message]
2010-12-21 20:45       ` Michal Simek
2010-12-21 21:15         ` Wolfgang Denk
2010-12-21 18:56   ` [U-Boot] [PATCH 2/3] Autogenerate GENERATED_BD_INFO_SIZE Wolfgang Denk
2010-12-21 18:55 ` [U-Boot] [PATCH 1/3] lib/asm-offsets.c: Clean coding style Wolfgang Denk
2010-12-21 20:02   ` Michal Simek
2010-12-21 21:11     ` Wolfgang Denk
2010-12-22  6:39       ` Michal Simek
2010-12-22  7:00         ` Wolfgang Denk
2010-12-22  7:19           ` Michal Simek
2010-12-22 11:38 ` Sergei Shtylyov

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=20101221190153.04CF1126EB1A@gemini.denx.de \
    --to=wd@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