[U-Boot] lib_arm global data pointer

Rabin Vincent rabin at rab.in
Mon Jul 13 15:38:46 CEST 2009


On Fri, Jul 10, 2009 at 02:52:32PM +0200, Drasko DRASKOVIC wrote:
[...]
> Suppose that I allocated  one register in start.S and put in it some data I
> want to have later on C side. From start.S we enter to start_armboot(void)
> function.
> Would this work :
> 
> void start_armboot (void)
> {
>     init_fnc_t **init_fnc_ptr;
>     char *s;
> #ifndef CFG_NO_FLASH
>     ulong size;
> #endif
> #if defined(CONFIG_VFD) || defined(CONFIG_LCD)
>     unsigned long addr;
> #endif
> *#ifdef DATA_FROM_ASM_IN_R10
>     register volatile unsigned long tmp asm ("r10");
> #endif*
> 
>     /* Pointer is writable since we allocated a register for it */
>     gd = (gd_t*)(_armboot_start - CFG_MALLOC_LEN - sizeof(gd_t));
>     /* compiler optimization barrier needed for GCC >= 3.4 */
>     __asm__ __volatile__("": : :"memory");
> 
>     memset ((void*)gd, 0, sizeof (gd_t));
>     gd->bd = (bd_t*)((char*)gd - sizeof(bd_t));
>     memset (gd->bd, 0, sizeof (bd_t));
> 
> *#ifdef DATA_FROM_ASM_IN_R10
>     /* data will be passed to C from assembly start-up in reg r10 */
>     gd->bd->bi_my_data = tmp;
> #endif*
> 
[...]
> 
> Would I from this point on really have on C stack what I had in r10 in
> start.S?
> 
> If not, does anybody have idea how I can do it?

While the above may work, why you don't just follow the procedure call
standard instead?  Place the value in r0 instead of r10, and you'll have
it as the first argument to the function.

Rabin


More information about the U-Boot mailing list