source: rtems/doc/user/init.t @ a73e3561

4.104.114.95
Last change on this file since a73e3561 was a73e3561, checked in by Joel Sherrill <joel.sherrill@…>, on 06/02/08 at 16:07:42

2008-06-02 Joel Sherrill <joel.sherrill@…>

  • user/bsp.t, user/init.t: Rework initialization and BSP chapters to account for changes to initialization framework.
  • Property mode set to 100644
File size: 13.6 KB
Line 
1@c
2@c  COPYRIGHT (c) 1988-2008.
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
13The Initialization Manager is responsible for
14initiating and shutting down RTEMS.  Initiating RTEMS involves
15creating and starting all configured initialization tasks, and
16for invoking the initialization routine for each user-supplied
17device driver.  In a multiprocessor configuration, this manager
18also initializes the interprocessor communications layer.  The
19directives provided by the Initialization Manager are:
20
21@itemize @bullet
22@item @code{@value{DIRPREFIX}initialize_data_structures} - Initialize RTEMS Data Structures
23@item @code{@value{DIRPREFIX}initialize_before_drivers} - Perform Initialization Before Device Drivers
24@item @code{@value{DIRPREFIX}initialize_device_drivers} - Initialize Device Drivers
25@item @code{@value{DIRPREFIX}initialize_start_multitasking} - Complete Initialization and Start Multitasking
26@item @code{@value{DIRPREFIX}shutdown_executive} - Shutdown RTEMS
27@end itemize
28
29@section Background
30
31@subsection Initialization Tasks
32
33@cindex initialization tasks
34
35Initialization task(s) are the mechanism by which
36RTEMS transfers initial control to the user's application.
37Initialization tasks differ from other application tasks in that
38they are defined in the User Initialization Tasks Table and
39automatically created and started by RTEMS as part of its
40initialization sequence.  Since the initialization tasks are
41scheduled using the same algorithm as all other RTEMS tasks,
42they must be configured at a priority and mode which will ensure
43that they will complete execution before other application tasks
44execute.  Although there is no upper limit on the number of
45initialization tasks, an application is required to define at
46least one.
47
48A typical initialization task will create and start
49the static set of application tasks.  It may also create any
50other objects used by the application.  Initialization tasks
51which only perform initialization should delete themselves upon
52completion to free resources for other tasks.  Initialization
53tasks may transform themselves into a "normal" application task.
54This transformation typically involves changing priority and
55execution mode.  RTEMS does not automatically delete the
56initialization tasks.
57
58@subsection System Initialization
59
60System Initialization begins with board reset and continues
61through RTEMS initialization, initialization of all device
62drivers, and eventually a context switch to the first user
63task.  Remember, that interrupts are disabled during
64initialization and the @i{initialization thread} is not
65a task in any sense and the user should be very careful
66during initialzation.
67
68The BSP must ensure that the there is enough stack
69space reserved for the initialization "thread" to
70successfully execute the initialization routines for
71all device drivers and, in multiprocessor configurations, the
72Multiprocessor Communications Interface Layer initialization
73routine.
74
75@subsection The Idle Task
76
77The Idle Task is the lowest priority task in a system
78and executes only when no other task is ready to execute.  This
79default implementation of this task consists of an infinite
80loop. RTEMS allows the Idle Task body to be replaced by a CPU
81specific implementation, a BSP specific implementation or an
82application specific implementation.
83
84The Idle Task is preemptible and @b{WILL} be preempted when
85any other task is made ready to execute.  This characteristic is
86critical to the overall behavior of any application.
87
88@subsection Initialization Manager Failure
89
90The @code{@value{DIRPREFIX}fatal_error_occurred} directive will
91be invoked from @code{@value{DIRPREFIX}initialize_executive}
92for any of the following reasons:
93
94@itemize @bullet
95@item If either the Configuration Table or the CPU Dependent
96Information Table is not provided.
97
98@item If the starting address of the RTEMS RAM Workspace,
99supplied by the application in the Configuration Table, is NULL
100or is not aligned on a four-byte boundary.
101
102@item If the size of the RTEMS RAM Workspace is not large
103enough 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
108the Multiprocessor Configuration Table is not between one and
109the maximum_nodes entry.
110
111@item If a multiprocessor system is being configured and no
112Multiprocessor Communications Interface is specified.
113
114@item If no user initialization tasks are configured.  At
115least one initialization task must be configured to allow RTEMS
116to pass control to the application at the end of the executive
117initialization sequence.
118
119@item If any of the user initialization tasks cannot be
120created or started successfully.
121@end itemize
122 
123A discussion of RTEMS actions when a fatal error occurs
124may be found @ref{Fatal Error Manager Announcing a Fatal Error}.
125
126
127@section Operations
128
129@subsection Initializing RTEMS
130
131The Initialization Manager directives are called by the
132Board Support Package framework as part of its initialization
133sequence.  RTEMS assumes that the Board Support Package
134successfully completed its initialization activities.  These
135directives initialize RTEMS by performing the following actions:
136
137@itemize @bullet
138@item Initializing internal RTEMS variables;
139@item Allocating system resources;
140@item Creating and starting the Idle Task;
141@item Initialize all device drivers;
142@item Creating and starting the user initialization task(s); and
143@item Initiating multitasking.
144@end itemize
145
146The initialization directives MUST be called in the proper
147sequence before any blocking directives may be used.  The services
148in this manager should be invoked just once per application
149and in precisely the following order:
150
151@itemize @bullet
152@item @code{@value{DIRPREFIX}initialize_data_structures}
153@item @code{@value{DIRPREFIX}initialize_before_drivers}
154@item @code{@value{DIRPREFIX}initialize_device_drivers}
155@item @code{@value{DIRPREFIX}initialize_start_multitasking}
156@end itemize
157
158It is recommended that the Board Support Package use the
159provided framework which will invoke these services as
160part of the executing the function @code{boot_card} in the
161file @code{c/src/lib/libbsp/shared/bootcard.c}.  This
162framework will also assist in allocating memory to the
163RTEMS Workspace and C Program Heap and initializing the
164C Library.
165
166The effect of calling any blocking RTEMS directives before
167@code{@value{DIRPREFIX}initialize_start_multitasking}
168is unpredictable but guaranteed to be bad.  Afer the
169directive @code{@value{DIRPREFIX}initialize_data_structures}
170is invoked, it is permissible to allocate RTEMS objects and
171perform non-blocking operations.  But the user should be
172distinctly aware that multitasking is not available yet
173and they are @b{NOT} executing in a task context.
174
175Many of RTEMS actions during initialization are based upon
176the contents of the Configuration Table.  For more information
177regarding the format and contents of this table, please refer
178to the chapter @ref{Configuring a System}.
179
180The final step in the initialization sequence is the
181initiation of multitasking.  When the scheduler and dispatcher
182are enabled, the highest priority, ready task will be dispatched
183to run.  Control will not be returned to the Board Support
184Package after multitasking is enabled until the
185@code{@value{DIRPREFIX}shutdown_executive} directive is called.
186This directive is called as a side-effect of POSIX calls
187including @code{exit}.
188
189@subsection Shutting Down RTEMS
190
191The @code{@value{DIRPREFIX}shutdown_executive} directive is invoked by the
192application to end multitasking and return control to the board
193support package.  The board support package resumes execution at
194the code immediately following the invocation of the
195@code{@value{DIRPREFIX}initialize_start_multitasking} directive.
196
197@section Directives
198
199This section details the Initialization Manager's
200directives.  A subsection is dedicated to each of this manager's
201directives and describes the calling sequence, related
202constants, usage, and status codes.
203
204@page
205@subsection INITIALIZE_DATA_STRUCTURES - Initialize RTEMS Data Structures
206
207@cindex initialize RTEMS data structures
208
209@subheading CALLING SEQUENCE:
210
211@ifset is-C
212@findex rtems_initialize_data_structures
213@example
214void rtems_initialize_data_structures(
215  rtems_configuration_table *configuration_table
216);
217@end example
218@end ifset
219
220@ifset is-Ada
221@example
222NOT SUPPORTED FROM Ada BINDING
223@end example
224@end ifset
225
226@subheading DIRECTIVE STATUS CODES:
227
228NONE
229
230@subheading DESCRIPTION:
231
232This directive is called when the Board Support
233Package has completed its basic initialization and
234allows RTEMS to initialize the application environment based upon the
235information in the Configuration Table, User Initialization
236Tasks Table, Device Driver Table, User Extension Table,
237Multiprocessor Configuration Table, and the Multiprocessor
238Communications Interface (MPCI) Table.  This directive returns
239to the caller after completing the basic RTEMS initialization.
240
241@subheading NOTES:
242
243The Initialization Manager directives must be used in the
244proper sequence and invokved only once in the life of an application.
245
246This directive must be invoked with interrupts disabled.
247Interrupts should be disabled as early as possible in
248the initialization sequence and remain disabled until
249the first context switch.
250
251@page
252@subsection INITIALIZE_BEFORE_DRIVERS - Perform Initialization Before Device Drivers
253
254@cindex initialize RTEMS before device drivers
255
256@subheading CALLING SEQUENCE:
257
258@ifset is-C
259@findex rtems_initialize_before_drivers
260@example
261void rtems_initialize_before_drivers(void);
262@end example
263@end ifset
264
265@ifset is-Ada
266@example
267NOT SUPPORTED FROM Ada BINDING
268@end example
269@end ifset
270
271@subheading DIRECTIVE STATUS CODES:
272
273NONE
274
275@subheading DESCRIPTION:
276
277This directive is called by the Board Support Package as the
278second step in initializing RTEMS.  This directive performs
279initialization that must occur between basis RTEMS data structure
280initialization and device driver initialization.  In particular,
281in a multiprocessor configuration, this directive will create the
282MPCI Server Task.  This directive returns to the caller after
283completing the basic RTEMS initialization.
284
285@subheading NOTES:
286
287The Initialization Manager directives must be used in the
288proper sequence and invokved only once in the life of an application.
289
290This directive must be invoked with interrupts disabled.
291Interrupts should be disabled as early as possible in
292the initialization sequence and remain disabled until
293the first context switch.
294
295@page
296@subsection INITIALIZE_DEVICE_DRIVERS - Initialize Device Drivers
297
298@cindex initialize device drivers
299
300@subheading CALLING SEQUENCE:
301
302@ifset is-C
303@findex rtems_initialize_device_drivers
304@example
305void rtems_initialize_device_drivers(void);
306@end example
307@end ifset
308
309@ifset is-Ada
310@example
311NOT SUPPORTED FROM Ada BINDING
312@end example
313@end ifset
314
315@subheading DIRECTIVE STATUS CODES:
316
317NONE
318
319@subheading DESCRIPTION:
320
321This directive is called by the Board Support Package as the
322third step in initializing RTEMS.  This directive initializes
323all statically configured device drivers and performs all RTEMS
324initialization which requires device drivers to be initialized.
325
326In a multiprocessor configuration, this service will initialize
327the Multiprocessor Communications Interface (MPCI) and synchronize
328with the other nodes in the system.
329
330After this directive is executed, control will be returned to
331the Board Support Package framework.
332
333@subheading NOTES:
334
335The Initialization Manager directives must be used in the
336proper sequence and invokved only once in the life of an application.
337
338This directive must be invoked with interrupts disabled.
339Interrupts should be disabled as early as possible in
340the initialization sequence and remain disabled until
341the first context switch.
342
343@page
344@subsection INITIALIZE_START_MULTITASKING - Complete Initialization and Start Multitasking
345
346@cindex initialize RTEMS
347@cindex start multitasking
348
349@subheading CALLING SEQUENCE:
350
351@ifset is-C
352@findex rtems_initialize_start_multitasking
353@example
354void rtems_initialize_start_multitasking(void);
355@end example
356@end ifset
357
358@ifset is-Ada
359@example
360NOT SUPPORTED FROM Ada BINDING
361@end example
362@end ifset
363
364@subheading DIRECTIVE STATUS CODES:
365
366NONE
367
368@subheading DESCRIPTION:
369
370This directive is called after the other Initialization Manager
371directives have successfully completed.  This directive
372initiates multitasking and performs a context switch to
373the first user application task and enables interrupts as
374a side-effect of that context switch.
375
376@subheading NOTES:
377
378This directive @b{DOES NOT RETURN} to the caller until the
379@code{@value{DIRPREFIX}shutdown_executive} is invoked.
380
381This directive causes all nodes in the system to
382verify that certain configuration parameters are the same as
383those of the local node.  If an inconsistency is detected, then
384a fatal error is generated.
385
386@page
387@subsection SHUTDOWN_EXECUTIVE - Shutdown RTEMS
388
389@cindex shutdown RTEMS
390
391@subheading CALLING SEQUENCE:
392
393@ifset is-C
394@findex rtems_shutdown_executive
395@example
396void rtems_shutdown_executive(
397  uint32_t result
398);
399@end example
400@end ifset
401
402@ifset is-Ada
403@example
404procedure Shutdown_Executive(
405  Status : in     RTEMS.Unsigned32
406);
407@end example
408@end ifset
409
410@subheading DIRECTIVE STATUS CODES:
411
412NONE
413
414@subheading DESCRIPTION:
415
416This directive is called when the application wishes
417to shutdown RTEMS and return control to the board support
418package.  The board support package resumes execution at the
419code immediately following the invocation of the
420@code{@value{DIRPREFIX}initialize_executive} directive.
421
422@subheading NOTES:
423
424This directive MUST be the last RTEMS directive
425invoked by an application and it DOES NOT RETURN to the caller.
426
427This directive should not be invoked until the
428executive has successfully completed initialization.
Note: See TracBrowser for help on using the repository browser.