[U-Boot] RFC: Aligning arch initialisation sequences
Graeme Russ
graeme.russ at gmail.com
Sun Nov 14 22:01:32 CET 2010
On Mon, Nov 15, 2010 at 7:16 AM, Reinhard Meyer
<u-boot at emk-elektronik.de> wrote:
> Dear Graeme Russ,
>>
>> On 15/11/10 00:46, Reinhard Meyer wrote:
>>>
>>> Dear Wolfgang Denk,
>>>
>>> To make it crystal clear now, and put the complete context:
>>>
>>> That simple change would rid us of all alignment concerns:
>>> Setting stack to end of initial storage will certainly
>>> be aligned, and the auto_gd will be aligned as the
>>> toolchain deems necessary.
>>>
>>> We would not need GENERATED_GBL_DATA_SIZE anymore.
>>>
>>> The auto_gd space on stack will be valid even into the call
>>> to relocate_code.
>>>
>>>> void board_init_f (ulong bootflag)
>>>> {
>>>> bd_t *bd;
>>>> init_fnc_t **init_fnc_ptr;
>>>> gd_t *id;
>>>> ulong addr, addr_sp;
>>>> + gd_t auto_gd;
>>>>
>>>> /* Pointer is writable since we allocated a register for it */
>>>> - gd = (gd_t *) (CONFIG_SYS_INIT_SP_ADDR);
>>>> + gd =&auto_gd;
>>>> /* compiler optimization barrier needed for GCC>= 3.4 */
>>>> /* Q: why is that needed anyway ??? */
>>>> __asm__ __volatile__("": : :"memory");
>>>>
>>>> memset ((void*)gd, 0, sizeof (gd_t));
>>>> ....
>>>> debug ("relocation Offset is: %08lx\n", gd->reloc_off);
>>>> memcpy (id, (void *)gd, sizeof (gd_t));
>>>>
>>>> relocate_code (addr_sp, id, addr);
>>>>
>>>> /* NOTREACHED - relocate_code() does not return */
>>>> }
>>>>
>>>> This, and setting CONFIG_SYS_INIT_SP_ADDR to an aligned value in
>>>> initial storage (SRAM, pinned down Cache, or other) removes alot
>>>> of the headache about making stuff aligned.
>>>>
>>>
>>> This three line change DOES NOT propose any different method
>>> of handling gd other then it is currently done.
>>>
>>> It is ONLY a more elegant way to allocate the pre-relocation
>>> storage for gd.
>>
>> On the proviso that gd is not needed _BEFORE_ board_init_f()
>
> At least on ARM, board_init_f() is the first C function called
> after basic SoC initialisation in ASM.
>
> And may patch does not move the point of availability of gd at all.
>
But do some arches populate some of gd before calling board_init_f()?
Hint: x86 does (but might not need to in the near future) - YMMV for
other arches
Regards,
Graeme
More information about the U-Boot
mailing list