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

4.115
Last change on this file since f0bfd7d8 was f0bfd7d8, checked in by Sebastian Huber <sebastian.huber@…>, on 07/24/13 at 11:25:57

score: Create prioritybitmap implementation header

Move implementation specific parts of prioritybitmap.h and
prioritybitmap.inl into new header file prioritybitmapimpl.h. The
prioritybitmap.h contains now only the application visible API.

Move content of bitfield.h into prioritybitmapimpl.h.

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