source: rtems/cpukit/sapi/src/exinit.c @ 06dcaf0

4.11
Last change on this file since 06dcaf0 was 06dcaf0, checked in by Joel Sherrill <joel.sherrill@…>, on Mar 16, 2011 at 8:05:06 PM

2011-03-16 Jennifer Averett <jennifer.averett@…>

PR 1729/cpukit

  • configure.ac, sapi/include/confdefs.h, sapi/src/exinit.c, score/Makefile.am, score/preinstall.am, score/cpu/i386/rtems/score/cpu.h, score/cpu/sparc/cpu_asm.S, score/cpu/sparc/rtems/score/cpu.h, score/include/rtems/score/basedefs.h, score/include/rtems/score/context.h, score/include/rtems/score/percpu.h, score/src/percpu.c, score/src/thread.c, score/src/threadcreateidle.c: Add next step in SMP support. This adds an allocated array of the Per_CPU structures to support multiple cpus vs a single instance of the structure which is still used if SMP support is disabled. Configuration support is also added to explicitly enable or disable SMP. But SMP can only be enabled for the CPUs which will support it initially -- SPARC and i386. With the stub BSP support, a BSP can be run as a single core SMP system from an RTEMS data structure standpoint.
  • aclocal/check-smp.m4, aclocal/enable-smp.m4, score/include/rtems/bspsmp.h, score/include/rtems/score/smplock.h, score/src/smp.c, score/src/smplock.c: New files.
  • Property mode set to 100644
File size: 6.1 KB
Line 
1/*
2 *  Initialization Manager
3 *
4 *  COPYRIGHT (c) 1989-2011.
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
60#if defined(RTEMS_SMP)
61  #include <rtems/bspsmp.h>
62  #include <rtems/score/percpu.h>
63#endif
64
65Objects_Information *_Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ];
66
67void rtems_initialize_data_structures(void)
68{
69  /*
70   *  Dispatching and interrupts are disabled until the end of the
71   *  initialization sequence.  This prevents an inadvertent context
72   *  switch before the executive is initialized.
73   *
74   *  WARNING: Interrupts should have been disabled by the BSP and
75   *           are disabled by boot_card().
76   */
77
78  #if defined(RTEMS_MULTIPROCESSING)
79    /*
80     *  Initialize the system state based on whether this is an MP system.
81     *  In an MP configuration, internally we view single processor
82     *  systems as a very restricted multiprocessor system.
83     */
84    _Configuration_MP_table = Configuration.User_multiprocessing_table;
85
86    if ( _Configuration_MP_table == NULL ) {
87      _Configuration_MP_table =
88        (void *)&_Initialization_Default_multiprocessing_table;
89      _System_state_Handler_initialization( FALSE );
90    } else {
91      _System_state_Handler_initialization( TRUE );
92    }
93  #else
94    _System_state_Handler_initialization( FALSE );
95  #endif
96
97  /*
98   * Initialize any target architecture specific support as early as possible
99   */
100  _CPU_Initialize();
101
102  #if defined(RTEMS_MULTIPROCESSING)
103    _Objects_MP_Handler_early_initialization();
104  #endif
105
106  /*
107   *  Do this as early as possible to ensure no debugging output
108   *  is even attempted to be printed.
109   */
110  _Debug_Manager_initialization();
111
112  _API_extensions_Initialization();
113
114  _Thread_Dispatch_initialization();
115
116  /*
117   *  Before this is called, we are not allowed to allocate memory
118   *  from the Workspace because it is not initialized.
119   */
120  _Workspace_Handler_initialization();
121
122  #if defined(RTEMS_SMP)
123    _SMP_Handler_initialize();
124  #endif
125
126  _User_extensions_Handler_initialization();
127  _ISR_Handler_initialization();
128
129  /*
130   * Initialize the internal support API and allocator Mutex
131   */
132  _Objects_Information_table[OBJECTS_INTERNAL_API] = _Internal_Objects;
133
134  _API_Mutex_Initialization( 1 );
135  _API_Mutex_Allocate( &_RTEMS_Allocator_Mutex );
136
137  _Priority_bit_map_Handler_initialization();
138  _Watchdog_Handler_initialization();
139  _TOD_Handler_initialization();
140
141  _Thread_Handler_initialization();
142
143  _Scheduler_Handler_initialization();
144
145  #if defined(RTEMS_MULTIPROCESSING)
146    _Objects_MP_Handler_initialization();
147    _MPCI_Handler_initialization( RTEMS_TIMEOUT );
148  #endif
149
150/* MANAGERS */
151
152  _RTEMS_API_Initialize();
153
154  _Extension_Manager_initialization();
155
156  _IO_Manager_initialization();
157
158  #ifdef RTEMS_POSIX_API
159    _POSIX_API_Initialize();
160  #endif
161
162  /*
163   * Discover and initialize the secondary cores in an SMP system.
164   */
165  #if defined(RTEMS_SMP)
166    _SMP_Processor_count = bsp_smp_initialize( rtems_smp_maximum_processors );
167  #endif
168
169  _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
170
171  /*
172   *  No threads should be created before this point!!!
173   *  _Thread_Executing and _Thread_Heir are not set.
174   *
175   *  At this point all API extensions are in place.  After the call to
176   *  _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set.
177   */
178  _Thread_Create_idle();
179
180  /*
181   *  Scheduling can properly occur now as long as we avoid dispatching.
182   */
183}
184
185void rtems_initialize_before_drivers(void)
186{
187
188  #if defined(RTEMS_MULTIPROCESSING)
189    _MPCI_Create_server();
190  #endif
191
192  #if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API)
193    /*
194     *  Run the API and BSPs predriver hook.
195     */
196    _API_extensions_Run_predriver();
197  #endif
198}
199
200void rtems_initialize_device_drivers(void)
201{
202  /*
203   *  Initialize all the device drivers and initialize the MPCI layer.
204   *
205   *  NOTE:  The MPCI may be build upon a device driver.
206   */
207
208  _IO_Initialize_all_drivers();
209
210  #if defined(RTEMS_MULTIPROCESSING)
211    if ( _System_state_Is_multiprocessing ) {
212      _MPCI_Initialization();
213      _MPCI_Internal_packets_Send_process_packet(
214        MPCI_PACKETS_SYSTEM_VERIFY
215      );
216    }
217  #endif
218
219  /*
220   *  Run the APIs and BSPs postdriver hooks.
221   *
222   *  The API extensions are supposed to create user initialization tasks.
223   */
224  _API_extensions_Run_postdriver();
225}
226
227void rtems_initialize_start_multitasking(void)
228{
229
230  _System_state_Set( SYSTEM_STATE_BEGIN_MULTITASKING );
231
232  _Thread_Start_multitasking();
233
234  /*******************************************************************
235   *******************************************************************
236   *******************************************************************
237   ******                 APPLICATION RUNS HERE                 ******
238   ******            RETURNS WHEN SYSTEM IS SHUT DOWN           ******
239   *******************************************************************
240   *******************************************************************
241   *******************************************************************/
242}
Note: See TracBrowser for help on using the repository browser.