Module Name:    src
Committed By:   matt
Date:           Tue Mar 15 07:33:36 UTC 2011

Modified Files:
        src/sys/arch/mips/include: mcontext.h types.h

Log Message:
Add MIPS TLS support.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/mips/include/mcontext.h
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/mips/include/types.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/mips/include/mcontext.h
diff -u src/sys/arch/mips/include/mcontext.h:1.16 src/sys/arch/mips/include/mcontext.h:1.17
--- src/sys/arch/mips/include/mcontext.h:1.16	Fri Feb 25 14:07:13 2011
+++ src/sys/arch/mips/include/mcontext.h	Tue Mar 15 07:33:36 2011
@@ -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_ */

Index: src/sys/arch/mips/include/types.h
diff -u src/sys/arch/mips/include/types.h:1.49 src/sys/arch/mips/include/types.h:1.50
--- src/sys/arch/mips/include/types.h:1.49	Thu Feb 24 04:28:47 2011
+++ src/sys/arch/mips/include/types.h	Tue Mar 15 07:33:36 2011
@@ -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 */
 

Reply via email to