source: rtems/cpukit/sapi/src/exinit.c @ 47a3cd8

4.115
Last change on this file since 47a3cd8 was 47a3cd8, checked in by Sebastian Huber <sebastian.huber@…>, on 08/09/12 at 14:48:00

score: Work area initialization API change

The work areas (RTEMS work space and C program heap) will be initialized
now in a separate step and are no longer part of
rtems_initialize_data_structures(). Initialization is performed with
tables of Heap_Area entries. This allows usage of scattered memory
areas present on various small scale micro-controllers.

The sbrk() support API changes also. The bsp_sbrk_init() must now deal
with a minimum size for the first memory chunk to take the configured
work space size into account.

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