RCS file: /usr1/CVS/rtems/cpukit/sapi/include/confdefs.h,v
retrieving revision 1.178
diff -u -r1.178 confdefs.h
|
|
|
44 | 44 | */ |
45 | 45 | #include <rtems.h> |
46 | 46 | #include <rtems/score/apimutex.h> |
| 47 | #include <rtems/score/wkspace.h> |
47 | 48 | |
48 | 49 | #ifdef __cplusplus |
49 | 50 | extern "C" { |
… |
… |
|
823 | 824 | #endif |
824 | 825 | |
825 | 826 | /** |
826 | | * Configure the very much optional task stack allocator |
| 827 | * Configure the very much optional task stack allocator initialization |
827 | 828 | */ |
828 | | #ifndef CONFIGURE_TASK_STACK_ALLOCATOR |
829 | | #define CONFIGURE_TASK_STACK_ALLOCATOR NULL |
| 829 | #ifndef CONFIGURE_TASK_STACK_ALLOCATOR_INIT |
| 830 | #define CONFIGURE_TASK_STACK_ALLOCATOR_INIT NULL |
830 | 831 | #endif |
831 | 832 | |
832 | | /** |
833 | | * Configure the very much optional task stack deallocator |
| 833 | /* |
| 834 | * Configure the very much optional task stack allocator and deallocator. |
834 | 835 | */ |
835 | | #ifndef CONFIGURE_TASK_STACK_DEALLOCATOR |
836 | | #define CONFIGURE_TASK_STACK_DEALLOCATOR NULL |
| 836 | #if !defined(CONFIGURE_TASK_STACK_ALLOCATOR) \ |
| 837 | && !defined(CONFIGURE_TASK_STACK_DEALLOCATOR) |
| 838 | #define CONFIGURE_TASK_STACK_ALLOCATOR _Workspace_Allocate |
| 839 | #define CONFIGURE_TASK_STACK_DEALLOCATOR _Workspace_Free |
| 840 | #elif (defined(CONFIGURE_TASK_STACK_ALLOCATOR) \ |
| 841 | && !defined(CONFIGURE_TASK_STACK_DEALLOCATOR)) \ |
| 842 | || (!defined(CONFIGURE_TASK_STACK_ALLOCATOR) \ |
| 843 | && defined(CONFIGURE_TASK_STACK_DEALLOCATOR)) |
| 844 | #error "CONFIGURE_TASK_STACK_ALLOCATOR and CONFIGURE_TASK_STACK_DEALLOCATOR must be both defined or both undefined" |
837 | 845 | #endif |
838 | 846 | |
839 | 847 | /** |
… |
… |
|
869 | 877 | #endif |
870 | 878 | |
871 | 879 | #ifdef CONFIGURE_UNIFIED_WORK_AREAS |
872 | | #include <rtems/score/wkspace.h> |
873 | 880 | Heap_Control *RTEMS_Malloc_Heap = &_Workspace_Area; |
874 | 881 | #else |
875 | 882 | Heap_Control RTEMS_Malloc_Area; |
… |
… |
|
929 | 936 | (ssize_t)((_size) + HEAP_BLOCK_HEADER_SIZE + CPU_HEAP_ALIGNMENT - 1) |
930 | 937 | |
931 | 938 | /** |
| 939 | * This is a helper macro used in stack space calculations in this file. It |
| 940 | * may be provided by the application in case a special task stack allocator |
| 941 | * is used. The default is allocation from the RTEMS Workspace. |
| 942 | */ |
| 943 | #ifdef CONFIGURE_TASK_STACK_FROM_ALLOCATOR |
| 944 | #define _Configure_From_stackspace(_stack_size) \ |
| 945 | CONFIGURE_TASK_STACK_FROM_ALLOCATOR(_stack_size) |
| 946 | #else |
| 947 | #define _Configure_From_stackspace(_stack_size) \ |
| 948 | _Configure_From_workspace(_stack_size) |
| 949 | #endif |
| 950 | |
| 951 | /** |
932 | 952 | * Do not use the unlimited bit as part of the multiplication |
933 | 953 | * for memory usage. |
934 | 954 | */ |
… |
… |
|
2051 | 2071 | |
2052 | 2072 | #define CONFIGURE_IDLE_TASKS_STACK \ |
2053 | 2073 | (CONFIGURE_IDLE_TASKS_COUNT * \ |
2054 | | _Configure_From_workspace( CONFIGURE_IDLE_TASK_STACK_SIZE ) ) |
| 2074 | _Configure_From_stackspace( CONFIGURE_IDLE_TASK_STACK_SIZE ) ) |
2055 | 2075 | |
2056 | 2076 | #define CONFIGURE_TASKS_STACK \ |
2057 | 2077 | (_Configure_Max_Objects( CONFIGURE_MAXIMUM_TASKS ) * \ |
2058 | | _Configure_From_workspace( CONFIGURE_MINIMUM_TASK_STACK_SIZE ) ) |
| 2078 | _Configure_From_stackspace( CONFIGURE_MINIMUM_TASK_STACK_SIZE ) ) |
2059 | 2079 | |
2060 | 2080 | #define CONFIGURE_POSIX_THREADS_STACK \ |
2061 | 2081 | (_Configure_Max_Objects( CONFIGURE_MAXIMUM_POSIX_THREADS ) * \ |
2062 | | _Configure_From_workspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) ) |
| 2082 | _Configure_From_stackspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) ) |
2063 | 2083 | |
2064 | 2084 | #define CONFIGURE_GOROUTINES_STACK \ |
2065 | 2085 | (_Configure_Max_Objects( CONFIGURE_MAXIMUM_GOROUTINES ) * \ |
2066 | | _Configure_From_workspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) ) |
| 2086 | _Configure_From_stackspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) ) |
2067 | 2087 | |
2068 | 2088 | #define CONFIGURE_ADA_TASKS_STACK \ |
2069 | 2089 | (_Configure_Max_Objects( CONFIGURE_MAXIMUM_ADA_TASKS ) * \ |
2070 | | _Configure_From_workspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) ) |
| 2090 | _Configure_From_stackspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) ) |
2071 | 2091 | |
2072 | 2092 | #else /* CONFIGURE_EXECUTIVE_RAM_SIZE */ |
2073 | 2093 | |
… |
… |
|
2180 | 2200 | CONFIGURE_IDLE_TASK_BODY, /* user's IDLE task */ |
2181 | 2201 | CONFIGURE_IDLE_TASK_STACK_SIZE, /* IDLE task stack size */ |
2182 | 2202 | CONFIGURE_INTERRUPT_STACK_SIZE, /* interrupt stack size */ |
| 2203 | CONFIGURE_TASK_STACK_ALLOCATOR_INIT, /* stack allocator init */ |
2183 | 2204 | CONFIGURE_TASK_STACK_ALLOCATOR, /* stack allocator */ |
2184 | 2205 | CONFIGURE_TASK_STACK_DEALLOCATOR, /* stack deallocator */ |
2185 | 2206 | CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY, /* true to clear memory */ |
RCS file: /usr1/CVS/rtems/cpukit/sapi/include/rtems/config.h,v
retrieving revision 1.57
diff -u -r1.57 config.h
|
|
|
84 | 84 | } rtems_multiprocessing_table; |
85 | 85 | #endif |
86 | 86 | |
| 87 | /** |
| 88 | * @brief Task stack allocator initialization hook. |
| 89 | * |
| 90 | * @param[in] stack_space_size Size of the stack space in bytes. |
| 91 | */ |
| 92 | typedef void (*rtems_stack_allocate_init_hook)( size_t stack_space_size ); |
| 93 | |
| 94 | /** |
| 95 | * @brief Task stack allocator hook. |
| 96 | * |
| 97 | * @param[in] stack_size Size of the task stack in bytes. |
| 98 | * |
| 99 | * @retval NULL Not enough memory. |
| 100 | * @retval other Pointer to task stack. |
| 101 | */ |
| 102 | typedef void *(*rtems_stack_allocate_hook)( size_t stack_size ); |
| 103 | |
| 104 | /** |
| 105 | * @brief Task stack deallocator hook. |
| 106 | * |
| 107 | * @param[in] addr Pointer to previously allocated task stack. |
| 108 | */ |
| 109 | typedef void (*rtems_stack_free_hook)( void *addr ); |
| 110 | |
87 | 111 | /* |
88 | 112 | * The following records define the Configuration Table. The |
89 | 113 | * information contained in this table is required in all |
… |
… |
|
139 | 163 | */ |
140 | 164 | uint32_t interrupt_stack_size; |
141 | 165 | |
142 | | /** The BSP may want to provide it's own stack allocation routines. |
143 | | * In this case, the BSP will provide this stack allocation hook. |
| 166 | /** |
| 167 | * @brief Optional task stack allocator initialization hook. |
144 | 168 | */ |
145 | | void * (*stack_allocate_hook)( size_t ); |
| 169 | rtems_stack_allocate_init_hook stack_allocate_init_hook; |
146 | 170 | |
147 | | /** The BSP may want to provide it's own stack free routines. |
148 | | * In this case, the BSP will provide this stack free hook. |
| 171 | /** |
| 172 | * @brief Optional task stack allocator hook. |
149 | 173 | */ |
150 | | void (*stack_free_hook)( void *); |
| 174 | rtems_stack_allocate_hook stack_allocate_hook; |
| 175 | |
| 176 | /** |
| 177 | * @brief Optional task stack free hook. |
| 178 | */ |
| 179 | rtems_stack_free_hook stack_free_hook; |
151 | 180 | |
152 | 181 | /** If this element is TRUE, then RTEMS will zero the Executive Workspace. |
153 | 182 | * When this element is FALSE, it is assumed that the BSP or invoking |
… |
… |
|
268 | 297 | #define rtems_configuration_get_interrupt_stack_size() \ |
269 | 298 | (Configuration.interrupt_stack_size) |
270 | 299 | |
| 300 | #define rtems_configuration_get_stack_allocate_init_hook() \ |
| 301 | (Configuration.stack_allocate_init_hook) |
| 302 | |
271 | 303 | #define rtems_configuration_get_stack_allocate_hook() \ |
272 | 304 | (Configuration.stack_allocate_hook) |
273 | 305 | |
RCS file: /usr1/CVS/rtems/cpukit/score/src/thread.c,v
retrieving revision 1.68
diff -u -r1.68 thread.c
|
|
|
49 | 49 | |
50 | 50 | void _Thread_Handler_initialization(void) |
51 | 51 | { |
52 | | uint32_t ticks_per_timeslice; |
53 | | uint32_t maximum_extensions; |
| 52 | uint32_t ticks_per_timeslice = |
| 53 | rtems_configuration_get_ticks_per_timeslice(); |
| 54 | uint32_t maximum_extensions = |
| 55 | rtems_configuration_get_maximum_extensions(); |
| 56 | rtems_stack_allocate_init_hook stack_allocate_init_hook = |
| 57 | rtems_configuration_get_stack_allocate_init_hook(); |
54 | 58 | uint32_t maximum_internal_threads; |
55 | 59 | #if defined(RTEMS_MULTIPROCESSING) |
56 | | uint32_t maximum_proxies; |
| 60 | uint32_t maximum_proxies = |
| 61 | _Configuration_MP_table->maximum_proxies; |
57 | 62 | #endif |
58 | 63 | |
59 | | ticks_per_timeslice = Configuration.ticks_per_timeslice; |
60 | | maximum_extensions = Configuration.maximum_extensions; |
61 | | #if defined(RTEMS_MULTIPROCESSING) |
62 | | maximum_proxies = _Configuration_MP_table->maximum_proxies; |
63 | | #endif |
64 | | /* |
65 | | * BOTH stacks hooks must be set or both must be NULL. |
66 | | * Do not allow mixture. |
67 | | */ |
68 | | if ( !( (!Configuration.stack_allocate_hook) |
69 | | == (!Configuration.stack_free_hook) ) ) |
| 64 | if ( rtems_configuration_get_stack_allocate_hook() == NULL || |
| 65 | rtems_configuration_get_stack_free_hook() == NULL) |
70 | 66 | _Internal_error_Occurred( |
71 | 67 | INTERNAL_ERROR_CORE, |
72 | 68 | true, |
73 | 69 | INTERNAL_ERROR_BAD_STACK_HOOK |
74 | 70 | ); |
75 | 71 | |
| 72 | if ( stack_allocate_init_hook != NULL ) |
| 73 | (*stack_allocate_init_hook)( rtems_configuration_get_stack_space_size() ); |
| 74 | |
76 | 75 | _Thread_Dispatch_necessary = false; |
77 | 76 | _Thread_Executing = NULL; |
78 | 77 | _Thread_Heir = NULL; |
RCS file: /usr1/CVS/rtems/cpukit/score/src/threadstackallocate.c,v
retrieving revision 1.15
diff -u -r1.15 threadstackallocate.c
|
|
|
46 | 46 | { |
47 | 47 | void *stack_addr = 0; |
48 | 48 | size_t the_stack_size; |
| 49 | rtems_stack_allocate_hook stack_allocate_hook = |
| 50 | rtems_configuration_get_stack_allocate_hook(); |
49 | 51 | |
50 | 52 | the_stack_size = _Stack_Ensure_minimum( stack_size ); |
51 | 53 | |
52 | 54 | /* |
53 | | * Call ONLY the CPU table stack allocate hook, _or_ the |
54 | | * the RTEMS workspace allocate. This is so the stack free |
55 | | * routine can call the correct deallocation routine. |
| 55 | * Pad the requested size so we allocate enough memory |
| 56 | * so the context initialization can align it properly. The address |
| 57 | * returned the workspace allocate must be directly stored in the |
| 58 | * stack control block because it is later used in the free sequence. |
| 59 | * |
| 60 | * Thus it is the responsibility of the CPU dependent code to |
| 61 | * get and keep the stack adjust factor, the stack alignment, and |
| 62 | * the context initialization sequence in sync. |
56 | 63 | */ |
| 64 | the_stack_size = _Stack_Adjust_size( the_stack_size ); |
57 | 65 | |
58 | | if ( Configuration.stack_allocate_hook ) { |
59 | | stack_addr = (*Configuration.stack_allocate_hook)( the_stack_size ); |
60 | | } else { |
61 | | |
62 | | /* |
63 | | * First pad the requested size so we allocate enough memory |
64 | | * so the context initialization can align it properly. The address |
65 | | * returned the workspace allocate must be directly stored in the |
66 | | * stack control block because it is later used in the free sequence. |
67 | | * |
68 | | * Thus it is the responsibility of the CPU dependent code to |
69 | | * get and keep the stack adjust factor, the stack alignment, and |
70 | | * the context initialization sequence in sync. |
71 | | */ |
72 | | |
73 | | the_stack_size = _Stack_Adjust_size( the_stack_size ); |
74 | | stack_addr = _Workspace_Allocate( the_stack_size ); |
75 | | } |
| 66 | stack_addr = (*stack_allocate_hook)( the_stack_size ); |
76 | 67 | |
77 | 68 | if ( !stack_addr ) |
78 | 69 | the_stack_size = 0; |
RCS file: /usr1/CVS/rtems/cpukit/score/src/threadstackfree.c,v
retrieving revision 1.8
diff -u -r1.8 threadstackfree.c
|
|
|
41 | 41 | Thread_Control *the_thread |
42 | 42 | ) |
43 | 43 | { |
| 44 | rtems_stack_free_hook stack_free_hook = |
| 45 | rtems_configuration_get_stack_free_hook(); |
| 46 | |
44 | 47 | #if defined(RTEMS_SCORE_THREAD_ENABLE_USER_PROVIDED_STACK_VIA_API) |
45 | 48 | /* |
46 | 49 | * If the API provided the stack space, then don't free it. |
… |
… |
|
55 | 58 | * routine properly matches the allocation of the stack. |
56 | 59 | */ |
57 | 60 | |
58 | | if ( Configuration.stack_free_hook ) |
59 | | (*Configuration.stack_free_hook)( the_thread->Start.Initial_stack.area ); |
60 | | else |
61 | | _Workspace_Free( the_thread->Start.Initial_stack.area ); |
| 61 | (*stack_free_hook)( the_thread->Start.Initial_stack.area ); |
62 | 62 | } |