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

4.115
Last change on this file since f8ff2a0 was 514705d, checked in by Sebastian Huber <sebastian.huber@…>, on 02/12/14 at 15:05:35

score: Delete _Thread_BSP_context

Do not return to BSP context in the exit() shutdown path. This makes it
possible to re-use the initialization stack. It can be used for the
interrupt stack for example. On targets with a small RAM this is a
considerable benefit.

This change eliminates also some special cases and simplifies the code.

Delete _Thread_Set_global_exit_status(),
_Thread_Get_global_exit_status() and _Thread_Stop_multitasking().

  • Property mode set to 100644
File size: 5.8 KB
Line 
1/**
2 * @file
3 *
4 * @brief Device Driver Initialization Functions
5 *
6 * @ingroup ClassicRTEMS
7 */
8
9/*
10 *  Initialization Manager
11 *
12 *  COPYRIGHT (c) 1989-2011.
13 *  On-Line Applications Research Corporation (OAR).
14 *
15 *  The license and distribution terms for this file may be
16 *  found in the file LICENSE in this distribution or at
17 *  http://www.rtems.com/license/LICENSE.
18 */
19
20#if HAVE_CONFIG_H
21#include "config.h"
22#endif
23
24/*
25 *  SCORE_INIT and SAPI_INIT are defined so all of the super core and
26 *  super API data will be included in this object file.
27 */
28
29#define SAPI_INIT
30#define SCORE_INIT
31
32#include <rtems/system.h>
33#include <rtems/config.h>
34#include <rtems/debug.h>
35#include <rtems/extensionimpl.h>
36#include <rtems/init.h>
37#include <rtems/io.h>
38#include <rtems/score/sysstate.h>
39
40#include <rtems/score/apiext.h>
41#include <rtems/score/apimutex.h>
42#include <rtems/score/copyrt.h>
43#include <rtems/score/heap.h>
44#include <rtems/score/interr.h>
45#include <rtems/score/isr.h>
46#include <rtems/score/priority.h>
47#include <rtems/score/schedulerimpl.h>
48#include <rtems/score/threadimpl.h>
49#include <rtems/score/todimpl.h>
50#include <rtems/score/userextimpl.h>
51#include <rtems/score/watchdogimpl.h>
52#include <rtems/score/wkspace.h>
53
54#include <rtems/sptables.h>
55
56
57#include <rtems/rtems/rtemsapi.h>
58#ifdef RTEMS_POSIX_API
59  #include <rtems/posix/posixapi.h>
60#endif
61
62#if defined(RTEMS_SMP)
63  #include <rtems/score/smp.h>
64  #include <rtems/score/percpu.h>
65#endif
66
67Objects_Information *_Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ];
68
69void rtems_initialize_data_structures(void)
70{
71  /*
72   *  Dispatching and interrupts are disabled until the end of the
73   *  initialization sequence.  This prevents an inadvertent context
74   *  switch before the executive is initialized.
75   *
76   *  WARNING: Interrupts should have been disabled by the BSP and
77   *           are disabled by boot_card().
78   */
79
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 = rtems_configuration_get_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
96    _System_state_Handler_initialization( FALSE );
97  #endif
98
99  /*
100   * Initialize any target architecture specific support as early as possible
101   */
102  _CPU_Initialize();
103
104  #if defined(RTEMS_MULTIPROCESSING)
105    _Objects_MP_Handler_early_initialization();
106  #endif
107
108  /*
109   *  Do this as early as possible to ensure no debugging output
110   *  is even attempted to be printed.
111   */
112  _Debug_Manager_initialization();
113
114  _API_extensions_Initialization();
115
116  _Thread_Dispatch_initialization();
117
118  _User_extensions_Handler_initialization();
119  _ISR_Handler_initialization();
120
121  /*
122   * Initialize the internal support API and allocator Mutex
123   */
124  _Objects_Information_table[OBJECTS_INTERNAL_API] = _Internal_Objects;
125
126  _API_Mutex_Initialization( 1 );
127  _API_Mutex_Allocate( &_RTEMS_Allocator_Mutex );
128
129  _Watchdog_Handler_initialization();
130  _TOD_Handler_initialization();
131
132  _Thread_Handler_initialization();
133
134  _Scheduler_Handler_initialization();
135
136  #if defined(RTEMS_MULTIPROCESSING)
137    _Objects_MP_Handler_initialization();
138    _MPCI_Handler_initialization( RTEMS_TIMEOUT );
139  #endif
140
141/* MANAGERS */
142
143  _RTEMS_API_Initialize();
144
145  _Extension_Manager_initialization();
146
147  _IO_Manager_initialization();
148
149  #ifdef RTEMS_POSIX_API
150    _POSIX_API_Initialize();
151  #endif
152
153  #if defined(RTEMS_SMP)
154    _SMP_Handler_initialize();
155  #endif
156
157  _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
158
159  /*
160   *  No threads should be created before this point!!!
161   *  _Thread_Executing and _Thread_Heir are not set.
162   *
163   *  At this point all API extensions are in place.  After the call to
164   *  _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set.
165   */
166  _Thread_Create_idle();
167
168  /*
169   *  Scheduling can properly occur now as long as we avoid dispatching.
170   */
171}
172
173void rtems_initialize_before_drivers(void)
174{
175
176  #if defined(RTEMS_MULTIPROCESSING)
177    _MPCI_Create_server();
178  #endif
179
180  #if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API)
181    /*
182     *  Run the API and BSPs predriver hook.
183     */
184    _API_extensions_Run_predriver();
185  #endif
186}
187
188void rtems_initialize_device_drivers(void)
189{
190  /*
191   *  Initialize all the device drivers and initialize the MPCI layer.
192   *
193   *  NOTE:  The MPCI may be build upon a device driver.
194   */
195
196  _IO_Initialize_all_drivers();
197
198  #if defined(RTEMS_MULTIPROCESSING)
199    if ( _System_state_Is_multiprocessing ) {
200      _MPCI_Initialization();
201      _MPCI_Internal_packets_Send_process_packet(
202        MPCI_PACKETS_SYSTEM_VERIFY
203      );
204    }
205  #endif
206
207  /*
208   *  Run the APIs and BSPs postdriver hooks.
209   *
210   *  The API extensions are supposed to create user initialization tasks.
211   */
212  _API_extensions_Run_postdriver();
213}
214
215void rtems_initialize_start_multitasking(void)
216{
217  _System_state_Set( SYSTEM_STATE_UP );
218
219#if defined(RTEMS_SMP)
220  _SMP_Request_other_cores_to_perform_first_context_switch();
221#endif
222
223  _Thread_Start_multitasking();
224
225  /*******************************************************************
226   *******************************************************************
227   *******************************************************************
228   ******                 APPLICATION RUNS HERE                 ******
229   ******              THE FUNCTION NEVER RETURNS               ******
230   *******************************************************************
231   *******************************************************************
232   *******************************************************************/
233}
Note: See TracBrowser for help on using the repository browser.