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

4.115
Last change on this file since 0faa9dad was 0faa9dad, checked in by Joel Sherrill <joel.sherrill@…>, on 11/24/10 at 15:51:28

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
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>
[0faa9dad]45#include <rtems/score/scheduler.h>
[5e9b32b]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>
[3a4ae6c]51
[ac7d5ef0]52#include <rtems/sptables.h>
53
[c627b2a3]54
[3a4ae6c]55#include <rtems/rtems/rtemsapi.h>
[c627b2a3]56#ifdef RTEMS_POSIX_API
[aac75d3b]57  #include <rtems/posix/posixapi.h>
[c627b2a3]58#endif
[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     */
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
[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
[f5f4566]111  /*
112   *  Before this is called, we are not allowed to allocate memory
113   *  from the Workspace because it is not initialized.
114   */
[790b50b]115  _Workspace_Handler_initialization();
[0451b44]116
[790b50b]117  _User_extensions_Handler_initialization();
[ac7d5ef0]118  _ISR_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
[a55e305]128  _Priority_bit_map_Handler_initialization();
[ac7d5ef0]129  _Watchdog_Handler_initialization();
[790b50b]130  _TOD_Handler_initialization();
[ac7d5ef0]131
[790b50b]132  _Thread_Handler_initialization();
[ac7d5ef0]133
[0faa9dad]134  _Scheduler_Handler_initialization();
135
[aac75d3b]136  #if defined(RTEMS_MULTIPROCESSING)
[584ab9e]137    _Objects_MP_Handler_initialization();
[790b50b]138    _MPCI_Handler_initialization( RTEMS_TIMEOUT );
[aac75d3b]139  #endif
[ac7d5ef0]140
[3a4ae6c]141/* MANAGERS */
[ac7d5ef0]142
[aac75d3b]143  _RTEMS_API_Initialize();
[0577ec1d]144
[790b50b]145  _Extension_Manager_initialization();
[ac7d5ef0]146
[790b50b]147  _IO_Manager_initialization();
[ac7d5ef0]148
[aac75d3b]149  #ifdef RTEMS_POSIX_API
150    _POSIX_API_Initialize();
151  #endif
[d4b44877]152
[56d34e6]153  _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
154
155  /*
[8486081]156   *  No threads should be created before this point!!!
[a2a8c5b]157   *  _Thread_Executing and _Thread_Heir are not set.
[56d34e6]158   *
159   *  At this point all API extensions are in place.  After the call to
[a2a8c5b]160   *  _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set.
[56d34e6]161   */
162  _Thread_Create_idle();
163
[a2a8c5b]164  /*
165   *  Scheduling can properly occur now as long as we avoid dispatching.
166   */
[d86ae06]167}
[a2a8c5b]168
[d86ae06]169void rtems_initialize_before_drivers(void)
170{
[a2a8c5b]171
[aac75d3b]172  #if defined(RTEMS_MULTIPROCESSING)
173    _MPCI_Create_server();
174  #endif
[ac7d5ef0]175
[27b961a]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
[d86ae06]182}
[8486081]183
[d86ae06]184void rtems_initialize_device_drivers(void)
185{
[389fa850]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   */
[8486081]191
[389fa850]192  _IO_Initialize_all_drivers();
[8486081]193
[aac75d3b]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
[8486081]202
[389fa850]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();
[ac7d5ef0]209}
210
[d86ae06]211void rtems_initialize_start_multitasking(void)
[ac7d5ef0]212{
213
214  _System_state_Set( SYSTEM_STATE_BEGIN_MULTITASKING );
215
[f972294d]216  _Thread_Start_multitasking();
[ac7d5ef0]217
[d86ae06]218  /*******************************************************************
219   *******************************************************************
220   *******************************************************************
221   ******                 APPLICATION RUNS HERE                 ******
222   ******            RETURNS WHEN SYSTEM IS SHUT DOWN           ******
223   *******************************************************************
224   *******************************************************************
225   *******************************************************************/
[ac7d5ef0]226}
Note: See TracBrowser for help on using the repository browser.