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

4.104.11
Last change on this file since aac75d3b was aac75d3b, checked in by Joel Sherrill <joel.sherrill@…>, on Dec 15, 2008 at 7:21:01 PM

2008-12-15 Joel Sherrill <joel.sherrill@…>

  • itron/include/rtems/itron/itronapi.h, libmisc/capture/capture.c, libmisc/monitor/mon-config.c, libmisc/monitor/mon-driver.c, libmisc/monitor/mon-itask.c, libmisc/monitor/mon-mpci.c, posix/include/rtems/posix/config.h, posix/include/rtems/posix/posixapi.h, rtems/include/rtems/rtems/config.h, rtems/include/rtems/rtems/rtemsapi.h, rtems/src/taskinitusers.c, sapi/include/confdefs.h, sapi/include/rtems/config.h, sapi/include/rtems/init.h, sapi/src/exinit.c, sapi/src/itronapi.c, sapi/src/posixapi.c, sapi/src/rtemsapi.c, score/src/isr.c, score/src/thread.c, score/src/threadcreateidle.c, score/src/threadstackallocate.c, score/src/threadstackfree.c, score/src/wkspace.c: Eliminate pointers to API configuration tables in the main configuration table. Reference the main configuration table and the API configuration tables directly using the confdefs.h version rather than obtaining a pointer to it. This eliminated some variables, a potential fatal error, some unnecessary default configuration structures. Overall, about a 4.5% reduction in the code size for minimum and hello on the SPARC.
  • Property mode set to 100644
File size: 6.4 KB
Line 
1/*
2 *  Initialization Manager
3 *
4 *  COPYRIGHT (c) 1989-2008.
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
64void rtems_initialize_data_structures(void)
65{
66  rtems_interrupt_level  bsp_level;
67
68  /*
69   *  Dispatching and interrupts are disabled until the end of the
70   *  initialization sequence.  This prevents an inadvertent context
71   *  switch before the executive is initialized.
72   */
73  _ISR_Disable( bsp_level );
74
75  /*
76   * Initialize any target architecture specific support as early as possible
77   */
78  _CPU_Initialize( _Thread_Dispatch );
79
80  #if defined(RTEMS_MULTIPROCESSING)
81    /*
82     *  Initialize the system state based on whether this is an MP system.
83     *  In an MP configuration, internally we view single processor
84     *  systems as a very restricted multiprocessor system.
85     */
86    _Configuration_MP_table = Configuration.User_multiprocessing_table;
87
88    if ( _Configuration_MP_table == NULL ) {
89      _Configuration_MP_table =
90        (void *)&_Initialization_Default_multiprocessing_table;
91      _System_state_Handler_initialization( FALSE );
92    } else {
93      _System_state_Handler_initialization( TRUE );
94    }
95  #else
96    _System_state_Handler_initialization( FALSE );
97  #endif
98
99  /*
100   *  Do this as early as possible to ensure no debugging output
101   *  is even attempted to be printed.
102   */
103
104  _Debug_Manager_initialization();
105
106  _API_extensions_Initialization();
107
108  _Thread_Dispatch_initialization();
109
110  /*
111   *  Before this is called, we are not allowed to allocate memory
112   *  from the Workspace because it is not initialized.
113   */
114  _Workspace_Handler_initialization(
115    Configuration.work_space_start,
116    Configuration.work_space_size
117  );
118
119  _User_extensions_Handler_initialization(
120    Configuration.number_of_initial_extensions,
121    Configuration.User_extension_table
122  );
123
124  _ISR_Handler_initialization();
125
126  _Objects_Handler_initialization(
127    #if defined(RTEMS_MULTIPROCESSING)
128      _Configuration_MP_table->node,
129      _Configuration_MP_table->maximum_nodes,
130      _Configuration_MP_table->maximum_global_objects
131    #endif
132  );
133
134  _Objects_Information_table[OBJECTS_INTERNAL_API] = _Internal_Objects;
135
136  /*
137   * Initialize the internal allocator Mutex
138   */
139  _API_Mutex_Initialization( 1 );
140  _API_Mutex_Allocate( &_RTEMS_Allocator_Mutex );
141
142  _Priority_Handler_initialization();
143
144  _Watchdog_Handler_initialization();
145
146  _TOD_Handler_initialization( Configuration.microseconds_per_tick );
147
148  _Thread_Handler_initialization(
149    Configuration.ticks_per_timeslice,
150    Configuration.maximum_extensions
151    #if defined(RTEMS_MULTIPROCESSING)
152      ,
153      _Configuration_MP_table->maximum_proxies
154    #endif
155  );
156
157  #if defined(RTEMS_MULTIPROCESSING)
158    _MPCI_Handler_initialization(
159      _Configuration_MP_table->User_mpci_table,
160      RTEMS_TIMEOUT
161    );
162  #endif
163
164/* MANAGERS */
165
166  _RTEMS_API_Initialize();
167
168  _Extension_Manager_initialization( Configuration.maximum_extensions );
169
170  _IO_Manager_initialization(
171    Configuration.Device_driver_table,
172    Configuration.number_of_device_drivers,
173    Configuration.maximum_drivers
174  );
175
176  #ifdef RTEMS_POSIX_API
177    _POSIX_API_Initialize();
178  #endif
179
180  #ifdef RTEMS_ITRON_API
181    _ITRON_API_Initialize();
182  #endif
183
184  _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
185
186  /*
187   *  No threads should be created before this point!!!
188   *  _Thread_Executing and _Thread_Heir are not set.
189   *
190   *  At this point all API extensions are in place.  After the call to
191   *  _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set.
192   */
193
194  _Thread_Create_idle();
195
196  /*
197   *  Scheduling can properly occur now as long as we avoid dispatching.
198   */
199}
200
201void rtems_initialize_before_drivers(void)
202{
203
204  #if defined(RTEMS_MULTIPROCESSING)
205    _MPCI_Create_server();
206  #endif
207
208  /*
209   *  Run the API and BSPs predriver hook.
210   */
211
212  _API_extensions_Run_predriver();
213
214}
215
216void rtems_initialize_device_drivers(void)
217{
218  /*
219   *  Initialize all the device drivers and initialize the MPCI layer.
220   *
221   *  NOTE:  The MPCI may be build upon a device driver.
222   */
223
224  _IO_Initialize_all_drivers();
225
226  #if defined(RTEMS_MULTIPROCESSING)
227    if ( _System_state_Is_multiprocessing ) {
228      _MPCI_Initialization();
229      _MPCI_Internal_packets_Send_process_packet(
230        MPCI_PACKETS_SYSTEM_VERIFY
231      );
232    }
233  #endif
234
235  /*
236   *  Run the APIs and BSPs postdriver hooks.
237   *
238   *  The API extensions are supposed to create user initialization tasks.
239   */
240
241  _API_extensions_Run_postdriver();
242}
243
244void rtems_initialize_start_multitasking(void)
245{
246
247  _System_state_Set( SYSTEM_STATE_BEGIN_MULTITASKING );
248
249  _Thread_Start_multitasking();
250
251  /*******************************************************************
252   *******************************************************************
253   *******************************************************************
254   ******                 APPLICATION RUNS HERE                 ******
255   ******            RETURNS WHEN SYSTEM IS SHUT DOWN           ******
256   *******************************************************************
257   *******************************************************************
258   *******************************************************************/
259}
Note: See TracBrowser for help on using the repository browser.