source: rtems/cpukit/sapi/src/exinit.c @ 0faa9dad

4.11
Last change on this file since 0faa9dad was 0faa9dad, checked in by Joel Sherrill <joel.sherrill@…>, on Nov 24, 2010 at 3:51:28 PM

2010-11-24 Gedare Bloom <giddyup44@…>

PR 1647/cpukit

  • posix/src/nanosleep.c, posix/src/sched_yield.c, rtems/src/taskwakeafter.c, sapi/include/confdefs.h, sapi/include/rtems/config.h, sapi/src/exinit.c, score/Makefile.am, score/preinstall.am, score/include/rtems/score/prioritybitmap.h, score/include/rtems/score/thread.h, score/inline/rtems/score/thread.inl, score/src/thread.c, score/src/threadchangepriority.c, score/src/threadclearstate.c, score/src/threadclose.c, score/src/threadinitialize.c, score/src/threadready.c, score/src/threadresume.c, score/src/threadsetpriority.c, score/src/threadsetstate.c, score/src/threadsettransient.c, score/src/threadsuspend.c, score/src/threadtickletimeslice.c: Refactor scheduler out of thread handler to facilitate alternate scheduler implementations.
  • score/src/threadyieldprocessor.c: Removed.
  • score/src/schedulerprioritythreadschedulerupdate.c, score/src/schedulerprioritythreadschedulerfree.c, score/src/schedulerpriorityblock.c, score/src/scheduler.c, score/src/schedulerprioritythreadschedulerallocate.c, score/src/schedulerpriorityunblock.c, score/src/schedulerpriority.c, score/src/schedulerpriorityyield.c, score/include/rtems/score/schedulerpriority.h, score/include/rtems/score/scheduler.h, score/inline/rtems/score/scheduler.inl, score/inline/rtems/score/schedulerpriority.inl: New files.
  • Property mode set to 100644
File size: 5.8 KB
Line 
1/*
2 *  Initialization Manager
3 *
4 *  COPYRIGHT (c) 1989-2008.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18/*
19 *  SCORE_INIT and SAPI_INIT are defined so all of the super core and
20 *  super API data will be included in this object file.
21 */
22
23#define SAPI_INIT
24#define SCORE_INIT
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>
33#include <rtems/score/sysstate.h>
34
35#include <rtems/score/apiext.h>
36#include <rtems/score/apimutex.h>
37#include <rtems/score/copyrt.h>
38#include <rtems/score/heap.h>
39#include <rtems/score/interr.h>
40#include <rtems/score/isr.h>
41#if defined(RTEMS_MULTIPROCESSING)
42#include <rtems/score/mpci.h>
43#endif
44#include <rtems/score/priority.h>
45#include <rtems/score/scheduler.h>
46#include <rtems/score/thread.h>
47#include <rtems/score/tod.h>
48#include <rtems/score/userext.h>
49#include <rtems/score/watchdog.h>
50#include <rtems/score/wkspace.h>
51
52#include <rtems/sptables.h>
53
54
55#include <rtems/rtems/rtemsapi.h>
56#ifdef RTEMS_POSIX_API
57  #include <rtems/posix/posixapi.h>
58#endif
59
60Objects_Information *_Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ];
61
62void rtems_initialize_data_structures(void)
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.
68   *
69   *  WARNING: Interrupts should have been disabled by the BSP and
70   *           are disabled by boot_card().
71   */
72
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     */
79    _Configuration_MP_table = Configuration.User_multiprocessing_table;
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
89    _System_state_Handler_initialization( FALSE );
90  #endif
91
92  /*
93   * Initialize any target architecture specific support as early as possible
94   */
95  _CPU_Initialize();
96
97  #if defined(RTEMS_MULTIPROCESSING)
98    _Objects_MP_Handler_early_initialization();
99  #endif
100
101  /*
102   *  Do this as early as possible to ensure no debugging output
103   *  is even attempted to be printed.
104   */
105  _Debug_Manager_initialization();
106
107  _API_extensions_Initialization();
108
109  _Thread_Dispatch_initialization();
110
111  /*
112   *  Before this is called, we are not allowed to allocate memory
113   *  from the Workspace because it is not initialized.
114   */
115  _Workspace_Handler_initialization();
116
117  _User_extensions_Handler_initialization();
118  _ISR_Handler_initialization();
119
120  /*
121   * Initialize the internal support API and allocator Mutex
122   */
123  _Objects_Information_table[OBJECTS_INTERNAL_API] = _Internal_Objects;
124
125  _API_Mutex_Initialization( 1 );
126  _API_Mutex_Allocate( &_RTEMS_Allocator_Mutex );
127
128  _Priority_bit_map_Handler_initialization();
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  _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
154
155  /*
156   *  No threads should be created before this point!!!
157   *  _Thread_Executing and _Thread_Heir are not set.
158   *
159   *  At this point all API extensions are in place.  After the call to
160   *  _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set.
161   */
162  _Thread_Create_idle();
163
164  /*
165   *  Scheduling can properly occur now as long as we avoid dispatching.
166   */
167}
168
169void rtems_initialize_before_drivers(void)
170{
171
172  #if defined(RTEMS_MULTIPROCESSING)
173    _MPCI_Create_server();
174  #endif
175
176  #if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API)
177    /*
178     *  Run the API and BSPs predriver hook.
179     */
180    _API_extensions_Run_predriver();
181  #endif
182}
183
184void rtems_initialize_device_drivers(void)
185{
186  /*
187   *  Initialize all the device drivers and initialize the MPCI layer.
188   *
189   *  NOTE:  The MPCI may be build upon a device driver.
190   */
191
192  _IO_Initialize_all_drivers();
193
194  #if defined(RTEMS_MULTIPROCESSING)
195    if ( _System_state_Is_multiprocessing ) {
196      _MPCI_Initialization();
197      _MPCI_Internal_packets_Send_process_packet(
198        MPCI_PACKETS_SYSTEM_VERIFY
199      );
200    }
201  #endif
202
203  /*
204   *  Run the APIs and BSPs postdriver hooks.
205   *
206   *  The API extensions are supposed to create user initialization tasks.
207   */
208  _API_extensions_Run_postdriver();
209}
210
211void rtems_initialize_start_multitasking(void)
212{
213
214  _System_state_Set( SYSTEM_STATE_BEGIN_MULTITASKING );
215
216  _Thread_Start_multitasking();
217
218  /*******************************************************************
219   *******************************************************************
220   *******************************************************************
221   ******                 APPLICATION RUNS HERE                 ******
222   ******            RETURNS WHEN SYSTEM IS SHUT DOWN           ******
223   *******************************************************************
224   *******************************************************************
225   *******************************************************************/
226}
Note: See TracBrowser for help on using the repository browser.