[U-Boot] [PATCH 02/10] board_init_f_mem(): Don't require memset()

Simon Glass sjg at chromium.org
Tue Apr 21 05:47:23 CEST 2015


Hi Masahiro,

On 20 April 2015 at 21:42, Masahiro Yamada
<yamada.masahiro at socionext.com> wrote:
> Hi Simon,
>
>
>
> 2015-04-16 10:14 GMT+09:00 Simon Glass <sjg at chromium.org>:
>> Unfortunately memset() is not always available, so provide a substitute when
>> needed.
>>
>> Signed-off-by: Simon Glass <sjg at chromium.org>
>> ---
>>
>>  common/init/global_data.c | 8 ++++++++
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/common/init/global_data.c b/common/init/global_data.c
>> index 2633f0d..ef055c4 100644
>> --- a/common/init/global_data.c
>> +++ b/common/init/global_data.c
>> @@ -21,7 +21,15 @@ ulong board_init_f_mem(ulong top)
>>         top -= sizeof(struct global_data);
>>         top = ALIGN(top, 16);
>>         gd = (struct global_data *)top;
>> +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBGENERIC_SUPPORT)
>>         memset((void *)gd, '\0', sizeof(*gd));
>> +#else
>> +       int *ptr = (int *)gd;
>> +       int *end = (int *)(gd + 1);
>> +
>> +       while (ptr < end)
>> +               *ptr++ = 0;
>> +#endif
>>
>>  #ifdef CONFIG_SYS_MALLOC_F_LEN
>>         top -= CONFIG_SYS_MALLOC_F_LEN;
>
>
> This patch implies that all the SPLs should have memset().
>
> Is it better to build lib/ unconditionally?
> I posted a patch to do so.
>
> Please consider to use it as a prerequisite
> for cleaning up 01/10  and 02/10.

That would be better I think - how did you manage it? I cannot see the
patch you are referring to. Although what about if SPL is very close
to the maximum size and adding memset() makes it too large? I suppose
in that case we would get a build error and notice the problem?
Regards,
Simon


More information about the U-Boot mailing list