source: rtems/cpukit/sapi/src/exinit.c @ c64da856

4.104.114.84.95
Last change on this file since c64da856 was c64da856, checked in by Joel Sherrill <joel.sherrill@…>, on 09/25/05 at 15:36:40

2005-09-25 Joel Sherrill <joel@…>

  • sapi/include/rtems/init.h, sapi/src/exinit.c: Remove unused and obsolete rtems_initialize_executive.
  • Property mode set to 100644
File size: 7.1 KB
RevLine 
[ac7d5ef0]1/*
2 *  Initialization Manager
3 *
[08311cc3]4 *  COPYRIGHT (c) 1989-1999.
[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>
45#include <rtems/score/thread.h>
46#include <rtems/score/tod.h>
47#include <rtems/score/userext.h>
48#include <rtems/score/watchdog.h>
49#include <rtems/score/wkspace.h>
[3a4ae6c]50
[ac7d5ef0]51#include <rtems/sptables.h>
52
[c627b2a3]53
[3a4ae6c]54#include <rtems/rtems/rtemsapi.h>
[c627b2a3]55#ifdef RTEMS_POSIX_API
56#include <rtems/posix/posixapi.h>
57#endif
[352c9b2]58#ifdef RTEMS_ITRON_API
59#include <rtems/itron/itronapi.h>
60#endif
61
[0577ec1d]62Objects_Information *_Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ];
[3a4ae6c]63
[ac7d5ef0]64rtems_interrupt_level rtems_initialize_executive_early(
65  rtems_configuration_table *configuration_table,
66  rtems_cpu_table           *cpu_table
67)
68{
69  rtems_interrupt_level        bsp_level;
70  rtems_multiprocessing_table *multiprocessing_table;
71
72  /*
73   *  Dispatching and interrupts are disabled until the end of the
74   *  initialization sequence.  This prevents an inadvertent context
75   *  switch before the executive is initialized.
76   */
77
78  _ISR_Disable( bsp_level );
79
[9a11e1f]80  if ( configuration_table == NULL )
[3a4ae6c]81    _Internal_error_Occurred(
82      INTERNAL_ERROR_CORE,
83      TRUE,
84      INTERNAL_ERROR_NO_CONFIGURATION_TABLE
85    );
[ac7d5ef0]86
[3a4ae6c]87  /*
88   *  Initialize the system state based on whether this is an MP system.
89   */
90
[97e2729d]91#if defined(RTEMS_MULTIPROCESSING)
[3a4ae6c]92  multiprocessing_table = configuration_table->User_multiprocessing_table;
93
94  _System_state_Handler_initialization(
95    (multiprocessing_table) ? TRUE : FALSE
96  );
[97e2729d]97#else
98  multiprocessing_table = NULL;
99
100  _System_state_Handler_initialization( FALSE );
101#endif
[ac7d5ef0]102
[88d594a]103  /*
[3a4ae6c]104   *  Provided just for user convenience.
[88d594a]105   */
106
[3a4ae6c]107  _Configuration_Table    = configuration_table;
108  _Configuration_MP_table = multiprocessing_table;
109
110  /*
111   *  Internally we view single processor systems as a very restricted
112   *  multiprocessor system.
113   */
[88d594a]114
[ac7d5ef0]115  if ( multiprocessing_table == NULL )
[8486081]116    multiprocessing_table =
[3a4ae6c]117      (void *)&_Initialization_Default_multiprocessing_table;
[ac7d5ef0]118
[3a4ae6c]119  if ( cpu_table == NULL )
120    _Internal_error_Occurred(
121      INTERNAL_ERROR_CORE,
122      TRUE,
123      INTERNAL_ERROR_NO_CPU_TABLE
124    );
125
126  _CPU_Initialize( cpu_table, _Thread_Dispatch );
[ac7d5ef0]127
[3a4ae6c]128  /*
129   *  Do this as early as possible to insure no debugging output
130   *  is even attempted to be printed.
131   */
132
133  _Debug_Manager_initialization();
[ac7d5ef0]134
[7af35da5]135  _API_extensions_Initialization();
136
[ac7d5ef0]137  _Thread_Dispatch_initialization();
138
139  _Workspace_Handler_initialization(
140     (void *)configuration_table->work_space_start,
141     configuration_table->work_space_size
142  );
143
[0451b44]144  _User_extensions_Handler_initialization(
145    configuration_table->number_of_initial_extensions,
146    configuration_table->User_extension_table
147  );
148
[ac7d5ef0]149  _ISR_Handler_initialization();
150
151  _Objects_Handler_initialization(
152    multiprocessing_table->node,
[3a4ae6c]153    multiprocessing_table->maximum_nodes,
[ac7d5ef0]154    multiprocessing_table->maximum_global_objects
155  );
156
[0577ec1d]157  _Objects_Information_table[OBJECTS_INTERNAL_API] = _Internal_Objects;
158
[ac7d5ef0]159  _Priority_Handler_initialization();
160
161  _Watchdog_Handler_initialization();
162
163  _TOD_Handler_initialization( configuration_table->microseconds_per_tick );
164
165  _Thread_Handler_initialization(
166    configuration_table->ticks_per_timeslice,
[3a4ae6c]167    configuration_table->maximum_extensions,
[ac7d5ef0]168    multiprocessing_table->maximum_proxies
169  );
170
[97e2729d]171#if defined(RTEMS_MULTIPROCESSING)
[3a4ae6c]172  _MPCI_Handler_initialization(
[18c5378]173    multiprocessing_table->User_mpci_table,
174    RTEMS_TIMEOUT
[3a4ae6c]175  );
[97e2729d]176#endif
[ac7d5ef0]177
[3a4ae6c]178/* MANAGERS */
[ac7d5ef0]179
[0577ec1d]180  _RTEMS_API_Initialize( configuration_table );
181
[ac7d5ef0]182  _Extension_Manager_initialization( configuration_table->maximum_extensions );
183
184  _IO_Manager_initialization(
185    configuration_table->Device_driver_table,
[3a4ae6c]186    configuration_table->number_of_device_drivers,
[059a3714]187    configuration_table->maximum_drivers,
[3a4ae6c]188    configuration_table->maximum_devices
[ac7d5ef0]189  );
190
[d4b44877]191#ifdef RTEMS_POSIX_API
192  _POSIX_API_Initialize( configuration_table );
193#endif
194
[352c9b2]195#ifdef RTEMS_ITRON_API
196  _ITRON_API_Initialize( configuration_table );
197#endif
198
[56d34e6]199  _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
200
201  /*
[8486081]202   *  No threads should be created before this point!!!
[a2a8c5b]203   *  _Thread_Executing and _Thread_Heir are not set.
[56d34e6]204   *
205   *  At this point all API extensions are in place.  After the call to
[a2a8c5b]206   *  _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set.
[56d34e6]207   */
[3a4ae6c]208
[56d34e6]209  _Thread_Create_idle();
210
[a2a8c5b]211
212  /*
213   *  Scheduling can properly occur now as long as we avoid dispatching.
214   */
215
216  if ( cpu_table->pretasking_hook )
217    (*cpu_table->pretasking_hook)();
218
[97e2729d]219#if defined(RTEMS_MULTIPROCESSING)
[56d34e6]220  _MPCI_Create_server();
[97e2729d]221#endif
[ac7d5ef0]222
[389fa850]223  /*
224   *  Run the API and BSPs predriver hook.
225   */
[8486081]226
[389fa850]227  _API_extensions_Run_predriver();
[8486081]228
[389fa850]229  if ( _CPU_Table.predriver_hook )
230    (*_CPU_Table.predriver_hook)();
[8486081]231
[389fa850]232  /*
233   *  Initialize all the device drivers and initialize the MPCI layer.
234   *
235   *  NOTE:  The MPCI may be build upon a device driver.
236   */
[8486081]237
[389fa850]238  _IO_Initialize_all_drivers();
[8486081]239
[97e2729d]240#if defined(RTEMS_MULTIPROCESSING)
[389fa850]241  if ( _System_state_Is_multiprocessing ) {
242    _MPCI_Initialization();
[56d34e6]243    _MPCI_Internal_packets_Send_process_packet(
244      MPCI_PACKETS_SYSTEM_VERIFY
[389fa850]245    );
246  }
[97e2729d]247#endif
[8486081]248
[389fa850]249  /*
250   *  Run the APIs and BSPs postdriver hooks.
251   *
252   *  The API extensions are supposed to create user initialization tasks.
253   */
[8486081]254
[389fa850]255  _API_extensions_Run_postdriver();
[8486081]256
[389fa850]257  if ( _CPU_Table.postdriver_hook )
258    (*_CPU_Table.postdriver_hook)();
259
[ac7d5ef0]260  return bsp_level;
261}
262
263void rtems_initialize_executive_late(
264  rtems_interrupt_level bsp_level
265)
266{
267
268  _System_state_Set( SYSTEM_STATE_BEGIN_MULTITASKING );
269
[f972294d]270  _Thread_Start_multitasking();
[ac7d5ef0]271
272  /*
273   *  Restore the interrupt level to what the BSP had.  Technically,
274   *  this is unnecessary since the BSP should have all interrupts
275   *  disabled when rtems_initialize_executive is invoked.  But this keeps
276   *  the ISR Disable/Enable calls paired.
277   */
278
279  _ISR_Enable( bsp_level );
280}
281
282/*PAGE
283 *
284 *  rtems_shutdown_executive
285 *
286 *  This kernel routine shutdowns the executive.  It halts multitasking
287 *  and returns control to the application execution "thread" which
288 *  initialially invoked the rtems_initialize_executive directive.
289 *
290 *  Input parameters:   NONE
291 *
292 *  Output parameters:  NONE
293 */
294
295void rtems_shutdown_executive(
[8bd41178]296   uint32_t   result
[ac7d5ef0]297)
298{
[eafd698]299  if ( _System_state_Current != SYSTEM_STATE_SHUTDOWN ) {
300    _System_state_Set( SYSTEM_STATE_SHUTDOWN );
301    _Thread_Stop_multitasking();
302  }
[ac7d5ef0]303}
Note: See TracBrowser for help on using the repository browser.