[PATCH 3/6] nios2: Add TLS support
Sebastian Huber
sebastian.huber at embedded-brains.de
Wed Jan 27 09:13:32 UTC 2021
Update #4214.
---
.../cpu/nios2/nios2-context-initialize.c | 19 +++++++++++++++----
1 file 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 );
+ }
}
--
2.26.2
More information about the devel
mailing list