source: rtems-docs/c-user/initialization.rst @ 39773ce

5
Last change on this file since 39773ce was e07e376, checked in by Sebastian Huber <sebastian.huber@…>, on 01/30/17 at 13:44:01

c-user: Update initialization

Update #2692.

  • Property mode set to 100644
File size: 12.5 KB
Line 
1.. comment SPDX-License-Identifier: CC-BY-SA-4.0
2
3.. COMMENT: COPYRIGHT (c) 1988-2008.
4.. COMMENT: On-Line Applications Research Corporation (OAR).
5.. COMMENT: All rights reserved.
6
7Initialization Manager
8**********************
9
10Introduction
11============
12
13The Initialization Manager is responsible for initializing the Board Support
14Package, RTEMS, device drivers, the root filesystem and the application.  The
15:ref:`Fatal Error Manager <fatal_error_manager>` is responsible for the system
16shutdown.
17
18The Initialization Manager provides only one directive:
19
20- rtems_initialize_executive_ - Initialize RTEMS
21
22Background
23==========
24
25Initialization Tasks
26--------------------
27.. index:: initialization tasks
28
29Initialization task(s) are the mechanism by which RTEMS transfers initial
30control to the user's application.  Initialization tasks differ from other
31application tasks in that they are defined in the User Initialization Tasks
32Table and automatically created and started by RTEMS as part of its
33initialization sequence.  Since the initialization tasks are scheduled using
34the same algorithm as all other RTEMS tasks, they must be configured at a
35priority and mode which will ensure that they will complete execution before
36other application tasks execute.  Although there is no upper limit on the
37number of initialization tasks, an application is required to define at least
38one.
39
40A typical initialization task will create and start the static set of
41application tasks.  It may also create any other objects used by the
42application.  Initialization tasks which only perform initialization should
43delete themselves upon completion to free resources for other tasks.
44Initialization tasks may transform themselves into a "normal" application task.
45This transformation typically involves changing priority and execution mode.
46RTEMS does not automatically delete the initialization tasks.
47
48The Idle Task
49-------------
50
51The Idle Task is the lowest priority task in a system and executes only when no
52other task is ready to execute.  The default implementation of this task
53consists of an infinite loop. RTEMS allows the Idle Task body to be replaced by
54a CPU specific implementation, a BSP specific implementation or an application
55specific implementation.
56
57The Idle Task is preemptible and *WILL* be preempted when any other task is
58made ready to execute.  This characteristic is critical to the overall behavior
59of any application.
60
61Initialization Manager Failure
62------------------------------
63
64System initialization errors are fatal.  See :ref:`internal_errors`.
65
66Operations
67==========
68
69Initializing RTEMS
70------------------
71
72The Initialization Manager :c:func:`rtems_initialize_executive()` directives is
73called by the :c:ref:`boot_card()` routine which is invoked by the Board
74Support Package once a basic C run-time environment is set up.  This consists
75of
76
77- a valid and accessible text section, read-only data, read-write data and
78  zero-initialized data,
79
80- an initialization stack large enough to initialize the rest of the Board
81  Support Package, RTEMS and the device drivers,
82
83- all registers and components mandated by Application Binary Interface, and
84
85- disabled interrupts.
86
87The :c:func:`rtems_initialize_executive()` directive uses a system
88initialization :ref:`linker set <linker_sets>` to initialize only those parts
89of the overall RTEMS feature set that is necessary for a particular
90application.  Each RTEMS feature used the application may optionally register
91an initialization handler.  The system initialization API is available via
92:samp:`#included <rtems/sysinit.h>`.
93
94A list of all initialization steps follows.  Some steps are optional depending
95on the requested feature set of the application.  The initialization steps are
96execute in the order presented here.
97
98RTEMS_SYSINIT_BSP_WORK_AREAS
99    The work areas consisting of C Program Heap and the RTEMS Workspace are
100    initialized by the Board Support Package.  This step is mandatory.
101
102RTEMS_SYSINIT_BSP_START
103    Basic initialization step provided by the Board Support Package.  This step
104    is mandatory.
105
106RTEMS_SYSINIT_INITIAL_EXTENSIONS
107    Registers the initial extensions.  This step is optional and depends on the
108    application configuration.
109
110RTEMS_SYSINIT_MP_EARLY
111    Early MPCI initialization.  This step is mandatory on MPCI configurations.
112
113RTEMS_SYSINIT_DATA_STRUCTURES
114    This directive is called when the Board Support Package has completed its
115    basic initialization and allows RTEMS to initialize the application
116    environment based upon the information in the Configuration Table, User
117    Initialization Tasks Table, Device Driver Table, User Extension Table,
118    Multiprocessor Configuration Table, and the Multiprocessor Communications
119    Interface (MPCI) Table.
120
121RTEMS_SYSINIT_CPU_SET
122    Initialization of system CPU set.  This step is optional and depends on the
123    application configuration.
124
125RTEMS_SYSINIT_MP
126    MPCI initialization.  This step is mandatory on MPCI configurations.
127
128RTEMS_SYSINIT_USER_EXTENSIONS
129    Initialization of the User Extensions object class.  This step is optional
130    and depends on the application configuration.
131
132RTEMS_SYSINIT_CLASSIC_TASKS
133    Initialization of the Classic Tasks object class.  This step is optional
134    and depends on the application configuration.
135
136RTEMS_SYSINIT_CLASSIC_TIMER
137    Initialization of the Classic Timer object class.  This step is optional
138    and depends on the application configuration.
139
140RTEMS_SYSINIT_CLASSIC_SIGNAL
141    Initialization of the Classic Signal support.  This step is optional and
142    depends on the application configuration.
143
144RTEMS_SYSINIT_CLASSIC_EVENT
145    Initialization of the Classic Event support.  This step is optional and
146    depends on the application configuration.  This step is only used on MPCI
147    configurations.
148
149RTEMS_SYSINIT_CLASSIC_MESSAGE_QUEUE
150    Initialization of the Classic Message Queue object class.  This step is
151    optional and depends on the application configuration.
152
153RTEMS_SYSINIT_CLASSIC_SEMAPHORE
154    Initialization of the Classic Semaphore object class.  This step is
155    optional and depends on the application configuration.
156
157RTEMS_SYSINIT_CLASSIC_PARTITION
158    Initialization of the Classic Partition object class.  This step is
159    optional and depends on the application configuration.
160
161RTEMS_SYSINIT_CLASSIC_REGION
162    Initialization of the Classic Region object class.  This step is optional
163    and depends on the application configuration.
164
165RTEMS_SYSINIT_CLASSIC_DUAL_PORTED_MEMORY
166    Initialization of the Classic Dual-Ported Memory object class.  This step
167    is optional and depends on the application configuration.
168
169RTEMS_SYSINIT_CLASSIC_RATE_MONOTONIC
170    Initialization of the Classic Rate-Monotonic object class.  This step is
171    optional and depends on the application configuration.
172
173RTEMS_SYSINIT_CLASSIC_BARRIER
174    Initialization of the Classic Barrier object class.  This step is optional
175    and depends on the application configuration.
176
177RTEMS_SYSINIT_POSIX_SIGNALS
178    Initialization of the POSIX Signals support.  This step is optional and
179    depends on the application configuration.
180
181RTEMS_SYSINIT_POSIX_THREADS
182    Initialization of the POSIX Threads object class.  This step is optional
183    and depends on the application configuration.
184
185RTEMS_SYSINIT_POSIX_CONDITION_VARIABLE
186    Initialization of the POSIX Condition Variable object class.  This step is
187    optional and depends on the application configuration.
188
189RTEMS_SYSINIT_POSIX_MUTEX
190    Initialization of the POSIX Mutex object class.  This step is optional and
191    depends on the application configuration.
192
193RTEMS_SYSINIT_POSIX_MESSAGE_QUEUE
194    Initialization of the POSIX Message Queue object class.  This step is
195    optional and depends on the application configuration.
196
197RTEMS_SYSINIT_POSIX_SEMAPHORE
198    Initialization of the POSIX Semaphore object class.  This step is optional
199    and depends on the application configuration.
200
201RTEMS_SYSINIT_POSIX_TIMER
202    Initialization of the POSIX Timer object class.  This step is optional and
203    depends on the application configuration.
204
205RTEMS_SYSINIT_POSIX_BARRIER
206    Initialization of the POSIX Barrier object class.  This step is optional
207    and depends on the application configuration.
208
209RTEMS_SYSINIT_POSIX_RWLOCK
210    Initialization of the POSIX Read-Write Locks object class.  This step is
211    optional and depends on the application configuration.
212
213RTEMS_SYSINIT_POSIX_KEYS
214    Initialization of the POSIX Keys object class.  This step is optional
215    and depends on the application configuration.
216
217RTEMS_SYSINIT_POSIX_CLEANUP
218    Initialization of the POSIX Cleanup support.  This step is optional and
219    depends on the application configuration.
220
221RTEMS_SYSINIT_IDLE_THREADS
222    Initialization of idle threads.  This step is mandatory.
223
224RTEMS_SYSINIT_LIBIO
225    Initialization of IO library.  This step is optional and depends on the
226    application configuration.
227
228RTEMS_SYSINIT_ROOT_FILESYSTEM
229    Initialization of the root filesystem.  This step is optional and depends
230    on the application configuration.
231
232RTEMS_SYSINIT_DRVMGR
233    Driver manager initialization.  This step is optional and depends on the
234    application configuration.  Only available if the driver manager is
235    enabled.
236
237RTEMS_SYSINIT_MP_SERVER
238    MPCI server initialization.  This step is mandatory on MPCI configurations.
239
240RTEMS_SYSINIT_BSP_PRE_DRIVERS
241    Initialization step performed right before device drivers are initialized.
242    This step is mandatory.
243
244RTEMS_SYSINIT_DRVMGR_LEVEL_1
245    Driver manager level 1 initialization.  This step is optional and depends
246    on the application configuration.  Only available if the driver manager is
247    enabled.
248
249RTEMS_SYSINIT_DEVICE_DRIVERS
250    This step initializes all statically configured device drivers and performs
251    all RTEMS initialization which requires device drivers to be initialized.
252    This step is mandatory.  In a multiprocessor configuration, this service
253    will initialize the Multiprocessor Communications Interface (MPCI) and
254    synchronize with the other nodes in the system.
255
256RTEMS_SYSINIT_DRVMGR_LEVEL_2
257    Driver manager level 2 initialization.  This step is optional and depends
258    on the application configuration.  Only available if the driver manager is
259    enabled.
260
261RTEMS_SYSINIT_DRVMGR_LEVEL_3
262    Driver manager level 3 initialization.  This step is optional and depends
263    on the application configuration.  Only available if the driver manager is
264    enabled.
265
266RTEMS_SYSINIT_DRVMGR_LEVEL_4
267    Driver manager level 4 initialization.  This step is optional and depends
268    on the application configuration.  Only available if the driver manager is
269    enabled.
270
271RTEMS_SYSINIT_MP_FINALIZE
272    Finalize MPCI initialization.  This step is mandatory on MPCI
273    configurations.
274
275RTEMS_SYSINIT_CLASSIC_USER_TASKS
276    Creates and starts the Classic initialization tasks.  This step is optional
277    and depends on the application configuration.
278
279RTEMS_SYSINIT_POSIX_USER_THREADS
280    Creates POSIX initialization threads.  This step is optional and depends on
281    the application configuration.
282
283RTEMS_SYSINIT_STD_FILE_DESCRIPTORS
284    Open the standard input, output and error file descriptors.  This step is
285    optional and depends on the application configuration.
286
287The final action of the :c:func:`rtems_initialize_executive()` directive is to
288start multitasking and switch to the highest priority ready thread.  RTEMS does
289not return to the initialization context and the initialization stack may be
290re-used for interrupt processing.
291
292Many of RTEMS actions during initialization are based upon the contents of the
293Configuration Table.  For more information regarding the format and contents of
294this table, please refer to the chapter :ref:`Configuring a System`.
295
296Directives
297==========
298
299This section details the Initialization Manager's directives.  A subsection is
300dedicated to each of this manager's directives and describes the calling
301sequence, related constants, usage, and status codes.
302
303.. raw:: latex
304
305   \clearpage
306
307.. _rtems_initialize_executive:
308
309INITIALIZE_EXECUTIVE - Initialize RTEMS
310---------------------------------------
311.. index:: initialize RTEMS
312.. index:: start multitasking
313
314.. index:: rtems_initialize_executive
315CALLING SEQUENCE:
316    .. code-block:: c
317
318        void rtems_initialize_executive(void);
319
320DIRECTIVE STATUS CODES:
321    NONE - This function will not return to the caller.
322
323DESCRIPTION:
324    Iterates through the system initialization linker set and invokes the
325    registered handlers.  The final step is to start multitasking.
326
327NOTES:
328    This directive should be called by :c:func:`boot_card()` only.
329
330    This directive *does not return* to the caller.  Errors in the
331    initialization sequence are usually fatal and lead to a system termination.
Note: See TracBrowser for help on using the repository browser.