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

5
Last change on this file since ef1a985f was 58089ff, checked in by Sebastian Huber <sebastian.huber@…>, on 12/14/15 at 14:28:51

rtems: Delete empty _RTEMS_API_Initialize()

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