RTEMS
ts-space-profile.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 
9 /*
10  * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  * notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  * notice, this list of conditions and the following disclaimer in the
19  * documentation and/or other materials provided with the distribution.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 /*
35  * Do not manually edit this file. It is part of the RTEMS quality process
36  * and was automatically generated.
37  *
38  * If you find something that needs to be fixed or worded better please
39  * post a report to an RTEMS mailing list or raise a bug report:
40  *
41  * https://docs.rtems.org/branches/master/user/support/bugs.html
42  *
43  * For information on updating and regenerating please refer to:
44  *
45  * https://docs.rtems.org/branches/master/eng/req/howto.html
46  */
47 
48 #ifdef HAVE_CONFIG_H
49 #include "config.h"
50 #endif
51 
52 #include <rtems.h>
53 #include <rtems/bspIo.h>
54 #include <rtems/sysinit.h>
55 #include <rtems/score/sysstate.h>
56 
57 #include <rtems/test.h>
58 
71 #define NAME rtems_build_name('N', 'A', 'M', 'E')
72 
73 static void fatal_extension(
74  rtems_fatal_source source,
75  bool always_set_to_false,
76  rtems_fatal_code error
77 )
78 {
79  T_make_runner();
80  T_step_eq_int(0, source, RTEMS_FATAL_SOURCE_APPLICATION);
81  T_step_false(1, always_set_to_false, "always_set_to_false");
82  T_step_eq_ulong(2, error, 123);
83  T_case_end();
84  T_run_finalize();
85 }
86 
87 static void Init(rtems_task_argument arg)
88 {
89  (void) arg;
90 
91  T_make_runner();
92  T_register();
93  T_run_all();
94  T_case_begin("SpaceProfileFatalError", NULL);
95  T_plan(3);
97 }
98 
99 #define INIT_TASK_ATTRIBUTES RTEMS_DEFAULT_ATTRIBUTES
100 
101 #define MAX_TLS_SIZE RTEMS_ALIGN_UP(64, RTEMS_TASK_STORAGE_ALIGNMENT)
102 
103 RTEMS_ALIGNED(RTEMS_TASK_STORAGE_ALIGNMENT) static char init_task_storage[
105  MAX_TLS_SIZE + RTEMS_MINIMUM_STACK_SIZE,
106  INIT_TASK_ATTRIBUTES
107  )
108 ];
109 
110 static char buffer[512];
111 
112 static void check_task_context(T_event event, const char *name)
113 {
115  T_check_task_context(event, name);
116  }
117 }
118 
119 static const T_action actions[] = {
120  T_report_hash_sha256,
121  check_task_context,
122  T_check_rtems_barriers,
123  T_check_rtems_extensions,
124  T_check_rtems_message_queues,
125  T_check_rtems_partitions,
126  T_check_rtems_periods,
127  T_check_rtems_semaphores,
128  T_check_rtems_tasks,
129  T_check_rtems_timers
130 };
131 
132 static const T_config test_config = {
133  .name = "SpaceProfile",
134  .buf = buffer,
135  .buf_size = sizeof(buffer),
136  .putchar = rtems_put_char,
137  .verbosity = T_VERBOSE,
138  .now = T_now_clock,
139  .action_count = T_ARRAY_SIZE(actions),
140  .actions = actions
141 };
142 
143 static const rtems_task_config task_config = {
144  .name = NAME,
145  .initial_priority = 1,
146  .storage_area = init_task_storage,
147  .storage_size = sizeof(init_task_storage),
148  .maximum_thread_local_storage_size = MAX_TLS_SIZE,
149  .initial_modes = RTEMS_DEFAULT_MODES,
150  .attributes = INIT_TASK_ATTRIBUTES
151 };
152 
153 static void init_task(void)
154 {
155  rtems_id id;
157 
158  T_run_initialize(&test_config);
159  T_case_begin("SpaceProfileTaskBuild", NULL);
160  T_plan(2);
161 
162  sc = rtems_task_construct(&task_config, &id);
163  T_step_rsc_success(0, sc);
164 
165  sc = rtems_task_start(id, Init, 0);
166  T_step_rsc_success(1, sc);
167 
168  T_check_rtems_tasks(T_EVENT_RUN_INITIALIZE_EARLY, T_case_name());
169  T_case_end();
170 }
171 
172 RTEMS_SYSINIT_ITEM(
173  init_task,
174  RTEMS_SYSINIT_CLASSIC_USER_TASKS,
175  RTEMS_SYSINIT_ORDER_MIDDLE
176 );
177 
178 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
179 
180 #define CONFIGURE_MAXIMUM_PROCESSORS 4
181 
182 #define CONFIGURE_MAXIMUM_BARRIERS 1
183 
184 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1
185 
186 #define CONFIGURE_MAXIMUM_PARTITIONS 1
187 
188 #define CONFIGURE_MAXIMUM_PERIODS 1
189 
190 #define CONFIGURE_MAXIMUM_SEMAPHORES 1
191 
192 #define CONFIGURE_MAXIMUM_TASKS 1
193 
194 #define CONFIGURE_MAXIMUM_TIMERS 1
195 
196 #define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
197 
198 #define CONFIGURE_MESSAGE_BUFFER_MEMORY 1
199 
200 #define CONFIGURE_MICROSECONDS_PER_TICK 10000
201 
202 #define CONFIGURE_SCHEDULER_NAME NAME
203 
204 #define CONFIGURE_INITIAL_EXTENSIONS { .fatal = fatal_extension }
205 
206 /* Mandatory for space profile */
207 
208 #define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 0
209 
210 #define CONFIGURE_DISABLE_NEWLIB_REENTRANCY
211 
212 #define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
213 
214 #define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION
215 
216 #define CONFIGURE_IDLE_TASK_BODY _CPU_Thread_Idle_body
217 
218 #define CONFIGURE_INIT
219 
220 #include <rtems/confdefs.h>
221 
static RTEMS_NO_RETURN void rtems_fatal(rtems_fatal_source fatal_source, rtems_fatal_code error_code)
%
Definition: fatal.h:162
static __inline__ bool _System_state_Is_up(System_state_Codes state)
Checks if the state is up.
Definition: sysstate.h:133
Evaluate Configuration Options.
rtems_name name
This member defines the name of the task.
Definition: tasks.h:138
This structure defines the configuration of a task constructed by rtems_task_construct().
Definition: tasks.h:134
rtems_status_code rtems_task_start(rtems_id id, rtems_task_entry entry_point, rtems_task_argument argument)
%
Definition: taskstart.c:25
CPU_Uint32ptr rtems_task_argument
This type is used to represent task argument values.
Definition: tasks.h:115
Internal_errors_Source
This type lists the possible sources from which an error can be reported.
Definition: interr.h:47
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:82
#define RTEMS_ALIGNED(_alignment)
Instructs the compiler in a declaration or definition to enforce the specified alignment.
Definition: basedefs.h:389
#define RTEMS_MINIMUM_STACK_SIZE
%
Definition: tasks.h:973
This header file defines the RTEMS Classic API.
Interface to Kernel Print Methods.
void rtems_put_char(int c, void *arg)
Puts the character via rtems_putc().
static __inline__ System_state_Codes _System_state_Get(void)
Gets the current system state.
Definition: sysstate.h:90
Internal_errors_t rtems_fatal_code
%
Definition: extension.h:132
#define RTEMS_TASK_STORAGE_SIZE(_size, _attributes)
Returns the recommended task storage area size for the specified size and task attributes.
Definition: tasks.h:1157
Objects_Id rtems_id
Values of this type identify an RTEMS object.
Definition: types.h:99
#define RTEMS_DEFAULT_MODES
This task mode constant represents the default mode set.
Definition: modes.h:137
System State Handler API.
Fatal source for application specific errors.
Definition: interr.h:77
rtems_status_code rtems_task_construct(const rtems_task_config *config, rtems_id *id)
Constructs a task from the specified the task configuration.
Definition: taskconstruct.c:73
#define RTEMS_TASK_STORAGE_ALIGNMENT
This constant defines the recommended alignment of a task storage area in bytes.
Definition: tasks.h:1135