source: rtems/cpukit/sapi/src/exinit.c @ 6c2eedc

4.115
Last change on this file since 6c2eedc was 6c2eedc, checked in by Sebastian Huber <sebastian.huber@…>, on 05/13/13 at 11:37:06

smp: Add maximum_processors field to config

Delete rtems_configuration_get_smp_maximum_processors(). Delete
rtems_configuration_smp_maximum_processors variable. Add
maximum_processors field to rtems_configuration_table if RTEMS_SMP is
defined. Add rtems_configuration_get_maximum_processors().

  • Property mode set to 100644
File size: 6.2 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>
35#include <rtems/extension.h>
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>
[97e2729d]47#if defined(RTEMS_MULTIPROCESSING)
[5e9b32b]48#include <rtems/score/mpci.h>
[97e2729d]49#endif
[5e9b32b]50#include <rtems/score/priority.h>
[0faa9dad]51#include <rtems/score/scheduler.h>
[5e9b32b]52#include <rtems/score/thread.h>
53#include <rtems/score/tod.h>
[3be0c9a]54#include <rtems/score/userextimpl.h>
[5e9b32b]55#include <rtems/score/watchdog.h>
56#include <rtems/score/wkspace.h>
[3a4ae6c]57
[ac7d5ef0]58#include <rtems/sptables.h>
59
[c627b2a3]60
[3a4ae6c]61#include <rtems/rtems/rtemsapi.h>
[c627b2a3]62#ifdef RTEMS_POSIX_API
[aac75d3b]63  #include <rtems/posix/posixapi.h>
[c627b2a3]64#endif
[352c9b2]65
[06dcaf0]66#if defined(RTEMS_SMP)
[0d5a9f1]67  #include <rtems/score/smp.h>
[06dcaf0]68  #include <rtems/score/percpu.h>
69#endif
70
[0577ec1d]71Objects_Information *_Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ];
[3a4ae6c]72
[aac75d3b]73void rtems_initialize_data_structures(void)
[ac7d5ef0]74{
75  /*
76   *  Dispatching and interrupts are disabled until the end of the
77   *  initialization sequence.  This prevents an inadvertent context
78   *  switch before the executive is initialized.
[a0d22251]79   *
80   *  WARNING: Interrupts should have been disabled by the BSP and
81   *           are disabled by boot_card().
[ac7d5ef0]82   */
83
[aac75d3b]84  #if defined(RTEMS_MULTIPROCESSING)
85    /*
86     *  Initialize the system state based on whether this is an MP system.
87     *  In an MP configuration, internally we view single processor
88     *  systems as a very restricted multiprocessor system.
89     */
[f536e12]90    _Configuration_MP_table = rtems_configuration_get_user_multiprocessing_table();
[aac75d3b]91
92    if ( _Configuration_MP_table == NULL ) {
93      _Configuration_MP_table =
94        (void *)&_Initialization_Default_multiprocessing_table;
95      _System_state_Handler_initialization( FALSE );
96    } else {
97      _System_state_Handler_initialization( TRUE );
98    }
99  #else
[9221838]100    _System_state_Handler_initialization( FALSE );
[aac75d3b]101  #endif
[ac7d5ef0]102
[45d107ec]103  /*
104   * Initialize any target architecture specific support as early as possible
105   */
106  _CPU_Initialize();
107
[562eab5c]108  #if defined(RTEMS_MULTIPROCESSING)
109    _Objects_MP_Handler_early_initialization();
110  #endif
111
[3a4ae6c]112  /*
[aac75d3b]113   *  Do this as early as possible to ensure no debugging output
[3a4ae6c]114   *  is even attempted to be printed.
115   */
116  _Debug_Manager_initialization();
[ac7d5ef0]117
[7af35da5]118  _API_extensions_Initialization();
119
[ac7d5ef0]120  _Thread_Dispatch_initialization();
121
[06dcaf0]122  #if defined(RTEMS_SMP)
123    _SMP_Handler_initialize();
124  #endif
125
[790b50b]126  _User_extensions_Handler_initialization();
[ac7d5ef0]127  _ISR_Handler_initialization();
[0577ec1d]128
[70669f28]129  /*
[790b50b]130   * Initialize the internal support API and allocator Mutex
[70669f28]131   */
[790b50b]132  _Objects_Information_table[OBJECTS_INTERNAL_API] = _Internal_Objects;
133
[70669f28]134  _API_Mutex_Initialization( 1 );
[8fd28d83]135  _API_Mutex_Allocate( &_RTEMS_Allocator_Mutex );
[70669f28]136
[a55e305]137  _Priority_bit_map_Handler_initialization();
[ac7d5ef0]138  _Watchdog_Handler_initialization();
[790b50b]139  _TOD_Handler_initialization();
[ac7d5ef0]140
[790b50b]141  _Thread_Handler_initialization();
[ac7d5ef0]142
[0faa9dad]143  _Scheduler_Handler_initialization();
144
[aac75d3b]145  #if defined(RTEMS_MULTIPROCESSING)
[584ab9e]146    _Objects_MP_Handler_initialization();
[790b50b]147    _MPCI_Handler_initialization( RTEMS_TIMEOUT );
[aac75d3b]148  #endif
[ac7d5ef0]149
[3a4ae6c]150/* MANAGERS */
[ac7d5ef0]151
[aac75d3b]152  _RTEMS_API_Initialize();
[0577ec1d]153
[790b50b]154  _Extension_Manager_initialization();
[ac7d5ef0]155
[790b50b]156  _IO_Manager_initialization();
[ac7d5ef0]157
[aac75d3b]158  #ifdef RTEMS_POSIX_API
159    _POSIX_API_Initialize();
160  #endif
[d4b44877]161
[06dcaf0]162  /*
163   * Discover and initialize the secondary cores in an SMP system.
164   */
165  #if defined(RTEMS_SMP)
[e79093a]166    _SMP_Processor_count =
[6c2eedc]167        bsp_smp_initialize( rtems_configuration_get_maximum_processors() );
[06dcaf0]168  #endif
169
[56d34e6]170  _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
171
172  /*
[8486081]173   *  No threads should be created before this point!!!
[a2a8c5b]174   *  _Thread_Executing and _Thread_Heir are not set.
[56d34e6]175   *
176   *  At this point all API extensions are in place.  After the call to
[a2a8c5b]177   *  _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set.
[56d34e6]178   */
179  _Thread_Create_idle();
180
[a2a8c5b]181  /*
182   *  Scheduling can properly occur now as long as we avoid dispatching.
183   */
[d86ae06]184}
[a2a8c5b]185
[d86ae06]186void rtems_initialize_before_drivers(void)
187{
[a2a8c5b]188
[aac75d3b]189  #if defined(RTEMS_MULTIPROCESSING)
190    _MPCI_Create_server();
191  #endif
[ac7d5ef0]192
[27b961a]193  #if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API)
194    /*
195     *  Run the API and BSPs predriver hook.
196     */
197    _API_extensions_Run_predriver();
198  #endif
[d86ae06]199}
[8486081]200
[d86ae06]201void rtems_initialize_device_drivers(void)
202{
[389fa850]203  /*
204   *  Initialize all the device drivers and initialize the MPCI layer.
205   *
206   *  NOTE:  The MPCI may be build upon a device driver.
207   */
[8486081]208
[389fa850]209  _IO_Initialize_all_drivers();
[8486081]210
[aac75d3b]211  #if defined(RTEMS_MULTIPROCESSING)
212    if ( _System_state_Is_multiprocessing ) {
213      _MPCI_Initialization();
214      _MPCI_Internal_packets_Send_process_packet(
215        MPCI_PACKETS_SYSTEM_VERIFY
216      );
217    }
218  #endif
[8486081]219
[389fa850]220  /*
221   *  Run the APIs and BSPs postdriver hooks.
222   *
223   *  The API extensions are supposed to create user initialization tasks.
224   */
225  _API_extensions_Run_postdriver();
[ac7d5ef0]226}
227
[48bff53b]228void rtems_initialize_start_multitasking(void)
[ac7d5ef0]229{
[48bff53b]230  uint32_t status;
231
[ac7d5ef0]232  _System_state_Set( SYSTEM_STATE_BEGIN_MULTITASKING );
233
[f972294d]234  _Thread_Start_multitasking();
[ac7d5ef0]235
[d86ae06]236  /*******************************************************************
237   *******************************************************************
238   *******************************************************************
239   ******                 APPLICATION RUNS HERE                 ******
240   ******            RETURNS WHEN SYSTEM IS SHUT DOWN           ******
241   *******************************************************************
242   *******************************************************************
243   *******************************************************************/
[f58ef8ae]244 
[48bff53b]245  status = _Per_CPU_Information[0].idle->Wait.return_code;
246  rtems_fatal( RTEMS_FATAL_SOURCE_EXIT, status );
[ac7d5ef0]247}
Note: See TracBrowser for help on using the repository browser.