source: rtems/cpukit/sapi/src/exinit.c @ 97e2729d

4.104.114.84.9
Last change on this file since 97e2729d was 97e2729d, checked in by Joel Sherrill <joel.sherrill@…>, on Nov 23, 1998 at 5:38:09 PM

Added --disable-multiprocessing flag and modified a lot of files to make
it work.

  • Property mode set to 100644
File size: 7.5 KB
Line 
1/*
2 *  Initialization Manager
3 *
4 *  COPYRIGHT (c) 1989-1998.
5 *  On-Line Applications Research Corporation (OAR).
6 *  Copyright assigned to U.S. Government, 1994.
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14
15/*
16 *  SCORE_INIT and SAPI_INIT are defined so all of the super core and
17 *  super API data will be included in this object file.
18 */
19
20#define SAPI_INIT
21#define SCORE_INIT
22
23#include <rtems/system.h>
24#include <rtems/config.h>
25#include <rtems/debug.h>
26#include <rtems/extension.h>
27#include <rtems/fatal.h>
28#include <rtems/init.h>
29#include <rtems/io.h>
30#include <rtems/score/sysstate.h>
31
32#include <rtems/score/apiext.h>
33#include <rtems/score/copyrt.h>
34#include <rtems/score/heap.h>
35#include <rtems/score/interr.h>
36#include <rtems/score/isr.h>
37#if defined(RTEMS_MULTIPROCESSING)
38#include <rtems/score/mpci.h>
39#endif
40#include <rtems/score/priority.h>
41#include <rtems/score/thread.h>
42#include <rtems/score/tod.h>
43#include <rtems/score/userext.h>
44#include <rtems/score/watchdog.h>
45#include <rtems/score/wkspace.h>
46
47#include <rtems/directives.h>
48#include <rtems/sptables.h>
49
50
51#include <rtems/rtems/rtemsapi.h>
52#ifdef RTEMS_POSIX_API
53#include <rtems/posix/posixapi.h>
54#endif
55
56/*PAGE
57 *
58 *  rtems_initialize_executive
59 *
60 *  This directive initializes all the kernels data structures
61 *  to the states necessary for the kernel to begin execution.  All
62 *  include files that contain global variable definitions should be
63 *  included in this file.  The system threads and initialization threads
64 *  are created and started by this routine.  This routine then
65 *  initiates multithreading.
66 *
67 *  Input parameters:
68 *    configuration_table - pointer to the user's configuration table
69 *    cpu_table           - pointer to the user's CPU configuration table
70 *
71 *  Output parameters:  NONE
72 */
73
74void rtems_initialize_executive(
75  rtems_configuration_table *configuration_table,
76  rtems_cpu_table           *cpu_table
77)
78{
79  rtems_interrupt_level bsp_level;
80
81  bsp_level = rtems_initialize_executive_early(configuration_table, cpu_table);
82  rtems_initialize_executive_late( bsp_level );
83}
84
85rtems_interrupt_level rtems_initialize_executive_early(
86  rtems_configuration_table *configuration_table,
87  rtems_cpu_table           *cpu_table
88)
89{
90  rtems_interrupt_level        bsp_level;
91  rtems_multiprocessing_table *multiprocessing_table;
92
93  /*
94   *  Dispatching and interrupts are disabled until the end of the
95   *  initialization sequence.  This prevents an inadvertent context
96   *  switch before the executive is initialized.
97   */
98
99  _ISR_Disable( bsp_level );
100
101  if ( configuration_table == NULL )
102    _Internal_error_Occurred(
103      INTERNAL_ERROR_CORE,
104      TRUE,
105      INTERNAL_ERROR_NO_CONFIGURATION_TABLE
106    );
107
108  /*
109   *  Initialize the system state based on whether this is an MP system.
110   */
111
112#if defined(RTEMS_MULTIPROCESSING)
113  multiprocessing_table = configuration_table->User_multiprocessing_table;
114
115  _System_state_Handler_initialization(
116    (multiprocessing_table) ? TRUE : FALSE
117  );
118#else
119  multiprocessing_table = NULL;
120
121  _System_state_Handler_initialization( FALSE );
122
123#endif
124
125  /*
126   *  Provided just for user convenience.
127   */
128
129  _Configuration_Table    = configuration_table;
130  _Configuration_MP_table = multiprocessing_table;
131
132  /*
133   *  Internally we view single processor systems as a very restricted
134   *  multiprocessor system.
135   */
136
137  if ( multiprocessing_table == NULL )
138    multiprocessing_table = 
139      (void *)&_Initialization_Default_multiprocessing_table;
140
141  if ( cpu_table == NULL )
142    _Internal_error_Occurred(
143      INTERNAL_ERROR_CORE,
144      TRUE,
145      INTERNAL_ERROR_NO_CPU_TABLE
146    );
147
148  _CPU_Initialize( cpu_table, _Thread_Dispatch );
149
150  /*
151   *  Do this as early as possible to insure no debugging output
152   *  is even attempted to be printed.
153   */
154
155  _Debug_Manager_initialization();
156
157  _API_extensions_Initialization();
158
159  _Thread_Dispatch_initialization();
160
161  _Workspace_Handler_initialization(
162     (void *)configuration_table->work_space_start,
163     configuration_table->work_space_size
164  );
165
166  _User_extensions_Handler_initialization(
167    configuration_table->number_of_initial_extensions,
168    configuration_table->User_extension_table
169  );
170
171  _ISR_Handler_initialization();
172
173  _Objects_Handler_initialization(
174    multiprocessing_table->node,
175    multiprocessing_table->maximum_nodes,
176    multiprocessing_table->maximum_global_objects
177  );
178
179  _Priority_Handler_initialization();
180
181  _Watchdog_Handler_initialization();
182
183  _TOD_Handler_initialization( configuration_table->microseconds_per_tick );
184
185  _Thread_Handler_initialization(
186    configuration_table->ticks_per_timeslice,
187    configuration_table->maximum_extensions,
188    multiprocessing_table->maximum_proxies
189  );
190
191#if defined(RTEMS_MULTIPROCESSING)
192  _MPCI_Handler_initialization(
193    multiprocessing_table->User_mpci_table,
194    RTEMS_TIMEOUT
195  );
196#endif
197
198/* MANAGERS */
199
200  _Extension_Manager_initialization( configuration_table->maximum_extensions );
201
202  _IO_Manager_initialization(
203    configuration_table->Device_driver_table,
204    configuration_table->number_of_device_drivers,
205    configuration_table->maximum_devices
206  );
207
208  _RTEMS_API_Initialize( configuration_table );
209
210#ifdef RTEMS_POSIX_API
211  _POSIX_API_Initialize( configuration_table );
212#endif
213
214  _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
215
216  if ( cpu_table->pretasking_hook )
217    (*cpu_table->pretasking_hook)();
218
219  /*
220   *  No threads should be created before this point!!!
221   *
222   *  At this point all API extensions are in place.  After the call to
223   *  _Thread_Create_idle() _Thread_Executing will be set.
224   *  and _Thread_Heir are not set yet.
225   */
226
227  _Thread_Create_idle();
228
229#if defined(RTEMS_MULTIPROCESSING)
230  _MPCI_Create_server();
231#endif
232
233  /*
234   *  Run the API and BSPs predriver hook.
235   */
236 
237  _API_extensions_Run_predriver();
238 
239  if ( _CPU_Table.predriver_hook )
240    (*_CPU_Table.predriver_hook)();
241 
242  /*
243   *  Initialize all the device drivers and initialize the MPCI layer.
244   *
245   *  NOTE:  The MPCI may be build upon a device driver.
246   */
247 
248  _IO_Initialize_all_drivers();
249 
250#if defined(RTEMS_MULTIPROCESSING)
251  if ( _System_state_Is_multiprocessing ) {
252    _MPCI_Initialization();
253    _MPCI_Internal_packets_Send_process_packet(
254      MPCI_PACKETS_SYSTEM_VERIFY
255    );
256  }
257#endif
258 
259  /*
260   *  Run the APIs and BSPs postdriver hooks.
261   *
262   *  The API extensions are supposed to create user initialization tasks.
263   */
264 
265  _API_extensions_Run_postdriver();
266 
267  if ( _CPU_Table.postdriver_hook )
268    (*_CPU_Table.postdriver_hook)();
269
270  return bsp_level;
271}
272
273void rtems_initialize_executive_late(
274  rtems_interrupt_level bsp_level
275)
276{
277
278  _System_state_Set( SYSTEM_STATE_BEGIN_MULTITASKING );
279
280  _Thread_Start_multitasking();
281
282  /*
283   *  Restore the interrupt level to what the BSP had.  Technically,
284   *  this is unnecessary since the BSP should have all interrupts
285   *  disabled when rtems_initialize_executive is invoked.  But this keeps
286   *  the ISR Disable/Enable calls paired.
287   */
288
289  _ISR_Enable( bsp_level );
290}
291
292/*PAGE
293 *
294 *  rtems_shutdown_executive
295 *
296 *  This kernel routine shutdowns the executive.  It halts multitasking
297 *  and returns control to the application execution "thread" which
298 *  initialially invoked the rtems_initialize_executive directive.
299 *
300 *  Input parameters:   NONE
301 *
302 *  Output parameters:  NONE
303 */
304
305void rtems_shutdown_executive(
306   unsigned32 result
307)
308{
309  if ( _System_state_Current != SYSTEM_STATE_SHUTDOWN ) {
310    _System_state_Set( SYSTEM_STATE_SHUTDOWN );
311    _Thread_Stop_multitasking();
312  }
313}
Note: See TracBrowser for help on using the repository browser.