source: rtems/cpukit/sapi/src/exinit.c @ 976162a6

4.104.114.9
Last change on this file since 976162a6 was 976162a6, checked in by Joel Sherrill <joel.sherrill@…>, on Dec 3, 2007 at 10:23:13 PM

2007-12-03 Joel Sherrill <joel.sherrill@…>

  • libcsupport/src/malloc.c, libmisc/monitor/mon-command.c, posix/preinstall.am, posix/include/rtems/posix/cond.h, posix/include/rtems/posix/mqueue.h, posix/include/rtems/posix/mutex.h, posix/include/rtems/posix/pthread.h, posix/include/rtems/posix/semaphore.h, posix/src/conddestroy.c, posix/src/mutexdestroy.c, posix/src/mutexinit.c, posix/src/mutexsetprioceiling.c, posix/src/mutexunlock.c, sapi/include/confdefs.h, sapi/include/rtems/config.h, sapi/include/rtems/init.h, sapi/include/rtems/sptables.h, sapi/src/exinit.c, score/include/rtems/system.h, score/include/rtems/score/mpci.h, score/src/mpci.c, score/src/thread.c, score/src/threadcreateidle.c, score/src/threadstackallocate.c, score/src/threadstackfree.c, score/src/wkspace.c: Moved most of the remaining CPU Table fields to the Configuration Table. This included pretasking_hook, predriver_hook, postdriver_hook, idle_task, do_zero_of_workspace, extra_mpci_receive_server_stack, stack_allocate_hook, and stack_free_hook. As a side-effect of this effort some multiprocessing code was made conditional and some style clean up occurred.
  • Property mode set to 100644
File size: 6.9 KB
Line 
1/*
2 *  Initialization Manager
3 *
4 *  COPYRIGHT (c) 1989-2007.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18/*
19 *  SCORE_INIT and SAPI_INIT are defined so all of the super core and
20 *  super API data will be included in this object file.
21 */
22
23#define SAPI_INIT
24#define SCORE_INIT
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>
33#include <rtems/score/sysstate.h>
34
35#include <rtems/score/apiext.h>
36#include <rtems/score/apimutex.h>
37#include <rtems/score/copyrt.h>
38#include <rtems/score/heap.h>
39#include <rtems/score/interr.h>
40#include <rtems/score/isr.h>
41#if defined(RTEMS_MULTIPROCESSING)
42#include <rtems/score/mpci.h>
43#endif
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>
50
51#include <rtems/sptables.h>
52
53
54#include <rtems/rtems/rtemsapi.h>
55#ifdef RTEMS_POSIX_API
56#include <rtems/posix/posixapi.h>
57#endif
58#ifdef RTEMS_ITRON_API
59#include <rtems/itron/itronapi.h>
60#endif
61
62Objects_Information *_Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ];
63
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
71  /*
72   *  Dispatching and interrupts are disabled until the end of the
73   *  initialization sequence.  This prevents an inadvertent context
74   *  switch before the executive is initialized.
75   */
76  _ISR_Disable( bsp_level );
77
78  /*
79   *  Make sure the parameters were not NULL.
80   */
81  if ( configuration_table == NULL )
82    _Internal_error_Occurred(
83      INTERNAL_ERROR_CORE,
84      TRUE,
85      INTERNAL_ERROR_NO_CONFIGURATION_TABLE
86    );
87
88  if ( cpu_table == NULL )
89    _Internal_error_Occurred(
90      INTERNAL_ERROR_CORE,
91      TRUE,
92      INTERNAL_ERROR_NO_CPU_TABLE
93    );
94
95  /*
96   *  Grab our own copy of the user's CPU table.
97   */
98  _CPU_Table = *cpu_table;
99
100  /*
101   *  Provide pointers just for later convenience.
102   */
103  _Configuration_Table    = configuration_table;
104
105  /*
106   * Initialize any target architecture specific support as early as possible
107   */
108  _CPU_Initialize( cpu_table, _Thread_Dispatch );
109
110#if defined(RTEMS_MULTIPROCESSING)
111  /*
112   *  Initialize the system state based on whether this is an MP system.
113   *  In an MP configuration, internally we view single processor
114   *  systems as a very restricted multiprocessor system.
115   */
116  _Configuration_MP_table = configuration_table->User_multiprocessing_table;
117
118  if ( _Configuration_MP_table == NULL ) {
119    _Configuration_MP_table =
120      (void *)&_Initialization_Default_multiprocessing_table;
121    _System_state_Handler_initialization( FALSE );
122  } else {
123    _System_state_Handler_initialization( TRUE );
124  }
125#else
126  _System_state_Handler_initialization( FALSE );
127#endif
128
129  /*
130   *  Do this as early as possible to insure no debugging output
131   *  is even attempted to be printed.
132   */
133
134  _Debug_Manager_initialization();
135
136  _API_extensions_Initialization();
137
138  _Thread_Dispatch_initialization();
139
140  _Workspace_Handler_initialization(
141     (void *)configuration_table->work_space_start,
142     configuration_table->work_space_size
143  );
144
145  _User_extensions_Handler_initialization(
146    configuration_table->number_of_initial_extensions,
147    configuration_table->User_extension_table
148  );
149
150  _ISR_Handler_initialization();
151
152  _Objects_Handler_initialization(
153#if defined(RTEMS_MULTIPROCESSING)
154    _Configuration_MP_table->node,
155    _Configuration_MP_table->maximum_nodes,
156    _Configuration_MP_table->maximum_global_objects
157#endif
158  );
159
160  _Objects_Information_table[OBJECTS_INTERNAL_API] = _Internal_Objects;
161
162  /*
163   * Initialize the internal allocator Mutex
164   */
165  _API_Mutex_Initialization( 1 );
166  _API_Mutex_Allocate( &_RTEMS_Allocator_Mutex );
167
168  _Priority_Handler_initialization();
169
170  _Watchdog_Handler_initialization();
171
172  _TOD_Handler_initialization( configuration_table->microseconds_per_tick );
173
174  _Thread_Handler_initialization(
175    configuration_table->ticks_per_timeslice,
176    configuration_table->maximum_extensions
177#if defined(RTEMS_MULTIPROCESSING)
178    ,
179    _Configuration_MP_table->maximum_proxies
180#endif
181  );
182
183#if defined(RTEMS_MULTIPROCESSING)
184  _MPCI_Handler_initialization(
185    _Configuration_MP_table->User_mpci_table,
186    RTEMS_TIMEOUT
187  );
188#endif
189
190/* MANAGERS */
191
192  _RTEMS_API_Initialize( configuration_table );
193
194  _Extension_Manager_initialization( configuration_table->maximum_extensions );
195
196  _IO_Manager_initialization(
197    configuration_table->Device_driver_table,
198    configuration_table->number_of_device_drivers,
199    configuration_table->maximum_drivers
200  );
201
202#ifdef RTEMS_POSIX_API
203  _POSIX_API_Initialize( configuration_table );
204#endif
205
206#ifdef RTEMS_ITRON_API
207  _ITRON_API_Initialize( configuration_table );
208#endif
209
210  _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
211
212  /*
213   *  No threads should be created before this point!!!
214   *  _Thread_Executing and _Thread_Heir are not set.
215   *
216   *  At this point all API extensions are in place.  After the call to
217   *  _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set.
218   */
219
220  _Thread_Create_idle();
221
222  /*
223   *  Scheduling can properly occur now as long as we avoid dispatching.
224   */
225
226  {
227    extern void bsp_pretasking_hook(void);
228    bsp_pretasking_hook();
229  }
230
231#if defined(RTEMS_MULTIPROCESSING)
232  _MPCI_Create_server();
233#endif
234
235  /*
236   *  Run the API and BSPs predriver hook.
237   */
238
239  _API_extensions_Run_predriver();
240
241  {
242    extern void bsp_predriver_hook(void);
243    bsp_predriver_hook();
244  }
245
246  /*
247   *  Initialize all the device drivers and initialize the MPCI layer.
248   *
249   *  NOTE:  The MPCI may be build upon a device driver.
250   */
251
252  _IO_Initialize_all_drivers();
253
254#if defined(RTEMS_MULTIPROCESSING)
255  if ( _System_state_Is_multiprocessing ) {
256    _MPCI_Initialization();
257    _MPCI_Internal_packets_Send_process_packet(
258      MPCI_PACKETS_SYSTEM_VERIFY
259    );
260  }
261#endif
262
263  /*
264   *  Run the APIs and BSPs postdriver hooks.
265   *
266   *  The API extensions are supposed to create user initialization tasks.
267   */
268
269  _API_extensions_Run_postdriver();
270
271  {
272    extern void bsp_postdriver_hook(void);
273    bsp_postdriver_hook();
274  }
275
276  return bsp_level;
277}
278
279void rtems_initialize_executive_late(
280  rtems_interrupt_level bsp_level
281)
282{
283
284  _System_state_Set( SYSTEM_STATE_BEGIN_MULTITASKING );
285
286  _Thread_Start_multitasking();
287
288  /*
289   *  Restore the interrupt level to what the BSP had.  Technically,
290   *  this is unnecessary since the BSP should have all interrupts
291   *  disabled when rtems_initialize_executive is invoked.  But this keeps
292   *  the ISR Disable/Enable calls paired.
293   */
294
295  _ISR_Enable( bsp_level );
296}
Note: See TracBrowser for help on using the repository browser.