Subversion Repositories HelenOS

Rev

Rev 2482 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2482 Rev 2586
Line 31... Line 31...
31
 */
31
 */
32
/** @file
32
/** @file
33
 * @ingroup libcmips32eb   
33
 * @ingroup libcmips32eb   
34
 */
34
 */
35
 
35
 
36
/* TLS for MIPS is described in http://www.linux-mips.org/wiki/NPTL */
-
 
37
 
-
 
38
#ifndef LIBC_mips32_THREAD_H_
36
#ifndef LIBC_mips32_THREAD_H_
39
#define LIBC_mips32_THREAD_H_
37
#define LIBC_mips32_THREAD_H_
40
 
38
 
41
/* I did not find any specification (neither MIPS nor PowerPC), but
-
 
42
 * as I found it
-
 
43
 * - it uses Variant II
-
 
44
 * - TCB is at Address(First TLS Block)+0x7000.
-
 
45
 * - DTV is at Address(First TLS Block)+0x8000
-
 
46
 * - What would happen if the TLS data was larger then 0x7000?
-
 
47
 * - The linker never accesses DTV directly, has the second definition any
-
 
48
 *   sense?
-
 
49
 * We will make it this way:
-
 
50
 * - TCB is at TP-0x7000-sizeof(tcb)
-
 
51
 * - No assumption about DTV etc., but it will not have a fixed address
-
 
52
 */
-
 
53
#define MIPS_TP_OFFSET 0x7000
-
 
54
 
-
 
55
typedef struct {
-
 
56
    void *fibril_data;
-
 
57
} tcb_t;
-
 
58
 
-
 
59
static inline void __tcb_set(tcb_t *tcb)
-
 
60
{
-
 
61
    void *tp = tcb;
-
 
62
    tp += MIPS_TP_OFFSET + sizeof(tcb_t);
-
 
63
 
-
 
64
    asm volatile ("add $27, %0, $0" : : "r"(tp)); /* Move tls to K1 */
-
 
65
}
-
 
66
 
-
 
67
static inline tcb_t * __tcb_get(void)
-
 
68
{
-
 
69
    void * retval;
-
 
70
 
-
 
71
    asm volatile("add %0, $27, $0" : "=r"(retval));
-
 
72
 
-
 
73
    return (tcb_t *)(retval - MIPS_TP_OFFSET - sizeof(tcb_t));
-
 
74
}
-
 
75
 
-
 
76
#endif
39
#endif
77
 
40
 
78
/** @}
41
/** @}
79
 */
42
 */