[Cbe-oss-dev] [PATCH 2/2] libspe2: setup intial registers with trampoline, rather than the regs file

Kazunori Asayama asayama at sm.sony.co.jp
Wed Aug 13 17:01:44 EST 2008


Jeremy Kerr wrote:
> Currently, libspe directly accesses a context's "regs" file to setup
> the initial register state. This has two drawbacks:
> 
>  * the regs file is not available for NOSCHED contexts; and
> 
>  * accessing the regs file requires the context to be de-scheduled.
>    Although contexts currently start in the saved state, this isn't
>    a defined bahaviour of spufs, so setting up the regs file in this
>    manner may cause a performance penalty with future kernels. This
>    will also be the case when already-loaded contexts are being
>    re-used with a new program.
> 
> This change alters the method used to setup the initial register set.
> Insead of accessing the regs file, we place a small trampoline area
> in the area of memory to be later used as the stack. This trampoline
> contains the initial values of r3-r6, plus the program entry point.

CBE Linux ABI and/or SPU ABI say that r1 (top of stack) and r2 (stack 
size) are also initialized by the system.

> 
> The trampoline code loads the register set, sets up the inital stack
> pointer, then branches to the program.

I can't find any code which sets up the initial stack pointer...

The current crt0 of SPU newlib ignores the initial stack pointer and 
overwrites r1 (I don't know why...), however I think it should be 
initialized by the system anyway, since that is required behavior by the 
ABI.

-- 
(ASAYAMA Kazunori
   (asayama at sm.sony.co.jp))
t



More information about the cbe-oss-dev mailing list