source: rtems/cpukit/sapi/src/exinit.c @ 562eab5c

4.104.115
Last change on this file since 562eab5c was 562eab5c, checked in by Joel Sherrill <joel.sherrill@…>, on 07/03/09 at 15:13:47

2009-07-03 Daniel Hellstrom <daniel@…>

  • sapi/src/exinit.c, score/include/rtems/score/objectmp.h, score/src/objectmp.c: Ensure local node number is set early enough in MP configurations.
  • Property mode set to 100644
File size: 5.8 KB
RevLine 
[ac7d5ef0]1/*
2 *  Initialization Manager
3 *
[d86ae06]4 *  COPYRIGHT (c) 1989-2008.
[ac7d5ef0]5 *  On-Line Applications Research Corporation (OAR).
6 *
[98e4ebf5]7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
[2ba508b]9 *  http://www.rtems.com/license/LICENSE.
[ac7d5ef0]10 *
11 *  $Id$
12 */
13
[16351f7a]14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
[ac7d5ef0]18/*
[8486081]19 *  SCORE_INIT and SAPI_INIT are defined so all of the super core and
[c627b2a3]20 *  super API data will be included in this object file.
[ac7d5ef0]21 */
22
[c627b2a3]23#define SAPI_INIT
24#define SCORE_INIT
[ac7d5ef0]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>
[5e9b32b]33#include <rtems/score/sysstate.h>
[ac7d5ef0]34
[5e9b32b]35#include <rtems/score/apiext.h>
[a2a8c5b]36#include <rtems/score/apimutex.h>
[5e9b32b]37#include <rtems/score/copyrt.h>
38#include <rtems/score/heap.h>
39#include <rtems/score/interr.h>
40#include <rtems/score/isr.h>
[97e2729d]41#if defined(RTEMS_MULTIPROCESSING)
[5e9b32b]42#include <rtems/score/mpci.h>
[97e2729d]43#endif
[5e9b32b]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>
[3a4ae6c]50
[ac7d5ef0]51#include <rtems/sptables.h>
52
[c627b2a3]53
[3a4ae6c]54#include <rtems/rtems/rtemsapi.h>
[c627b2a3]55#ifdef RTEMS_POSIX_API
[aac75d3b]56  #include <rtems/posix/posixapi.h>
[c627b2a3]57#endif
[352c9b2]58#ifdef RTEMS_ITRON_API
[aac75d3b]59  #include <rtems/itron/itronapi.h>
[352c9b2]60#endif
61
[0577ec1d]62Objects_Information *_Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ];
[3a4ae6c]63
[aac75d3b]64void rtems_initialize_data_structures(void)
[ac7d5ef0]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.
[a0d22251]70   *
71   *  WARNING: Interrupts should have been disabled by the BSP and
72   *           are disabled by boot_card().
[ac7d5ef0]73   */
74
[aac75d3b]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
[9221838]91    _System_state_Handler_initialization( FALSE );
[aac75d3b]92  #endif
[ac7d5ef0]93
[45d107ec]94  /*
95   * Initialize any target architecture specific support as early as possible
96   */
97  _CPU_Initialize();
98
[562eab5c]99  #if defined(RTEMS_MULTIPROCESSING)
100    _Objects_MP_Handler_early_initialization();
101  #endif
102
[3a4ae6c]103  /*
[aac75d3b]104   *  Do this as early as possible to ensure no debugging output
[3a4ae6c]105   *  is even attempted to be printed.
106   */
107
108  _Debug_Manager_initialization();
[ac7d5ef0]109
[7af35da5]110  _API_extensions_Initialization();
111
[ac7d5ef0]112  _Thread_Dispatch_initialization();
113
[f5f4566]114  /*
115   *  Before this is called, we are not allowed to allocate memory
116   *  from the Workspace because it is not initialized.
117   */
[790b50b]118  _Workspace_Handler_initialization();
[0451b44]119
[790b50b]120  _User_extensions_Handler_initialization();
[ac7d5ef0]121  _ISR_Handler_initialization();
[0577ec1d]122
[70669f28]123  /*
[790b50b]124   * Initialize the internal support API and allocator Mutex
[70669f28]125   */
[790b50b]126  _Objects_Information_table[OBJECTS_INTERNAL_API] = _Internal_Objects;
127
[70669f28]128  _API_Mutex_Initialization( 1 );
[8fd28d83]129  _API_Mutex_Allocate( &_RTEMS_Allocator_Mutex );
[70669f28]130
[ac7d5ef0]131  _Priority_Handler_initialization();
132  _Watchdog_Handler_initialization();
[790b50b]133  _TOD_Handler_initialization();
[ac7d5ef0]134
[790b50b]135  _Thread_Handler_initialization();
[ac7d5ef0]136
[aac75d3b]137  #if defined(RTEMS_MULTIPROCESSING)
[584ab9e]138    _Objects_MP_Handler_initialization();
[790b50b]139    _MPCI_Handler_initialization( RTEMS_TIMEOUT );
[aac75d3b]140  #endif
[ac7d5ef0]141
[3a4ae6c]142/* MANAGERS */
[ac7d5ef0]143
[aac75d3b]144  _RTEMS_API_Initialize();
[0577ec1d]145
[790b50b]146  _Extension_Manager_initialization();
[ac7d5ef0]147
[790b50b]148  _IO_Manager_initialization();
[ac7d5ef0]149
[aac75d3b]150  #ifdef RTEMS_POSIX_API
151    _POSIX_API_Initialize();
152  #endif
[d4b44877]153
[aac75d3b]154  #ifdef RTEMS_ITRON_API
155    _ITRON_API_Initialize();
156  #endif
[352c9b2]157
[56d34e6]158  _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
159
160  /*
[8486081]161   *  No threads should be created before this point!!!
[a2a8c5b]162   *  _Thread_Executing and _Thread_Heir are not set.
[56d34e6]163   *
164   *  At this point all API extensions are in place.  After the call to
[a2a8c5b]165   *  _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set.
[56d34e6]166   */
[3a4ae6c]167
[56d34e6]168  _Thread_Create_idle();
169
[a2a8c5b]170  /*
171   *  Scheduling can properly occur now as long as we avoid dispatching.
172   */
[d86ae06]173}
[a2a8c5b]174
[d86ae06]175void rtems_initialize_before_drivers(void)
176{
[a2a8c5b]177
[aac75d3b]178  #if defined(RTEMS_MULTIPROCESSING)
179    _MPCI_Create_server();
180  #endif
[ac7d5ef0]181
[389fa850]182  /*
183   *  Run the API and BSPs predriver hook.
184   */
[8486081]185
[389fa850]186  _API_extensions_Run_predriver();
[8486081]187
[d86ae06]188}
[8486081]189
[d86ae06]190void rtems_initialize_device_drivers(void)
191{
[389fa850]192  /*
193   *  Initialize all the device drivers and initialize the MPCI layer.
194   *
195   *  NOTE:  The MPCI may be build upon a device driver.
196   */
[8486081]197
[389fa850]198  _IO_Initialize_all_drivers();
[8486081]199
[aac75d3b]200  #if defined(RTEMS_MULTIPROCESSING)
201    if ( _System_state_Is_multiprocessing ) {
202      _MPCI_Initialization();
203      _MPCI_Internal_packets_Send_process_packet(
204        MPCI_PACKETS_SYSTEM_VERIFY
205      );
206    }
207  #endif
[8486081]208
[389fa850]209  /*
210   *  Run the APIs and BSPs postdriver hooks.
211   *
212   *  The API extensions are supposed to create user initialization tasks.
213   */
[8486081]214
[389fa850]215  _API_extensions_Run_postdriver();
[ac7d5ef0]216}
217
[d86ae06]218void rtems_initialize_start_multitasking(void)
[ac7d5ef0]219{
220
221  _System_state_Set( SYSTEM_STATE_BEGIN_MULTITASKING );
222
[f972294d]223  _Thread_Start_multitasking();
[ac7d5ef0]224
[d86ae06]225  /*******************************************************************
226   *******************************************************************
227   *******************************************************************
228   ******                 APPLICATION RUNS HERE                 ******
229   ******            RETURNS WHEN SYSTEM IS SHUT DOWN           ******
230   *******************************************************************
231   *******************************************************************
232   *******************************************************************/
[ac7d5ef0]233}
Note: See TracBrowser for help on using the repository browser.