Changeset 0b05082 in mainline
- Timestamp:
- 2018-07-18T18:56:16Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 40abf56
- Parents:
- 9b1baac
- git-author:
- Jiří Zárevúcky <jiri.zarevucky@…> (2018-07-18 14:25:11)
- git-committer:
- Jiří Zárevúcky <jiri.zarevucky@…> (2018-07-18 18:56:16)
- Location:
- uspace/lib/c
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/arch/abs32le/include/libarch/tls.h
r9b1baac r0b05082 41 41 #include <stddef.h> 42 42 43 /* Some architectures store the value with an offset. Some do not. */ 44 #define ARCH_TP_OFFSET 0 45 43 46 typedef struct { 44 47 void *self; … … 46 49 } tcb_t; 47 50 48 static inline void __tcb_ set(tcb_t *tcb)51 static inline void __tcb_raw_set(void *tls) 49 52 { 53 /* Usually a short assembly assigning to an ABI-defined register. */ 50 54 } 51 55 52 static inline tcb_t *__tcb_get(void)56 static inline void *__tcb_raw_get(void) 53 57 { 58 /* Usually a short assembly reading from an ABI-defined register. */ 54 59 return NULL; 55 60 } -
uspace/lib/c/arch/amd64/include/libarch/tls.h
r9b1baac r0b05082 38 38 #define CONFIG_TLS_VARIANT_2 39 39 40 #define ARCH_TP_OFFSET 0 41 40 42 #include <libc.h> 41 43 … … 45 47 } tcb_t; 46 48 47 static inline void __tcb_ set(tcb_t *tcb)49 static inline void __tcb_raw_set(void *tls) 48 50 { 49 asm volatile ("movq %0, %%fs:0" :: "r" (t cb));51 asm volatile ("movq %0, %%fs:0" :: "r" (tls)); 50 52 } 51 53 52 static inline tcb_t *__tcb_get(void)54 static inline void *__tcb_raw_get(void) 53 55 { 54 tcb_t *retval; 55 56 void *retval; 56 57 asm volatile ("movq %%fs:0, %0" : "=r" (retval)); 57 58 return retval; -
uspace/lib/c/arch/arm32/include/libarch/fibril.h
r9b1baac r0b05082 62 62 (c)->pc = (sysarg_t) (_pc); \ 63 63 (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \ 64 (c)->tls = ((sysarg_t)(ptls)) + sizeof(tcb_t) + ARM_TP_OFFSET; \64 (c)->tls = ((sysarg_t)(ptls)) + ARCH_TP_OFFSET; \ 65 65 (c)->fp = 0; \ 66 66 } while (0) -
uspace/lib/c/arch/arm32/include/libarch/tls.h
r9b1baac r0b05082 42 42 43 43 /** Offsets for accessing thread-local variables are shifted 8 bytes higher. */ 44 #define AR M_TP_OFFSET (-8)44 #define ARCH_TP_OFFSET (sizeof(tcb_t) - 8) 45 45 46 46 /** TCB (Thread Control Block) struct. … … 53 53 } tcb_t; 54 54 55 56 /** Sets TLS address to the r9 register. 57 * 58 * @param tcb TCB (TLS starts behind) 59 */ 60 static inline void __tcb_set(tcb_t *tcb) 55 static inline void *__tcb_raw_get(void) 61 56 { 62 uint8_t *tls = (uint8_t *) tcb; 63 tls += sizeof(tcb_t) + ARM_TP_OFFSET; 64 asm volatile ( 65 "mov r9, %0" 66 : 67 : "r" (tls) 68 ); 57 uint8_t *ret; 58 asm volatile ("mov %0, r9" : "=r" (ret)); 59 return ret; 69 60 } 70 61 71 72 /** Returns TCB address. 73 * 74 * @return TCB address (starts before TLS which address is stored 75 * in r9 register). 76 */ 77 static inline tcb_t *__tcb_get(void) 62 static inline void __tcb_raw_set(void *tls) 78 63 { 79 uint8_t *ret; 80 asm volatile ( 81 "mov %0, r9" 82 : "=r" (ret) 83 ); 84 return (tcb_t *) (ret - ARM_TP_OFFSET - sizeof(tcb_t)); 64 asm volatile ("mov r9, %0" :: "r" (tls)); 85 65 } 86 87 66 88 67 /** Returns TLS address stored. -
uspace/lib/c/arch/ia32/include/libarch/tls.h
r9b1baac r0b05082 38 38 #define CONFIG_TLS_VARIANT_2 39 39 40 #define ARCH_TP_OFFSET 0 41 40 42 #include <libc.h> 41 43 … … 46 48 } tcb_t; 47 49 48 static inline void __tcb_ set(tcb_t *tcb)50 static inline void __tcb_raw_set(void *tls) 49 51 { 50 asm volatile ("movl %0, %%gs:0" :: "r" (t cb));52 asm volatile ("movl %0, %%gs:0" :: "r" (tls)); 51 53 } 52 54 53 static inline tcb_t *__tcb_get(void)55 static inline void *__tcb_raw_get(void) 54 56 { 55 tcb_t *retval; 56 57 void *retval; 57 58 asm volatile ("movl %%gs:0, %0" : "=r" (retval)); 58 59 59 return retval; 60 60 } -
uspace/lib/c/arch/ia64/include/libarch/tls.h
r9b1baac r0b05082 38 38 #define CONFIG_TLS_VARIANT_1 39 39 40 #define ARCH_TP_OFFSET 0 41 40 42 /* This structure must be exactly 16 bytes long */ 41 43 typedef struct { … … 44 46 } tcb_t; 45 47 46 static inline void __tcb_ set(tcb_t*tcb)48 static inline void __tcb_raw_set(void *tcb) 47 49 { 48 50 asm volatile ("mov r13 = %0\n" : : "r" (tcb) : "r13"); 49 51 } 50 52 51 static inline tcb_t *__tcb_get(void)53 static inline void *__tcb_raw_get(void) 52 54 { 53 tcb_t *retval; 54 55 void *retval; 55 56 asm volatile ("mov %0 = r13\n" : "=r" (retval)); 56 57 57 return retval; 58 58 } -
uspace/lib/c/arch/mips32/include/libarch/tls.h
r9b1baac r0b05082 61 61 * - No assumption about DTV etc., but it will not have a fixed address 62 62 */ 63 #define MIPS_TP_OFFSET 0x700063 #define ARCH_TP_OFFSET (0x7000 + sizeof(tcb_t)) 64 64 65 65 typedef struct { … … 67 67 } tcb_t; 68 68 69 static inline void __tcb_ set(tcb_t *tcb)69 static inline void __tcb_raw_set(void *tls) 70 70 { 71 uint8_t *tp = (uint8_t *) tcb; 72 tp += MIPS_TP_OFFSET + sizeof(tcb_t); 73 74 asm volatile ("add $27, %0, $0" : : "r" (tp)); /* Move tls to K1 */ 71 /* Move tls to K1 */ 72 asm volatile ("add $27, %0, $0" :: "r" (tls)); 75 73 } 76 74 77 static inline tcb_t *__tcb_get(void)75 static inline void *__tcb_raw_get(void) 78 76 { 79 uint8_t *retval; 80 77 void *retval; 81 78 asm volatile ("add %0, $27, $0" : "=r" (retval)); 82 83 return (tcb_t *)(retval - MIPS_TP_OFFSET - sizeof(tcb_t)); 79 return retval; 84 80 } 85 81 -
uspace/lib/c/arch/ppc32/include/libarch/tls.h
r9b1baac r0b05082 40 40 #include <libc.h> 41 41 42 #define PPC_TP_OFFSET 0x700042 #define ARCH_TP_OFFSET (0x7000 + sizeof(tcb_t)) 43 43 44 44 typedef struct { … … 46 46 } tcb_t; 47 47 48 static inline void __tcb_ set(tcb_t *tcb)48 static inline void __tcb_raw_set(void *tls) 49 49 { 50 uint8_t *tp = (uint8_t *) tcb; 51 tp += PPC_TP_OFFSET + sizeof(tcb_t); 52 53 asm volatile ( 54 "mr %%r2, %0\n" 55 : 56 : "r" (tp) 57 ); 50 asm volatile ("mr %%r2, %0\n" :: "r" (tls)); 58 51 } 59 52 60 static inline tcb_t *__tcb_get(void)53 static inline void *__tcb_raw_get(void) 61 54 { 62 uint8_t *retval; 63 64 asm volatile ( 65 "mr %0, %%r2\n" 66 : "=r" (retval) 67 ); 68 69 return (tcb_t *) (retval - PPC_TP_OFFSET - sizeof(tcb_t)); 55 void *retval; 56 asm volatile ("mr %0, %%r2\n" : "=r" (retval)); 57 return retval; 70 58 } 71 59 -
uspace/lib/c/arch/riscv64/include/libarch/tls.h
r9b1baac r0b05082 40 40 #include <libc.h> 41 41 42 /* Some architectures store the value with an offset. Some do not. */ 43 #define ARCH_TP_OFFSET 0 44 42 45 typedef struct { 43 46 void *self; … … 45 48 } tcb_t; 46 49 47 static inline void __tcb_ set(tcb_t *tcb)50 static inline void __tcb_raw_set(void *tls) 48 51 { 52 // TODO 49 53 } 50 54 51 static inline tcb_t *__tcb_get(void)55 static inline void *__tcb_raw_get(void) 52 56 { 53 return (tcb_t *) 0; 57 // TODO 58 return 0; 54 59 } 55 60 -
uspace/lib/c/arch/sparc64/include/libarch/tls.h
r9b1baac r0b05082 41 41 #define CONFIG_TLS_VARIANT_2 42 42 43 #define ARCH_TP_OFFSET 0 44 43 45 typedef struct { 44 46 void *self; … … 46 48 } tcb_t; 47 49 48 static inline void __tcb_ set(tcb_t*tcb)50 static inline void __tcb_raw_set(void *tcb) 49 51 { 50 52 asm volatile ("mov %0, %%g7\n" : : "r" (tcb) : "g7"); 51 53 } 52 54 53 static inline tcb_t *__tcb_get(void)55 static inline void *__tcb_raw_get(void) 54 56 { 55 tcb_t *retval; 56 57 void *retval; 57 58 asm volatile ("mov %%g7, %0\n" : "=r" (retval)); 58 59 59 return retval; 60 60 } -
uspace/lib/c/generic/context.c
r9b1baac r0b05082 29 29 #include <context.h> 30 30 #include <setjmp.h> 31 #include < libarch/tls.h>31 #include <tls.h> 32 32 #include <libarch/fibril.h> 33 33 #include <libarch/faddr.h> -
uspace/lib/c/generic/private/fibril.h
r9b1baac r0b05082 32 32 #include <adt/list.h> 33 33 #include <context.h> 34 #include < libarch/tls.h>34 #include <tls.h> 35 35 #include <abi/proc/uarg.h> 36 36 #include <atomic.h> -
uspace/lib/c/include/fibril_synch.h
r9b1baac r0b05082 38 38 #include <fibril.h> 39 39 #include <adt/list.h> 40 #include < libarch/tls.h>40 #include <tls.h> 41 41 #include <sys/time.h> 42 42 #include <stdbool.h> -
uspace/lib/c/include/tls.h
r9b1baac r0b05082 37 37 38 38 #include <libarch/tls.h> 39 #include <stdbool.h> 39 40 #include <stddef.h> 40 41 #include <stdint.h> 42 43 static inline void __tcb_reset(void) 44 { 45 __tcb_raw_set(NULL); 46 } 47 48 static inline void __tcb_set(tcb_t *tcb) 49 { 50 __tcb_raw_set((uint8_t *)tcb + ARCH_TP_OFFSET); 51 } 52 53 54 static inline tcb_t *__tcb_get(void) 55 { 56 return (tcb_t *)((uint8_t *)__tcb_raw_get() - ARCH_TP_OFFSET); 57 } 58 59 /* 60 * The TP register is supposed to be zero when the thread is first created 61 * by the kernel. We use this for some debugging assertions. 62 */ 63 static inline bool __tcb_is_set(void) 64 { 65 return __tcb_raw_get() != NULL; 66 } 41 67 42 68 /** DTV Generation number - equals vector length */
Note:
See TracChangeset
for help on using the changeset viewer.