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