diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2011-11-10 14:40:13 +0000 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2011-11-10 14:40:13 +0000 |
commit | b4f635e9d00dc0dfa871e886b9f130e0798b2f82 (patch) | |
tree | 0f8ccbe555f1491c4a5c9b5f7f825b11d332eaef | |
parent | 2011-11-10 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff) | |
download | rtems-b4f635e9d00dc0dfa871e886b9f130e0798b2f82.tar.bz2 |
2011-11-10 Sebastian Huber <sebastian.huber@embedded-brains.de>
PR 1924/cpukit
* sapi/include/rtems/config.h: New fields stack_space_size,
unified_work_area, and stack_allocator_avoids_work_space in
rtems_configuration_table.
* sapi/include/confdefs.h: Removed rtems_unified_work_area (this is
now part of the Configuration). Separate work space and stack space
estimate. Added CONFIGURE_TASK_STACK_ALLOCATOR_AVOIDS_WORK_SPACE
configuration option.
* libmisc/shell/main_wkspaceinfo.c, score/src/wkspace.c,
libcsupport/src/malloc_initialize.c: Update due to API changes.
-rw-r--r-- | cpukit/ChangeLog | 13 | ||||
-rw-r--r-- | cpukit/libcsupport/src/malloc_initialize.c | 9 | ||||
-rw-r--r-- | cpukit/libmisc/shell/main_wkspaceinfo.c | 4 | ||||
-rw-r--r-- | cpukit/sapi/include/confdefs.h | 445 | ||||
-rw-r--r-- | cpukit/sapi/include/rtems/config.h | 48 | ||||
-rw-r--r-- | cpukit/score/src/wkspace.c | 8 |
6 files changed, 323 insertions, 204 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index 3df8fbf6b8..97fb6c70cf 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,5 +1,18 @@ 2011-11-10 Sebastian Huber <sebastian.huber@embedded-brains.de> + PR 1924/cpukit + * sapi/include/rtems/config.h: New fields stack_space_size, + unified_work_area, and stack_allocator_avoids_work_space in + rtems_configuration_table. + * sapi/include/confdefs.h: Removed rtems_unified_work_area (this is + now part of the Configuration). Separate work space and stack space + estimate. Added CONFIGURE_TASK_STACK_ALLOCATOR_AVOIDS_WORK_SPACE + configuration option. + * libmisc/shell/main_wkspaceinfo.c, score/src/wkspace.c, + libcsupport/src/malloc_initialize.c: Update due to API changes. + +2011-11-10 Sebastian Huber <sebastian.huber@embedded-brains.de> + * rtems/include/rtems/rtems/event.h, rtems/include/rtems/rtems/eventset.h, rtems/inline/rtems/rtems/eventset.inl: Documentation. diff --git a/cpukit/libcsupport/src/malloc_initialize.c b/cpukit/libcsupport/src/malloc_initialize.c index 3c8c14c188..eb10ca52e4 100644 --- a/cpukit/libcsupport/src/malloc_initialize.c +++ b/cpukit/libcsupport/src/malloc_initialize.c @@ -35,7 +35,6 @@ void RTEMS_Malloc_Initialize( } #else rtems_malloc_statistics_t rtems_malloc_statistics; -extern bool rtems_unified_work_area; void RTEMS_Malloc_Initialize( void *heap_begin, @@ -43,6 +42,7 @@ void RTEMS_Malloc_Initialize( size_t sbrk_amount ) { + bool separate_areas = !rtems_configuration_get_unified_work_area(); /* * If configured, initialize the statistics support */ @@ -86,10 +86,7 @@ void RTEMS_Malloc_Initialize( * left over from another process. This would be a security violation. */ - if ( - !rtems_unified_work_area - && rtems_configuration_get_do_zero_of_workspace() - ) { + if ( separate_areas && rtems_configuration_get_do_zero_of_workspace() ) { memset( heap_begin, 0, heap_size ); } @@ -99,7 +96,7 @@ void RTEMS_Malloc_Initialize( * STDIO cannot work because there will be no buffers. */ - if ( !rtems_unified_work_area ) { + if ( separate_areas ) { uintptr_t status = _Protected_heap_Initialize( RTEMS_Malloc_Heap, heap_begin, diff --git a/cpukit/libmisc/shell/main_wkspaceinfo.c b/cpukit/libmisc/shell/main_wkspaceinfo.c index fd7c531854..9f7be701b6 100644 --- a/cpukit/libmisc/shell/main_wkspaceinfo.c +++ b/cpukit/libmisc/shell/main_wkspaceinfo.c @@ -24,12 +24,10 @@ #include <rtems/score/protectedheap.h> #include "internal.h" -extern bool rtems_unified_work_area; - void rtems_shell_print_unified_work_area_message(void) { printf( "\nC Program Heap and RTEMS Workspace are %s.\n", - ((rtems_unified_work_area) ? "the same" : "separate") + rtems_configuration_get_unified_work_area() ? "the same" : "separate" ); } diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h index a82dd00a87..21a21dd135 100644 --- a/cpukit/sapi/include/confdefs.h +++ b/cpukit/sapi/include/confdefs.h @@ -764,6 +764,9 @@ rtems_fs_init_functions_t rtems_fs_init_helper = #define CONFIGURE_MINIMUM_TASK_STACK_SIZE CPU_STACK_MINIMUM_SIZE #endif +#define CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE \ + (2 * CONFIGURE_MINIMUM_TASK_STACK_SIZE) + /** * @brief Idle task stack size configuration * @@ -777,6 +780,9 @@ rtems_fs_init_functions_t rtems_fs_init_helper = #define CONFIGURE_IDLE_TASK_STACK_SIZE CONFIGURE_MINIMUM_TASK_STACK_SIZE #endif #endif +#if CONFIGURE_IDLE_TASK_STACK_SIZE < CONFIGURE_MINIMUM_TASK_STACK_SIZE + #error "CONFIGURE_IDLE_TASK_STACK_SIZE less than CONFIGURE_MINIMUM_TASK_STACK_SIZE" +#endif /** * @brief Interrupt stack size configuration @@ -855,11 +861,9 @@ rtems_fs_init_functions_t rtems_fs_init_helper = #ifdef CONFIGURE_UNIFIED_WORK_AREAS #include <rtems/score/wkspace.h> Heap_Control *RTEMS_Malloc_Heap = &_Workspace_Area; - bool rtems_unified_work_area = true; #else Heap_Control RTEMS_Malloc_Area; Heap_Control *RTEMS_Malloc_Heap = &RTEMS_Malloc_Area; - bool rtems_unified_work_area = false; #endif #endif @@ -1241,6 +1245,10 @@ rtems_fs_init_functions_t rtems_fs_init_helper = #define CONFIGURE_LIBBLOCK_SEMAPHORES 0 #endif /* CONFIGURE_APPLICATION_NEEDS_LIBBLOCK */ +#ifndef CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK + #define CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK 0 +#endif + #if defined(RTEMS_MULTIPROCESSING) /* * Default Multiprocessing Configuration Table. The defaults are @@ -1273,10 +1281,6 @@ rtems_fs_init_functions_t rtems_fs_init_helper = #define CONFIGURE_MEMORY_FOR_PROXIES(_proxies) \ _Configure_Object_RAM((_proxies) + 1, sizeof(Thread_Proxy_control) ) - #ifndef CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK - #define CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK 0 - #endif - #ifndef CONFIGURE_MP_MPCI_TABLE_POINTER #include <mpci.h> #define CONFIGURE_MP_MPCI_TABLE_POINTER &MPCI_table @@ -1521,7 +1525,6 @@ rtems_fs_init_functions_t rtems_fs_init_helper = #define CONFIGURE_MEMORY_PER_TASK_FOR_POSIX_API \ _Configure_From_workspace( \ - CONFIGURE_MINIMUM_TASK_STACK_SIZE + \ sizeof (POSIX_API_Control) + \ (sizeof (void *) * (CONFIGURE_MAXIMUM_POSIX_KEYS)) \ ) @@ -1639,7 +1642,7 @@ rtems_fs_init_functions_t rtems_fs_init_helper = #ifndef CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE #define CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE \ - (CONFIGURE_MINIMUM_TASK_STACK_SIZE * 2) + CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE #endif #ifdef CONFIGURE_INIT @@ -1685,8 +1688,7 @@ rtems_fs_init_functions_t rtems_fs_init_helper = CONFIGURE_MAXIMUM_POSIX_SPINLOCKS ) + \ CONFIGURE_MEMORY_FOR_POSIX_RWLOCKS( \ CONFIGURE_MAXIMUM_POSIX_RWLOCKS ) + \ - CONFIGURE_MEMORY_FOR_POSIX_TIMERS( CONFIGURE_MAXIMUM_POSIX_TIMERS ) + \ - (CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE) \ + CONFIGURE_MEMORY_FOR_POSIX_TIMERS( CONFIGURE_MAXIMUM_POSIX_TIMERS ) \ ) #else @@ -1728,18 +1730,10 @@ rtems_fs_init_functions_t rtems_fs_init_helper = #define CONFIGURE_MAXIMUM_FAKE_ADA_TASKS 0 #endif - /** - * Ada tasks are allocated twice the minimum stack space. - */ - #define CONFIGURE_ADA_TASKS_STACK \ - (CONFIGURE_MAXIMUM_ADA_TASKS * \ - (CONFIGURE_MINIMUM_TASK_STACK_SIZE + (6 * 1024))) - #else #define CONFIGURE_GNAT_MUTEXES 0 #define CONFIGURE_MAXIMUM_ADA_TASKS 0 #define CONFIGURE_MAXIMUM_FAKE_ADA_TASKS 0 - #define CONFIGURE_ADA_TASKS_STACK 0 #endif #ifdef CONFIGURE_ENABLE_GO @@ -1795,6 +1789,13 @@ rtems_fs_init_functions_t rtems_fs_init_helper = #define CONFIGURE_MEMORY_PER_TASK_FOR_NEWLIB 0 #endif +/** + * This is so we can account for tasks with stacks greater than minimum + * size. This is in bytes. + */ +#ifndef CONFIGURE_EXTRA_TASK_STACKS + #define CONFIGURE_EXTRA_TASK_STACKS 0 +#endif /* * Calculate the RAM size based on the maximum number of objects configured. @@ -1813,8 +1814,7 @@ rtems_fs_init_functions_t rtems_fs_init_helper = ( \ _Configure_Object_RAM(_tasks, sizeof(Thread_Control)) + \ (_Configure_Max_Objects(_tasks) * \ - (_Configure_From_workspace(CONFIGURE_MINIMUM_TASK_STACK_SIZE) + \ - CONFIGURE_MEMORY_PER_TASK_FOR_CLASSIC_API + \ + (CONFIGURE_MEMORY_PER_TASK_FOR_CLASSIC_API + \ CONFIGURE_MEMORY_PER_TASK_FOR_NEWLIB + \ CONFIGURE_MEMORY_PER_TASK_FOR_POSIX_API + \ CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER)) + \ @@ -1833,22 +1833,13 @@ rtems_fs_init_functions_t rtems_fs_init_helper = (CONFIGURE_MEMORY_FOR_PROXIES(CONFIGURE_MP_MAXIMUM_PROXIES) + \ CONFIGURE_MEMORY_FOR_GLOBAL_OBJECTS( \ CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS) + \ - CONFIGURE_MEMORY_FOR_TASKS(1, 1) + \ - CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK \ + CONFIGURE_MEMORY_FOR_TASKS(1, 1) \ ) #else #define CONFIGURE_MEMORY_FOR_MP 0 #endif /** - * This is so we can account for tasks with stacks greater than minimum - * size. This is in bytes. - */ -#ifndef CONFIGURE_EXTRA_TASK_STACKS - #define CONFIGURE_EXTRA_TASK_STACKS 0 -#endif - -/** * The following macro is used to calculate the memory allocated by RTEMS * for the message buffers associated with a particular message queue. * There is a fixed amount of overhead per message. @@ -1915,27 +1906,23 @@ rtems_fs_init_functions_t rtems_fs_init_helper = _Configure_Object_RAM(1, sizeof(API_Mutex_Control)) /** - * This defines the formula used to compute the amount of memory - * reserved for IDLE task control structures and stacks. - */ -#define CONFIGURE_IDLE_TASKS(_count) \ - (CONFIGURE_MEMORY_FOR_TASKS(_count, 0) + \ - _count * _Configure_From_workspace( \ - (CONFIGURE_IDLE_TASK_STACK_SIZE - CONFIGURE_MINIMUM_TASK_STACK_SIZE))) - -/** * This calculates the amount of memory reserved for the IDLE tasks. * In an SMP system, each CPU core has its own idle task. */ #if defined(RTEMS_SMP) - #define CONFIGURE_MEMORY_FOR_IDLE_TASK \ - CONFIGURE_IDLE_TASKS(CONFIGURE_SMP_MAXIMUM_PROCESSORS) + #define CONFIGURE_IDLE_TASKS_COUNT CONFIGURE_SMP_MAXIMUM_PROCESSORS #else - #define CONFIGURE_MEMORY_FOR_IDLE_TASK \ - CONFIGURE_IDLE_TASKS(1) + #define CONFIGURE_IDLE_TASKS_COUNT 1 #endif /** + * This defines the formula used to compute the amount of memory + * reserved for IDLE task control structures. + */ +#define CONFIGURE_MEMORY_FOR_IDLE_TASK \ + CONFIGURE_MEMORY_FOR_TASKS(CONFIGURE_IDLE_TASKS_COUNT, 0) + +/** * This macro accounts for general RTEMS system overhead. */ #define CONFIGURE_MEMORY_FOR_SYSTEM_OVERHEAD \ @@ -1946,42 +1933,6 @@ rtems_fs_init_functions_t rtems_fs_init_helper = CONFIGURE_API_MUTEX_MEMORY /* allocation mutex */ \ ) -/* - * Now account for any extra memory that initialization tasks or threads - * may have requested. - */ - -/** - * This accounts for any extra memory required by the Classic API - * Initialization Task. - */ -#if (CONFIGURE_INIT_TASK_STACK_SIZE > CONFIGURE_MINIMUM_TASK_STACK_SIZE) - #define CONFIGURE_INITIALIZATION_THREADS_STACKS_CLASSIC_PART \ - (CONFIGURE_INIT_TASK_STACK_SIZE - CONFIGURE_MINIMUM_TASK_STACK_SIZE) -#else - #define CONFIGURE_INITIALIZATION_THREADS_STACKS_CLASSIC_PART 0 -#endif - -/** - * This accounts for any extra memory required by the POSIX API - * Initialization Thread. - */ -#if defined(RTEMS_POSIX_API) && \ - (CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE > CONFIGURE_MINIMUM_TASK_STACK_SIZE) - #define CONFIGURE_INITIALIZATION_THREADS_STACKS_POSIX_PART \ - (CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE - CONFIGURE_MINIMUM_TASK_STACK_SIZE) -#else - #define CONFIGURE_INITIALIZATION_THREADS_STACKS_POSIX_PART 0 -#endif - -/** - * This macro provides a summation of the various initialization task - * and thread stack requirements. - */ -#define CONFIGURE_INITIALIZATION_THREADS_STACKS \ - (CONFIGURE_INITIALIZATION_THREADS_STACKS_CLASSIC_PART + \ - CONFIGURE_INITIALIZATION_THREADS_STACKS_POSIX_PART) - /** * This macro provides a summation of the various task and thread * requirements. @@ -2030,110 +1981,6 @@ rtems_fs_init_functions_t rtems_fs_init_helper = #define CONFIGURE_MEMORY_FOR_SMP 0 #endif -#if defined(CONFIGURE_CONFDEFS_DEBUG) && defined(CONFIGURE_INIT) - /** - * This is a debug mechanism, so if you need to, the executable will - * have a structure with various partial values. Add to this as you - * need to. Viewing this structure in gdb combined with dumping - * the Configuration structures generated should help a lot in tracing - * down errors and analyzing where over and under allocations are. - */ - typedef struct { - uint32_t SYSTEM_OVERHEAD; - uint32_t STATIC_EXTENSIONS; - uint32_t INITIALIZATION_THREADS_STACKS; - - uint32_t PER_INTEGER_TASK; - uint32_t FP_OVERHEAD; - uint32_t CLASSIC; - uint32_t POSIX; - - /* System overhead pieces */ - uint32_t INTERRUPT_VECTOR_TABLE; - uint32_t INTERRUPT_STACK_MEMORY; - uint32_t MEMORY_FOR_IDLE_TASK; - uint32_t MEMORY_FOR_SCHEDULER; - uint32_t MEMORY_PER_TASK_FOR_SCHEDULER; - - /* Classic API Pieces */ - uint32_t CLASSIC_TASKS; - uint32_t TASK_VARIABLES; - uint32_t TIMERS; - uint32_t SEMAPHORES; - uint32_t MESSAGE_QUEUES; - uint32_t PARTITIONS; - uint32_t REGIONS; - uint32_t PORTS; - uint32_t PERIODS; - uint32_t BARRIERS; - uint32_t USER_EXTENSIONS; -#ifdef RTEMS_POSIX_API - /* POSIX API Pieces */ - uint32_t POSIX_MUTEXES; - uint32_t POSIX_CONDITION_VARIABLES; - uint32_t POSIX_KEYS; - uint32_t POSIX_TIMERS; - uint32_t POSIX_QUEUED_SIGNALS; - uint32_t POSIX_MESSAGE_QUEUES; - uint32_t POSIX_SEMAPHORES; - uint32_t POSIX_BARRIERS; - uint32_t POSIX_SPINLOCKS; - uint32_t POSIX_RWLOCKS; -#endif - } Configuration_Debug_t; - - Configuration_Debug_t Configuration_Memory_Debug = { - /* General Information */ - CONFIGURE_MEMORY_FOR_SYSTEM_OVERHEAD, - CONFIGURE_MEMORY_FOR_STATIC_EXTENSIONS, - CONFIGURE_INITIALIZATION_THREADS_STACKS, - CONFIGURE_MEMORY_FOR_TASKS(1, 0), - CONFIGURE_MEMORY_FOR_TASKS(0, 1), - CONFIGURE_MEMORY_FOR_CLASSIC, - CONFIGURE_MEMORY_FOR_POSIX, - - /* System overhead pieces */ - CONFIGURE_INTERRUPT_VECTOR_TABLE, - CONFIGURE_INTERRUPT_STACK_MEMORY, - CONFIGURE_MEMORY_FOR_IDLE_TASK, - CONFIGURE_MEMORY_FOR_SCHEDULER, - CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER, - - /* Classic API Pieces */ - CONFIGURE_MEMORY_FOR_TASKS(CONFIGURE_MAXIMUM_TASKS, 0), - CONFIGURE_MEMORY_FOR_TASK_VARIABLES(CONFIGURE_MAXIMUM_TASK_VARIABLES + - CONFIGURE_GOROUTINES_TASK_VARIABLES), - CONFIGURE_MEMORY_FOR_TIMERS(CONFIGURE_MAXIMUM_TIMERS), - CONFIGURE_MEMORY_FOR_SEMAPHORES(CONFIGURE_SEMAPHORES), - CONFIGURE_MEMORY_FOR_MESSAGE_QUEUES(CONFIGURE_MAXIMUM_MESSAGE_QUEUES), - CONFIGURE_MEMORY_FOR_PARTITIONS(CONFIGURE_MAXIMUM_PARTITIONS), - CONFIGURE_MEMORY_FOR_REGIONS( CONFIGURE_MAXIMUM_REGIONS ), - CONFIGURE_MEMORY_FOR_PORTS(CONFIGURE_MAXIMUM_PORTS), - CONFIGURE_MEMORY_FOR_PERIODS(CONFIGURE_MAXIMUM_PERIODS), - CONFIGURE_MEMORY_FOR_BARRIERS(CONFIGURE_BARRIERS), - CONFIGURE_MEMORY_FOR_USER_EXTENSIONS(CONFIGURE_MAXIMUM_USER_EXTENSIONS), - -#ifdef RTEMS_POSIX_API - /* POSIX API Pieces */ - CONFIGURE_MEMORY_FOR_POSIX_MUTEXES( CONFIGURE_MAXIMUM_POSIX_MUTEXES + - CONFIGURE_MAXIMUM_GO_CHANNELS + CONFIGURE_GO_INIT_MUTEXES), - CONFIGURE_MEMORY_FOR_POSIX_CONDITION_VARIABLES( - CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES + - CONFIGURE_MAXIMUM_GO_CHANNELS + CONFIGURE_GO_INIT_CONDITION_VARIABLES), - CONFIGURE_MEMORY_FOR_POSIX_KEYS( CONFIGURE_MAXIMUM_POSIX_KEYS ), - CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS( - CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS ), - CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES( - CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES ), - CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES( CONFIGURE_MAXIMUM_POSIX_SEMAPHORES ), - CONFIGURE_MEMORY_FOR_POSIX_BARRIERS( CONFIGURE_MAXIMUM_POSIX_BARRIERS ), - CONFIGURE_MEMORY_FOR_POSIX_SPINLOCKS( CONFIGURE_MAXIMUM_POSIX_SPINLOCKS ), - CONFIGURE_MEMORY_FOR_POSIX_RWLOCKS( CONFIGURE_MAXIMUM_POSIX_RWLOCKS ), - CONFIGURE_MEMORY_FOR_POSIX_TIMERS( CONFIGURE_MAXIMUM_POSIX_TIMERS ), -#endif - }; -#endif - /** * This calculates the memory required for the executive workspace. */ @@ -2145,18 +1992,102 @@ rtems_fs_init_functions_t rtems_fs_init_helper = CONFIGURE_TOTAL_TASKS_AND_THREADS, CONFIGURE_TOTAL_TASKS_AND_THREADS) + \ CONFIGURE_MEMORY_FOR_CLASSIC + \ CONFIGURE_MEMORY_FOR_POSIX + \ - (CONFIGURE_MAXIMUM_POSIX_THREADS * CONFIGURE_MINIMUM_TASK_STACK_SIZE ) + \ - (CONFIGURE_MAXIMUM_GOROUTINES * CONFIGURE_MINIMUM_TASK_STACK_SIZE) + \ - CONFIGURE_INITIALIZATION_THREADS_STACKS + \ CONFIGURE_MEMORY_FOR_STATIC_EXTENSIONS + \ CONFIGURE_MEMORY_FOR_MP + \ CONFIGURE_MEMORY_FOR_SMP + \ CONFIGURE_MESSAGE_BUFFER_MEMORY + \ - (CONFIGURE_MEMORY_OVERHEAD * 1024) + \ - (CONFIGURE_EXTRA_TASK_STACKS) + (CONFIGURE_ADA_TASKS_STACK) \ + (CONFIGURE_MEMORY_OVERHEAD * 1024) \ ) & ~0x7) + +/* + * Now account for any extra memory that initialization tasks or threads + * may have requested. + */ + +/** + * This accounts for any extra memory required by the Classic API + * Initialization Task. + */ +#if (CONFIGURE_INIT_TASK_STACK_SIZE > CONFIGURE_MINIMUM_TASK_STACK_SIZE) + #define CONFIGURE_INITIALIZATION_THREADS_STACKS_CLASSIC_PART \ + (CONFIGURE_INIT_TASK_STACK_SIZE - CONFIGURE_MINIMUM_TASK_STACK_SIZE) +#else + #define CONFIGURE_INITIALIZATION_THREADS_STACKS_CLASSIC_PART 0 #endif +/** + * This accounts for any extra memory required by the POSIX API + * Initialization Thread. + */ +#if defined(RTEMS_POSIX_API) && \ + (CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE > \ + CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE) + #define CONFIGURE_INITIALIZATION_THREADS_STACKS_POSIX_PART \ + (CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE - \ + CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE) +#else + #define CONFIGURE_INITIALIZATION_THREADS_STACKS_POSIX_PART 0 +#endif + +/** + * This macro provides a summation of the various initialization task + * and thread stack requirements. + */ +#define CONFIGURE_INITIALIZATION_THREADS_EXTRA_STACKS \ + (CONFIGURE_INITIALIZATION_THREADS_STACKS_CLASSIC_PART + \ + CONFIGURE_INITIALIZATION_THREADS_STACKS_POSIX_PART) + +#define CONFIGURE_IDLE_TASKS_STACK \ + (CONFIGURE_IDLE_TASKS_COUNT * \ + _Configure_From_workspace( CONFIGURE_IDLE_TASK_STACK_SIZE ) ) + +#define CONFIGURE_TASKS_STACK \ + (_Configure_Max_Objects( CONFIGURE_MAXIMUM_TASKS ) * \ + _Configure_From_workspace( CONFIGURE_MINIMUM_TASK_STACK_SIZE ) ) + +#define CONFIGURE_POSIX_THREADS_STACK \ + (_Configure_Max_Objects( CONFIGURE_MAXIMUM_POSIX_THREADS ) * \ + _Configure_From_workspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) ) + +#define CONFIGURE_GOROUTINES_STACK \ + (_Configure_Max_Objects( CONFIGURE_MAXIMUM_GOROUTINES ) * \ + _Configure_From_workspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) ) + +#define CONFIGURE_ADA_TASKS_STACK \ + (_Configure_Max_Objects( CONFIGURE_MAXIMUM_ADA_TASKS ) * \ + _Configure_From_workspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) ) + +#else /* CONFIGURE_EXECUTIVE_RAM_SIZE */ + +#define CONFIGURE_IDLE_TASKS_STACK 0 +#define CONFIGURE_INITIALIZATION_THREADS_EXTRA_STACKS 0 +#define CONFIGURE_TASKS_STACK 0 +#define CONFIGURE_POSIX_THREADS_STACK 0 +#define CONFIGURE_GOROUTINES_STACK 0 +#define CONFIGURE_ADA_TASKS_STACK 0 + +#if CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK != 0 + #error "CONFIGURE_EXECUTIVE_RAM_SIZE defined with request for CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK" +#endif + +#if CONFIGURE_EXTRA_TASK_STACKS != 0 + #error "CONFIGURE_EXECUTIVE_RAM_SIZE defined with request for CONFIGURE_EXTRA_TASK_STACKS" +#endif + +#endif /* CONFIGURE_EXECUTIVE_RAM_SIZE */ + +#define CONFIGURE_STACK_SPACE_SIZE \ + ( \ + CONFIGURE_IDLE_TASKS_STACK + \ + CONFIGURE_INITIALIZATION_THREADS_EXTRA_STACKS + \ + CONFIGURE_TASKS_STACK + \ + CONFIGURE_POSIX_THREADS_STACK + \ + CONFIGURE_GOROUTINES_STACK + \ + CONFIGURE_ADA_TASKS_STACK + \ + CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK + \ + CONFIGURE_EXTRA_TASK_STACKS \ + ) + #ifdef CONFIGURE_INIT /** * This is the Classic API Configuration Table. @@ -2230,6 +2161,7 @@ rtems_fs_init_functions_t rtems_fs_init_helper = rtems_configuration_table Configuration = { NULL, /* filled in by BSP */ CONFIGURE_EXECUTIVE_RAM_SIZE, /* required RTEMS workspace */ + CONFIGURE_STACK_SPACE_SIZE, /* required stack space */ CONFIGURE_MAXIMUM_USER_EXTENSIONS, /* maximum dynamic extensions */ CONFIGURE_MICROSECONDS_PER_TICK, /* microseconds per clock tick */ CONFIGURE_TICKS_PER_TIMESLICE, /* ticks per timeslice quantum */ @@ -2239,6 +2171,18 @@ rtems_fs_init_functions_t rtems_fs_init_helper = CONFIGURE_TASK_STACK_ALLOCATOR, /* stack allocator */ CONFIGURE_TASK_STACK_DEALLOCATOR, /* stack deallocator */ CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY, /* true to clear memory */ + #ifdef CONFIGURE_UNIFIED_WORK_AREAS /* true for unified work areas */ + true, + #else + false, + #endif + #ifdef CONFIGURE_TASK_STACK_ALLOCATOR_AVOIDS_WORK_SPACE /* true to avoid + work space for thread stack + allocation */ + true, + #else + false, + #endif CONFIGURE_MAXIMUM_DRIVERS, /* maximum device drivers */ CONFIGURE_NUMBER_OF_DRIVERS, /* static device drivers */ Device_drivers, /* pointer to driver table */ @@ -2318,6 +2262,131 @@ rtems_fs_init_functions_t rtems_fs_init_helper = ****************************************************************** */ +#if defined(CONFIGURE_CONFDEFS_DEBUG) && defined(CONFIGURE_INIT) + /** + * This is a debug mechanism, so if you need to, the executable will + * have a structure with various partial values. Add to this as you + * need to. Viewing this structure in gdb combined with dumping + * the Configuration structures generated should help a lot in tracing + * down errors and analyzing where over and under allocations are. + */ + typedef struct { + uint32_t SYSTEM_OVERHEAD; + uint32_t STATIC_EXTENSIONS; + uint32_t INITIALIZATION_THREADS_STACKS; + + uint32_t PER_INTEGER_TASK; + uint32_t FP_OVERHEAD; + uint32_t CLASSIC; + uint32_t POSIX; + + /* System overhead pieces */ + uint32_t INTERRUPT_VECTOR_TABLE; + uint32_t INTERRUPT_STACK_MEMORY; + uint32_t MEMORY_FOR_IDLE_TASK; + uint32_t MEMORY_FOR_SCHEDULER; + uint32_t MEMORY_PER_TASK_FOR_SCHEDULER; + + /* Classic API Pieces */ + uint32_t CLASSIC_TASKS; + uint32_t TASK_VARIABLES; + uint32_t TIMERS; + uint32_t SEMAPHORES; + uint32_t MESSAGE_QUEUES; + uint32_t PARTITIONS; + uint32_t REGIONS; + uint32_t PORTS; + uint32_t PERIODS; + uint32_t BARRIERS; + uint32_t USER_EXTENSIONS; + +#ifdef RTEMS_POSIX_API + /* POSIX API Pieces */ + uint32_t POSIX_MUTEXES; + uint32_t POSIX_CONDITION_VARIABLES; + uint32_t POSIX_KEYS; + uint32_t POSIX_TIMERS; + uint32_t POSIX_QUEUED_SIGNALS; + uint32_t POSIX_MESSAGE_QUEUES; + uint32_t POSIX_SEMAPHORES; + uint32_t POSIX_BARRIERS; + uint32_t POSIX_SPINLOCKS; + uint32_t POSIX_RWLOCKS; +#endif + + /* Stack space sizes */ + uint32_t IDLE_TASKS_STACK; + uint32_t INITIALIZATION_THREADS_EXTRA_STACKS; + uint32_t TASKS_STACK; + uint32_t POSIX_THREADS_STACK; + uint32_t GOROUTINES_STACK; + uint32_t ADA_TASKS_STACK; + uint32_t EXTRA_MPCI_RECEIVE_SERVER_STACK; + uint32_t EXTRA_TASK_STACKS; + } Configuration_Debug_t; + + Configuration_Debug_t Configuration_Memory_Debug = { + /* General Information */ + CONFIGURE_MEMORY_FOR_SYSTEM_OVERHEAD, + CONFIGURE_MEMORY_FOR_STATIC_EXTENSIONS, + CONFIGURE_INITIALIZATION_THREADS_EXTRA_STACKS, + CONFIGURE_MEMORY_FOR_TASKS(1, 0), + CONFIGURE_MEMORY_FOR_TASKS(0, 1), + CONFIGURE_MEMORY_FOR_CLASSIC, + CONFIGURE_MEMORY_FOR_POSIX, + + /* System overhead pieces */ + CONFIGURE_INTERRUPT_VECTOR_TABLE, + CONFIGURE_INTERRUPT_STACK_MEMORY, + CONFIGURE_MEMORY_FOR_IDLE_TASK, + CONFIGURE_MEMORY_FOR_SCHEDULER, + CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER, + + /* Classic API Pieces */ + CONFIGURE_MEMORY_FOR_TASKS(CONFIGURE_MAXIMUM_TASKS, 0), + CONFIGURE_MEMORY_FOR_TASK_VARIABLES(CONFIGURE_MAXIMUM_TASK_VARIABLES + + CONFIGURE_GOROUTINES_TASK_VARIABLES), + CONFIGURE_MEMORY_FOR_TIMERS(CONFIGURE_MAXIMUM_TIMERS), + CONFIGURE_MEMORY_FOR_SEMAPHORES(CONFIGURE_SEMAPHORES), + CONFIGURE_MEMORY_FOR_MESSAGE_QUEUES(CONFIGURE_MAXIMUM_MESSAGE_QUEUES), + CONFIGURE_MEMORY_FOR_PARTITIONS(CONFIGURE_MAXIMUM_PARTITIONS), + CONFIGURE_MEMORY_FOR_REGIONS( CONFIGURE_MAXIMUM_REGIONS ), + CONFIGURE_MEMORY_FOR_PORTS(CONFIGURE_MAXIMUM_PORTS), + CONFIGURE_MEMORY_FOR_PERIODS(CONFIGURE_MAXIMUM_PERIODS), + CONFIGURE_MEMORY_FOR_BARRIERS(CONFIGURE_BARRIERS), + CONFIGURE_MEMORY_FOR_USER_EXTENSIONS(CONFIGURE_MAXIMUM_USER_EXTENSIONS), + +#ifdef RTEMS_POSIX_API + /* POSIX API Pieces */ + CONFIGURE_MEMORY_FOR_POSIX_MUTEXES( CONFIGURE_MAXIMUM_POSIX_MUTEXES + + CONFIGURE_MAXIMUM_GO_CHANNELS + CONFIGURE_GO_INIT_MUTEXES), + CONFIGURE_MEMORY_FOR_POSIX_CONDITION_VARIABLES( + CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES + + CONFIGURE_MAXIMUM_GO_CHANNELS + CONFIGURE_GO_INIT_CONDITION_VARIABLES), + CONFIGURE_MEMORY_FOR_POSIX_KEYS( CONFIGURE_MAXIMUM_POSIX_KEYS ), + CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS( + CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS ), + CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES( + CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES ), + CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES( CONFIGURE_MAXIMUM_POSIX_SEMAPHORES ), + CONFIGURE_MEMORY_FOR_POSIX_BARRIERS( CONFIGURE_MAXIMUM_POSIX_BARRIERS ), + CONFIGURE_MEMORY_FOR_POSIX_SPINLOCKS( CONFIGURE_MAXIMUM_POSIX_SPINLOCKS ), + CONFIGURE_MEMORY_FOR_POSIX_RWLOCKS( CONFIGURE_MAXIMUM_POSIX_RWLOCKS ), + CONFIGURE_MEMORY_FOR_POSIX_TIMERS( CONFIGURE_MAXIMUM_POSIX_TIMERS ), +#endif + + /* Stack space sizes */ + CONFIGURE_IDLE_TASKS_STACK, + CONFIGURE_INITIALIZATION_THREADS_EXTRA_STACKS, + CONFIGURE_TASKS_STACK, + CONFIGURE_POSIX_THREADS_STACK, + CONFIGURE_GOROUTINES_STACK, + CONFIGURE_ADA_TASKS_STACK, + CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK, + CONFIGURE_EXTRA_TASK_STACKS + }; +#endif + /* * Make sure a task/thread of some sort is configured. * diff --git a/cpukit/sapi/include/rtems/config.h b/cpukit/sapi/include/rtems/config.h index c2d71b0746..590999c029 100644 --- a/cpukit/sapi/include/rtems/config.h +++ b/cpukit/sapi/include/rtems/config.h @@ -104,6 +104,10 @@ typedef struct { */ uintptr_t work_space_size; + /** This field specifies the size in bytes of the RTEMS thread stack space. + */ + uintptr_t stack_space_size; + /** This field specifies the maximum number of dynamically installed * used extensions. */ @@ -152,6 +156,23 @@ typedef struct { */ bool do_zero_of_workspace; + /** + * @brief Specifies if a unified work area is used or not. + * + * If this element is @a true, then the RTEMS Workspace and the C Program + * Heap use the same heap, otherwise they use separate heaps. + */ + bool unified_work_area; + + /** + * @brief Specifies if the stack allocator avoids the work space. + * + * If this element is @a true, then the stack allocator must not allocate the + * thread stacks from the RTEMS Workspace, otherwise it should allocate the + * thread stacks from the RTEMS Workspace. + */ + bool stack_allocator_avoids_work_space; + uint32_t maximum_drivers; uint32_t number_of_device_drivers; rtems_driver_address_table *Device_driver_table; @@ -193,11 +214,31 @@ extern rtems_configuration_table Configuration; #define rtems_configuration_get_table() \ (&Configuration) +#define rtems_configuration_get_unified_work_area() \ + (Configuration.unified_work_area) + +#define rtems_configuration_get_stack_allocator_avoids_work_space() \ + (Configuration.stack_allocator_avoids_work_space) + +#define rtems_configuration_get_stack_space_size() \ + (Configuration.stack_space_size) + +#define rtems_configuration_set_stack_space_size( _size ) \ + do { Configuration.stack_space_size = (_size); } while (0) + #define rtems_configuration_get_work_space_start() \ (Configuration.work_space_start) +#define rtems_configuration_set_work_space_start( _start ) \ + do { Configuration.work_space_start = (_start); } while (0) + #define rtems_configuration_get_work_space_size() \ - (Configuration.work_space_size) + (Configuration.work_space_size + \ + (rtems_configuration_get_stack_allocator_avoids_work_space() ? \ + 0 : rtems_configuration_get_stack_space_size())) + +#define rtems_configuration_set_work_space_size( _size ) \ + do { Configuration.work_space_size = (_size); } while (0) #define rtems_configuration_get_maximum_extensions() \ (Configuration.maximum_extensions) @@ -254,9 +295,10 @@ extern rtems_configuration_table Configuration; #if defined(RTEMS_MULTIPROCESSING) #define rtems_configuration_get_user_multiprocessing_table() \ - (Configuration.User_multiprocessing_table) + (Configuration.User_multiprocessing_table) #else - #define rtems_configuration_get_user_multiprocessing_table() NULL + #define rtems_configuration_get_user_multiprocessing_table() \ + NULL #endif #define rtems_configuration_get_rtems_api_configuration() \ diff --git a/cpukit/score/src/wkspace.c b/cpukit/score/src/wkspace.c index 568bfc1ce7..179f08d9cc 100644 --- a/cpukit/score/src/wkspace.c +++ b/cpukit/score/src/wkspace.c @@ -33,11 +33,11 @@ void _Workspace_Handler_initialization(void) { uintptr_t memory_available = 0; - void *starting_address = Configuration.work_space_start; - uintptr_t size = Configuration.work_space_size; + void *starting_address = rtems_configuration_get_work_space_start(); + uintptr_t size = rtems_configuration_get_work_space_size(); - if ( Configuration.do_zero_of_workspace ) - memset( starting_address, 0, size ); + if ( rtems_configuration_get_do_zero_of_workspace() ) + memset( starting_address, 0, size ); memory_available = _Heap_Initialize( &_Workspace_Area, |