source: rtems-schedsim/schedsim/rtems/rtems_init.c @ caee146

Last change on this file since caee146 was 783fbfe, checked in by Joel Sherrill <joel.sherrill@…>, on 05/01/13 at 00:05:08

schedsim/rtems/rtems_init.c: Update to current RTEMS

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*
2 *  BASED UPON SOURCE IN RTEMS, MODIFIED FOR SIMULATOR
3 *
4 *  COPYRIGHT (c) 1989-2013.
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#define SAPI_INIT
15#define SCORE_INIT
16#define RTEMS_API_INIT
17
18#include <rtems.h>
19#include <rtems/score/apiext.h>
20#include <rtems/score/bitfield.h>
21#include <rtems/score/apimutex.h>
22#include <rtems/score/userextimpl.h>
23#include <rtems/score/wkspace.h>
24
25Objects_Information *_Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ];
26
27Objects_Information *_RTEMS_Objects[ OBJECTS_RTEMS_CLASSES_LAST + 1 ];
28
29extern void check_heir_and_executing(void);
30
31void rtems_initialize_data_structures(void)
32{
33  _System_state_Handler_initialization( FALSE );
34
35  /*
36   *  Do this as early as possible to ensure no debugging output
37   *  is even attempted to be printed.
38   */
39  _Debug_Manager_initialization();
40
41  _API_extensions_Initialization();
42
43  _Thread_Dispatch_initialization();
44
45  /*
46   *  Before this is called, we are not allowed to allocate memory
47   *  from the Workspace because it is not initialized.
48   */
49  _Workspace_Handler_initialization(NULL, 0, NULL);
50
51  #if defined(RTEMS_SMP)
52    _SMP_Handler_initialize();
53  #endif
54
55  _User_extensions_Handler_initialization();
56
57  _ISR_Handler_initialization();
58
59  /*
60   * Initialize the internal support API and allocator Mutex
61   */
62  _Objects_Information_table[OBJECTS_INTERNAL_API] = _Internal_Objects;
63
64  _API_Mutex_Initialization( 1 );
65  _API_Mutex_Allocate( &_RTEMS_Allocator_Mutex );
66
67  _Priority_bit_map_Handler_initialization();
68  _Watchdog_Handler_initialization();
69  _TOD_Handler_initialization();
70
71  _Thread_Handler_initialization();
72
73  _Scheduler_Handler_initialization();
74
75
76/* MANAGERS */
77  /*
78   * Install our API Object Management Table and initialize the
79   * various managers.
80   */
81  _Objects_Information_table[OBJECTS_CLASSIC_API] = _RTEMS_Objects;
82
83  _RTEMS_tasks_Manager_initialization();
84  _Semaphore_Manager_initialization();
85
86  /*
87   * Discover and initialize the secondary cores in an SMP system.
88   */
89  #if defined(RTEMS_SMP)
90    _SMP_Processor_count =
91      bsp_smp_initialize( rtems_configuration_smp_maximum_processors );
92  #endif
93
94  _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
95
96  /*
97   *  No threads should be created before this point!!!
98   *  _Thread_Executing and _Thread_Heir are not set.
99   *
100   *  At this point all API extensions are in place.  After the call to
101   *  _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set.
102   */
103  _Thread_Create_idle();
104
105  /*
106   *  Scheduling can properly occur now as long as we avoid dispatching.
107   */
108
109  _System_state_Set( SYSTEM_STATE_BEGIN_MULTITASKING );
110
111  _Thread_Start_multitasking();
112
113  /*
114   *  Now we are back in a non-dispatching critical section
115   */
116  _Thread_Dispatch_set_disable_level(0);
117
118  /*
119   * Print an initial message
120   */
121  check_heir_and_executing();
122}
Note: See TracBrowser for help on using the repository browser.