1 /* 2 * Copyright (c) 2020 Intel Corporation 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <kernel.h> 8 #include <kernel_structs.h> 9 #include <kernel_internal.h> 10 #include <kernel_tls.h> 11 #include <app_memory/app_memdomain.h> 12 #include <sys/util.h> 13 arch_tls_stack_setup(struct k_thread * new_thread,char * stack_ptr)14size_t arch_tls_stack_setup(struct k_thread *new_thread, char *stack_ptr) 15 { 16 /* 17 * TLS area for RISC-V is simple without any extra 18 * data. 19 */ 20 21 /* 22 * Since we are populating things backwards, 23 * setup the TLS data/bss area first. 24 */ 25 stack_ptr -= z_tls_data_size(); 26 z_tls_copy(stack_ptr); 27 28 /* 29 * Set thread TLS pointer which is used in 30 * context switch to point to TLS area. 31 */ 32 new_thread->tls = POINTER_TO_UINT(stack_ptr); 33 34 return z_tls_data_size(); 35 } 36