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

4.11
Last change on this file since a55e305 was a55e305, checked in by Joel Sherrill <joel.sherrill@…>, on Jul 29, 2010 at 5:52:10 PM

2010-07-29 Gedare Bloom <giddyup44@…>

PR 1635/cpukit

  • sapi/src/exinit.c, score/Makefile.am, score/preinstall.am, score/include/rtems/score/bitfield.h, score/include/rtems/score/priority.h, score/include/rtems/score/thread.h, score/inline/rtems/score/priority.inl, score/inline/rtems/score/thread.inl, score/src/threadchangepriority.c, score/src/threadclearstate.c, score/src/threadready.c, score/src/threadresume.c, score/src/threadsetpriority.c, score/src/threadsetstate.c, score/src/threadsettransient.c, score/src/threadsuspend.c: Refactoring of priority handling, to isolate the bitmap implementation of priorities in the supercore so that priority management is a little more modular. This change is in anticipation of scheduler implementations that can select how they manage tracking priority levels / finding the highest priority ready task. Note that most of the changes here are simple renaming, to clarify the use of the bitmap-based priority management.
  • score/include/rtems/score/prioritybitmap.h, score/inline/rtems/score/prioritybitmap.inl: New files.
  • Property mode set to 100644
File size: 5.8 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/prioritybitmap.h>
46#include <rtems/score/thread.h>
47#include <rtems/score/tod.h>
48#include <rtems/score/userext.h>
49#include <rtems/score/watchdog.h>
50#include <rtems/score/wkspace.h>
51
52#include <rtems/sptables.h>
53
54
55#include <rtems/rtems/rtemsapi.h>
56#ifdef RTEMS_POSIX_API
57  #include <rtems/posix/posixapi.h>
58#endif
59
60Objects_Information *_Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ];
61
62void rtems_initialize_data_structures(void)
63{
64  /*
65   *  Dispatching and interrupts are disabled until the end of the
66   *  initialization sequence.  This prevents an inadvertent context
67   *  switch before the executive is initialized.
68   *
69   *  WARNING: Interrupts should have been disabled by the BSP and
70   *           are disabled by boot_card().
71   */
72
73  #if defined(RTEMS_MULTIPROCESSING)
74    /*
75     *  Initialize the system state based on whether this is an MP system.
76     *  In an MP configuration, internally we view single processor
77     *  systems as a very restricted multiprocessor system.
78     */
79    _Configuration_MP_table = Configuration.User_multiprocessing_table;
80
81    if ( _Configuration_MP_table == NULL ) {
82      _Configuration_MP_table =
83        (void *)&_Initialization_Default_multiprocessing_table;
84      _System_state_Handler_initialization( FALSE );
85    } else {
86      _System_state_Handler_initialization( TRUE );
87    }
88  #else
89    _System_state_Handler_initialization( FALSE );
90  #endif
91
92  /*
93   * Initialize any target architecture specific support as early as possible
94   */
95  _CPU_Initialize();
96
97  #if defined(RTEMS_MULTIPROCESSING)
98    _Objects_MP_Handler_early_initialization();
99  #endif
100
101  /*
102   *  Do this as early as possible to ensure no debugging output
103   *  is even attempted to be printed.
104   */
105  _Debug_Manager_initialization();
106
107  _API_extensions_Initialization();
108
109  _Thread_Dispatch_initialization();
110
111  /*
112   *  Before this is called, we are not allowed to allocate memory
113   *  from the Workspace because it is not initialized.
114   */
115  _Workspace_Handler_initialization();
116
117  _User_extensions_Handler_initialization();
118  _ISR_Handler_initialization();
119
120  /*
121   * Initialize the internal support API and allocator Mutex
122   */
123  _Objects_Information_table[OBJECTS_INTERNAL_API] = _Internal_Objects;
124
125  _API_Mutex_Initialization( 1 );
126  _API_Mutex_Allocate( &_RTEMS_Allocator_Mutex );
127
128  _Priority_bit_map_Handler_initialization();
129  _Watchdog_Handler_initialization();
130  _TOD_Handler_initialization();
131
132  _Thread_Handler_initialization();
133
134  #if defined(RTEMS_MULTIPROCESSING)
135    _Objects_MP_Handler_initialization();
136    _MPCI_Handler_initialization( RTEMS_TIMEOUT );
137  #endif
138
139/* MANAGERS */
140
141  _RTEMS_API_Initialize();
142
143  _Extension_Manager_initialization();
144
145  _IO_Manager_initialization();
146
147  #ifdef RTEMS_POSIX_API
148    _POSIX_API_Initialize();
149  #endif
150
151  _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
152
153  /*
154   *  No threads should be created before this point!!!
155   *  _Thread_Executing and _Thread_Heir are not set.
156   *
157   *  At this point all API extensions are in place.  After the call to
158   *  _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set.
159   */
160  _Thread_Create_idle();
161
162  /*
163   *  Scheduling can properly occur now as long as we avoid dispatching.
164   */
165}
166
167void rtems_initialize_before_drivers(void)
168{
169
170  #if defined(RTEMS_MULTIPROCESSING)
171    _MPCI_Create_server();
172  #endif
173
174  #if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API)
175    /*
176     *  Run the API and BSPs predriver hook.
177     */
178    _API_extensions_Run_predriver();
179  #endif
180}
181
182void rtems_initialize_device_drivers(void)
183{
184  /*
185   *  Initialize all the device drivers and initialize the MPCI layer.
186   *
187   *  NOTE:  The MPCI may be build upon a device driver.
188   */
189
190  _IO_Initialize_all_drivers();
191
192  #if defined(RTEMS_MULTIPROCESSING)
193    if ( _System_state_Is_multiprocessing ) {
194      _MPCI_Initialization();
195      _MPCI_Internal_packets_Send_process_packet(
196        MPCI_PACKETS_SYSTEM_VERIFY
197      );
198    }
199  #endif
200
201  /*
202   *  Run the APIs and BSPs postdriver hooks.
203   *
204   *  The API extensions are supposed to create user initialization tasks.
205   */
206  _API_extensions_Run_postdriver();
207}
208
209void rtems_initialize_start_multitasking(void)
210{
211
212  _System_state_Set( SYSTEM_STATE_BEGIN_MULTITASKING );
213
214  _Thread_Start_multitasking();
215
216  /*******************************************************************
217   *******************************************************************
218   *******************************************************************
219   ******                 APPLICATION RUNS HERE                 ******
220   ******            RETURNS WHEN SYSTEM IS SHUT DOWN           ******
221   *******************************************************************
222   *******************************************************************
223   *******************************************************************/
224}
Note: See TracBrowser for help on using the repository browser.