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

5
Last change on this file since d0c39838 was d0c39838, checked in by Sebastian Huber <sebastian.huber@…>, on 09/22/15 at 14:21:12

Use linker set for system initialization

Make rtems_initialize_data_structures(),
rtems_initialize_before_drivers() and rtems_initialize_device_drivers()
static. Rename rtems_initialize_start_multitasking() to
rtems_initialize_executive() and call the registered system
initialization handlers in this function. Add system initialization API
available via #include <rtems/sysinit.h>. Update the documentation
accordingly.

This is no functional change, only the method to call the existing
initialization routines changes. Instead of direct function calls a
table of function pointers contained in the new RTEMS system
initialization linker set is used. This table looks like this (the
actual addresses depend on the target).

nm *.exe | grep _Linker | sort
0201a2d0 D _Linker_setSysinit_begin
0201a2d0 D _Linker_set
Sysinit_bsp_work_area_initialize
0201a2d4 D _Linker_setSysinit_bsp_start
0201a2d8 D _Linker_set
Sysinit_rtems_initialize_data_structures
0201a2dc D _Linker_setSysinit_bsp_libc_init
0201a2e0 D _Linker_set
Sysinit_rtems_initialize_before_drivers
0201a2e4 D _Linker_setSysinit_bsp_predriver_hook
0201a2e8 D _Linker_set
Sysinit_rtems_initialize_device_drivers
0201a2ec D _Linker_setSysinit_bsp_postdriver_hook
0201a2f0 D _Linker_set
Sysinit_end

Add test sptests/spsysinit01.

Update #2408.

  • Property mode set to 100644
File size: 10.3 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_DATA_STRUCTURES
161This directive is called when the Board Support Package has completed its basic
162initialization and allows RTEMS to initialize the application environment based
163upon the information in the Configuration Table, User Initialization Tasks
164Table, Device Driver Table, User Extension Table, Multiprocessor Configuration
165Table, and the Multiprocessor Communications Interface (MPCI) Table.
166
167@item RTEMS_SYSINIT_BSP_LIBC
168Depending on the application configuration the IO library and root filesystem
169is initialized.  This step is mandatory.
170
171@item RTEMS_SYSINIT_BEFORE_DRIVERS
172This directive performs initialization that must occur between basis RTEMS data
173structure initialization and device driver initialization.  In particular, in a
174multiprocessor configuration, this directive will create the MPCI Server Task.
175
176@item RTEMS_SYSINIT_BSP_PRE_DRIVERS
177Initialization step performed right before device drivers are initialized
178provided by the Board Support Package.  This step is mandatory.
179
180@item RTEMS_SYSINIT_DEVICE_DRIVERS
181This step initializes all statically configured device drivers and performs all
182RTEMS initialization which requires device drivers to be initialized.  This
183step is mandatory.
184
185In a multiprocessor configuration, this service will initialize the
186Multiprocessor Communications Interface (MPCI) and synchronize with the other
187nodes in the system.
188
189@item RTEMS_SYSINIT_BSP_POST_DRIVERS
190Initialization step performed right after device drivers are initialized
191provided by the Board Support Package.  This step is mandatory.
192
193@end table
194
195The final action of the @code{@value{DIRPREFIX}initialize_executive} directive
196is to start multitasking.  RTEMS does not return to the initialization context
197and the initialization stack may be re-used for interrupt processing.
198
199Many of RTEMS actions during initialization are based upon
200the contents of the Configuration Table.  For more information
201regarding the format and contents of this table, please refer
202to the chapter @ref{Configuring a System}.
203
204The final action in the initialization sequence is the
205initiation of multitasking.  When the scheduler and dispatcher
206are enabled, the highest priority, ready task will be dispatched
207to run.  Control will not be returned to the Board Support
208Package after multitasking is enabled.  The initialization stack may be re-used
209for interrupt processing.
210
211@subsection Shutting Down RTEMS
212
213The @code{@value{DIRPREFIX}shutdown_executive} directive is invoked by the
214application to end multitasking and terminate the system.
215
216@section Directives
217
218This section details the Initialization Manager's
219directives.  A subsection is dedicated to each of this manager's
220directives and describes the calling sequence, related
221constants, usage, and status codes.
222
223@page
224@subsection INITIALIZE_EXECUTIVE - Initialize RTEMS
225
226@cindex initialize RTEMS
227@cindex start multitasking
228
229@subheading CALLING SEQUENCE:
230
231@ifset is-C
232@findex rtems_initialize_executive
233@example
234void rtems_initialize_executive(void);
235@end example
236@end ifset
237
238@ifset is-Ada
239@example
240NOT SUPPORTED FROM Ada BINDING
241@end example
242@end ifset
243
244@subheading DIRECTIVE STATUS CODES:
245
246NONE
247
248@subheading DESCRIPTION:
249
250Iterates through the system initialization linker set and invokes the
251registered handlers.  The final step is to start multitasking.
252
253@subheading NOTES:
254
255This directive should be called by @code{boot_card} only.
256
257This directive @b{does not return} to the caller.  Errors in the initialization
258sequence are usually fatal and lead to a system termination.
259
260@page
261@subsection SHUTDOWN_EXECUTIVE - Shutdown RTEMS
262
263@cindex shutdown RTEMS
264
265@subheading CALLING SEQUENCE:
266
267@ifset is-C
268@findex rtems_shutdown_executive
269@example
270void rtems_shutdown_executive(
271  uint32_t result
272);
273@end example
274@end ifset
275
276@ifset is-Ada
277@example
278procedure Shutdown_Executive(
279  Status : in     RTEMS.Unsigned32
280);
281@end example
282@end ifset
283
284@subheading DIRECTIVE STATUS CODES:
285
286NONE
287
288@subheading DESCRIPTION:
289
290This directive is called when the application wishes to shutdown RTEMS.  The
291system is terminated with a fatal source of @code{RTEMS_FATAL_SOURCE_EXIT} and
292the specified @code{result} code.
293
294@subheading NOTES:
295
296This directive @b{must} be the last RTEMS directive
297invoked by an application and it @b{does not return} to the caller.
298
299This directive may be called any time.
Note: See TracBrowser for help on using the repository browser.