diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-01-28 12:10:08 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-02-04 10:06:35 +0100 |
commit | 022851aba54d32831feaff13deb3d9943e130eee (patch) | |
tree | c1d6a8404dae393bd147790f6a9cf09c2f327b5a /cpukit/score/src/wkspace.c | |
parent | bsps: Thread-local storage (TLS) for linkcmds (diff) | |
download | rtems-022851aba54d32831feaff13deb3d9943e130eee.tar.bz2 |
Add thread-local storage (TLS) support
Tested and implemented on ARM, m68k, PowerPC and SPARC. Other
architectures need more work.
Diffstat (limited to 'cpukit/score/src/wkspace.c')
-rw-r--r-- | cpukit/score/src/wkspace.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/cpukit/score/src/wkspace.c b/cpukit/score/src/wkspace.c index 65806863c2..f437b885c0 100644 --- a/cpukit/score/src/wkspace.c +++ b/cpukit/score/src/wkspace.c @@ -21,6 +21,8 @@ #include <rtems/score/wkspace.h> #include <rtems/score/heapimpl.h> #include <rtems/score/interr.h> +#include <rtems/score/threadimpl.h> +#include <rtems/score/tls.h> #include <rtems/config.h> #include <string.h> /* for memset */ @@ -30,6 +32,25 @@ #include <rtems/bspIo.h> #endif +static uint32_t _Get_maximum_thread_count(void) +{ + uint32_t thread_count = 0; + + thread_count += _Thread_Get_maximum_internal_threads(); + + thread_count += rtems_resource_maximum_per_allocation( + Configuration_RTEMS_API.maximum_tasks + ); + +#if defined(RTEMS_POSIX_API) + thread_count += rtems_resource_maximum_per_allocation( + Configuration_POSIX_API.maximum_threads + ); +#endif + + return thread_count; +} + void _Workspace_Handler_initialization( Heap_Area *areas, size_t area_count, @@ -42,8 +63,17 @@ void _Workspace_Handler_initialization( bool unified = rtems_configuration_get_unified_work_area(); uintptr_t page_size = CPU_HEAP_ALIGNMENT; uintptr_t overhead = _Heap_Area_overhead( page_size ); + uintptr_t tls_size = (uintptr_t) _TLS_Size; size_t i; + if ( tls_size > 0 ) { + uintptr_t tls_alignment = (uintptr_t) _TLS_Alignment; + uintptr_t tls_alloc = _TLS_Get_allocation_size( tls_size, tls_alignment ); + + remaining += _Get_maximum_thread_count() + * _Heap_Size_with_overhead( page_size, tls_alloc, tls_alignment ); + } + for (i = 0; i < area_count; ++i) { Heap_Area *area = &areas [i]; |