source: rtems/cpukit/sapi/src/exinit.c @ 790b50b

4.104.115
Last change on this file since 790b50b was 790b50b, checked in by Joel Sherrill <joel.sherrill@…>, on 12/17/08 at 22:46:05

2008-12-17 Joel Sherrill <joel.sherrill@…>

  • sapi/include/rtems/extension.h, sapi/include/rtems/io.h, sapi/src/exinit.c, sapi/src/extension.c, sapi/src/io.c, score/include/rtems/score/mpci.h, score/include/rtems/score/object.h, score/include/rtems/score/thread.h, score/include/rtems/score/tod.h, score/include/rtems/score/userext.h, score/include/rtems/score/wkspace.h, score/src/coretod.c, score/src/mpci.c, score/src/object.c, score/src/thread.c, score/src/userext.c, score/src/wkspace.c: Convert SAPI manager and SuperCore? Handler initialization routines to directly pull parameters from configuration table.
  • Property mode set to 100644
File size: 5.6 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{
[aac75d3b]66  rtems_interrupt_level  bsp_level;
[ac7d5ef0]67
68  /*
69   *  Dispatching and interrupts are disabled until the end of the
70   *  initialization sequence.  This prevents an inadvertent context
71   *  switch before the executive is initialized.
72   */
73  _ISR_Disable( bsp_level );
74
[976162a6]75  /*
76   * Initialize any target architecture specific support as early as possible
77   */
[6aa25da]78  _CPU_Initialize( _Thread_Dispatch );
[976162a6]79
[aac75d3b]80  #if defined(RTEMS_MULTIPROCESSING)
81    /*
82     *  Initialize the system state based on whether this is an MP system.
83     *  In an MP configuration, internally we view single processor
84     *  systems as a very restricted multiprocessor system.
85     */
86    _Configuration_MP_table = Configuration.User_multiprocessing_table;
87
88    if ( _Configuration_MP_table == NULL ) {
89      _Configuration_MP_table =
90        (void *)&_Initialization_Default_multiprocessing_table;
91      _System_state_Handler_initialization( FALSE );
92    } else {
93      _System_state_Handler_initialization( TRUE );
94    }
95  #else
[9221838]96    _System_state_Handler_initialization( FALSE );
[aac75d3b]97  #endif
[ac7d5ef0]98
[3a4ae6c]99  /*
[aac75d3b]100   *  Do this as early as possible to ensure no debugging output
[3a4ae6c]101   *  is even attempted to be printed.
102   */
103
104  _Debug_Manager_initialization();
[ac7d5ef0]105
[7af35da5]106  _API_extensions_Initialization();
107
[ac7d5ef0]108  _Thread_Dispatch_initialization();
109
[f5f4566]110  /*
111   *  Before this is called, we are not allowed to allocate memory
112   *  from the Workspace because it is not initialized.
113   */
[790b50b]114  _Workspace_Handler_initialization();
[0451b44]115
[790b50b]116  _User_extensions_Handler_initialization();
[ac7d5ef0]117  _ISR_Handler_initialization();
[790b50b]118  _Objects_Handler_initialization();
[0577ec1d]119
[70669f28]120  /*
[790b50b]121   * Initialize the internal support API and allocator Mutex
[70669f28]122   */
[790b50b]123  _Objects_Information_table[OBJECTS_INTERNAL_API] = _Internal_Objects;
124
[70669f28]125  _API_Mutex_Initialization( 1 );
[8fd28d83]126  _API_Mutex_Allocate( &_RTEMS_Allocator_Mutex );
[70669f28]127
[ac7d5ef0]128  _Priority_Handler_initialization();
129  _Watchdog_Handler_initialization();
[790b50b]130  _TOD_Handler_initialization();
[ac7d5ef0]131
[790b50b]132  _Thread_Handler_initialization();
[ac7d5ef0]133
[aac75d3b]134  #if defined(RTEMS_MULTIPROCESSING)
[790b50b]135    _MPCI_Handler_initialization( RTEMS_TIMEOUT );
[aac75d3b]136  #endif
[ac7d5ef0]137
[3a4ae6c]138/* MANAGERS */
[ac7d5ef0]139
[aac75d3b]140  _RTEMS_API_Initialize();
[0577ec1d]141
[790b50b]142  _Extension_Manager_initialization();
[ac7d5ef0]143
[790b50b]144  _IO_Manager_initialization();
[ac7d5ef0]145
[aac75d3b]146  #ifdef RTEMS_POSIX_API
147    _POSIX_API_Initialize();
148  #endif
[d4b44877]149
[aac75d3b]150  #ifdef RTEMS_ITRON_API
151    _ITRON_API_Initialize();
152  #endif
[352c9b2]153
[56d34e6]154  _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
155
156  /*
[8486081]157   *  No threads should be created before this point!!!
[a2a8c5b]158   *  _Thread_Executing and _Thread_Heir are not set.
[56d34e6]159   *
160   *  At this point all API extensions are in place.  After the call to
[a2a8c5b]161   *  _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set.
[56d34e6]162   */
[3a4ae6c]163
[56d34e6]164  _Thread_Create_idle();
165
[a2a8c5b]166  /*
167   *  Scheduling can properly occur now as long as we avoid dispatching.
168   */
[d86ae06]169}
[a2a8c5b]170
[d86ae06]171void rtems_initialize_before_drivers(void)
172{
[a2a8c5b]173
[aac75d3b]174  #if defined(RTEMS_MULTIPROCESSING)
175    _MPCI_Create_server();
176  #endif
[ac7d5ef0]177
[389fa850]178  /*
179   *  Run the API and BSPs predriver hook.
180   */
[8486081]181
[389fa850]182  _API_extensions_Run_predriver();
[8486081]183
[d86ae06]184}
[8486081]185
[d86ae06]186void rtems_initialize_device_drivers(void)
187{
[389fa850]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   */
[8486081]193
[389fa850]194  _IO_Initialize_all_drivers();
[8486081]195
[aac75d3b]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
[8486081]204
[389fa850]205  /*
206   *  Run the APIs and BSPs postdriver hooks.
207   *
208   *  The API extensions are supposed to create user initialization tasks.
209   */
[8486081]210
[389fa850]211  _API_extensions_Run_postdriver();
[ac7d5ef0]212}
213
[d86ae06]214void rtems_initialize_start_multitasking(void)
[ac7d5ef0]215{
216
217  _System_state_Set( SYSTEM_STATE_BEGIN_MULTITASKING );
218
[f972294d]219  _Thread_Start_multitasking();
[ac7d5ef0]220
[d86ae06]221  /*******************************************************************
222   *******************************************************************
223   *******************************************************************
224   ******                 APPLICATION RUNS HERE                 ******
225   ******            RETURNS WHEN SYSTEM IS SHUT DOWN           ******
226   *******************************************************************
227   *******************************************************************
228   *******************************************************************/
[ac7d5ef0]229}
Note: See TracBrowser for help on using the repository browser.