From: Thomas Chou <thomas@wytron.com.tw>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3] Fix board init code to use a valid C runtime environment
Date: Sat, 14 Nov 2015 14:23:31 +0800 [thread overview]
Message-ID: <5646D363.6000404@wytron.com.tw> (raw)
In-Reply-To: <1447425803-24281-1-git-send-email-albert.u.boot@aribaud.net>
Hi Albert,
On 2015?11?13? 22:43, Albert ARIBAUD wrote:
> +/*
> + * Initialize reserved space (which has been safely allocated on the C
> + * stack from the C runtime environment handling code).
> + *
> + * Do not use 'gd->' until arch_setup_gd() has been called!
> + */
> +
> +void board_init_f_init_reserve(ulong base)
> {
> struct global_data *gd_ptr;
> #ifndef _USE_MEMCPY
> int *ptr;
> #endif
>
> - /* Leave space for the stack we are running with now */
> - top -= 0x40;
> + /*
> + * clear GD entirely
> + */
>
> - top -= sizeof(struct global_data);
> - top = ALIGN(top, 16);
> - gd_ptr = (struct global_data *)top;
> + gd_ptr = (struct global_data *)base;
> + /* go down one GD plus 16-byte alignment */
> + base += roundup(sizeof(struct global_data), 16);
Maybe it can keep the original order, top--gd--malloc--base.
#if defined(CONFIG_SYS_MALLOC_F)
base += CONFIG_SYS_MALLOC_F_LEN;
#endif
gd_ptr = (struct global_data *)base;
> + /* zero the area */
> #ifdef _USE_MEMCPY
> memset(gd_ptr, '\0', sizeof(*gd));
> #else
> for (ptr = (int *)gd_ptr; ptr < (int *)(gd_ptr + 1); )
> *ptr++ = 0;
> #endif
> + /* set GD unless architecture did it already */
> +#if !defined(CONFIG_X86) && !defined(CONFIG_SYS_THUMB_BUILD)
> arch_setup_gd(gd_ptr);
> +#endif
> +
> + /*
> + * record malloc arena start
> + */
>
> #if defined(CONFIG_SYS_MALLOC_F)
> - top -= CONFIG_SYS_MALLOC_F_LEN;
> - gd->malloc_base = top;
> + /* go down one malloc arena */
> + gd->malloc_base = base;
#if defined(CONFIG_SYS_MALLOC_F)
base -= CONFIG_SYS_MALLOC_F_LEN;
gd->malloc_base = base;
#endif
> + base += CONFIG_SYS_MALLOC_F_LEN;
Useless statement.
Best regards,
Thomas
next prev parent reply other threads:[~2015-11-14 6:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-13 14:43 [U-Boot] [PATCH v3] Fix board init code to use a valid C runtime environment Albert ARIBAUD
2015-11-14 2:29 ` Simon Glass
2015-11-14 14:36 ` Albert ARIBAUD
2015-11-14 15:41 ` Simon Glass
2015-11-15 11:44 ` Albert ARIBAUD
2015-11-14 6:23 ` Thomas Chou [this message]
2015-11-14 15:06 ` Albert ARIBAUD
2015-11-15 2:11 ` Thomas Chou
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=5646D363.6000404@wytron.com.tw \
--to=thomas@wytron.com.tw \
--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