[U-Boot] lib_arm global data pointer

Drasko DRASKOVIC drasko.draskovic at gmail.com
Mon Jul 13 16:00:30 CEST 2009


>
> 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.
>
there is a reason why I use r10 (and why somebody used r8,  I suppose) - I
search some address during start.S, and want to stock it in the place that
will not be corrupted during continuation of the code in start.S. As you can
see, start.S will heavily use r0, r1, probably other low-numbered regs.

Yes, I can put r10 to r0 just before the call of the function (and change
signature of start(void) to start(int my_var), is that rght?) but what would
this change. If the thisngs work with r10, even better...

And one thing I also noted that is strange a variable of "register
volatile". I played around with arm gcc compiler - does this volatile stuff
really have some effect? Compiler seems to produce asm code like it is not
volatile (optimize by deleting conditions, assign values by add and not mov,
etc...)

BR,
Drasko

On Mon, Jul 13, 2009 at 3:38 PM, Rabin Vincent <rabin at rab.in> wrote:

> 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