source: rtems/doc/user/init.t @ 190169fe

5
Last change on this file since 190169fe was 190169fe, checked in by Sebastian Huber <sebastian.huber@…>, on 12/10/15 at 14:30:41

Optional CPU Set Handler initialization

Update #2408.

  • Property mode set to 100644
File size: 10.7 KB
Line 
1@c
2@c  COPYRIGHT (c) 1988-2008.
3@c  On-Line Applications Research Corporation (OAR).
4@c  All rights reserved.
5
6@chapter Initialization Manager
7
8@section Introduction
9
10The Initialization Manager is responsible for
11initiating and shutting down RTEMS.  Initiating RTEMS involves
12creating and starting all configured initialization tasks, and
13for invoking the initialization routine for each user-supplied
14device driver.  In a multiprocessor configuration, this manager
15also initializes the interprocessor communications layer.  The
16directives provided by the Initialization Manager are:
17
18@itemize @bullet
19@item @code{@value{DIRPREFIX}initialize_executive} - Initialize RTEMS
20@item @code{@value{DIRPREFIX}shutdown_executive} - Shutdown RTEMS
21@end itemize
22
23@section Background
24
25@subsection Initialization Tasks
26
27@cindex initialization tasks
28
29Initialization task(s) are the mechanism by which
30RTEMS transfers initial control to the user's application.
31Initialization tasks differ from other application tasks in that
32they are defined in the User Initialization Tasks Table and
33automatically created and started by RTEMS as part of its
34initialization sequence.  Since the initialization tasks are
35scheduled using the same algorithm as all other RTEMS tasks,
36they must be configured at a priority and mode which will ensure
37that they will complete execution before other application tasks
38execute.  Although there is no upper limit on the number of
39initialization tasks, an application is required to define at
40least one.
41
42A typical initialization task will create and start
43the static set of application tasks.  It may also create any
44other objects used by the application.  Initialization tasks
45which only perform initialization should delete themselves upon
46completion to free resources for other tasks.  Initialization
47tasks may transform themselves into a "normal" application task.
48This transformation typically involves changing priority and
49execution mode.  RTEMS does not automatically delete the
50initialization tasks.
51
52@subsection System Initialization
53
54System Initialization begins with board reset and continues
55through RTEMS initialization, initialization of all device
56drivers, and eventually a context switch to the first user
57task.  Remember, that interrupts are disabled during
58initialization and the @i{initialization context} is not
59a task in any sense and the user should be very careful
60during initialization.
61
62The BSP must ensure that the there is enough stack
63space reserved for the initialization context to
64successfully execute the initialization routines for
65all device drivers and, in multiprocessor configurations, the
66Multiprocessor Communications Interface Layer initialization
67routine.
68
69@subsection The Idle Task
70
71The Idle Task is the lowest priority task in a system
72and executes only when no other task is ready to execute.  This
73default implementation of this task consists of an infinite
74loop. RTEMS allows the Idle Task body to be replaced by a CPU
75specific implementation, a BSP specific implementation or an
76application specific implementation.
77
78The Idle Task is preemptible and @b{WILL} be preempted when
79any other task is made ready to execute.  This characteristic is
80critical to the overall behavior of any application.
81
82@subsection Initialization Manager Failure
83
84The @code{@value{DIRPREFIX}fatal_error_occurred} directive will
85be invoked from @code{@value{DIRPREFIX}initialize_executive}
86for any of the following reasons:
87
88@itemize @bullet
89@item If either the Configuration Table or the CPU Dependent
90Information Table is not provided.
91
92@item If the starting address of the RTEMS RAM Workspace,
93supplied by the application in the Configuration Table, is NULL
94or is not aligned on a four-byte boundary.
95
96@item If the size of the RTEMS RAM Workspace is not large
97enough to initialize and configure the system.
98
99@item If the interrupt stack size specified is too small.
100
101@item If multiprocessing is configured and the node entry in
102the Multiprocessor Configuration Table is not between one and
103the maximum_nodes entry.
104
105@item If a multiprocessor system is being configured and no
106Multiprocessor Communications Interface is specified.
107
108@item If no user initialization tasks are configured.  At
109least one initialization task must be configured to allow RTEMS
110to pass control to the application at the end of the executive
111initialization sequence.
112
113@item If any of the user initialization tasks cannot be
114created or started successfully.
115@end itemize
116 
117A discussion of RTEMS actions when a fatal error occurs
118may be found @ref{Fatal Error Manager Announcing a Fatal Error}.
119
120
121@section Operations
122
123@subsection Initializing RTEMS
124
125The Initialization Manager @code{@value{DIRPREFIX}initialize_executive}
126directives is called by the @code{boot_card} routine.  The @code{boot_card}
127routine is invoked by the Board Support Package once a basic C run-time
128environment is set up.  This consists of
129
130@itemize @bullet
131@item a valid and accessible text section, read-only data, read-write data and
132zero-initialized data,
133@item an initialization stack large enough to initialize the rest of the Board
134Support Package, RTEMS and the device drivers,
135@item all registers and components mandated by Application Binary Interface, and
136@item disabled interrupts.
137@end itemize
138
139The @code{@value{DIRPREFIX}initialize_executive} directive uses a system
140initialization linker set to initialize only those parts of the overall RTEMS
141feature set that is necessary for a particular application.  @xref{Linker
142Sets}.  Each RTEMS feature used the application may optionally register an
143initialization handler.  The system initialization API is available via
144@code{#included <rtems/sysinit.h>}.
145
146A list of all initialization steps follows.  Some steps are optional depending
147on the requested feature set of the application.  The initialization steps are
148execute in the order presented here.
149
150@table @dfn
151
152@item RTEMS_SYSINIT_BSP_WORK_AREAS
153The work areas consisting of C Program Heap and the RTEMS Workspace are
154initialized by the Board Support Package.  This step is mandatory.
155
156@item RTEMS_SYSINIT_BSP_START
157Basic initialization step provided by the Board Support Package.  This step is
158mandatory.
159
160@item RTEMS_SYSINIT_INITIAL_EXTENSIONS
161Initializes the initial extensions if at least one is configured by the Board
162Support Package or application.
163
164@item RTEMS_SYSINIT_DATA_STRUCTURES
165This directive is called when the Board Support Package has completed its basic
166initialization and allows RTEMS to initialize the application environment based
167upon the information in the Configuration Table, User Initialization Tasks
168Table, Device Driver Table, Multiprocessor Configuration Table, and the
169Multiprocessor Communications Interface (MPCI) Table.
170
171@item RTEMS_SYSINIT_USER_EXTENSIONS
172Initializes the @ref{User Extensions Manager} in case it is used by the
173application.
174
175@item RTEMS_SYSINIT_CPU_SET
176Initializes the global CPU set on SMP configurations in case the application
177uses this information.
178
179@item RTEMS_SYSINIT_BSP_LIBC
180Depending on the application configuration the IO library and root filesystem
181is initialized.  This step is mandatory.
182
183@item RTEMS_SYSINIT_BEFORE_DRIVERS
184This directive performs initialization that must occur between basis RTEMS data
185structure initialization and device driver initialization.  In particular, in a
186multiprocessor configuration, this directive will create the MPCI Server Task.
187
188@item RTEMS_SYSINIT_BSP_PRE_DRIVERS
189Initialization step performed right before device drivers are initialized
190provided by the Board Support Package.  This step is mandatory.
191
192@item RTEMS_SYSINIT_DEVICE_DRIVERS
193This step initializes all statically configured device drivers and performs all
194RTEMS initialization which requires device drivers to be initialized.  This
195step is mandatory.
196
197In a multiprocessor configuration, this service will initialize the
198Multiprocessor Communications Interface (MPCI) and synchronize with the other
199nodes in the system.
200
201@item RTEMS_SYSINIT_BSP_POST_DRIVERS
202Initialization step performed right after device drivers are initialized
203provided by the Board Support Package.  This step is mandatory.
204
205@end table
206
207The final action of the @code{@value{DIRPREFIX}initialize_executive} directive
208is to start multitasking.  RTEMS does not return to the initialization context
209and the initialization stack may be re-used for interrupt processing.
210
211Many of RTEMS actions during initialization are based upon
212the contents of the Configuration Table.  For more information
213regarding the format and contents of this table, please refer
214to the chapter @ref{Configuring a System}.
215
216The final action in the initialization sequence is the
217initiation of multitasking.  When the scheduler and dispatcher
218are enabled, the highest priority, ready task will be dispatched
219to run.  Control will not be returned to the Board Support
220Package after multitasking is enabled.  The initialization stack may be re-used
221for interrupt processing.
222
223@subsection Shutting Down RTEMS
224
225The @code{@value{DIRPREFIX}shutdown_executive} directive is invoked by the
226application to end multitasking and terminate the system.
227
228@section Directives
229
230This section details the Initialization Manager's
231directives.  A subsection is dedicated to each of this manager's
232directives and describes the calling sequence, related
233constants, usage, and status codes.
234
235@page
236@subsection INITIALIZE_EXECUTIVE - Initialize RTEMS
237
238@cindex initialize RTEMS
239@cindex start multitasking
240
241@subheading CALLING SEQUENCE:
242
243@ifset is-C
244@findex rtems_initialize_executive
245@example
246void rtems_initialize_executive(void);
247@end example
248@end ifset
249
250@ifset is-Ada
251@example
252NOT SUPPORTED FROM Ada BINDING
253@end example
254@end ifset
255
256@subheading DIRECTIVE STATUS CODES:
257
258NONE
259
260@subheading DESCRIPTION:
261
262Iterates through the system initialization linker set and invokes the
263registered handlers.  The final step is to start multitasking.
264
265@subheading NOTES:
266
267This directive should be called by @code{boot_card} only.
268
269This directive @b{does not return} to the caller.  Errors in the initialization
270sequence are usually fatal and lead to a system termination.
271
272@page
273@subsection SHUTDOWN_EXECUTIVE - Shutdown RTEMS
274
275@cindex shutdown RTEMS
276
277@subheading CALLING SEQUENCE:
278
279@ifset is-C
280@findex rtems_shutdown_executive
281@example
282void rtems_shutdown_executive(
283  uint32_t result
284);
285@end example
286@end ifset
287
288@ifset is-Ada
289@example
290procedure Shutdown_Executive(
291  Status : in     RTEMS.Unsigned32
292);
293@end example
294@end ifset
295
296@subheading DIRECTIVE STATUS CODES:
297
298NONE
299
300@subheading DESCRIPTION:
301
302This directive is called when the application wishes to shutdown RTEMS.  The
303system is terminated with a fatal source of @code{RTEMS_FATAL_SOURCE_EXIT} and
304the specified @code{result} code.
305
306@subheading NOTES:
307
308This directive @b{must} be the last RTEMS directive
309invoked by an application and it @b{does not return} to the caller.
310
311This directive may be called any time.
Note: See TracBrowser for help on using the repository browser.