[U-Boot] [PATCH v3] Fix board init code to use a valid C runtime environment
Thomas Chou
thomas at wytron.com.tw
Sat Nov 14 07:23:31 CET 2015
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
More information about the U-Boot
mailing list