5 #include <asm/asm-offsets.h>
6 .macro switch_tls_none
, base
, tp
, tpuser
, tmp1
, tmp2
9 .macro switch_tls_v6k
, base
, tp
, tpuser
, tmp1
, tmp2
10 mrc p15
, 0, \tmp
2, c13
, c0
, 2 @ get the user r
/w
register
11 mcr p15
, 0, \tp
, c13
, c0
, 3 @ set TLS
register
12 mcr p15
, 0, \tpuser
, c13
, c0
, 2 @
and the user r
/w
register
13 str
\tmp
2, [\base
, #TI_TP_VALUE + 4] @ save it
16 .macro switch_tls_v6
, base
, tp
, tpuser
, tmp1
, tmp2
18 ldr
\tmp
1, [\tmp
1, #0]
19 mov
\tmp
2, #0xffff0fff
20 tst
\tmp
1, #HWCAP_TLS @ hardware TLS available?
21 streq
\tp
, [\tmp
2, #-15] @ set TLS value at 0xffff0ff0
22 mrcne p15
, 0, \tmp
2, c13
, c0
, 2 @ get the user r
/w
register
23 mcrne p15
, 0, \tp
, c13
, c0
, 3 @ yes
, set TLS
register
24 mcrne p15
, 0, \tpuser
, c13
, c0
, 2 @ set user r
/w
register
25 strne
\tmp
2, [\base
, #TI_TP_VALUE + 4] @ save it
28 .macro switch_tls_software
, base
, tp
, tpuser
, tmp1
, tmp2
29 mov
\tmp
1, #0xffff0fff
30 str
\tp
, [\tmp
1, #-15] @ set TLS value at 0xffff0ff0
34 #ifdef CONFIG_TLS_REG_EMUL
37 #define switch_tls switch_tls_none
38 #elif defined(CONFIG_CPU_V6)
40 #define has_tls_reg (elf_hwcap & HWCAP_TLS)
41 #define switch_tls switch_tls_v6
42 #elif defined(CONFIG_CPU_32v6K)
45 #define switch_tls switch_tls_v6k
49 #define switch_tls switch_tls_software
53 static inline unsigned long get_tpuser(void)
55 unsigned long reg
= 0;
57 if (has_tls_reg
&& !tls_emu
)
58 __asm__("mrc p15, 0, %0, c13, c0, 2" : "=r" (reg
));
63 #endif /* __ASMARM_TLS_H */