sparc: add support for thread local storage
Adds the necessary bits to initialize TLS in the stack area and sets up CPU registers during context switch. Register g7 is used to point to the thread data. Thread data is accessed with negative offsets from g7. Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
This commit is contained in:
parent
07160fa153
commit
feae3249b2
5 changed files with 28 additions and 0 deletions
|
@ -45,6 +45,7 @@ config SPARC
|
|||
select BIG_ENDIAN
|
||||
select ATOMIC_OPERATIONS_BUILTIN if SPARC_CASA
|
||||
select ATOMIC_OPERATIONS_C if !SPARC_CASA
|
||||
select ARCH_HAS_THREAD_LOCAL_STORAGE
|
||||
help
|
||||
SPARC architecture
|
||||
|
||||
|
|
|
@ -17,3 +17,4 @@ zephyr_library_sources(
|
|||
)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_IRQ_OFFLOAD irq_offload.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_THREAD_LOCAL_STORAGE tls.c)
|
||||
|
|
|
@ -118,6 +118,9 @@ SECTION_FUNC(TEXT, z_sparc_context_switch)
|
|||
|
||||
/* restore output registers */
|
||||
ldd [%o0 + _thread_offset_to_o6], %o6
|
||||
#ifdef CONFIG_THREAD_LOCAL_STORAGE
|
||||
ld [%o0 + _thread_offset_to_tls], %g7
|
||||
#endif
|
||||
|
||||
ld [%o0 + _thread_offset_to_psr], %g1 /* %g1 = new thread psr */
|
||||
|
||||
|
|
22
arch/sparc/core/tls.c
Normal file
22
arch/sparc/core/tls.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (c) 2019-2020 Cobham Gaisler AB
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <kernel.h>
|
||||
#include <kernel_structs.h>
|
||||
#include <kernel_internal.h>
|
||||
#include <kernel_tls.h>
|
||||
#include <app_memory/app_memdomain.h>
|
||||
#include <sys/util.h>
|
||||
|
||||
size_t arch_tls_stack_setup(struct k_thread *new_thread, char *stack_ptr)
|
||||
{
|
||||
new_thread->tls = POINTER_TO_UINT(stack_ptr);
|
||||
|
||||
stack_ptr -= z_tls_data_size();
|
||||
z_tls_copy(stack_ptr);
|
||||
|
||||
return z_tls_data_size();
|
||||
}
|
|
@ -42,6 +42,7 @@ SECTIONS
|
|||
_image_text_end = .;
|
||||
|
||||
#include <linker/common-rom.ld>
|
||||
#include <linker/thread-local-storage.ld>
|
||||
|
||||
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue