source: rtems-schedsim/schedsim/rtems/rtems_init.c @ 726b27c

Last change on this file since 726b27c was 726b27c, checked in by Joel Sherrill <joel.sherrill@…>, on Dec 13, 2013 at 5:01:48 PM

schedsim: Update to latest RTEMS. Works Uniprocessor

  • Property mode set to 100644
File size: 3.6 KB
RevLine 
[abb18dc]1/*
2 *  BASED UPON SOURCE IN RTEMS, MODIFIED FOR SIMULATOR
[726b27c]3 */
4
5/*
6 *  COPYRIGHT (c) 1989-2014.
[abb18dc]7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 */
13
14#define SAPI_INIT
15#define SCORE_INIT
16#define RTEMS_API_INIT
[726b27c]17#define POSIX_API_INIT
18
19#include <rtems/system.h>
20#include <rtems/config.h>
21#include <rtems/debug.h>
22#include <rtems/extensionimpl.h>
23#include <rtems/fatal.h>
24#include <rtems/init.h>
25#include <rtems/io.h>
26#include <rtems/score/sysstate.h>
[abb18dc]27
28#include <rtems/score/apiext.h>
29#include <rtems/score/apimutex.h>
[726b27c]30#include <rtems/score/cpusetimpl.h>
[783fbfe]31#include <rtems/score/userextimpl.h>
[726b27c]32#include <rtems/score/schedulerimpl.h>
33#include <rtems/score/smpimpl.h>
34#include <rtems/score/threadimpl.h>
35#include <rtems/score/todimpl.h>
36#include <rtems/score/watchdogimpl.h>
[abb18dc]37#include <rtems/score/wkspace.h>
38
[726b27c]39#include <rtems/rtems/tasksimpl.h>
40#include <rtems/rtems/semimpl.h>
41
42#include <rtems/posix/keyimpl.h>
43
44/*
45 *  Declare Object Information tables directly here instead of API
46 *  specific initialization files as in cpukit/sapi/src.
47 */
[abb18dc]48Objects_Information *_Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ];
49
50Objects_Information *_RTEMS_Objects[ OBJECTS_RTEMS_CLASSES_LAST + 1 ];
51
[726b27c]52Objects_Information *_POSIX_Objects[ OBJECTS_POSIX_CLASSES_LAST + 1 ];
53
[abb18dc]54extern void check_heir_and_executing(void);
55
56void rtems_initialize_data_structures(void)
57{
58  _System_state_Handler_initialization( FALSE );
59
60  /*
61   *  Do this as early as possible to ensure no debugging output
62   *  is even attempted to be printed.
63   */
64  _Debug_Manager_initialization();
65
66  _API_extensions_Initialization();
67
68  _Thread_Dispatch_initialization();
69
70  _User_extensions_Handler_initialization();
[aebb1ca]71  _ISR_Handler_initialization();
[abb18dc]72
73  /*
74   * Initialize the internal support API and allocator Mutex
75   */
76  _Objects_Information_table[OBJECTS_INTERNAL_API] = _Internal_Objects;
77
[726b27c]78  _API_Mutex_Initialization( 2 );
[abb18dc]79  _API_Mutex_Allocate( &_RTEMS_Allocator_Mutex );
[726b27c]80  _API_Mutex_Allocate( &_Once_Mutex );
[abb18dc]81
82  _Watchdog_Handler_initialization();
83  _TOD_Handler_initialization();
84
85  _Thread_Handler_initialization();
86
87  _Scheduler_Handler_initialization();
88
[726b27c]89  _SMP_Handler_initialize();
90
91  _CPU_set_Handler_initialization();
[abb18dc]92
93/* MANAGERS */
94  /*
95   * Install our API Object Management Table and initialize the
96   * various managers.
97   */
98  _Objects_Information_table[OBJECTS_CLASSIC_API] = _RTEMS_Objects;
99
100  _RTEMS_tasks_Manager_initialization();
101  _Semaphore_Manager_initialization();
102
[726b27c]103  /*
104   * Install our API Object Management Table and initialize the
105   * various managers.
106   */
107  _Objects_Information_table[OBJECTS_POSIX_API] = _POSIX_Objects;
108
109  _POSIX_Key_Manager_initialization();
110
[aebb1ca]111  /*
112   * Discover and initialize the secondary cores in an SMP system.
113   */
[726b27c]114  _SMP_Handler_initialize();
[aebb1ca]115
[abb18dc]116  _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
117
118  /*
119   *  No threads should be created before this point!!!
120   *  _Thread_Executing and _Thread_Heir are not set.
121   *
122   *  At this point all API extensions are in place.  After the call to
123   *  _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set.
124   */
125  _Thread_Create_idle();
126
127  /*
128   *  Scheduling can properly occur now as long as we avoid dispatching.
129   */
130
[726b27c]131  _System_state_Set( SYSTEM_STATE_UP );
132
133 _SMP_Request_start_multitasking();
[abb18dc]134
135  _Thread_Start_multitasking();
136
137  /*
138   *  Now we are back in a non-dispatching critical section
139   */
[726b27c]140  #if defined(RTEMS_SMP)
141    #error "NOT IMPLEMENTED"
142  #else
143    _Thread_Enable_dispatch();
144  #endif
[abb18dc]145
146  /*
147   * Print an initial message
148   */
149  check_heir_and_executing();
150}
Note: See TracBrowser for help on using the repository browser.