On Fri, Feb 26, 2016 at 08:59:41PM -0800, Philip Guenther wrote:
> On Sat, Feb 20, 2016 at 1:49 PM, Patrick Wildt <[email protected]> wrote:
> > since ARMv6 the coprocessor provides special registers to store software
> > defined values.  Those registers are:
> >
> >   * TPIDRURW -> kernel RW, user RW
> >   * TPIDRURO -> kernel RW, user RO
> >   * TPIDRPRW -> kernel RW
> >
> > TPIDRPRW is typically used to store the pointer to the curcpu struct,
> > while TPIDRURO is used to point to the TCB.
> >
> > The following diff implements using TPIDRPRW to store and retrieve the
> > curcpu struct pointer.  This will especially be helpful in future MP
> > efforts.  I have guarded it for ARMv7 only, as that's the only hardware
> > I have that supports it and I was able to test on.
> 
> I don't know arm, but of those choices that makes sense.
> 
> 
> > If TCB_GET()'s only user is libpthread, then it could make sense to
> > store the TCB pointer in TPIDRURO.  If it's possible that it's also
> > used in ports, then the arm packages won't be compatible to
> > armish/zaurus anymore.  But the TCB stuff is not part of this diff.
> 
> The userland bits in <machine/tcb.h> should match the platform's ABI
> for the thread register.  The last time I tried to figure this out
> from the arm ABI docs I wanted to stab someone, but I was hopefully
> just looking at the wrong docs.  Looking at the bits in FreeBSD I see
> 
> static inline void
> set_tls(void *tls)
> {
>         __asm __volatile("mcr p15, 0, %0, c13, c0, 3" : : "r" (tls));
> }
> 
> so, uh, whichever register that sets is presumably the correct one for 
> userland.

Yep, that's TPIDRURO.  It's not a lot of work to use this register, but
it might just not work out as zaurus and armv7 use the same packages.

> 
> (What is it with the arm docs giving N names to registers without a
> "here's the mapping" table splatted somewhere obvious?)

No idea.  ARM's "Infocenter" is really hard to read.  Instead I always
have a copy of the ARM ARM and Cortex-XX PDFs around.

> 
> 
> Philip Guenther
> 

Reply via email to