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

4.11
Last change on this file since e6c87f7 was e6c87f7, checked in by Joel Sherrill <joel.sherrill@…>, on Mar 4, 2014 at 9:54:12 PM

POSIX keys now enabled in all configurations.

Formerly POSIX keys were only enabled when POSIX threads
were enabled. Because they are a truly safe alternative
to per-task variables in an SMP system, they are being
enabled in all configurations.

  • 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.com/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/io.h>
36#include <rtems/score/sysstate.h>
37
38#include <rtems/score/apiext.h>
39#include <rtems/score/apimutex.h>
40#include <rtems/score/copyrt.h>
41#include <rtems/score/cpusetimpl.h>
42#include <rtems/score/heap.h>
43#include <rtems/score/interr.h>
44#include <rtems/score/isr.h>
45#include <rtems/score/priority.h>
46#include <rtems/score/schedulerimpl.h>
47#include <rtems/score/smpimpl.h>
48#include <rtems/score/threadimpl.h>
49#include <rtems/score/todimpl.h>
50#include <rtems/score/userextimpl.h>
51#include <rtems/score/watchdogimpl.h>
52#include <rtems/score/wkspace.h>
53
54#include <rtems/sptables.h>
55
56
57#include <rtems/rtems/rtemsapi.h>
58#include <rtems/posix/posixapi.h>
59
60Objects_Information *_Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ];
61
62void rtems_initialize_data_structures(void)
63{
64  /*
65   *  Dispatching and interrupts are disabled until the end of the
66   *  initialization sequence.  This prevents an inadvertent context
67   *  switch before the executive is initialized.
68   *
69   *  WARNING: Interrupts should have been disabled by the BSP and
70   *           are disabled by boot_card().
71   */
72
73  #if defined(RTEMS_MULTIPROCESSING)
74    /*
75     *  Initialize the system state based on whether this is an MP system.
76     *  In an MP configuration, internally we view single processor
77     *  systems as a very restricted multiprocessor system.
78     */
79    _Configuration_MP_table = rtems_configuration_get_user_multiprocessing_table();
80
81    if ( _Configuration_MP_table == NULL ) {
82      _Configuration_MP_table =
83        (void *)&_Initialization_Default_multiprocessing_table;
84      _System_state_Handler_initialization( FALSE );
85    } else {
86      _System_state_Handler_initialization( TRUE );
87    }
88  #else
89    _System_state_Handler_initialization( FALSE );
90  #endif
91
92  /*
93   * Initialize any target architecture specific support as early as possible
94   */
95  _CPU_Initialize();
96
97  #if defined(RTEMS_MULTIPROCESSING)
98    _Objects_MP_Handler_early_initialization();
99  #endif
100
101  /*
102   *  Do this as early as possible to ensure no debugging output
103   *  is even attempted to be printed.
104   */
105  _Debug_Manager_initialization();
106
107  _API_extensions_Initialization();
108
109  _Thread_Dispatch_initialization();
110
111  _User_extensions_Handler_initialization();
112  _ISR_Handler_initialization();
113
114  /*
115   * Initialize the internal support API and allocator Mutex
116   */
117  _Objects_Information_table[OBJECTS_INTERNAL_API] = _Internal_Objects;
118
119  _API_Mutex_Initialization( 1 );
120  _API_Mutex_Allocate( &_RTEMS_Allocator_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  _IO_Manager_initialization();
145
146  _POSIX_API_Initialize();
147
148  _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
149
150  /*
151   *  No threads should be created before this point!!!
152   *  _Thread_Executing and _Thread_Heir are not set.
153   *
154   *  At this point all API extensions are in place.  After the call to
155   *  _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set.
156   */
157  _Thread_Create_idle();
158
159  /*
160   *  Scheduling can properly occur now as long as we avoid dispatching.
161   */
162}
163
164void rtems_initialize_before_drivers(void)
165{
166
167  #if defined(RTEMS_MULTIPROCESSING)
168    _MPCI_Create_server();
169  #endif
170
171  #if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API)
172    /*
173     *  Run the API and BSPs predriver hook.
174     */
175    _API_extensions_Run_predriver();
176  #endif
177}
178
179void rtems_initialize_device_drivers(void)
180{
181  /*
182   *  Initialize all the device drivers and initialize the MPCI layer.
183   *
184   *  NOTE:  The MPCI may be build upon a device driver.
185   */
186
187  _IO_Initialize_all_drivers();
188
189  #if defined(RTEMS_MULTIPROCESSING)
190    if ( _System_state_Is_multiprocessing ) {
191      _MPCI_Initialization();
192      _MPCI_Internal_packets_Send_process_packet(
193        MPCI_PACKETS_SYSTEM_VERIFY
194      );
195    }
196  #endif
197
198  /*
199   *  Run the APIs and BSPs postdriver hooks.
200   *
201   *  The API extensions are supposed to create user initialization tasks.
202   */
203  _API_extensions_Run_postdriver();
204}
205
206void rtems_initialize_start_multitasking(void)
207{
208  _System_state_Set( SYSTEM_STATE_UP );
209
210  _SMP_Request_start_multitasking();
211
212  _Thread_Start_multitasking();
213
214  /*******************************************************************
215   *******************************************************************
216   *******************************************************************
217   ******                 APPLICATION RUNS HERE                 ******
218   ******              THE FUNCTION NEVER RETURNS               ******
219   *******************************************************************
220   *******************************************************************
221   *******************************************************************/
222}
Note: See TracBrowser for help on using the repository browser.