Index: libc/arch/mips32/include/psthread.h
===================================================================
--- libc/arch/mips32/include/psthread.h	(revision a71d9af9f07b33417eac0e091ee4318de370ac93)
+++ libc/arch/mips32/include/psthread.h	(revision fcd10af6fb760d39a824242ffd2987aa8db7c809)
@@ -32,4 +32,15 @@
 #include <types.h>
 
+/* We define our own context_set, because we need to set
+ * the TLS pointer to the tcb+0x7000
+ *
+ * See tls_set in thread.h
+ */
+#define context_set(c, _pc, stack, size, ptls) 			\
+	(c)->pc = (sysarg_t) (_pc);				\
+	(c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; 	\
+        (c)->tls = ((sysarg_t)(ptls)) + 0x7000 + sizeof(tcb_t);
+
+
 /* +16 is just for sure that the called function
  * have space to store it's arguments
Index: libc/arch/mips32/include/thread.h
===================================================================
--- libc/arch/mips32/include/thread.h	(revision a71d9af9f07b33417eac0e091ee4318de370ac93)
+++ libc/arch/mips32/include/thread.h	(revision fcd10af6fb760d39a824242ffd2987aa8db7c809)
@@ -32,15 +32,37 @@
 #define __LIBC__mips32THREAD_H__
 
-static inline void __tls_set(void *tls)
+/* I did not find any specification (neither MIPS nor PowerPC), but
+ * as I found it
+ * - it uses Variant II
+ * - TCB is at Address(First TLS Block)+0x7000.
+ * - DTV is at Address(First TLS Block)+0x8000
+ * - What would happen if the TLS data was larger then 0x7000?
+ * - The linker never accesses DTV directly, has the second definition any
+ *   sense?
+ * We will make it this way:
+ * - TCB is at TP-0x7000-sizeof(tcb)
+ * - No assumption about DTV etc., but it will not have a fixed address
+ */
+#define MIPS_TP_OFFSET 0x7000
+
+typedef struct {
+	void *pst_data;
+} tcb_t;
+
+static inline void __tcb_set(tcb_t *tcb)
 {
-	__asm__ volatile ("add $27, %0, $0" : : "r"(tls)); /* Move tls to K1 */
+	void *tp = tcb;
+	tp += MIPS_TP_OFFSET + sizeof(tcb_t);
+
+	__asm__ volatile ("add $27, %0, $0" : : "r"(tp)); /* Move tls to K1 */
 }
 
-static inline void * __tls_get(void)
+static inline tcb_t * __tcb_get(void)
 {
 	void * retval;
 
 	__asm__ volatile("add %0, $27, $0" : "=r"(retval));
-	return retval;
+
+	return (tcb_t *)(retval - MIPS_TP_OFFSET - sizeof(tcb_t));
 }
 
