diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-01-08 09:04:22 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-02-01 06:26:18 +0100 |
commit | c968b27fbd8d8b4f012b638826d35446b4f4e0c0 (patch) | |
tree | bab5af9b27f76594d34d2305091458f3d20a9275 /cpukit/score/cpu/nios2/nios2-context-initialize.c | |
parent | nios2: Make _ISR_Is_in_progress() weak (diff) | |
download | rtems-c968b27fbd8d8b4f012b638826d35446b4f4e0c0.tar.bz2 |
nios2: Add TLS support
Update #4214.
Diffstat (limited to '')
-rw-r--r-- | cpukit/score/cpu/nios2/nios2-context-initialize.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/cpukit/score/cpu/nios2/nios2-context-initialize.c b/cpukit/score/cpu/nios2/nios2-context-initialize.c index 1b7d1bbc9e..6950ce4bd6 100644 --- a/cpukit/score/cpu/nios2/nios2-context-initialize.c +++ b/cpukit/score/cpu/nios2/nios2-context-initialize.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 embedded brains GmbH + * Copyright (c) 2011, 2021 embedded brains GmbH * * Copyright (c) 2006 Kolja Waschk (rtemsdev/ixo.de) * @@ -20,6 +20,7 @@ #include <rtems/score/cpu.h> #include <rtems/score/nios2-utility.h> #include <rtems/score/interr.h> +#include <rtems/score/tls.h> void _CPU_Context_Initialize( Context_Control *context, @@ -44,9 +45,12 @@ void _CPU_Context_Initialize( if ( mpu_config != NULL ) { Nios2_MPU_Region_descriptor desc = { .index = mpu_config->data_index_for_stack_protection, - /* FIXME: Brocken stack allocator */ - .base = (void *) ((int) stack_area_begin & ~((1 << mpu_config->data_region_size_log2) - 1)), - .end = (char *) stack_area_begin + stack_area_size, + .base = stack_area_begin, + .end = (const void *) RTEMS_ALIGN_UP( + (uintptr_t) stack_area_begin + stack_area_size + + _TLS_Get_allocation_size(), + 1U << mpu_config->data_region_size_log2 + ), .perm = NIOS2_MPU_DATA_PERM_SVR_READWRITE_USER_NONE, .data = true, .cacheable = mpu_config->enable_data_cache_for_stack, @@ -65,4 +69,11 @@ void _CPU_Context_Initialize( _Terminate( INTERNAL_ERROR_CORE, 0xdeadbeef ); } } + + if ( tls_area != NULL ) { + context->r23 = (uintptr_t) tls_area + + _TLS_Get_thread_control_block_area_size( (uintptr_t) _TLS_Alignment ) + + 0x7000; + _TLS_TCB_before_TLS_block_initialize( tls_area ); + } } |