File indexing completed on 2025-05-11 08:24:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 #ifndef _RTEMS_CONFDEFS_WKSPACE_H
0038 #define _RTEMS_CONFDEFS_WKSPACE_H
0039
0040 #ifndef __CONFIGURATION_TEMPLATE_h
0041 #error "Do not include this file directly, use <rtems/confdefs.h> instead"
0042 #endif
0043
0044 #ifdef CONFIGURE_INIT
0045
0046 #include <rtems/confdefs/bdbuf.h>
0047 #include <rtems/confdefs/inittask.h>
0048 #include <rtems/confdefs/initthread.h>
0049 #include <rtems/confdefs/objectsposix.h>
0050 #include <rtems/confdefs/percpu.h>
0051 #include <rtems/confdefs/threads.h>
0052 #include <rtems/confdefs/wkspacesupport.h>
0053 #include <rtems/score/coremsg.h>
0054 #include <rtems/score/context.h>
0055 #include <rtems/score/memory.h>
0056 #include <rtems/score/stack.h>
0057 #include <rtems/sysinit.h>
0058
0059 #if CPU_STACK_ALIGNMENT > CPU_HEAP_ALIGNMENT
0060 #define _CONFIGURE_TASK_STACK_ALLOC_SIZE( _stack_size ) \
0061 ( RTEMS_ALIGN_UP( \
0062 ( _stack_size ) + CONTEXT_FP_SIZE, \
0063 CPU_STACK_ALIGNMENT \
0064 ) + CPU_STACK_ALIGNMENT - CPU_HEAP_ALIGNMENT )
0065 #else
0066 #define _CONFIGURE_TASK_STACK_ALLOC_SIZE( _stack_size ) \
0067 RTEMS_ALIGN_UP( ( _stack_size ) + CONTEXT_FP_SIZE, CPU_STACK_ALIGNMENT )
0068 #endif
0069
0070 #ifdef CONFIGURE_TASK_STACK_FROM_ALLOCATOR
0071 #define _Configure_From_stackspace( _stack_size ) \
0072 CONFIGURE_TASK_STACK_FROM_ALLOCATOR( \
0073 _CONFIGURE_TASK_STACK_ALLOC_SIZE( _stack_size ) \
0074 )
0075 #else
0076 #define _Configure_From_stackspace( _stack_size ) \
0077 _Configure_From_workspace( \
0078 _CONFIGURE_TASK_STACK_ALLOC_SIZE( _stack_size ) \
0079 )
0080 #endif
0081
0082 #ifndef CONFIGURE_EXTRA_TASK_STACKS
0083 #define CONFIGURE_EXTRA_TASK_STACKS 0
0084 #endif
0085
0086 #ifndef CONFIGURE_EXECUTIVE_RAM_SIZE
0087
0088 #define CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE( _messages, _size ) \
0089 _Configure_From_workspace( \
0090 ( _messages ) * ( _Configure_Align_up( _size, sizeof( uintptr_t ) ) \
0091 + sizeof( CORE_message_queue_Buffer ) ) )
0092
0093 #ifndef CONFIGURE_MESSAGE_BUFFER_MEMORY
0094 #define CONFIGURE_MESSAGE_BUFFER_MEMORY 0
0095 #endif
0096
0097 #ifndef CONFIGURE_MEMORY_OVERHEAD
0098 #define CONFIGURE_MEMORY_OVERHEAD 0
0099 #endif
0100
0101
0102
0103
0104
0105
0106 #define _CONFIGURE_HEAP_HANDLER_OVERHEAD \
0107 _Configure_Align_up( HEAP_BLOCK_HEADER_SIZE, CPU_HEAP_ALIGNMENT )
0108
0109 #define CONFIGURE_EXECUTIVE_RAM_SIZE \
0110 ( _CONFIGURE_MEMORY_FOR_POSIX_OBJECTS \
0111 + CONFIGURE_MESSAGE_BUFFER_MEMORY \
0112 + 1024 * CONFIGURE_MEMORY_OVERHEAD \
0113 + _CONFIGURE_HEAP_HANDLER_OVERHEAD )
0114
0115 #if defined(CONFIGURE_IDLE_TASK_STORAGE_SIZE) || \
0116 defined(CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE)
0117 #define _CONFIGURE_IDLE_TASK_STACKS 0
0118 #else
0119 #define _CONFIGURE_IDLE_TASK_STACKS \
0120 ( _CONFIGURE_MAXIMUM_PROCESSORS * \
0121 _Configure_From_stackspace( CONFIGURE_IDLE_TASK_STACK_SIZE ) )
0122 #endif
0123
0124 #define _CONFIGURE_STACK_SPACE_SIZE \
0125 ( _CONFIGURE_INIT_TASK_STACK_EXTRA \
0126 + _CONFIGURE_IDLE_TASK_STACKS \
0127 + _CONFIGURE_POSIX_INIT_THREAD_STACK_EXTRA \
0128 + _CONFIGURE_LIBBLOCK_TASKS_STACK_EXTRA \
0129 + CONFIGURE_EXTRA_TASK_STACKS \
0130 + rtems_resource_maximum_per_allocation( \
0131 _CONFIGURE_TASKS - CONFIGURE_MINIMUM_TASKS_WITH_USER_PROVIDED_STORAGE \
0132 ) \
0133 * _Configure_From_stackspace( CONFIGURE_MINIMUM_TASK_STACK_SIZE ) \
0134 + rtems_resource_maximum_per_allocation( CONFIGURE_MAXIMUM_POSIX_THREADS ) \
0135 * _Configure_From_stackspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) \
0136 + _CONFIGURE_HEAP_HANDLER_OVERHEAD )
0137
0138 #else
0139
0140 #if CONFIGURE_EXTRA_TASK_STACKS != 0
0141 #error "CONFIGURE_EXECUTIVE_RAM_SIZE defined with request for CONFIGURE_EXTRA_TASK_STACKS"
0142 #endif
0143
0144 #define _CONFIGURE_STACK_SPACE_SIZE 0
0145
0146 #endif
0147
0148 #ifdef __cplusplus
0149 extern "C" {
0150 #endif
0151
0152 const uintptr_t _Workspace_Size = CONFIGURE_EXECUTIVE_RAM_SIZE;
0153
0154 #ifdef CONFIGURE_UNIFIED_WORK_AREAS
0155 const bool _Workspace_Is_unified = true;
0156
0157 struct Heap_Control *( * const _Workspace_Malloc_initializer )( void ) =
0158 _Workspace_Malloc_initialize_unified;
0159 #endif
0160
0161 uint32_t rtems_minimum_stack_size = CONFIGURE_MINIMUM_TASK_STACK_SIZE;
0162
0163 const uintptr_t _Stack_Space_size = _CONFIGURE_STACK_SPACE_SIZE;
0164
0165 #if defined(CONFIGURE_TASK_STACK_ALLOCATOR) \
0166 && defined(CONFIGURE_TASK_STACK_DEALLOCATOR)
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176 #pragma GCC diagnostic push
0177 #pragma GCC diagnostic ignored "-Waddress"
0178 #pragma GCC diagnostic ignored "-Wpragmas"
0179 #pragma GCC diagnostic ignored "-Wtautological-pointer-compare"
0180
0181
0182 #ifdef CONFIGURE_TASK_STACK_ALLOCATOR_AVOIDS_WORK_SPACE
0183 const bool _Stack_Allocator_avoids_workspace = true;
0184 #else
0185 const bool _Stack_Allocator_avoids_workspace = false;
0186 #endif
0187
0188
0189 #ifdef CONFIGURE_TASK_STACK_ALLOCATOR_INIT
0190 const Stack_Allocator_initialize _Stack_Allocator_initialize =
0191 _CONFIGURE_ASSERT_NOT_NULL(
0192 Stack_Allocator_initialize,
0193 CONFIGURE_TASK_STACK_ALLOCATOR_INIT
0194 );
0195
0196 RTEMS_SYSINIT_ITEM(
0197 _Stack_Allocator_do_initialize,
0198 RTEMS_SYSINIT_STACK_ALLOCATOR,
0199 RTEMS_SYSINIT_ORDER_MIDDLE
0200 );
0201 #endif
0202
0203
0204 const Stack_Allocator_allocate _Stack_Allocator_allocate =
0205 _CONFIGURE_ASSERT_NOT_NULL(
0206 Stack_Allocator_allocate,
0207 CONFIGURE_TASK_STACK_ALLOCATOR
0208 );
0209
0210 const Stack_Allocator_free _Stack_Allocator_free =
0211 _CONFIGURE_ASSERT_NOT_NULL(
0212 Stack_Allocator_free,
0213 CONFIGURE_TASK_STACK_DEALLOCATOR
0214 );
0215
0216 #pragma GCC diagnostic pop
0217
0218
0219
0220
0221 #elif defined(CONFIGURE_TASK_STACK_ALLOCATOR) \
0222 || defined(CONFIGURE_TASK_STACK_DEALLOCATOR)
0223 #error "CONFIGURE_TASK_STACK_ALLOCATOR and CONFIGURE_TASK_STACK_DEALLOCATOR must be both defined or both undefined"
0224 #endif
0225
0226 #ifdef CONFIGURE_IDLE_TASK_STORAGE_SIZE
0227 #ifdef CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE
0228 #error "CONFIGURE_IDLE_TASK_STORAGE_SIZE and CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE are mutually exclusive"
0229 #endif
0230
0231 #define _CONFIGURE_IDLE_TASK_STORAGE_SIZE \
0232 RTEMS_ALIGN_UP( \
0233 RTEMS_TASK_STORAGE_SIZE( \
0234 CONFIGURE_IDLE_TASK_STORAGE_SIZE, \
0235 RTEMS_DEFAULT_ATTRIBUTES \
0236 ), \
0237 CPU_INTERRUPT_STACK_ALIGNMENT \
0238 )
0239
0240 const size_t _Stack_Allocator_allocate_for_idle_storage_size =
0241 _CONFIGURE_IDLE_TASK_STORAGE_SIZE;
0242
0243 char _Stack_Allocator_allocate_for_idle_storage_areas[
0244 _CONFIGURE_MAXIMUM_PROCESSORS * _CONFIGURE_IDLE_TASK_STORAGE_SIZE
0245 ] RTEMS_ALIGNED( CPU_INTERRUPT_STACK_ALIGNMENT )
0246 RTEMS_SECTION( ".rtemsstack.idle" );
0247
0248 #define CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE \
0249 _Stack_Allocator_allocate_for_idle_static
0250 #endif
0251
0252 #ifndef CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE
0253 #define CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE \
0254 _Stack_Allocator_allocate_for_idle_workspace
0255 #endif
0256
0257 const Stack_Allocator_allocate_for_idle _Stack_Allocator_allocate_for_idle =
0258 CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE;
0259
0260 #ifdef CONFIGURE_DIRTY_MEMORY
0261 RTEMS_SYSINIT_ITEM(
0262 _Memory_Dirty_free_areas,
0263 RTEMS_SYSINIT_DIRTY_MEMORY,
0264 RTEMS_SYSINIT_ORDER_MIDDLE
0265 );
0266 #endif
0267
0268 #ifdef CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY
0269 const bool _Memory_Zero_before_use = true;
0270
0271 RTEMS_SYSINIT_ITEM(
0272 _Memory_Zero_free_areas,
0273 RTEMS_SYSINIT_ZERO_MEMORY,
0274 RTEMS_SYSINIT_ORDER_MIDDLE
0275 );
0276 #endif
0277
0278 #ifdef __cplusplus
0279 }
0280 #endif
0281
0282 #endif
0283
0284 #endif