source: rtems/cpukit/sapi/src/exinit.c @ 6c2b8a4b

5
Last change on this file since 6c2b8a4b was 6c2b8a4b, checked in by Sebastian Huber <sebastian.huber@…>, on 11/29/17 at 05:23:27

score: Use self-contained API mutex

Use a self-contained recursive mutex for API_Mutex_Control. The API
mutexes are protected against asynchronous thread cancellation.

Add dedicated mutexes for libatomic and TOD.

Close #2629.
Close #2630.

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/**
2 * @file
3 *
4 * @brief Initialization Manager
5 *
6 * @ingroup ClassicRTEMS
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-2014.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.org/license/LICENSE.
16 */
17
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <rtems/system.h>
23#include <rtems/config.h>
24#include <rtems/extensionimpl.h>
25#include <rtems/init.h>
26#include <rtems/ioimpl.h>
27#include <rtems/sysinit.h>
28#include <rtems/score/sysstate.h>
29
30#include <rtems/score/copyrt.h>
31#include <rtems/score/heap.h>
32#include <rtems/score/interr.h>
33#include <rtems/score/isr.h>
34#include <rtems/score/priority.h>
35#include <rtems/score/schedulerimpl.h>
36#include <rtems/score/smpimpl.h>
37#include <rtems/score/timecounter.h>
38#include <rtems/score/threadimpl.h>
39#include <rtems/score/todimpl.h>
40#include <rtems/score/wkspace.h>
41
42const char _Copyright_Notice[] =
43"COPYRIGHT (c) 1989-2008.\n\
44On-Line Applications Research Corporation (OAR).\n";
45
46static Objects_Information *
47_Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ];
48
49static Objects_Information *_RTEMS_Objects[ OBJECTS_RTEMS_CLASSES_LAST + 1 ];
50
51static Objects_Information *_POSIX_Objects[ OBJECTS_POSIX_CLASSES_LAST + 1 ];
52
53Objects_Information ** const
54_Objects_Information_table[ OBJECTS_APIS_LAST + 1 ] = {
55  NULL,
56  &_Internal_Objects[ 0 ],
57  &_RTEMS_Objects[ 0 ],
58  &_POSIX_Objects[ 0 ]
59};
60
61static void rtems_initialize_data_structures(void)
62{
63  /*
64   *  Dispatching and interrupts are disabled until the end of the
65   *  initialization sequence.  This prevents an inadvertent context
66   *  switch before the executive is initialized.
67   *
68   *  WARNING: Interrupts should have been disabled by the BSP and
69   *           are disabled by boot_card().
70   */
71
72  /*
73   * Initialize any target architecture specific support as early as possible
74   */
75  _CPU_Initialize();
76
77  _Thread_Dispatch_initialization();
78
79  _ISR_Handler_initialization();
80
81  _Thread_Handler_initialization();
82
83  _Scheduler_Handler_initialization();
84
85  _SMP_Handler_initialize();
86}
87
88RTEMS_LINKER_ROSET( _Sysinit, rtems_sysinit_item );
89
90RTEMS_SYSINIT_ITEM(
91  rtems_initialize_data_structures,
92  RTEMS_SYSINIT_DATA_STRUCTURES,
93  RTEMS_SYSINIT_ORDER_MIDDLE
94);
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 *  Scheduling can properly occur afterwards as long as we avoid dispatching.
104 */
105RTEMS_SYSINIT_ITEM(
106  _Thread_Create_idle,
107  RTEMS_SYSINIT_IDLE_THREADS,
108  RTEMS_SYSINIT_ORDER_MIDDLE
109);
110
111/* Initialize I/O drivers.
112 *
113 * Driver Manager note:
114 * All drivers may not be registered yet. Drivers will dynamically
115 * be initialized when registered in level 2,3 and 4.
116 */
117RTEMS_SYSINIT_ITEM(
118  _IO_Initialize_all_drivers,
119  RTEMS_SYSINIT_DEVICE_DRIVERS,
120  RTEMS_SYSINIT_ORDER_MIDDLE
121);
122
123void rtems_initialize_executive(void)
124{
125  const rtems_sysinit_item *item;
126
127  /* Invoke the registered system initialization handlers */
128  RTEMS_LINKER_SET_FOREACH( _Sysinit, item ) {
129    ( *item->handler )();
130  }
131
132  _System_state_Set( SYSTEM_STATE_UP );
133
134  _SMP_Request_start_multitasking();
135
136  _Thread_Start_multitasking();
137
138  /*******************************************************************
139   *******************************************************************
140   *******************************************************************
141   ******                 APPLICATION RUNS HERE                 ******
142   ******              THE FUNCTION NEVER RETURNS               ******
143   *******************************************************************
144   *******************************************************************
145   *******************************************************************/
146}
Note: See TracBrowser for help on using the repository browser.