Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/mips/include Add MIPS TLS support.



details:   https://anonhg.NetBSD.org/src/rev/edc0d06615da
branches:  trunk
changeset: 763248:edc0d06615da
user:      matt <matt%NetBSD.org@localhost>
date:      Tue Mar 15 07:33:36 2011 +0000

description:
Add MIPS TLS support.

diffstat:

 sys/arch/mips/include/mcontext.h |  40 +++++++++++++++++++++++++++++++++-------
 sys/arch/mips/include/types.h    |  30 ++++++++++++++++--------------
 2 files changed, 49 insertions(+), 21 deletions(-)

diffs (127 lines):

diff -r 848c7480b950 -r edc0d06615da sys/arch/mips/include/mcontext.h
--- a/sys/arch/mips/include/mcontext.h  Tue Mar 15 07:32:53 2011 +0000
+++ b/sys/arch/mips/include/mcontext.h  Tue Mar 15 07:33:36 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mcontext.h,v 1.16 2011/02/25 14:07:13 joerg Exp $      */
+/*     $NetBSD: mcontext.h,v 1.17 2011/03/15 07:33:36 matt Exp $       */
 
 /*-
  * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
@@ -186,16 +186,42 @@
 #error O64 is not supported
 #endif
 
-#ifndef __ASSEMBLER__
-static __inline void *
-__lwp_getprivate_fast(void)
+#if defined(_LIBC_SOURCE) || defined(_RTLD_SOURCE) || defined(__LIBPTHREAD_SOURCE__)
+#define        TLS_TP_OFFSET   0x7000
+#define        TLS_DTV_OFFSET  0x8000
+
+#include <sys/tls.h>
+
+__CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x8000);
+__CTASSERT(TLS_TP_OFFSET % sizeof(struct tls_tcb) == 0);
+
+static __inline struct tls_tcb *
+__lwp_gettcb_fast(void)
 {
-       register void *__tcb;
+       struct tls_tcb *__tcb;
 
-       __asm volatile(".set push; .set mips32r2; "
-               "rdhwr %0, $29; .set pop" : "=v"(__tcb));
+       /*
+        * Only emit a rdhwr $3, $29 so the kernel can quickly emulate it.
+        */
+       __asm __volatile(".set push; .set mips32r2; "
+               "rdhwr $3,$29; .set pop;"
+#ifdef _LP64
+               "daddiu %[__tcb],$3,%1"
+#else
+               "addiu %[__tcb],$3,%1"
+#endif
+           : [__tcb]"=r"(__tcb)
+           : [__offset]"n"(-(TLS_TP_OFFSET + sizeof(*__tcb)))
+           : "v1");
        return __tcb;
 }
+
+static inline void
+__lwp_settcb(struct tls_tcb *__tcb)
+{
+       __tcb += TLS_TP_OFFSET / sizeof(*__tcb) + 1;
+       _lwp_setprivate(__tcb);
+}
 #endif
 
 #endif /* _MIPS_MCONTEXT_H_ */
diff -r 848c7480b950 -r edc0d06615da sys/arch/mips/include/types.h
--- a/sys/arch/mips/include/types.h     Tue Mar 15 07:32:53 2011 +0000
+++ b/sys/arch/mips/include/types.h     Tue Mar 15 07:33:36 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: types.h,v 1.49 2011/02/24 04:28:47 joerg Exp $ */
+/*     $NetBSD: types.h,v 1.50 2011/03/15 07:33:36 matt Exp $  */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -53,20 +53,20 @@
 #if defined(_MIPS_PADDR_T_64BIT) || defined(_LP64)
 typedef __uint64_t     paddr_t;
 typedef __uint64_t     psize_t;
-#define PRIxPADDR      PRIx64
-#define PRIxPSIZE      PRIx64
-#define PRIdPSIZE      PRId64
+#define        PRIxPADDR       PRIx64
+#define        PRIxPSIZE       PRIx64
+#define        PRIdPSIZE       PRId64
 #else
 typedef __uint32_t     paddr_t;
 typedef __uint32_t     psize_t;
-#define PRIxPADDR      PRIx32
-#define PRIxPSIZE      PRIx32
-#define PRIdPSIZE      PRId32
+#define        PRIxPADDR       PRIx32
+#define        PRIxPSIZE       PRIx32
+#define        PRIdPSIZE       PRId32
 #endif
 #ifdef _LP64
 typedef __uint64_t     vaddr_t;
 typedef __uint64_t     vsize_t;
-#define PRIxVADDR      PRIx64
+#define        PRIxVADDR       PRIx64
 #define PRIxVSIZE      PRIx64
 #define PRIdVSIZE      PRId64
 #else
@@ -142,15 +142,17 @@
 #define        __HAVE_AST_PERPROC
 #define        __HAVE_SYSCALL_INTERN
 #define        __HAVE_PROCESS_XFPREGS
+#define        __HAVE_CPU_LWP_SETPRIVATE
 #define        __HAVE_CPU_DATA_FIRST
-#define __HAVE_MD_CPU_OFFLINE
+#define        __HAVE_MD_CPU_OFFLINE
 #ifdef MIPS3_PLUS      /* XXX bogus! */
 #define        __HAVE_CPU_COUNTER
 #endif
-#define __HAVE_CPU_UAREA_ROUTINES
-#if 0
-#define        __HAVE___LWP_GETPRIVATE_FAST
-#endif
+#define        __HAVE_CPU_UAREA_ROUTINES
+#define        __HAVE_COMMON___TLS_GET_ADDR
+#define        __HAVE___LWP_GETTCB_FAST
+#define        __HAVE___LWP_SETTCB
+#define        __HAVE_TLS_VARIANT_I
 
 #if !defined(__mips_o32)
 #define        __HAVE_ATOMIC64_OPS
@@ -159,7 +161,7 @@
 #if defined(_KERNEL)
 #define        __HAVE_RAS
 #if defined(_LP64)
-#define __HAVE_CPU_VMSPACE_EXEC
+#define        __HAVE_CPU_VMSPACE_EXEC
 #endif
 #endif /* _KERNEL */
 



Home | Main Index | Thread Index | Old Index