source: rtems/cpukit/sapi/src/exinit.c

Last change on this file was bd2e898, checked in by Joel Sherrill <joel@…>, on 02/16/22 at 22:48:55

sapi/src/*.c: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 4.9 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup RTEMSImplClassic
7 *
8 * @brief This source file contains the definition of ::_Copyright_Notice,
9 *   ::_Objects_Information_table, the flexible per-CPU data linker set limits,
10 *   the system initialization linker set limits and the implementation of
11 *   rtems_initialize_executive().
12 */
13
14/*
15 *  COPYRIGHT (c) 1989-2014.
16 *  On-Line Applications Research Corporation (OAR).
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 * 1. Redistributions of source code must retain the above copyright
22 *    notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 *    notice, this list of conditions and the following disclaimer in the
25 *    documentation and/or other materials provided with the distribution.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40#ifdef HAVE_CONFIG_H
41#include "config.h"
42#endif
43
44#include <rtems/config.h>
45#include <rtems/extensionimpl.h>
46#include <rtems/init.h>
47#include <rtems/sysinit.h>
48#include <rtems/score/sysstate.h>
49
50#include <rtems/score/copyrt.h>
51#include <rtems/score/heap.h>
52#include <rtems/score/interr.h>
53#include <rtems/score/isr.h>
54#include <rtems/score/priority.h>
55#include <rtems/score/schedulerimpl.h>
56#include <rtems/score/smpimpl.h>
57#include <rtems/score/timecounter.h>
58#include <rtems/score/threadimpl.h>
59#include <rtems/score/todimpl.h>
60
61RTEMS_SECTION(".rtemsroset.copyright") const char _Copyright_Notice[] =
62  "Copyright (C) 1989, 2021 RTEMS Project and contributors";
63
64static Objects_Information *
65_Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ];
66
67static Objects_Information *_RTEMS_Objects[ OBJECTS_RTEMS_CLASSES_LAST + 1 ];
68
69static Objects_Information *_POSIX_Objects[ OBJECTS_POSIX_CLASSES_LAST + 1 ];
70
71Objects_Information ** const
72_Objects_Information_table[ OBJECTS_APIS_LAST + 1 ] = {
73  NULL,
74  &_Internal_Objects[ 0 ],
75  &_RTEMS_Objects[ 0 ],
76  &_POSIX_Objects[ 0 ]
77};
78
79static void rtems_initialize_data_structures(void)
80{
81  /*
82   *  Dispatching and interrupts are disabled until the end of the
83   *  initialization sequence.  This prevents an inadvertent context
84   *  switch before the executive is initialized.
85   *
86   *  WARNING: Interrupts should have been disabled by the BSP and
87   *           are disabled by boot_card().
88   */
89
90  /*
91   * Initialize any target architecture specific support as early as possible
92   */
93  _CPU_Initialize();
94
95  _Thread_Dispatch_initialization();
96
97  _ISR_Handler_initialization();
98
99  _Thread_Handler_initialization();
100
101  _Scheduler_Handler_initialization();
102
103  _SMP_Handler_initialize();
104}
105
106RTEMS_LINKER_ROSET( _Sysinit, rtems_sysinit_item );
107
108RTEMS_SYSINIT_ITEM(
109  rtems_initialize_data_structures,
110  RTEMS_SYSINIT_DATA_STRUCTURES,
111  RTEMS_SYSINIT_ORDER_MIDDLE
112);
113
114/*
115 *  No threads should be created before this point!!!
116 *  _Thread_Executing and _Thread_Heir are not set.
117 *
118 *  At this point all API extensions are in place.  After the call to
119 *  _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set.
120 *
121 *  Scheduling can properly occur afterwards as long as we avoid dispatching.
122 */
123RTEMS_SYSINIT_ITEM(
124  _Thread_Create_idle,
125  RTEMS_SYSINIT_IDLE_THREADS,
126  RTEMS_SYSINIT_ORDER_MIDDLE
127);
128
129void rtems_initialize_executive(void)
130{
131  const rtems_sysinit_item *item;
132
133  /* Invoke the registered system initialization handlers */
134  RTEMS_LINKER_SET_FOREACH( _Sysinit, item ) {
135    ( *item->handler )();
136  }
137
138  _System_state_Set( SYSTEM_STATE_UP );
139
140  _SMP_Request_start_multitasking();
141
142  _Thread_Start_multitasking();
143
144  /*******************************************************************
145   *******************************************************************
146   *******************************************************************
147   ******                 APPLICATION RUNS HERE                 ******
148   ******              THE FUNCTION NEVER RETURNS               ******
149   *******************************************************************
150   *******************************************************************
151   *******************************************************************/
152}
Note: See TracBrowser for help on using the repository browser.