source: rtems/cpukit/sapi/src/exinit.c @ b767683a

4.115
Last change on this file since b767683a was 263f4bec, checked in by Sebastian Huber <sebastian.huber@…>, on 04/07/14 at 12:50:37

score: Statically initialize IO manager

This simplifies the RTEMS initialization and helps to avoid a memory
overhead. The workspace demands of the IO manager were not included in
the <rtems/confdefs.h> workspace size estimate. This is also fixed as a
side-effect.

Update documentation and move "Specifying Application Defined Device
Driver Table" to the section end. This sub-section is not that
important for the user. Mentioning this at the beginning may lead to
confusion.

  • Property mode set to 100644
File size: 5.6 KB
Line 
1/**
2 * @file
3 *
4 * @brief Initialization Manager
5 *
6 * @ingroup ClassicRTEMS
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-2014.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.org/license/LICENSE.
16 */
17
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22/*
23 *  SCORE_INIT and SAPI_INIT are defined so all of the super core and
24 *  super API data will be included in this object file.
25 */
26
27#define SAPI_INIT
28#define SCORE_INIT
29
30#include <rtems/system.h>
31#include <rtems/config.h>
32#include <rtems/debug.h>
33#include <rtems/extensionimpl.h>
34#include <rtems/init.h>
35#include <rtems/score/sysstate.h>
36
37#include <rtems/score/apiext.h>
38#include <rtems/score/apimutex.h>
39#include <rtems/score/copyrt.h>
40#include <rtems/score/cpusetimpl.h>
41#include <rtems/score/heap.h>
42#include <rtems/score/interr.h>
43#include <rtems/score/isr.h>
44#include <rtems/score/priority.h>
45#include <rtems/score/schedulerimpl.h>
46#include <rtems/score/smpimpl.h>
47#include <rtems/score/threadimpl.h>
48#include <rtems/score/todimpl.h>
49#include <rtems/score/userextimpl.h>
50#include <rtems/score/watchdogimpl.h>
51#include <rtems/score/wkspace.h>
52
53#include <rtems/sptables.h>
54
55
56#include <rtems/rtems/rtemsapi.h>
57#include <rtems/posix/posixapi.h>
58
59Objects_Information *_Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ];
60
61void rtems_initialize_data_structures(void)
62{
63  /*
64   *  Dispatching and interrupts are disabled until the end of the
65   *  initialization sequence.  This prevents an inadvertent context
66   *  switch before the executive is initialized.
67   *
68   *  WARNING: Interrupts should have been disabled by the BSP and
69   *           are disabled by boot_card().
70   */
71
72  #if defined(RTEMS_MULTIPROCESSING)
73    /*
74     *  Initialize the system state based on whether this is an MP system.
75     *  In an MP configuration, internally we view single processor
76     *  systems as a very restricted multiprocessor system.
77     */
78    _Configuration_MP_table = rtems_configuration_get_user_multiprocessing_table();
79
80    if ( _Configuration_MP_table == NULL ) {
81      _Configuration_MP_table =
82        (void *)&_Initialization_Default_multiprocessing_table;
83      _System_state_Handler_initialization( FALSE );
84    } else {
85      _System_state_Handler_initialization( TRUE );
86    }
87  #else
88    _System_state_Handler_initialization( FALSE );
89  #endif
90
91  /*
92   * Initialize any target architecture specific support as early as possible
93   */
94  _CPU_Initialize();
95
96  #if defined(RTEMS_MULTIPROCESSING)
97    _Objects_MP_Handler_early_initialization();
98  #endif
99
100  /*
101   *  Do this as early as possible to ensure no debugging output
102   *  is even attempted to be printed.
103   */
104  _Debug_Manager_initialization();
105
106  _API_extensions_Initialization();
107
108  _Thread_Dispatch_initialization();
109
110  _User_extensions_Handler_initialization();
111  _ISR_Handler_initialization();
112
113  /*
114   * Initialize the internal support API and allocator Mutex
115   */
116  _Objects_Information_table[OBJECTS_INTERNAL_API] = _Internal_Objects;
117
118  _API_Mutex_Initialization( 2 );
119  _API_Mutex_Allocate( &_RTEMS_Allocator_Mutex );
120  _API_Mutex_Allocate( &_Once_Mutex );
121
122  _Watchdog_Handler_initialization();
123  _TOD_Handler_initialization();
124
125  _Thread_Handler_initialization();
126
127  _Scheduler_Handler_initialization();
128
129  #if defined(RTEMS_MULTIPROCESSING)
130    _Objects_MP_Handler_initialization();
131    _MPCI_Handler_initialization( RTEMS_TIMEOUT );
132  #endif
133
134  _SMP_Handler_initialize();
135
136  _CPU_set_Handler_initialization();
137
138/* MANAGERS */
139
140  _RTEMS_API_Initialize();
141
142  _Extension_Manager_initialization();
143
144  _POSIX_API_Initialize();
145
146  _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
147
148  /*
149   *  No threads should be created before this point!!!
150   *  _Thread_Executing and _Thread_Heir are not set.
151   *
152   *  At this point all API extensions are in place.  After the call to
153   *  _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set.
154   */
155  _Thread_Create_idle();
156
157  /*
158   *  Scheduling can properly occur now as long as we avoid dispatching.
159   */
160}
161
162void rtems_initialize_before_drivers(void)
163{
164
165  #if defined(RTEMS_MULTIPROCESSING)
166    _MPCI_Create_server();
167  #endif
168
169  #if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API)
170    /*
171     *  Run the API and BSPs predriver hook.
172     */
173    _API_extensions_Run_predriver();
174  #endif
175}
176
177void rtems_initialize_device_drivers(void)
178{
179  /*
180   *  Initialize all the device drivers and initialize the MPCI layer.
181   *
182   *  NOTE:  The MPCI may be build upon a device driver.
183   */
184
185  _IO_Initialize_all_drivers();
186
187  #if defined(RTEMS_MULTIPROCESSING)
188    if ( _System_state_Is_multiprocessing ) {
189      _MPCI_Initialization();
190      _MPCI_Internal_packets_Send_process_packet(
191        MPCI_PACKETS_SYSTEM_VERIFY
192      );
193    }
194  #endif
195
196  /*
197   *  Run the APIs and BSPs postdriver hooks.
198   *
199   *  The API extensions are supposed to create user initialization tasks.
200   */
201  _API_extensions_Run_postdriver();
202}
203
204void rtems_initialize_start_multitasking(void)
205{
206  _System_state_Set( SYSTEM_STATE_UP );
207
208  _SMP_Request_start_multitasking();
209
210  _Thread_Start_multitasking();
211
212  /*******************************************************************
213   *******************************************************************
214   *******************************************************************
215   ******                 APPLICATION RUNS HERE                 ******
216   ******              THE FUNCTION NEVER RETURNS               ******
217   *******************************************************************
218   *******************************************************************
219   *******************************************************************/
220}
Note: See TracBrowser for help on using the repository browser.