RTEMS 6.1-rc4
Loading...
Searching...
No Matches
ts-default.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
12/*
13 * Copyright (C) 2020 embedded brains GmbH & Co. KG
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#include <bsp.h>
38#include <rtems/bspIo.h>
39#include <rtems/chain.h>
40#include <rtems/test-info.h>
41#include <rtems/testopts.h>
42
43#include <rtems/test.h>
45
46#include "ts-config.h"
47#include "tx-support.h"
48
49#if !defined( MAX_TLS_SIZE )
50#define MAX_TLS_SIZE TEST_MAXIMUM_TLS_SIZE
51#endif
52
53#define MAX_TASKS ( TEST_MAXIMUM_TASKS - 1 )
54
55#define TASK_ATTRIBUTES RTEMS_FLOATING_POINT
56
57#define TASK_STORAGE_SIZE \
58 RTEMS_TASK_STORAGE_SIZE( \
59 MAX_TLS_SIZE + TEST_MINIMUM_STACK_SIZE + \
60 CPU_STACK_ALIGNMENT - CPU_HEAP_ALIGNMENT, \
61 TASK_ATTRIBUTES \
62 )
63
64static char buffer[ 512 ];
65
66static const T_action actions[] = {
67 T_report_hash_sha256,
68 T_memory_action,
69 T_check_task_context,
70 T_check_rtems_barriers,
71 T_check_rtems_extensions,
72 T_check_rtems_message_queues,
73 T_check_rtems_partitions,
74 T_check_rtems_periods,
75 T_check_rtems_semaphores,
76 T_check_rtems_tasks,
77 T_check_rtems_timers
78};
79
80static const T_config test_config = {
81 .name = rtems_test_name,
82 .buf = buffer,
83 .buf_size = sizeof( buffer ),
84 .putchar = rtems_put_char,
85 .verbosity = RTEMS_TEST_VERBOSITY,
86#if defined(CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER)
87 .now = T_now_clock,
88#else
89 .now = T_now_tick,
90#endif
91 .allocate = T_memory_allocate,
92 .deallocate = T_memory_deallocate,
93 .action_count = T_ARRAY_SIZE( actions ),
94 .actions = actions
95};
96
97static rtems_chain_control free_task_storage =
98 RTEMS_CHAIN_INITIALIZER_EMPTY( free_task_storage );
99
100static union {
102 storage[ TASK_STORAGE_SIZE ];
103 rtems_chain_node node;
104} task_storage[ MAX_TASKS ];
105
106rtems_task_argument test_runner_argument;
107
108rtems_task_priority test_runner_initial_priority;
109
110rtems_mode test_runner_initial_modes;
111
112static void Runner( rtems_task_argument arg )
113{
114 int exit_code;
115
116 test_runner_argument = arg;
117
118 (void) rtems_task_mode(
119 RTEMS_ASR,
121 &test_runner_initial_modes
122 );
123
127 &test_runner_initial_priority
128 );
129
130 rtems_chain_initialize(
131 &free_task_storage,
132 task_storage,
133 RTEMS_ARRAY_SIZE( task_storage ),
134 sizeof( task_storage[ 0 ] )
135 );
136
137 rtems_test_begin( rtems_test_name, TEST_STATE );
138 T_register();
139 exit_code = T_main( &test_config );
140
141 if ( exit_code == 0 ) {
143 }
144
145 rtems_fatal( RTEMS_FATAL_SOURCE_EXIT, (uint32_t) exit_code );
146}
147
148void *test_task_stack_allocate( size_t size )
149{
150 if ( size > sizeof( task_storage[ 0 ] ) ) {
151 return NULL;
152 }
153
154 T_quiet_ge_sz( size, TEST_MINIMUM_STACK_SIZE );
155
156 return rtems_chain_get_unprotected( &free_task_storage );
157}
158
159void test_task_stack_deallocate( void *stack )
160{
161 rtems_chain_append_unprotected(
162 &free_task_storage,
163 (rtems_chain_node *) stack
164 );
165}
166
167#if !defined( CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER )
168#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
169#endif
170
171#define CONFIGURE_MINIMUM_TASK_STACK_SIZE TEST_MINIMUM_STACK_SIZE
172
173#define CONFIGURE_INTERRUPT_STACK_SIZE TEST_INTERRUPT_STACK_SIZE
174
175#define CONFIGURE_MAXIMUM_BARRIERS TEST_MAXIMUM_BARRIERS
176
177#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES TEST_MAXIMUM_MESSAGE_QUEUES
178
179#define CONFIGURE_MAXIMUM_PARTITIONS TEST_MAXIMUM_PARTITIONS
180
181#define CONFIGURE_MAXIMUM_PERIODS TEST_MAXIMUM_PERIODS
182
183#define CONFIGURE_MAXIMUM_SEMAPHORES TEST_MAXIMUM_SEMAPHORES
184
185#define CONFIGURE_MAXIMUM_TASKS TEST_MAXIMUM_TASKS
186
187#define CONFIGURE_MINIMUM_TASKS_WITH_USER_PROVIDED_STORAGE \
188 CONFIGURE_MAXIMUM_TASKS
189
190#define CONFIGURE_MAXIMUM_TIMERS TEST_MAXIMUM_TIMERS
191
192#define CONFIGURE_MAXIMUM_USER_EXTENSIONS TEST_MAXIMUM_USER_EXTENSIONS
193
194#define CONFIGURE_MICROSECONDS_PER_TICK TEST_MICROSECONDS_PER_TICK
195
196#define CONFIGURE_TICKS_PER_TIMESLICE TEST_TICKS_PER_TIMESLICE
197
198#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 0
199
200#define CONFIGURE_DISABLE_NEWLIB_REENTRANCY
201
202#define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
203
204#define CONFIGURE_MAXIMUM_THREAD_LOCAL_STORAGE_SIZE MAX_TLS_SIZE
205
206#define CONFIGURE_TASK_STACK_ALLOCATOR_AVOIDS_WORK_SPACE
207
208#define CONFIGURE_TASK_STACK_ALLOCATOR test_task_stack_allocate
209
210#define CONFIGURE_TASK_STACK_DEALLOCATOR test_task_stack_deallocate
211
212#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
213
214#define CONFIGURE_INIT_TASK_ARGUMENTS TEST_RUNNER_ARGUMENT
215
216#define CONFIGURE_INIT_TASK_ATTRIBUTES ( RTEMS_SYSTEM_TASK | TASK_ATTRIBUTES )
217
218#define CONFIGURE_INIT_TASK_CONSTRUCT_STORAGE_SIZE TASK_STORAGE_SIZE
219
220#define CONFIGURE_INIT_TASK_ENTRY_POINT Runner
221
222#define CONFIGURE_INIT_TASK_INITIAL_MODES TEST_RUNNER_INITIAL_MODES
223
224#define CONFIGURE_INIT_TASK_NAME TEST_RUNNER_NAME
225
226#define CONFIGURE_INIT_TASK_PRIORITY 0
227
228#if !defined( CONFIGURE_INITIAL_EXTENSIONS )
229#define CONFIGURE_INITIAL_EXTENSIONS { .fatal = FatalInitialExtension }
230#endif
231
232#if defined( RTEMS_SMP ) && \
233 ( CONFIGURE_MAXIMUM_PROCESSORS == 4 || CONFIGURE_MAXIMUM_PROCESSORS == 5 )
234
236
238T_scheduler_operations[ CONFIGURE_MAXIMUM_PROCESSORS ] = {
239 SCHEDULER_EDF_SMP_ENTRY_POINTS,
240 SCHEDULER_EDF_SMP_ENTRY_POINTS,
241 SCHEDULER_EDF_SMP_ENTRY_POINTS,
242#if CONFIGURE_MAXIMUM_PROCESSORS >= 5
243 SCHEDULER_EDF_SMP_ENTRY_POINTS,
244#endif
245 SCHEDULER_EDF_SMP_ENTRY_POINTS
246};
247
248#undef SCHEDULER_EDF_SMP_ENTRY_POINTS
249
250#define SCHEDULER_EDF_SMP_ENTRY_POINTS T_SCHEDULER_ENTRY_POINTS
251
252#define CONFIGURE_SCHEDULER_EDF_SMP
253
254#include <rtems/scheduler.h>
255
257
259
261
263
264#define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
265 RTEMS_SCHEDULER_TABLE_EDF_SMP( a, TEST_SCHEDULER_A_NAME ), \
266 RTEMS_SCHEDULER_TABLE_EDF_SMP( b, TEST_SCHEDULER_B_NAME ), \
267 RTEMS_SCHEDULER_TABLE_EDF_SMP( c, TEST_SCHEDULER_C_NAME ), \
268 RTEMS_SCHEDULER_TABLE_EDF_SMP( d, TEST_SCHEDULER_D_NAME )
269
270#if CONFIGURE_MAXIMUM_PROCESSORS == 5
271#define CONFIGURE_SCHEDULER_ASSIGNMENTS \
272 RTEMS_SCHEDULER_ASSIGN(0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY), \
273 RTEMS_SCHEDULER_ASSIGN(1, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL), \
274 RTEMS_SCHEDULER_ASSIGN(2, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL), \
275 RTEMS_SCHEDULER_ASSIGN(2, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL), \
276 RTEMS_SCHEDULER_ASSIGN_NO_SCHEDULER
277#else
278#define CONFIGURE_SCHEDULER_ASSIGNMENTS \
279 RTEMS_SCHEDULER_ASSIGN(0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY), \
280 RTEMS_SCHEDULER_ASSIGN(1, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL), \
281 RTEMS_SCHEDULER_ASSIGN(2, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL), \
282 RTEMS_SCHEDULER_ASSIGN(2, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL)
283#endif
284
285#elif !defined( CONFIGURE_SCHEDULER_ASSIGNMENTS )
286
288
289#undef CONFIGURE_MAXIMUM_PROCESSORS
290#define CONFIGURE_MAXIMUM_PROCESSORS 1
291
293T_scheduler_operations[ CONFIGURE_MAXIMUM_PROCESSORS ] = {
295};
296
297#undef SCHEDULER_PRIORITY_ENTRY_POINTS
298
299#define SCHEDULER_PRIORITY_ENTRY_POINTS T_SCHEDULER_ENTRY_POINTS
300
301#define CONFIGURE_SCHEDULER_PRIORITY
302
303#if defined(CONFIGURE_SCHEDULER_TABLE_ENTRIES)
304
305#include <rtems/scheduler.h>
306
308
309#else /* CONFIGURE_SCHEDULER_TABLE_ENTRIES */
310
311#define CONFIGURE_SCHEDULER_NAME TEST_SCHEDULER_A_NAME
312
313#define CONFIGURE_MAXIMUM_PRIORITY 127
314
315#endif /* CONFIGURE_SCHEDULER_TABLE_ENTRIES */
316
317#endif
318
319#define CONFIGURE_IDLE_TASK_STACK_SIZE TEST_IDLE_STACK_SIZE
320
321static char test_idle_stacks[ CONFIGURE_MAXIMUM_PROCESSORS ][
323 MAX_TLS_SIZE + TEST_IDLE_STACK_SIZE + CPU_IDLE_TASK_IS_FP * CONTEXT_FP_SIZE,
324 CPU_INTERRUPT_STACK_ALIGNMENT
325 )
326]
327RTEMS_ALIGNED( CPU_INTERRUPT_STACK_ALIGNMENT )
328RTEMS_SECTION( ".rtemsstack.idle" );
329
330void *test_idle_task_stack_allocate( uint32_t cpu_index, size_t *size )
331{
332 if ( *size > sizeof( test_idle_stacks[ 0 ] ) ) {
333 rtems_fatal( RTEMS_FATAL_SOURCE_APPLICATION, 0xABAD1DEA );
334 }
335
336 return &test_idle_stacks[ cpu_index ][0];
337}
338
339#define CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE test_idle_task_stack_allocate
340
341#define CONFIGURE_INIT
342
343#include <rtems/confdefs.h>
#define MAX_TASKS
Maximum number of tasks in the system. This number is hardware-dependent and not user configuration.
Definition: bestcomm_api.h:71
This header file provides the kernel character input/output support API.
This header file provides the Chains API.
This header file evaluates the application configuration options defined by the application.
#define RTEMS_ALIGN_UP(_value, _alignment)
Aligns up the value to the alignment.
Definition: basedefs.h:141
#define RTEMS_SECTION(_section)
Instructs the compiler to place the variable or function in the section.
Definition: basedefs.h:411
#define RTEMS_ALIGNED(_alignment)
Instructs the compiler in a declaration or definition to enforce the alignment.
Definition: basedefs.h:157
#define RTEMS_ARRAY_SIZE(_array)
Gets the element count of the array.
Definition: basedefs.h:244
#define RTEMS_CHAIN_INITIALIZER_EMPTY(name)
Chain initializer for an empty chain with designator name.
Definition: chain.h:67
#define RTEMS_ASR_MASK
This mode constant corresponds to the signal enable/disable bit.
Definition: modes.h:101
#define RTEMS_ASR
This task mode constant indicates that signal processing is disabled.
Definition: modes.h:92
uint32_t rtems_mode
This type represents a Classic API task mode set.
Definition: modes.h:174
#define RTEMS_SELF
This compile time constant may be used to identify the calling task in task related directives.
Definition: tasks.h:351
#define RTEMS_TASK_STORAGE_ALIGNMENT
This compile time constant defines the recommended alignment of a task storage area in bytes.
Definition: tasks.h:365
rtems_status_code rtems_task_mode(rtems_mode mode_set, rtems_mode mask, rtems_mode *previous_mode_set)
Gets and optionally sets the mode of the calling task.
Definition: taskmode.c:50
rtems_status_code rtems_task_set_priority(rtems_id id, rtems_task_priority new_priority, rtems_task_priority *old_priority)
Sets the real priority or gets the current priority of the task.
Definition: tasksetpriority.c:82
CPU_Uint32ptr rtems_task_argument
This integer type represents task argument values.
Definition: tasks.h:100
uint32_t rtems_task_priority
This integer type represents task priorities of the Classic API.
Definition: types.h:257
void rtems_put_char(int c, void *unused)
Puts the character using rtems_putc()
Definition: rtems_put_char.c:42
#define RTEMS_SCHEDULER_EDF_SMP(name)
Defines an EDF SMP Scheduler instantiation.
Definition: scheduler.h:259
#define RTEMS_SCHEDULER_PRIORITY(name, prio_count)
Defines a Deterministic Priority Scheduler instantiation.
Definition: scheduler.h:324
#define CONFIGURE_MAXIMUM_PROCESSORS
This configuration option is an integer define.
Definition: appl-config.h:2967
#define CONTEXT_FP_SIZE
Size of floating point context area.
Definition: context.h:70
@ RTEMS_FATAL_SOURCE_APPLICATION
Fatal source for application specific errors.
Definition: interr.h:93
@ RTEMS_FATAL_SOURCE_EXIT
Fatal source of exit().
Definition: interr.h:100
#define SCHEDULER_PRIORITY_ENTRY_POINTS
Definition: schedulerpriority.h:64
#define PRIO_DEFAULT
This constants represents the default priority of the runner task.
Definition: tx-support.h:70
const char rtems_test_name[]
Each test must define a test name string.
Definition: init.c:6899
int rtems_test_begin(const char *name, const RTEMS_TEST_STATE state)
Prints a begin of test message using printf().
Definition: testbeginend.c:56
int rtems_test_end(const char *name)
Prints an end of test message using printf().
Definition: testbeginend.c:93
This header file provides the interfaces of the Earliest Deadline First (EDF) Priority SMP Scheduler.
This header file provides interfaces of the Deterministic Priority Scheduler which are used by the im...
This structure represents a chain node.
Definition: chain.h:78
The scheduler operations.
Definition: scheduler.h:62
Definition: test.h:2295
This header file provides interfaces of the RTEMS Test Support.
This header file defines the scheduler test support API.
This header file provides interfaces of the RTEMS Test Framework.
This header file provides the constants used by the test suite configuration.
This header file provides the support functions for the validation test cases.
This union represents a chain control block.
Definition: chain.h:96