source: rtems/cpukit/sapi/src/exinit.c @ 7f6a24ab

4.104.114.84.95
Last change on this file since 7f6a24ab was 5250ff39, checked in by Joel Sherrill <joel.sherrill@…>, on 08/23/95 at 21:06:31

Moved _Thread_Information -> _RTEMS_tasks_Information.

Added a table of object information control blocks.

Modified _Thread_Get so it looks up a thread regardless of which
thread management "entity" (manager, internal, etc) actually "owns" it.

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