source: rtems/cpukit/sapi/src/exinit.c @ 56d34e6

4.104.114.84.9
Last change on this file since 56d34e6 was 56d34e6, checked in by Joel Sherrill <joel.sherrill@…>, on Feb 21, 1996 at 2:32:02 PM

Removed the internal thread objects and dispersed its contents to
the thread handler (IDLE), MPCI object (SYSI now MP Receive)
and initialize_executive_early (IO initialization). The SYSI task
no longer exists in a single processor configuration. This reduces
single processor Workspace requirements by a TCB and a stack which
is often larger than the minimum stack size. Moving the IO initialization
plus accompanying BSP hooks eliminated an initialization ordering problem
in which a global task could be created before the MPCI was initialized.

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