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

Last change on this file since ac6e5c7 was abb18dc, checked in by Joel Sherrill <joel.sherrill@…>, on Apr 25, 2011 at 3:53:10 PM

Initial import.

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
2 *  BASED UPON SOURCE IN RTEMS, MODIFIED FOR SIMULATOR
3 *
4 *  COPYRIGHT (c) 1989-2010.
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
15#define SAPI_INIT
16#define SCORE_INIT
17#define RTEMS_API_INIT
18
19#include <rtems.h> 
20#include <rtems/score/apiext.h>
21#include <rtems/score/bitfield.h>
22#include <rtems/score/apimutex.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();
50
51  _User_extensions_Handler_initialization();
52
53  // _ISR_Handler_initialization();
54
55  /*
56   * Initialize the internal support API and allocator Mutex
57   */
58  _Objects_Information_table[OBJECTS_INTERNAL_API] = _Internal_Objects;
59
60  _API_Mutex_Initialization( 1 );
61  _API_Mutex_Allocate( &_RTEMS_Allocator_Mutex );
62
63  _Priority_bit_map_Handler_initialization();
64  _Watchdog_Handler_initialization();
65  _TOD_Handler_initialization();
66
67  _Thread_Handler_initialization();
68
69  _Scheduler_Handler_initialization();
70
71
72/* MANAGERS */
73  /*
74   * Install our API Object Management Table and initialize the
75   * various managers.
76   */
77  _Objects_Information_table[OBJECTS_CLASSIC_API] = _RTEMS_Objects;
78
79  _RTEMS_tasks_Manager_initialization();
80  _Semaphore_Manager_initialization();
81
82  _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
83
84  /*
85   *  No threads should be created before this point!!!
86   *  _Thread_Executing and _Thread_Heir are not set.
87   *
88   *  At this point all API extensions are in place.  After the call to
89   *  _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set.
90   */
91  _Thread_Create_idle();
92
93  /*
94   *  Scheduling can properly occur now as long as we avoid dispatching.
95   */
96
97  _System_state_Set( SYSTEM_STATE_BEGIN_MULTITASKING );
98
99  _Thread_Start_multitasking();
100
101  /*
102   *  Now we are back in a non-dispatching critical section
103   */
104  _Thread_Dispatch_set_disable_level(0);
105
106  /*
107   * Print an initial message
108   */
109  check_heir_and_executing();
110}
Note: See TracBrowser for help on using the repository browser.