| [c4c5de5] | 1 | /*
|
|---|
| [d7f7a4a] | 2 | * SPDX-FileCopyrightText: 2007 Jakub Jermar
|
|---|
| [c4c5de5] | 3 | *
|
|---|
| [d7f7a4a] | 4 | * SPDX-License-Identifier: BSD-3-Clause
|
|---|
| [c4c5de5] | 5 | */
|
|---|
| 6 |
|
|---|
| [fa23560] | 7 | /** @addtogroup libc
|
|---|
| [e209fc96] | 8 | * @{
|
|---|
| 9 | */
|
|---|
| 10 | /** @file
|
|---|
| 11 | */
|
|---|
| 12 |
|
|---|
| [4805495] | 13 | #ifndef _LIBC_TLS_H_
|
|---|
| 14 | #define _LIBC_TLS_H_
|
|---|
| [c4c5de5] | 15 |
|
|---|
| [fa23560] | 16 | #include <libarch/tls.h>
|
|---|
| [0b05082] | 17 | #include <stdbool.h>
|
|---|
| [8d2dd7f2] | 18 | #include <stddef.h>
|
|---|
| 19 | #include <stdint.h>
|
|---|
| [fa23560] | 20 |
|
|---|
| [0b05082] | 21 | static inline void __tcb_reset(void)
|
|---|
| 22 | {
|
|---|
| 23 | __tcb_raw_set(NULL);
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | static inline void __tcb_set(tcb_t *tcb)
|
|---|
| 27 | {
|
|---|
| 28 | __tcb_raw_set((uint8_t *)tcb + ARCH_TP_OFFSET);
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | static inline tcb_t *__tcb_get(void)
|
|---|
| 32 | {
|
|---|
| 33 | return (tcb_t *)((uint8_t *)__tcb_raw_get() - ARCH_TP_OFFSET);
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | /*
|
|---|
| 37 | * The TP register is supposed to be zero when the thread is first created
|
|---|
| 38 | * by the kernel. We use this for some debugging assertions.
|
|---|
| 39 | */
|
|---|
| 40 | static inline bool __tcb_is_set(void)
|
|---|
| 41 | {
|
|---|
| 42 | return __tcb_raw_get() != NULL;
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| [d2bb25e7] | 45 | /** DTV Generation number - equals vector length */
|
|---|
| 46 | #define DTV_GN(dtv) (((uintptr_t *)(dtv))[0])
|
|---|
| 47 |
|
|---|
| [40abf56a] | 48 | extern tcb_t *tls_make(const void *);
|
|---|
| 49 | extern tcb_t *tls_make_initial(const void *);
|
|---|
| [4f205248] | 50 | extern tcb_t *tls_alloc_arch(size_t, size_t);
|
|---|
| [31399f3] | 51 | extern void tls_free(tcb_t *);
|
|---|
| [4f205248] | 52 | extern void tls_free_arch(tcb_t *, size_t, size_t);
|
|---|
| [e2f26002] | 53 | extern void *tls_get(void);
|
|---|
| [c4c5de5] | 54 |
|
|---|
| [fa23560] | 55 | #ifdef CONFIG_TLS_VARIANT_1
|
|---|
| [4f205248] | 56 | extern tcb_t *tls_alloc_variant_1(size_t, size_t);
|
|---|
| 57 | extern void tls_free_variant_1(tcb_t *, size_t, size_t);
|
|---|
| [fa23560] | 58 | #endif
|
|---|
| [47b7006] | 59 |
|
|---|
| [fa23560] | 60 | #ifdef CONFIG_TLS_VARIANT_2
|
|---|
| [4f205248] | 61 | extern tcb_t *tls_alloc_variant_2(size_t, size_t);
|
|---|
| 62 | extern void tls_free_variant_2(tcb_t *, size_t, size_t);
|
|---|
| [fa23560] | 63 | #endif
|
|---|
| [c4c5de5] | 64 |
|
|---|
| [fa23560] | 65 | #endif
|
|---|
| [e209fc96] | 66 |
|
|---|
| [fadd381] | 67 | /** @}
|
|---|
| [e209fc96] | 68 | */
|
|---|