[bd2e898] | 1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
| 2 | |
---|
[4c98a3e] | 3 | /** |
---|
| 4 | * @file |
---|
| 5 | * |
---|
[3db9c820] | 6 | * @ingroup RTEMSImplClassic |
---|
[4c98a3e] | 7 | * |
---|
[3db9c820] | 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(). |
---|
[4c98a3e] | 12 | */ |
---|
| 13 | |
---|
[ac7d5ef0] | 14 | /* |
---|
[e6c87f7] | 15 | * COPYRIGHT (c) 1989-2014. |
---|
[ac7d5ef0] | 16 | * On-Line Applications Research Corporation (OAR). |
---|
| 17 | * |
---|
[bd2e898] | 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. |
---|
[ac7d5ef0] | 38 | */ |
---|
| 39 | |
---|
[80cf60e] | 40 | #ifdef HAVE_CONFIG_H |
---|
[16351f7a] | 41 | #include "config.h" |
---|
| 42 | #endif |
---|
| 43 | |
---|
[ac7d5ef0] | 44 | #include <rtems/config.h> |
---|
[ac252bdc] | 45 | #include <rtems/extensionimpl.h> |
---|
[ac7d5ef0] | 46 | #include <rtems/init.h> |
---|
[d0c39838] | 47 | #include <rtems/sysinit.h> |
---|
[5e9b32b] | 48 | #include <rtems/score/sysstate.h> |
---|
[ac7d5ef0] | 49 | |
---|
[5e9b32b] | 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> |
---|
[c6e21ee1] | 55 | #include <rtems/score/schedulerimpl.h> |
---|
[6ca4f6a] | 56 | #include <rtems/score/smpimpl.h> |
---|
[7cd2484] | 57 | #include <rtems/score/timecounter.h> |
---|
[5618c37a] | 58 | #include <rtems/score/threadimpl.h> |
---|
[f031df0e] | 59 | #include <rtems/score/todimpl.h> |
---|
[3a4ae6c] | 60 | |
---|
[3ce3cdf] | 61 | RTEMS_SECTION(".rtemsroset.copyright") const char _Copyright_Notice[] = |
---|
[3272dcb] | 62 | "Copyright (C) 1989, 2021 RTEMS Project and contributors"; |
---|
[358bd740] | 63 | |
---|
[17e6f86] | 64 | static Objects_Information * |
---|
| 65 | _Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ]; |
---|
| 66 | |
---|
| 67 | static Objects_Information *_RTEMS_Objects[ OBJECTS_RTEMS_CLASSES_LAST + 1 ]; |
---|
| 68 | |
---|
| 69 | static Objects_Information *_POSIX_Objects[ OBJECTS_POSIX_CLASSES_LAST + 1 ]; |
---|
| 70 | |
---|
[876dde7a] | 71 | Objects_Information ** const |
---|
| 72 | _Objects_Information_table[ OBJECTS_APIS_LAST + 1 ] = { |
---|
[17e6f86] | 73 | NULL, |
---|
| 74 | &_Internal_Objects[ 0 ], |
---|
| 75 | &_RTEMS_Objects[ 0 ], |
---|
| 76 | &_POSIX_Objects[ 0 ] |
---|
| 77 | }; |
---|
[3a4ae6c] | 78 | |
---|
[d0c39838] | 79 | static void rtems_initialize_data_structures(void) |
---|
[ac7d5ef0] | 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. |
---|
[a0d22251] | 85 | * |
---|
| 86 | * WARNING: Interrupts should have been disabled by the BSP and |
---|
| 87 | * are disabled by boot_card(). |
---|
[ac7d5ef0] | 88 | */ |
---|
| 89 | |
---|
[45d107ec] | 90 | /* |
---|
| 91 | * Initialize any target architecture specific support as early as possible |
---|
| 92 | */ |
---|
| 93 | _CPU_Initialize(); |
---|
| 94 | |
---|
[ac7d5ef0] | 95 | _Thread_Dispatch_initialization(); |
---|
| 96 | |
---|
| 97 | _ISR_Handler_initialization(); |
---|
[0577ec1d] | 98 | |
---|
[790b50b] | 99 | _Thread_Handler_initialization(); |
---|
[ac7d5ef0] | 100 | |
---|
[0faa9dad] | 101 | _Scheduler_Handler_initialization(); |
---|
| 102 | |
---|
[039a189d] | 103 | _SMP_Handler_initialize(); |
---|
[d86ae06] | 104 | } |
---|
[a2a8c5b] | 105 | |
---|
[d0c39838] | 106 | RTEMS_LINKER_ROSET( _Sysinit, rtems_sysinit_item ); |
---|
| 107 | |
---|
| 108 | RTEMS_SYSINIT_ITEM( |
---|
| 109 | rtems_initialize_data_structures, |
---|
| 110 | RTEMS_SYSINIT_DATA_STRUCTURES, |
---|
| 111 | RTEMS_SYSINIT_ORDER_MIDDLE |
---|
| 112 | ); |
---|
| 113 | |
---|
[36b86d7] | 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 | */ |
---|
| 123 | RTEMS_SYSINIT_ITEM( |
---|
| 124 | _Thread_Create_idle, |
---|
| 125 | RTEMS_SYSINIT_IDLE_THREADS, |
---|
| 126 | RTEMS_SYSINIT_ORDER_MIDDLE |
---|
| 127 | ); |
---|
| 128 | |
---|
[d0c39838] | 129 | void rtems_initialize_executive(void) |
---|
[ac7d5ef0] | 130 | { |
---|
[4b579c5f] | 131 | const rtems_sysinit_item *item; |
---|
[d0c39838] | 132 | |
---|
| 133 | /* Invoke the registered system initialization handlers */ |
---|
[4b579c5f] | 134 | RTEMS_LINKER_SET_FOREACH( _Sysinit, item ) { |
---|
| 135 | ( *item->handler )(); |
---|
[d0c39838] | 136 | } |
---|
| 137 | |
---|
[b4b309c] | 138 | _System_state_Set( SYSTEM_STATE_UP ); |
---|
| 139 | |
---|
[7336be9d] | 140 | _SMP_Request_start_multitasking(); |
---|
[e071c183] | 141 | |
---|
[514705d] | 142 | _Thread_Start_multitasking(); |
---|
[ac7d5ef0] | 143 | |
---|
[d86ae06] | 144 | /******************************************************************* |
---|
| 145 | ******************************************************************* |
---|
| 146 | ******************************************************************* |
---|
| 147 | ****** APPLICATION RUNS HERE ****** |
---|
[514705d] | 148 | ****** THE FUNCTION NEVER RETURNS ****** |
---|
[d86ae06] | 149 | ******************************************************************* |
---|
| 150 | ******************************************************************* |
---|
| 151 | *******************************************************************/ |
---|
[ac7d5ef0] | 152 | } |
---|