1 | /* |
---|
2 | * Copyright (c) 2015 embedded brains GmbH. All rights reserved. |
---|
3 | * |
---|
4 | * embedded brains GmbH |
---|
5 | * Dornierstr. 4 |
---|
6 | * 82178 Puchheim |
---|
7 | * Germany |
---|
8 | * <rtems@embedded-brains.de> |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may be |
---|
11 | * found in the file LICENSE in this distribution or at |
---|
12 | * http://www.rtems.com/license/LICENSE. |
---|
13 | */ |
---|
14 | |
---|
15 | #ifdef HAVE_CONFIG_H |
---|
16 | #include "config.h" |
---|
17 | #endif |
---|
18 | |
---|
19 | #include <assert.h> |
---|
20 | #include <stdlib.h> |
---|
21 | |
---|
22 | #include <rtems.h> |
---|
23 | #include <rtems/libio_.h> |
---|
24 | #include <rtems/sysinit.h> |
---|
25 | #include <rtems/test.h> |
---|
26 | |
---|
27 | #include <rtems/extensionimpl.h> |
---|
28 | #include <rtems/rtems/messageimpl.h> |
---|
29 | #include <rtems/rtems/tasksimpl.h> |
---|
30 | #include <rtems/rtems/timerimpl.h> |
---|
31 | #include <rtems/score/apimutex.h> |
---|
32 | #include <rtems/score/sysstate.h> |
---|
33 | #include <rtems/score/userextimpl.h> |
---|
34 | #include <rtems/score/wkspace.h> |
---|
35 | |
---|
36 | const char rtems_test_name[] = "SPSYSINIT 1"; |
---|
37 | |
---|
38 | typedef enum { |
---|
39 | BSP_WORK_AREAS_PRE, |
---|
40 | BSP_WORK_AREAS_POST, |
---|
41 | BSP_START_PRE, |
---|
42 | BSP_START_POST, |
---|
43 | INITIAL_EXTENSIONS_PRE, |
---|
44 | INITIAL_EXTENSIONS_POST, |
---|
45 | DATA_STRUCTURES_PRE, |
---|
46 | DATA_STRUCTURES_POST, |
---|
47 | USER_EXTENSIONS_PRE, |
---|
48 | USER_EXTENSIONS_POST, |
---|
49 | CLASSIC_TASKS_PRE, |
---|
50 | CLASSIC_TASKS_POST, |
---|
51 | CLASSIC_TIMER_PRE, |
---|
52 | CLASSIC_TIMER_POST, |
---|
53 | CLASSIC_SIGNAL_PRE, |
---|
54 | CLASSIC_SIGNAL_POST, |
---|
55 | CLASSIC_EVENT_PRE, |
---|
56 | CLASSIC_EVENT_POST, |
---|
57 | CLASSIC_MESSAGE_QUEUE_PRE, |
---|
58 | CLASSIC_MESSAGE_QUEUE_POST, |
---|
59 | IDLE_THREADS_PRE, |
---|
60 | IDLE_THREADS_POST, |
---|
61 | BSP_LIBC_PRE, |
---|
62 | BSP_LIBC_POST, |
---|
63 | BEFORE_DRIVERS_PRE, |
---|
64 | BEFORE_DRIVERS_POST, |
---|
65 | BSP_PRE_DRIVERS_PRE, |
---|
66 | BSP_PRE_DRIVERS_POST, |
---|
67 | DEVICE_DRIVERS_PRE, |
---|
68 | DEVICE_DRIVERS_POST, |
---|
69 | BSP_POST_DRIVERS_PRE, |
---|
70 | BSP_POST_DRIVERS_POST, |
---|
71 | INIT_TASK, |
---|
72 | DONE |
---|
73 | } init_step; |
---|
74 | |
---|
75 | #define FIRST(x) \ |
---|
76 | static void x##_first(void); \ |
---|
77 | RTEMS_SYSINIT_ITEM( \ |
---|
78 | x##_first, \ |
---|
79 | x, \ |
---|
80 | RTEMS_SYSINIT_ORDER_FIRST \ |
---|
81 | ); \ |
---|
82 | static void x##_first(void) |
---|
83 | |
---|
84 | #define LAST(x) \ |
---|
85 | static void x##_last(void); \ |
---|
86 | RTEMS_SYSINIT_ITEM( \ |
---|
87 | x##_last, \ |
---|
88 | x, \ |
---|
89 | RTEMS_SYSINIT_ORDER_LAST \ |
---|
90 | ); \ |
---|
91 | static void x##_last(void) |
---|
92 | |
---|
93 | static init_step step; |
---|
94 | |
---|
95 | static void next_step(init_step expected) |
---|
96 | { |
---|
97 | assert(step == expected); |
---|
98 | step = expected + 1; |
---|
99 | } |
---|
100 | |
---|
101 | FIRST(RTEMS_SYSINIT_BSP_WORK_AREAS) |
---|
102 | { |
---|
103 | rtems_test_begink(); |
---|
104 | assert(_Workspace_Area.area_begin == 0); |
---|
105 | next_step(BSP_WORK_AREAS_PRE); |
---|
106 | } |
---|
107 | |
---|
108 | LAST(RTEMS_SYSINIT_BSP_WORK_AREAS) |
---|
109 | { |
---|
110 | assert(_Workspace_Area.area_begin != 0); |
---|
111 | next_step(BSP_WORK_AREAS_POST); |
---|
112 | } |
---|
113 | |
---|
114 | FIRST(RTEMS_SYSINIT_BSP_START) |
---|
115 | { |
---|
116 | /* |
---|
117 | * Since the work performed here is BSP-specific, there is no way to test pre |
---|
118 | * and post conditions. |
---|
119 | */ |
---|
120 | next_step(BSP_START_PRE); |
---|
121 | } |
---|
122 | |
---|
123 | LAST(RTEMS_SYSINIT_BSP_START) |
---|
124 | { |
---|
125 | next_step(BSP_START_POST); |
---|
126 | } |
---|
127 | |
---|
128 | FIRST(RTEMS_SYSINIT_INITIAL_EXTENSIONS) |
---|
129 | { |
---|
130 | assert(_Chain_Is_empty(&_User_extensions_Switches_list)); |
---|
131 | next_step(INITIAL_EXTENSIONS_PRE); |
---|
132 | } |
---|
133 | |
---|
134 | LAST(RTEMS_SYSINIT_INITIAL_EXTENSIONS) |
---|
135 | { |
---|
136 | assert(!_Chain_Is_empty(&_User_extensions_Switches_list)); |
---|
137 | next_step(INITIAL_EXTENSIONS_POST); |
---|
138 | } |
---|
139 | |
---|
140 | FIRST(RTEMS_SYSINIT_DATA_STRUCTURES) |
---|
141 | { |
---|
142 | assert(_RTEMS_Allocator_Mutex == NULL); |
---|
143 | next_step(DATA_STRUCTURES_PRE); |
---|
144 | } |
---|
145 | |
---|
146 | LAST(RTEMS_SYSINIT_DATA_STRUCTURES) |
---|
147 | { |
---|
148 | assert(_RTEMS_Allocator_Mutex != NULL); |
---|
149 | next_step(DATA_STRUCTURES_POST); |
---|
150 | } |
---|
151 | |
---|
152 | FIRST(RTEMS_SYSINIT_USER_EXTENSIONS) |
---|
153 | { |
---|
154 | assert(_Extension_Information.maximum == 0); |
---|
155 | next_step(USER_EXTENSIONS_PRE); |
---|
156 | } |
---|
157 | |
---|
158 | LAST(RTEMS_SYSINIT_USER_EXTENSIONS) |
---|
159 | { |
---|
160 | assert(_Extension_Information.maximum != 0); |
---|
161 | next_step(USER_EXTENSIONS_POST); |
---|
162 | } |
---|
163 | |
---|
164 | FIRST(RTEMS_SYSINIT_CLASSIC_TASKS) |
---|
165 | { |
---|
166 | assert(_RTEMS_tasks_Information.Objects.maximum == 0); |
---|
167 | next_step(CLASSIC_TASKS_PRE); |
---|
168 | } |
---|
169 | |
---|
170 | LAST(RTEMS_SYSINIT_CLASSIC_TASKS) |
---|
171 | { |
---|
172 | assert(_RTEMS_tasks_Information.Objects.maximum != 0); |
---|
173 | next_step(CLASSIC_TASKS_POST); |
---|
174 | } |
---|
175 | |
---|
176 | FIRST(RTEMS_SYSINIT_CLASSIC_TIMER) |
---|
177 | { |
---|
178 | assert(_Timer_Information.maximum == 0); |
---|
179 | next_step(CLASSIC_TIMER_PRE); |
---|
180 | } |
---|
181 | |
---|
182 | LAST(RTEMS_SYSINIT_CLASSIC_TIMER) |
---|
183 | { |
---|
184 | assert(_Timer_Information.maximum != 0); |
---|
185 | next_step(CLASSIC_TIMER_POST); |
---|
186 | } |
---|
187 | |
---|
188 | FIRST(RTEMS_SYSINIT_CLASSIC_SIGNAL) |
---|
189 | { |
---|
190 | /* There is nothing to do in case RTEMS_MULTIPROCESSING is not defined */ |
---|
191 | next_step(CLASSIC_SIGNAL_PRE); |
---|
192 | } |
---|
193 | |
---|
194 | LAST(RTEMS_SYSINIT_CLASSIC_SIGNAL) |
---|
195 | { |
---|
196 | next_step(CLASSIC_SIGNAL_POST); |
---|
197 | } |
---|
198 | |
---|
199 | FIRST(RTEMS_SYSINIT_CLASSIC_EVENT) |
---|
200 | { |
---|
201 | /* There is nothing to do in case RTEMS_MULTIPROCESSING is not defined */ |
---|
202 | next_step(CLASSIC_EVENT_PRE); |
---|
203 | } |
---|
204 | |
---|
205 | LAST(RTEMS_SYSINIT_CLASSIC_EVENT) |
---|
206 | { |
---|
207 | next_step(CLASSIC_EVENT_POST); |
---|
208 | } |
---|
209 | |
---|
210 | FIRST(RTEMS_SYSINIT_CLASSIC_MESSAGE_QUEUE) |
---|
211 | { |
---|
212 | assert(_Message_queue_Information.maximum == 0); |
---|
213 | next_step(CLASSIC_MESSAGE_QUEUE_PRE); |
---|
214 | } |
---|
215 | |
---|
216 | LAST(RTEMS_SYSINIT_CLASSIC_MESSAGE_QUEUE) |
---|
217 | { |
---|
218 | assert(_Message_queue_Information.maximum != 0); |
---|
219 | next_step(CLASSIC_MESSAGE_QUEUE_POST); |
---|
220 | } |
---|
221 | |
---|
222 | FIRST(RTEMS_SYSINIT_IDLE_THREADS) |
---|
223 | { |
---|
224 | assert(_System_state_Is_before_initialization(_System_state_Get())); |
---|
225 | next_step(IDLE_THREADS_PRE); |
---|
226 | } |
---|
227 | |
---|
228 | LAST(RTEMS_SYSINIT_IDLE_THREADS) |
---|
229 | { |
---|
230 | assert(_System_state_Is_before_multitasking(_System_state_Get())); |
---|
231 | next_step(IDLE_THREADS_POST); |
---|
232 | } |
---|
233 | |
---|
234 | FIRST(RTEMS_SYSINIT_BSP_LIBC) |
---|
235 | { |
---|
236 | assert(rtems_libio_semaphore == 0); |
---|
237 | next_step(BSP_LIBC_PRE); |
---|
238 | } |
---|
239 | |
---|
240 | LAST(RTEMS_SYSINIT_BSP_LIBC) |
---|
241 | { |
---|
242 | assert(rtems_libio_semaphore != 0); |
---|
243 | next_step(BSP_LIBC_POST); |
---|
244 | } |
---|
245 | |
---|
246 | FIRST(RTEMS_SYSINIT_BEFORE_DRIVERS) |
---|
247 | { |
---|
248 | /* Omit test of build configuration specific pre and post conditions */ |
---|
249 | next_step(BEFORE_DRIVERS_PRE); |
---|
250 | } |
---|
251 | |
---|
252 | LAST(RTEMS_SYSINIT_BEFORE_DRIVERS) |
---|
253 | { |
---|
254 | next_step(BEFORE_DRIVERS_POST); |
---|
255 | } |
---|
256 | |
---|
257 | FIRST(RTEMS_SYSINIT_BSP_PRE_DRIVERS) |
---|
258 | { |
---|
259 | /* |
---|
260 | * Since the work performed here is BSP-specific, there is no way to test pre |
---|
261 | * and post conditions. |
---|
262 | */ |
---|
263 | next_step(BSP_PRE_DRIVERS_PRE); |
---|
264 | } |
---|
265 | |
---|
266 | LAST(RTEMS_SYSINIT_BSP_PRE_DRIVERS) |
---|
267 | { |
---|
268 | next_step(BSP_PRE_DRIVERS_POST); |
---|
269 | } |
---|
270 | |
---|
271 | FIRST(RTEMS_SYSINIT_DEVICE_DRIVERS) |
---|
272 | { |
---|
273 | assert(!_IO_All_drivers_initialized); |
---|
274 | next_step(DEVICE_DRIVERS_PRE); |
---|
275 | } |
---|
276 | |
---|
277 | LAST(RTEMS_SYSINIT_DEVICE_DRIVERS) |
---|
278 | { |
---|
279 | assert(_IO_All_drivers_initialized); |
---|
280 | next_step(DEVICE_DRIVERS_POST); |
---|
281 | } |
---|
282 | |
---|
283 | FIRST(RTEMS_SYSINIT_BSP_POST_DRIVERS) |
---|
284 | { |
---|
285 | assert(rtems_libio_iop_freelist != NULL); |
---|
286 | next_step(BSP_POST_DRIVERS_PRE); |
---|
287 | } |
---|
288 | |
---|
289 | LAST(RTEMS_SYSINIT_BSP_POST_DRIVERS) |
---|
290 | { |
---|
291 | assert(rtems_libio_iop_freelist == NULL); |
---|
292 | next_step(BSP_POST_DRIVERS_POST); |
---|
293 | } |
---|
294 | |
---|
295 | static void Init(rtems_task_argument arg) |
---|
296 | { |
---|
297 | next_step(INIT_TASK); |
---|
298 | rtems_test_endk(); |
---|
299 | exit(0); |
---|
300 | } |
---|
301 | |
---|
302 | #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER |
---|
303 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
304 | |
---|
305 | #define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1 |
---|
306 | |
---|
307 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1 |
---|
308 | |
---|
309 | #define CONFIGURE_MAXIMUM_TASKS 1 |
---|
310 | |
---|
311 | #define CONFIGURE_MAXIMUM_TIMERS 1 |
---|
312 | |
---|
313 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
314 | |
---|
315 | #define CONFIGURE_STACK_CHECKER_ENABLED |
---|
316 | |
---|
317 | #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION |
---|
318 | |
---|
319 | #define CONFIGURE_INIT |
---|
320 | |
---|
321 | #include <rtems/confdefs.h> |
---|