source: rtems/c/src/exec/sapi/src/exinit.c @ 18c5378

4.104.114.84.95
Last change on this file since 18c5378 was 18c5378, checked in by Joel Sherrill <joel.sherrill@…>, on 09/22/95 at 15:35:48

moving files around and adding the exec/wrapup directory

  • Property mode set to 100644
File size: 6.1 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/core/sysstate.h>
30
31#include <rtems/core/apiext.h>
32#include <rtems/core/copyrt.h>
33#include <rtems/core/heap.h>
34#include <rtems/core/interr.h>
35#include <rtems/intthrd.h>
36#include <rtems/core/isr.h>
37#include <rtems/core/mpci.h>
38#include <rtems/core/priority.h>
39#include <rtems/core/thread.h>
40#include <rtems/core/tod.h>
41#include <rtems/core/userext.h>
42#include <rtems/core/watchdog.h>
43#include <rtems/core/wkspace.h>
44
45#include <rtems/directives.h>
46#include <rtems/sptables.h>
47
48#include <rtems/rtems/rtemsapi.h>
49
50/*PAGE
51 *
52 *  rtems_initialize_executive
53 *
54 *  This directive initializes all the kernels data structures
55 *  to the states necessary for the kernel to begin execution.  All
56 *  include files that contain global variable definitions should be
57 *  included in this file.  The system threads and initialization threads
58 *  are created and started by this routine.  This routine then
59 *  initiates multithreading.
60 *
61 *  Input parameters:
62 *    configuration_table - pointer to the user's configuration table
63 *    cpu_table           - pointer to the user's CPU configuration table
64 *
65 *  Output parameters:  NONE
66 */
67
68struct months {
69  unsigned32 months[2][13];
70};
71
72void rtems_initialize_executive(
73  rtems_configuration_table *configuration_table,
74  rtems_cpu_table           *cpu_table
75)
76{
77  rtems_interrupt_level bsp_level;
78
79  bsp_level = rtems_initialize_executive_early(configuration_table, cpu_table);
80  rtems_initialize_executive_late( bsp_level );
81}
82
83rtems_interrupt_level rtems_initialize_executive_early(
84  rtems_configuration_table *configuration_table,
85  rtems_cpu_table           *cpu_table
86)
87{
88  rtems_interrupt_level        bsp_level;
89  rtems_multiprocessing_table *multiprocessing_table;
90
91  /*
92   *  Dispatching and interrupts are disabled until the end of the
93   *  initialization sequence.  This prevents an inadvertent context
94   *  switch before the executive is initialized.
95   */
96
97  _ISR_Disable( bsp_level );
98
99  if ( cpu_table == NULL )
100    _Internal_error_Occurred(
101      INTERNAL_ERROR_CORE,
102      TRUE,
103      INTERNAL_ERROR_NO_CONFIGURATION_TABLE
104    );
105
106  /*
107   *  Initialize the system state based on whether this is an MP system.
108   */
109
110  multiprocessing_table = configuration_table->User_multiprocessing_table;
111
112  _System_state_Handler_initialization(
113    (multiprocessing_table) ? TRUE : FALSE
114  );
115
116  /*
117   *  Provided just for user convenience.
118   */
119
120  _Configuration_Table    = configuration_table;
121  _Configuration_MP_table = multiprocessing_table;
122
123  /*
124   *  Internally we view single processor systems as a very restricted
125   *  multiprocessor system.
126   */
127
128  if ( multiprocessing_table == NULL )
129    multiprocessing_table =
130      (void *)&_Initialization_Default_multiprocessing_table;
131
132  if ( cpu_table == NULL )
133    _Internal_error_Occurred(
134      INTERNAL_ERROR_CORE,
135      TRUE,
136      INTERNAL_ERROR_NO_CPU_TABLE
137    );
138
139  _CPU_Initialize( cpu_table, _Thread_Dispatch );
140
141  /*
142   *  Do this as early as possible to insure no debugging output
143   *  is even attempted to be printed.
144   */
145
146  _Debug_Manager_initialization();
147
148  _API_extensions_Initialization();
149
150  _Thread_Dispatch_initialization();
151
152  _User_extensions_Handler_initialization(
153    configuration_table->User_extension_table
154  );
155
156  _Workspace_Handler_initialization(
157     (void *)configuration_table->work_space_start,
158     configuration_table->work_space_size
159  );
160
161  _ISR_Handler_initialization();
162
163  _Objects_Handler_initialization(
164    multiprocessing_table->node,
165    multiprocessing_table->maximum_nodes,
166    multiprocessing_table->maximum_global_objects
167  );
168
169  _Priority_Handler_initialization();
170
171  _Watchdog_Handler_initialization();
172
173  _TOD_Handler_initialization( configuration_table->microseconds_per_tick );
174
175  _Thread_Handler_initialization(
176    configuration_table->ticks_per_timeslice,
177    configuration_table->maximum_extensions,
178    multiprocessing_table->maximum_proxies
179  );
180
181  _MPCI_Handler_initialization(
182    multiprocessing_table->User_mpci_table,
183    RTEMS_TIMEOUT
184  );
185
186  _Internal_threads_Initialization();
187
188/* MANAGERS */
189
190  _Extension_Manager_initialization( configuration_table->maximum_extensions );
191
192  _IO_Manager_initialization(
193    configuration_table->Device_driver_table,
194    configuration_table->number_of_device_drivers,
195    configuration_table->maximum_devices
196  );
197
198  _RTEMS_API_Initialize( configuration_table );
199
200  if ( cpu_table->pretasking_hook )
201    (*cpu_table->pretasking_hook)();
202
203  _Internal_threads_Start();
204
205  _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
206
207  return bsp_level;
208}
209
210void rtems_initialize_executive_late(
211  rtems_interrupt_level bsp_level
212)
213{
214
215  _System_state_Set( SYSTEM_STATE_BEGIN_MULTITASKING );
216
217  _Thread_Start_multitasking(
218    _Internal_threads_System_initialization_thread,
219    _Internal_threads_Idle_thread
220  );
221
222  /*
223   *  Restore the interrupt level to what the BSP had.  Technically,
224   *  this is unnecessary since the BSP should have all interrupts
225   *  disabled when rtems_initialize_executive is invoked.  But this keeps
226   *  the ISR Disable/Enable calls paired.
227   */
228
229  _ISR_Enable( bsp_level );
230}
231
232/*PAGE
233 *
234 *  rtems_shutdown_executive
235 *
236 *  This kernel routine shutdowns the executive.  It halts multitasking
237 *  and returns control to the application execution "thread" which
238 *  initialially invoked the rtems_initialize_executive directive.
239 *
240 *  Input parameters:   NONE
241 *
242 *  Output parameters:  NONE
243 */
244
245void rtems_shutdown_executive(
246   unsigned32 result
247)
248{
249  _Thread_Stop_multitasking();
250}
Note: See TracBrowser for help on using the repository browser.