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

4.104.115
Last change on this file since fc5490f was 45d107ec, checked in by Joel Sherrill <joel.sherrill@…>, on 02/11/09 at 21:48:42

2009-02-11 Joel Sherrill <joel.sherrill@…>

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