source: rtems-schedsim/schedsim/rtems/rtems_init.c @ 187d93c

Last change on this file since 187d93c was 8703c13, checked in by Joel Sherrill <joel.sherrill@…>, on 04/14/14 at 23:18:34

Now works uniprocessor with debug enabled

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