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

4.115
Last change on this file since b4b309c was b4b309c, checked in by Sebastian Huber <sebastian.huber@…>, on 08/01/13 at 13:20:17

smp: Generalize _Thread_Start_multitasking()

Add context parameter to _Thread_Start_multitasking() and use this
function in rtems_smp_secondary_cpu_initialize(). This avoids
duplication of code.

Fix missing floating point context initialization in
rtems_smp_secondary_cpu_initialize(). Now performed via
_Thread_Start_multitasking().

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