1/* 2 * Copyright 2019, Data61 3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO) 4 * ABN 41 687 119 230. 5 * 6 * This software may be distributed and modified according to the terms of 7 * the BSD 2-Clause license. Note that NO WARRANTY is provided. 8 * See "LICENSE_BSD2.txt" for details. 9 * 10 * @TAG(DATA61_BSD) 11 */ 12#include <autoconf.h> 13#include <sel4runtime/stdint.h> 14 15/* 16 * Obtain the value of the TLS base for the current thread. 17 */ 18static inline sel4runtime_uintptr_t sel4runtime_get_tls_base(void) 19{ 20 sel4runtime_uintptr_t tp; 21 __asm__ __volatile__("movl %%gs:0,%0" : "=r"(tp)); 22 return tp; 23} 24 25#ifdef CONFIG_SET_TLS_BASE_SELF 26/* 27 * Set the value of the TLS base for the current thread. 28 */ 29static inline void sel4runtime_set_tls_base(sel4runtime_uintptr_t tls_base) 30{ 31 seL4_SetTLSBase(tls_base); 32} 33#else 34#error "Set TLS for ia32 not implemented" 35#endif /* CONFIG_SET_TLS_BASE_SELF */ 36