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

5
Last change on this file since bd91f446 was bd91f446, checked in by Sebastian Huber <sebastian.huber@…>, on 12/08/15 at 07:34:08

score: Delete unused API extensions

Update #2408.

  • Property mode set to 100644
File size: 7.1 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/extensionimpl.h>
33#include <rtems/init.h>
34#include <rtems/score/sysstate.h>
35
36#include <rtems/score/apiext.h>
37#include <rtems/score/apimutex.h>
38#include <rtems/score/copyrt.h>
39#include <rtems/score/cpusetimpl.h>
40#include <rtems/score/heap.h>
41#include <rtems/score/interr.h>
42#include <rtems/score/isr.h>
43#include <rtems/score/priority.h>
44#include <rtems/score/schedulerimpl.h>
45#include <rtems/score/smpimpl.h>
46#include <rtems/score/timecounter.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
59#ifdef RTEMS_DRVMGR_STARTUP
60  #include <drvmgr/drvmgr.h>
61#endif
62
63Objects_Information *_Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ];
64
65void rtems_initialize_data_structures(void)
66{
67  /*
68   *  Dispatching and interrupts are disabled until the end of the
69   *  initialization sequence.  This prevents an inadvertent context
70   *  switch before the executive is initialized.
71   *
72   *  WARNING: Interrupts should have been disabled by the BSP and
73   *           are disabled by boot_card().
74   */
75
76  #if defined(RTEMS_MULTIPROCESSING)
77    /*
78     *  Initialize the system state based on whether this is an MP system.
79     *  In an MP configuration, internally we view single processor
80     *  systems as a very restricted multiprocessor system.
81     */
82    _Configuration_MP_table = rtems_configuration_get_user_multiprocessing_table();
83
84    if ( _Configuration_MP_table == NULL ) {
85      _Configuration_MP_table =
86        (void *)&_Initialization_Default_multiprocessing_table;
87      _System_state_Handler_initialization( FALSE );
88    } else {
89      _System_state_Handler_initialization( TRUE );
90    }
91  #else
92    _System_state_Handler_initialization( FALSE );
93  #endif
94
95  /*
96   * Initialize any target architecture specific support as early as possible
97   */
98  _CPU_Initialize();
99
100  #if defined(RTEMS_MULTIPROCESSING)
101    _Objects_MP_Handler_early_initialization();
102  #endif
103
104  _Thread_Dispatch_initialization();
105
106  _User_extensions_Handler_initialization();
107  _ISR_Handler_initialization();
108
109  /*
110   * Initialize the internal support API and allocator Mutex
111   */
112  _Objects_Information_table[OBJECTS_INTERNAL_API] = _Internal_Objects;
113
114  _API_Mutex_Initialization( 2 );
115  _API_Mutex_Allocate( &_RTEMS_Allocator_Mutex );
116  _API_Mutex_Allocate( &_Once_Mutex );
117
118  _Watchdog_Handler_initialization();
119  _TOD_Handler_initialization();
120
121  _Thread_Handler_initialization();
122
123  _Scheduler_Handler_initialization();
124
125  #if defined(RTEMS_MULTIPROCESSING)
126    _Objects_MP_Handler_initialization();
127    _MPCI_Handler_initialization( RTEMS_TIMEOUT );
128  #endif
129
130  _SMP_Handler_initialize();
131
132  _CPU_set_Handler_initialization();
133
134/* MANAGERS */
135
136  _RTEMS_API_Initialize();
137
138  _Extension_Manager_initialization();
139
140  _POSIX_API_Initialize();
141
142  _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
143
144  /*
145   *  No threads should be created before this point!!!
146   *  _Thread_Executing and _Thread_Heir are not set.
147   *
148   *  At this point all API extensions are in place.  After the call to
149   *  _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set.
150   */
151  _Thread_Create_idle();
152
153  /*
154   *  Scheduling can properly occur now as long as we avoid dispatching.
155   */
156}
157
158void rtems_initialize_before_drivers(void)
159{
160  #ifdef RTEMS_DRVMGR_STARTUP
161  _DRV_Manager_initialization();
162  #endif
163
164  #if defined(RTEMS_MULTIPROCESSING)
165    _MPCI_Create_server();
166  #endif
167}
168
169void rtems_initialize_device_drivers(void)
170{
171  /*
172   *  Initialize all the device drivers and initialize the MPCI layer.
173   *
174   *  NOTE:  The MPCI may be build upon a device driver.
175   */
176
177  #ifdef RTEMS_DRVMGR_STARTUP
178  /* BSPs has already registered their "root bus" driver in the
179   * bsp_predriver hook or so.
180   *
181   * Init Drivers to Level 1, constraints:
182   *   - Interrupts and system clock timer does not work.
183   *   - malloc() work, however other memory services may not
184   *     have been initialized yet.
185   *   - initializes most basic stuff
186   *
187   * Typical setup in Level 1:
188   *   - Find most devices in system, do PCI scan and configuration.
189   *   - Reset hardware if needed.
190   *   - Install IRQ driver
191   *   - Install Timer driver
192   *   - Install console driver and debug printk()
193   *   - Install extra memory.
194   */
195  _DRV_Manager_init_level(1);
196  bsp_driver_level_hook(1);
197  #endif
198
199  /* Initialize I/O drivers.
200   *
201   * Driver Manager note:
202   * All drivers may not be registered yet. Drivers will dynamically
203   * be initialized when registered in level 2,3 and 4.
204   */
205  _IO_Initialize_all_drivers();
206
207  #ifdef RTEMS_DRVMGR_STARTUP
208  /* Init Drivers to Level 2, constraints:
209   *  - Interrupts can be registered and enabled.
210   *  - System Clock is running
211   *  - Console may be used.
212   *
213   * This is typically where drivers are initialized
214   * for the first time.
215   */
216  _DRV_Manager_init_level(2);
217  bsp_driver_level_hook(2);
218
219  /* Init Drivers to Level 3
220   *
221   * This is typically where normal drivers are initialized
222   * for the second time, they may depend on other drivers
223   * API inited in level 2
224   */
225  _DRV_Manager_init_level(3);
226  bsp_driver_level_hook(3);
227
228  /* Init Drivers to Level 4,
229   * Init drivers that depend on services initialized in Level 3
230   */
231  _DRV_Manager_init_level(4);
232  bsp_driver_level_hook(4);
233  #endif
234
235  #if defined(RTEMS_MULTIPROCESSING)
236    if ( _System_state_Is_multiprocessing ) {
237      _MPCI_Initialization();
238      _MPCI_Internal_packets_Send_process_packet(
239        MPCI_PACKETS_SYSTEM_VERIFY
240      );
241    }
242  #endif
243
244  /*
245   *  Run the APIs and BSPs postdriver hooks.
246   *
247   *  The API extensions are supposed to create user initialization tasks.
248   */
249  _API_extensions_Run_postdriver();
250}
251
252void rtems_initialize_start_multitasking(void)
253{
254  _System_state_Set( SYSTEM_STATE_UP );
255
256  _SMP_Request_start_multitasking();
257
258  _Thread_Start_multitasking();
259
260  /*******************************************************************
261   *******************************************************************
262   *******************************************************************
263   ******                 APPLICATION RUNS HERE                 ******
264   ******              THE FUNCTION NEVER RETURNS               ******
265   *******************************************************************
266   *******************************************************************
267   *******************************************************************/
268}
Note: See TracBrowser for help on using the repository browser.