1 | @c |
---|
2 | @c COPYRIGHT (c) 1988-2002. |
---|
3 | @c On-Line Applications Research Corporation (OAR). |
---|
4 | @c All rights reserved. |
---|
5 | @c |
---|
6 | @c $Id$ |
---|
7 | @c |
---|
8 | |
---|
9 | @chapter Initialization Manager |
---|
10 | |
---|
11 | @section Introduction |
---|
12 | |
---|
13 | The initialization manager is responsible for |
---|
14 | initiating and shutting down RTEMS. Initiating RTEMS involves |
---|
15 | creating and starting all configured initialization tasks, and |
---|
16 | for invoking the initialization routine for each user-supplied |
---|
17 | device driver. In a multiprocessor configuration, this manager |
---|
18 | also initializes the interprocessor communications layer. The |
---|
19 | directives provided by the initialization manager are: |
---|
20 | |
---|
21 | @itemize @bullet |
---|
22 | @item @code{@value{DIRPREFIX}initialize_executive} - Initialize RTEMS |
---|
23 | @item @code{@value{DIRPREFIX}initialize_executive_early} - Initialize RTEMS and do NOT Start Multitasking |
---|
24 | @item @code{@value{DIRPREFIX}initialize_executive_late} - Complete Initialization and Start Multitasking |
---|
25 | @item @code{@value{DIRPREFIX}shutdown_executive} - Shutdown RTEMS |
---|
26 | @end itemize |
---|
27 | |
---|
28 | @section Background |
---|
29 | |
---|
30 | @subsection Initialization Tasks |
---|
31 | |
---|
32 | @cindex initialization tasks |
---|
33 | |
---|
34 | Initialization task(s) are the mechanism by which |
---|
35 | RTEMS transfers initial control to the user's application. |
---|
36 | Initialization tasks differ from other application tasks in that |
---|
37 | they are defined in the User Initialization Tasks Table and |
---|
38 | automatically created and started by RTEMS as part of its |
---|
39 | initialization sequence. Since the initialization tasks are |
---|
40 | scheduled using the same algorithm as all other RTEMS tasks, |
---|
41 | they must be configured at a priority and mode which will insure |
---|
42 | that they will complete execution before other application tasks |
---|
43 | execute. Although there is no upper limit on the number of |
---|
44 | initialization tasks, an application is required to define at |
---|
45 | least one. |
---|
46 | |
---|
47 | A typical initialization task will create and start |
---|
48 | the static set of application tasks. It may also create any |
---|
49 | other objects used by the application. Initialization tasks |
---|
50 | which only perform initialization should delete themselves upon |
---|
51 | completion to free resources for other tasks. Initialization |
---|
52 | tasks may transform themselves into a "normal" application task. |
---|
53 | This transformation typically involves changing priority and |
---|
54 | execution mode. RTEMS does not automatically delete the |
---|
55 | initialization tasks. |
---|
56 | |
---|
57 | @subsection The System Initialization Task |
---|
58 | |
---|
59 | The System Initialization Task is responsible for |
---|
60 | initializing all device drivers. As a result, this task has a |
---|
61 | higher priority than all other tasks to insure that no |
---|
62 | application tasks executes until all device drivers are |
---|
63 | initialized. After device initialization in a single processor |
---|
64 | system, this task will delete itself. |
---|
65 | |
---|
66 | The System Initialization Task must have enough stack |
---|
67 | space to successfully execute the initialization routines for |
---|
68 | all device drivers and, in multiprocessor configurations, the |
---|
69 | Multiprocessor Communications Interface Layer initialization |
---|
70 | routine. The CPU Configuration Table contains a field which |
---|
71 | allows the application or BSP to increase the default amount of |
---|
72 | stack space allocated for this task. |
---|
73 | |
---|
74 | In multiprocessor configurations, the System |
---|
75 | Initialization Task does not delete itself after initializing |
---|
76 | the device drivers. Instead it transforms itself into the |
---|
77 | Multiprocessing Server which initializes the Multiprocessor |
---|
78 | Communications Interface Layer, verifies multiprocessor system |
---|
79 | consistency, and processes all requests from remote nodes. |
---|
80 | |
---|
81 | @subsection The Idle Task |
---|
82 | |
---|
83 | The Idle Task is the lowest priority task in a system |
---|
84 | and executes only when no other task is ready to execute. This |
---|
85 | task consists of an infinite loop and will be preempted when any |
---|
86 | other task is made ready to execute. |
---|
87 | |
---|
88 | @subsection Initialization Manager Failure |
---|
89 | |
---|
90 | The @code{@value{DIRPREFIX}ifatal_error_occurred} directive will be called |
---|
91 | from @code{@value{DIRPREFIX}initialize_executive} |
---|
92 | for any of the following reasons: |
---|
93 | |
---|
94 | @itemize @bullet |
---|
95 | @item If either the Configuration Table or the CPU Dependent |
---|
96 | Information Table is not provided. |
---|
97 | |
---|
98 | @item If the starting address of the RTEMS RAM Workspace, |
---|
99 | supplied by the application in the Configuration Table, is NULL |
---|
100 | or is not aligned on a four-byte boundary. |
---|
101 | |
---|
102 | @item If the size of the RTEMS RAM Workspace is not large |
---|
103 | enough to initialize and configure the system. |
---|
104 | |
---|
105 | @item If the interrupt stack size specified is too small. |
---|
106 | |
---|
107 | @item If multiprocessing is configured and the node entry in |
---|
108 | the Multiprocessor Configuration Table is not between one and |
---|
109 | the maximum_nodes entry. |
---|
110 | |
---|
111 | @item If a multiprocessor system is being configured and no |
---|
112 | Multiprocessor Communications Interface is specified. |
---|
113 | |
---|
114 | @item If no user initialization tasks are configured. At |
---|
115 | least one initialization task must be configured to allow RTEMS |
---|
116 | to pass control to the application at the end of the executive |
---|
117 | initialization sequence. |
---|
118 | |
---|
119 | @item If any of the user initialization tasks cannot be |
---|
120 | created or started successfully. |
---|
121 | @end itemize |
---|
122 | |
---|
123 | @section Operations |
---|
124 | |
---|
125 | @subsection Initializing RTEMS |
---|
126 | |
---|
127 | The @code{@value{DIRPREFIX}initialize_executive} |
---|
128 | directive is called by the |
---|
129 | board support package at the completion of its initialization |
---|
130 | sequence. RTEMS assumes that the board support package |
---|
131 | successfully completed its initialization activities. The |
---|
132 | @code{@value{DIRPREFIX}initialize_executive} |
---|
133 | directive completes the initialization |
---|
134 | sequence by performing the following actions: |
---|
135 | |
---|
136 | @itemize @bullet |
---|
137 | @item Initializing internal RTEMS variables; |
---|
138 | @item Allocating system resources; |
---|
139 | @item Creating and starting the System Initialization Task; |
---|
140 | @item Creating and starting the Idle Task; |
---|
141 | @item Creating and starting the user initialization task(s); and |
---|
142 | @item Initiating multitasking. |
---|
143 | @end itemize |
---|
144 | |
---|
145 | This directive MUST be called before any other RTEMS |
---|
146 | directives. The effect of calling any RTEMS directives before |
---|
147 | @code{@value{DIRPREFIX}initialize_executive} |
---|
148 | is unpredictable. Many of RTEMS actions |
---|
149 | during initialization are based upon the contents of the |
---|
150 | Configuration Table and CPU Dependent Information Table. For |
---|
151 | more information regarding the format and contents of these |
---|
152 | tables, please refer to the chapter Configuring a System. |
---|
153 | |
---|
154 | The final step in the initialization sequence is the |
---|
155 | initiation of multitasking. When the scheduler and dispatcher |
---|
156 | are enabled, the highest priority, ready task will be dispatched |
---|
157 | to run. Control will not be returned to the board support |
---|
158 | package after multitasking is enabled until |
---|
159 | @code{@value{DIRPREFIX}shutdown_executive} |
---|
160 | the directive is called. |
---|
161 | |
---|
162 | The @code{@value{DIRPREFIX}initialize_executive} |
---|
163 | directive provides a |
---|
164 | conceptually simple way to initialize RTEMS. However, in |
---|
165 | certain cases, this mechanism cannot be used. The |
---|
166 | @code{@value{DIRPREFIX}initialize_executive_early} |
---|
167 | and @code{@value{DIRPREFIX}initialize_executive_late} |
---|
168 | directives are provided as an alternative mechanism for |
---|
169 | initializing RTEMS. The |
---|
170 | @code{@value{DIRPREFIX}initialize_executive_early} directive |
---|
171 | returns to the caller BEFORE initiating multitasking. The |
---|
172 | @code{@value{DIRPREFIX}initialize_executive_late} |
---|
173 | directive is invoked to start |
---|
174 | multitasking. It is critical that only one of the RTEMS |
---|
175 | initialization sequences be used in an application. |
---|
176 | |
---|
177 | @subsection Shutting Down RTEMS |
---|
178 | |
---|
179 | The @code{@value{DIRPREFIX}shutdown_executive} directive is invoked by the |
---|
180 | application to end multitasking and return control to the board |
---|
181 | support package. The board support package resumes execution at |
---|
182 | the code immediately following the invocation of the |
---|
183 | @code{@value{DIRPREFIX}initialize_executive} directive. |
---|
184 | |
---|
185 | @section Directives |
---|
186 | |
---|
187 | This section details the initialization manager's |
---|
188 | directives. A subsection is dedicated to each of this manager's |
---|
189 | directives and describes the calling sequence, related |
---|
190 | constants, usage, and status codes. |
---|
191 | |
---|
192 | @page |
---|
193 | @subsection INITIALIZE_EXECUTIVE - Initialize RTEMS |
---|
194 | |
---|
195 | @cindex initialize RTEMS |
---|
196 | |
---|
197 | @subheading CALLING SEQUENCE: |
---|
198 | |
---|
199 | @ifset is-C |
---|
200 | @findex rtems_initialize_executive |
---|
201 | @example |
---|
202 | void rtems_initialize_executive( |
---|
203 | rtems_configuration_table *configuration_table, |
---|
204 | rtems_cpu_table *cpu_table |
---|
205 | ); |
---|
206 | @end example |
---|
207 | @end ifset |
---|
208 | |
---|
209 | @ifset is-Ada |
---|
210 | @example |
---|
211 | procedure Initialize_Executive ( |
---|
212 | Configuration_Table : in RTEMS.Configuration_Table_Pointer; |
---|
213 | CPU_Table : in RTEMS.CPU_Table_Pointer |
---|
214 | ); |
---|
215 | @end example |
---|
216 | @end ifset |
---|
217 | |
---|
218 | @subheading DIRECTIVE STATUS CODES: |
---|
219 | |
---|
220 | NONE |
---|
221 | |
---|
222 | @subheading DESCRIPTION: |
---|
223 | |
---|
224 | This directive is called when the board support |
---|
225 | package has completed its initialization to allow RTEMS to |
---|
226 | initialize the application environment based upon the |
---|
227 | information in the Configuration Table, CPU Dependent |
---|
228 | Information Table, User Initialization Tasks Table, Device |
---|
229 | Driver Table, User Extension Table, Multiprocessor Configuration |
---|
230 | Table, and the Multiprocessor Communications Interface (MPCI) |
---|
231 | Table. This directive starts multitasking and does not return |
---|
232 | to the caller until the @code{@value{DIRPREFIX}shutdown_executive} |
---|
233 | directive is invoked. |
---|
234 | |
---|
235 | @subheading NOTES: |
---|
236 | |
---|
237 | This directive MUST be the first RTEMS directive |
---|
238 | called and it DOES NOT RETURN to the caller until the |
---|
239 | @code{@value{DIRPREFIX}shutdown_executive} |
---|
240 | is invoked. |
---|
241 | |
---|
242 | This directive causes all nodes in the system to |
---|
243 | verify that certain configuration parameters are the same as |
---|
244 | those of the local node. If an inconsistency is detected, then |
---|
245 | a fatal error is generated. |
---|
246 | |
---|
247 | The application must use only one of the two |
---|
248 | initialization sequences: |
---|
249 | @code{@value{DIRPREFIX}initialize_executive} or |
---|
250 | @code{@value{DIRPREFIX}initialize_executive_early} and |
---|
251 | @code{@value{DIRPREFIX}initialize_executive_late}. The |
---|
252 | @code{@value{DIRPREFIX}initialize_executive} |
---|
253 | directive is logically equivalent to invoking |
---|
254 | @code{@value{DIRPREFIX}initialize_executive_early} and |
---|
255 | @code{@value{DIRPREFIX}initialize_executive_late} |
---|
256 | with no intervening actions. |
---|
257 | |
---|
258 | @page |
---|
259 | @subsection INITIALIZE_EXECUTIVE_EARLY - Initialize RTEMS and do NOT Start Multitasking |
---|
260 | |
---|
261 | @cindex initialize RTEMS |
---|
262 | |
---|
263 | @subheading CALLING SEQUENCE: |
---|
264 | |
---|
265 | @ifset is-C |
---|
266 | @findex rtems_initialize_executive_early |
---|
267 | @example |
---|
268 | rtems_interrupt_level rtems_initialize_executive_early( |
---|
269 | rtems_configuration_table *configuration_table, |
---|
270 | rtems_cpu_table *cpu_table |
---|
271 | ); |
---|
272 | @end example |
---|
273 | @end ifset |
---|
274 | |
---|
275 | @ifset is-Ada |
---|
276 | @example |
---|
277 | procedure Initialize_Executive_Early( |
---|
278 | Configuration_Table : in RTEMS.Configuration_Table_Pointer; |
---|
279 | CPU_Table : in RTEMS.Cpu_Table; |
---|
280 | Level : out RTEMS.ISR_Level |
---|
281 | ); |
---|
282 | @end example |
---|
283 | @end ifset |
---|
284 | |
---|
285 | @subheading DIRECTIVE STATUS CODES: |
---|
286 | |
---|
287 | NONE |
---|
288 | |
---|
289 | @subheading DESCRIPTION: |
---|
290 | |
---|
291 | This directive is called when the board support |
---|
292 | package has completed its initialization to allow RTEMS to |
---|
293 | initialize the application environment based upon the |
---|
294 | information in the Configuration Table, CPU Dependent |
---|
295 | Information Table, User Initialization Tasks Table, Device |
---|
296 | Driver Table, User Extension Table, Multiprocessor Configuration |
---|
297 | Table, and the Multiprocessor Communications Interface (MPCI) |
---|
298 | Table. This directive returns to the caller after completing |
---|
299 | the basic RTEMS initialization but before multitasking is |
---|
300 | initiated. The interrupt level in place when the directive is |
---|
301 | invoked is returned to the caller. This interrupt level should |
---|
302 | be the same one passed to |
---|
303 | @code{@value{DIRPREFIX}initialize_executive_late}. |
---|
304 | |
---|
305 | @subheading NOTES: |
---|
306 | |
---|
307 | The application must use only one of the two |
---|
308 | initialization sequences: |
---|
309 | @code{@value{DIRPREFIX}initialize_executive} or |
---|
310 | @code{@value{DIRPREFIX}initialize_executive_early} and |
---|
311 | @code{@value{DIRPREFIX}initialize_executive_late}. |
---|
312 | |
---|
313 | @page |
---|
314 | @subsection INITIALIZE_EXECUTIVE_LATE - Complete Initialization and Start Multitasking |
---|
315 | |
---|
316 | @cindex initialize RTEMS |
---|
317 | @cindex start multitasking |
---|
318 | |
---|
319 | @subheading CALLING SEQUENCE: |
---|
320 | |
---|
321 | @ifset is-C |
---|
322 | @findex rtems_initialize_executive_late |
---|
323 | @example |
---|
324 | void rtems_initialize_executive_late( |
---|
325 | rtems_interrupt_level bsp_level |
---|
326 | ); |
---|
327 | @end example |
---|
328 | @end ifset |
---|
329 | |
---|
330 | @ifset is-Ada |
---|
331 | @example |
---|
332 | procedure Initialize_Executive_Late( |
---|
333 | BSP_Level : in RTEMS.ISR_Level |
---|
334 | ); |
---|
335 | @end example |
---|
336 | @end ifset |
---|
337 | |
---|
338 | @subheading DIRECTIVE STATUS CODES: |
---|
339 | |
---|
340 | NONE |
---|
341 | |
---|
342 | @subheading DESCRIPTION: |
---|
343 | |
---|
344 | This directive is called after the |
---|
345 | @code{@value{DIRPREFIX}initialize_executive_early} |
---|
346 | directive has been called to complete |
---|
347 | the RTEMS initialization sequence and initiate multitasking. |
---|
348 | The interrupt level returned by the |
---|
349 | @code{@value{DIRPREFIX}initialize_executive_early} |
---|
350 | directive should be in bsp_level and this value is restored as |
---|
351 | part of this directive returning to the caller after the |
---|
352 | @code{@value{DIRPREFIX}shutdown_executive} |
---|
353 | directive is invoked. |
---|
354 | |
---|
355 | @subheading NOTES: |
---|
356 | |
---|
357 | This directive MUST be the second RTEMS directive |
---|
358 | called and it DOES NOT RETURN to the caller until the |
---|
359 | @code{@value{DIRPREFIX}shutdown_executive} is invoked. |
---|
360 | |
---|
361 | This directive causes all nodes in the system to |
---|
362 | verify that certain configuration parameters are the same as |
---|
363 | those of the local node. If an inconsistency is detected, then |
---|
364 | a fatal error is generated. |
---|
365 | |
---|
366 | The application must use only one of the two |
---|
367 | initialization sequences: |
---|
368 | @code{@value{DIRPREFIX}initialize_executive} or |
---|
369 | @code{@value{DIRPREFIX}initialize_executive_early} and |
---|
370 | @code{@value{DIRPREFIX}initialize_executive_late}. |
---|
371 | |
---|
372 | |
---|
373 | |
---|
374 | @page |
---|
375 | @subsection SHUTDOWN_EXECUTIVE - Shutdown RTEMS |
---|
376 | |
---|
377 | @cindex shutdown RTEMS |
---|
378 | |
---|
379 | @subheading CALLING SEQUENCE: |
---|
380 | |
---|
381 | @ifset is-C |
---|
382 | @findex rtems_shutdown_executive |
---|
383 | @example |
---|
384 | void rtems_shutdown_executive( |
---|
385 | rtems_unsigned32 result |
---|
386 | ); |
---|
387 | @end example |
---|
388 | @end ifset |
---|
389 | |
---|
390 | @ifset is-Ada |
---|
391 | @example |
---|
392 | procedure Shutdown_Executive( |
---|
393 | result : in RTEMS.Unsigned32 |
---|
394 | ); |
---|
395 | @end example |
---|
396 | @end ifset |
---|
397 | |
---|
398 | @subheading DIRECTIVE STATUS CODES: |
---|
399 | |
---|
400 | NONE |
---|
401 | |
---|
402 | @subheading DESCRIPTION: |
---|
403 | |
---|
404 | This directive is called when the application wishes |
---|
405 | to shutdown RTEMS and return control to the board support |
---|
406 | package. The board support package resumes execution at the |
---|
407 | code immediately following the invocation of the |
---|
408 | @code{@value{DIRPREFIX}initialize_executive} directive. |
---|
409 | |
---|
410 | @subheading NOTES: |
---|
411 | |
---|
412 | This directive MUST be the last RTEMS directive |
---|
413 | invoked by an application and it DOES NOT RETURN to the caller. |
---|
414 | |
---|
415 | This directive should not be invoked until the |
---|
416 | executive has successfully completed initialization. |
---|