Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/powerpc/include Add __lwp_gettcb_fast and __lwp_set...



details:   https://anonhg.NetBSD.org/src/rev/43a09287a209
branches:  trunk
changeset: 763171:43a09287a209
user:      matt <matt%NetBSD.org@localhost>
date:      Sat Mar 12 07:38:16 2011 +0000

description:
Add __lwp_gettcb_fast and __lwp_settcb helper inline functions

diffstat:

 sys/arch/powerpc/include/mcontext.h |  35 +++++++++++++++++++++++++++++++----
 1 files changed, 31 insertions(+), 4 deletions(-)

diffs (53 lines):

diff -r 54a56a58761b -r 43a09287a209 sys/arch/powerpc/include/mcontext.h
--- a/sys/arch/powerpc/include/mcontext.h       Sat Mar 12 07:29:41 2011 +0000
+++ b/sys/arch/powerpc/include/mcontext.h       Sat Mar 12 07:38:16 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mcontext.h,v 1.12 2011/02/25 14:07:13 joerg Exp $      */
+/*     $NetBSD: mcontext.h,v 1.13 2011/03/12 07:38:16 matt Exp $       */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -122,13 +122,40 @@
 
 #define        _UC_MACHINE_SET_PC(uc, pc)      _UC_MACHINE_PC(uc) = (pc)
 
+#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || defined(__LIBPTHREAD_SOURCE__)
+#include <sys/tls.h>
+
+/*
+ * On PowerPC, since displacements are signed 16-bit values, the TCB Pointer
+ * is biased by 0x7000 + sizeof(tcb) so that first thread datum can be 
+ * addressed by -28672 thereby leaving 60KB available for use as thread data.
+ */
+#define        TLS_TP_OFFSET   0x7000
+#define        TLS_DTV_OFFSET  0x8000
+__CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x8000);
+
 static __inline void *
-__lwp_getprivate_fast(void)
+__lwp_gettcb_fast(void)
 {
-       register void *__tcb;
-       __asm("mr %r2, %%0" : "=r"(__tcb));
+       void *__tcb;
+
+       __asm __volatile(
+               "addi %[__tcb],%%r2,%[__offset]@l"
+           :   [__tcb] "=r" (__tcb)
+           :   [__offset] "n" (-(TLS_TP_OFFSET + sizeof(struct tls_tcb))));
 
        return __tcb;
 }
 
+static __inline void
+__lwp_settcb(void *__tcb)
+{
+       __asm __volatile(
+               "addi %%r2,%[__tcb],%[__offset]@l"
+           :
+           :   [__tcb] "r" (__tcb),
+               [__offset] "n" (TLS_TP_OFFSET + sizeof(struct tls_tcb)));
+}
+#endif /* _RTLD_SOURCE || _LIBC_SOURCE || __LIBPTHREAD_SOURCE__ */
+
 #endif /* !_POWERPC_MCONTEXT_H_ */



Home | Main Index | Thread Index | Old Index