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

4.115
Last change on this file since e6c87f7 was e6c87f7, checked in by Joel Sherrill <joel.sherrill@…>, on 03/04/14 at 21:54:12

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
RevLine 
[4c98a3e]1/**
2 * @file
3 *
[e6c87f7]4 * @brief Initialization Manager
[4c98a3e]5 *
6 * @ingroup ClassicRTEMS
7 */
8
[ac7d5ef0]9/*
[e6c87f7]10 *  COPYRIGHT (c) 1989-2014.
[ac7d5ef0]11 *  On-Line Applications Research Corporation (OAR).
12 *
[98e4ebf5]13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
[2ba508b]15 *  http://www.rtems.com/license/LICENSE.
[ac7d5ef0]16 */
17
[16351f7a]18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
[ac7d5ef0]22/*
[8486081]23 *  SCORE_INIT and SAPI_INIT are defined so all of the super core and
[c627b2a3]24 *  super API data will be included in this object file.
[ac7d5ef0]25 */
26
[c627b2a3]27#define SAPI_INIT
28#define SCORE_INIT
[ac7d5ef0]29
30#include <rtems/system.h>
31#include <rtems/config.h>
32#include <rtems/debug.h>
[ac252bdc]33#include <rtems/extensionimpl.h>
[ac7d5ef0]34#include <rtems/init.h>
35#include <rtems/io.h>
[5e9b32b]36#include <rtems/score/sysstate.h>
[ac7d5ef0]37
[5e9b32b]38#include <rtems/score/apiext.h>
[a2a8c5b]39#include <rtems/score/apimutex.h>
[5e9b32b]40#include <rtems/score/copyrt.h>
[039a189d]41#include <rtems/score/cpusetimpl.h>
[5e9b32b]42#include <rtems/score/heap.h>
43#include <rtems/score/interr.h>
44#include <rtems/score/isr.h>
45#include <rtems/score/priority.h>
[c6e21ee1]46#include <rtems/score/schedulerimpl.h>
[6ca4f6a]47#include <rtems/score/smpimpl.h>
[5618c37a]48#include <rtems/score/threadimpl.h>
[f031df0e]49#include <rtems/score/todimpl.h>
[3be0c9a]50#include <rtems/score/userextimpl.h>
[4b48ece0]51#include <rtems/score/watchdogimpl.h>
[5e9b32b]52#include <rtems/score/wkspace.h>
[3a4ae6c]53
[ac7d5ef0]54#include <rtems/sptables.h>
55
[c627b2a3]56
[3a4ae6c]57#include <rtems/rtems/rtemsapi.h>
[e6c87f7]58#include <rtems/posix/posixapi.h>
[352c9b2]59
[0577ec1d]60Objects_Information *_Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ];
[3a4ae6c]61
[aac75d3b]62void rtems_initialize_data_structures(void)
[ac7d5ef0]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.
[a0d22251]68   *
69   *  WARNING: Interrupts should have been disabled by the BSP and
70   *           are disabled by boot_card().
[ac7d5ef0]71   */
72
[aac75d3b]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     */
[f536e12]79    _Configuration_MP_table = rtems_configuration_get_user_multiprocessing_table();
[aac75d3b]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
[9221838]89    _System_state_Handler_initialization( FALSE );
[aac75d3b]90  #endif
[ac7d5ef0]91
[45d107ec]92  /*
93   * Initialize any target architecture specific support as early as possible
94   */
95  _CPU_Initialize();
96
[562eab5c]97  #if defined(RTEMS_MULTIPROCESSING)
98    _Objects_MP_Handler_early_initialization();
99  #endif
100
[3a4ae6c]101  /*
[aac75d3b]102   *  Do this as early as possible to ensure no debugging output
[3a4ae6c]103   *  is even attempted to be printed.
104   */
105  _Debug_Manager_initialization();
[ac7d5ef0]106
[7af35da5]107  _API_extensions_Initialization();
108
[ac7d5ef0]109  _Thread_Dispatch_initialization();
110
[790b50b]111  _User_extensions_Handler_initialization();
[ac7d5ef0]112  _ISR_Handler_initialization();
[0577ec1d]113
[70669f28]114  /*
[790b50b]115   * Initialize the internal support API and allocator Mutex
[70669f28]116   */
[790b50b]117  _Objects_Information_table[OBJECTS_INTERNAL_API] = _Internal_Objects;
118
[70669f28]119  _API_Mutex_Initialization( 1 );
[8fd28d83]120  _API_Mutex_Allocate( &_RTEMS_Allocator_Mutex );
[70669f28]121
[ac7d5ef0]122  _Watchdog_Handler_initialization();
[790b50b]123  _TOD_Handler_initialization();
[ac7d5ef0]124
[790b50b]125  _Thread_Handler_initialization();
[ac7d5ef0]126
[0faa9dad]127  _Scheduler_Handler_initialization();
128
[aac75d3b]129  #if defined(RTEMS_MULTIPROCESSING)
[584ab9e]130    _Objects_MP_Handler_initialization();
[790b50b]131    _MPCI_Handler_initialization( RTEMS_TIMEOUT );
[aac75d3b]132  #endif
[ac7d5ef0]133
[039a189d]134  _SMP_Handler_initialize();
135
136  _CPU_set_Handler_initialization();
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
[e6c87f7]146  _POSIX_API_Initialize();
[d4b44877]147
[56d34e6]148  _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
149
150  /*
[8486081]151   *  No threads should be created before this point!!!
[a2a8c5b]152   *  _Thread_Executing and _Thread_Heir are not set.
[56d34e6]153   *
154   *  At this point all API extensions are in place.  After the call to
[a2a8c5b]155   *  _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set.
[56d34e6]156   */
157  _Thread_Create_idle();
158
[a2a8c5b]159  /*
160   *  Scheduling can properly occur now as long as we avoid dispatching.
161   */
[d86ae06]162}
[a2a8c5b]163
[d86ae06]164void rtems_initialize_before_drivers(void)
165{
[a2a8c5b]166
[aac75d3b]167  #if defined(RTEMS_MULTIPROCESSING)
168    _MPCI_Create_server();
169  #endif
[ac7d5ef0]170
[27b961a]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
[d86ae06]177}
[8486081]178
[d86ae06]179void rtems_initialize_device_drivers(void)
180{
[389fa850]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   */
[8486081]186
[389fa850]187  _IO_Initialize_all_drivers();
[8486081]188
[aac75d3b]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
[8486081]197
[389fa850]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();
[ac7d5ef0]204}
205
[48bff53b]206void rtems_initialize_start_multitasking(void)
[ac7d5ef0]207{
[b4b309c]208  _System_state_Set( SYSTEM_STATE_UP );
209
[7336be9d]210  _SMP_Request_start_multitasking();
[e071c183]211
[514705d]212  _Thread_Start_multitasking();
[ac7d5ef0]213
[d86ae06]214  /*******************************************************************
215   *******************************************************************
216   *******************************************************************
217   ******                 APPLICATION RUNS HERE                 ******
[514705d]218   ******              THE FUNCTION NEVER RETURNS               ******
[d86ae06]219   *******************************************************************
220   *******************************************************************
221   *******************************************************************/
[ac7d5ef0]222}
Note: See TracBrowser for help on using the repository browser.