1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * |
---|
6 | * @ingroup RTEMSScoreIntErr |
---|
7 | * |
---|
8 | * @brief This header file provides the interfaces of the |
---|
9 | * @ref RTEMSScoreIntErr. |
---|
10 | */ |
---|
11 | |
---|
12 | /* |
---|
13 | * COPYRIGHT (c) 1989-2009. |
---|
14 | * On-Line Applications Research Corporation (OAR). |
---|
15 | * |
---|
16 | * Redistribution and use in source and binary forms, with or without |
---|
17 | * modification, are permitted provided that the following conditions |
---|
18 | * are met: |
---|
19 | * 1. Redistributions of source code must retain the above copyright |
---|
20 | * notice, this list of conditions and the following disclaimer. |
---|
21 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
22 | * notice, this list of conditions and the following disclaimer in the |
---|
23 | * documentation and/or other materials provided with the distribution. |
---|
24 | * |
---|
25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
35 | * POSSIBILITY OF SUCH DAMAGE. |
---|
36 | */ |
---|
37 | |
---|
38 | #ifndef _RTEMS_SCORE_INTERR_H |
---|
39 | #define _RTEMS_SCORE_INTERR_H |
---|
40 | |
---|
41 | #include <rtems/score/cpu.h> |
---|
42 | |
---|
43 | /** |
---|
44 | * @defgroup RTEMSScoreIntErr Internal Error Handler |
---|
45 | * |
---|
46 | * @ingroup RTEMSScore |
---|
47 | * |
---|
48 | * @brief This group contains the Internal Error Handler implementation. |
---|
49 | * |
---|
50 | * This handler encapsulates functionality to terminate the system. |
---|
51 | * |
---|
52 | * @{ |
---|
53 | */ |
---|
54 | |
---|
55 | #ifdef __cplusplus |
---|
56 | extern "C" { |
---|
57 | #endif |
---|
58 | |
---|
59 | /** |
---|
60 | * @brief This type lists the possible sources from which an error |
---|
61 | * can be reported. |
---|
62 | */ |
---|
63 | typedef enum { |
---|
64 | /** |
---|
65 | * @brief Errors of the core system. |
---|
66 | * |
---|
67 | * @see Internal_errors_Core_list. |
---|
68 | */ |
---|
69 | INTERNAL_ERROR_CORE = 0, |
---|
70 | |
---|
71 | /** |
---|
72 | * @brief Errors of the RTEMS API. |
---|
73 | */ |
---|
74 | INTERNAL_ERROR_RTEMS_API = 1, |
---|
75 | |
---|
76 | /** |
---|
77 | * @brief Errors of the POSIX API. |
---|
78 | */ |
---|
79 | INTERNAL_ERROR_POSIX_API = 2, |
---|
80 | |
---|
81 | /** |
---|
82 | * @brief Fatal source for the block device cache. |
---|
83 | * |
---|
84 | * @see rtems_bdbuf_fatal_code. |
---|
85 | */ |
---|
86 | RTEMS_FATAL_SOURCE_BDBUF = 3, |
---|
87 | |
---|
88 | /** |
---|
89 | * @brief Fatal source for application specific errors. |
---|
90 | * |
---|
91 | * The fatal code is application specific. |
---|
92 | */ |
---|
93 | RTEMS_FATAL_SOURCE_APPLICATION = 4, |
---|
94 | |
---|
95 | /** |
---|
96 | * @brief Fatal source of exit(). |
---|
97 | * |
---|
98 | * The fatal code is the exit() status code. |
---|
99 | */ |
---|
100 | RTEMS_FATAL_SOURCE_EXIT = 5, |
---|
101 | |
---|
102 | /** |
---|
103 | * @brief Fatal source for BSP errors. |
---|
104 | * |
---|
105 | * The fatal codes are defined in <bsp/fatal.h>. Examples are interrupt and |
---|
106 | * exception initialization. |
---|
107 | * |
---|
108 | * @see bsp_fatal_code and bsp_fatal(). |
---|
109 | */ |
---|
110 | RTEMS_FATAL_SOURCE_BSP = 6, |
---|
111 | |
---|
112 | /** |
---|
113 | * @brief Fatal source of assert(). |
---|
114 | * |
---|
115 | * The fatal code is the pointer value of the assert context. |
---|
116 | * |
---|
117 | * @see rtems_assert_context. |
---|
118 | */ |
---|
119 | RTEMS_FATAL_SOURCE_ASSERT = 7, |
---|
120 | |
---|
121 | /** |
---|
122 | * @brief Fatal source of the stack checker. |
---|
123 | * |
---|
124 | * The fatal code is the object name of the executing task. |
---|
125 | */ |
---|
126 | RTEMS_FATAL_SOURCE_STACK_CHECKER = 8, |
---|
127 | |
---|
128 | /** |
---|
129 | * @brief Fatal source of the exceptions. |
---|
130 | * |
---|
131 | * The fatal code is the pointer value of the exception frame pointer. |
---|
132 | * |
---|
133 | * @see rtems_exception_frame and rtems_exception_frame_print(). |
---|
134 | */ |
---|
135 | RTEMS_FATAL_SOURCE_EXCEPTION = 9, |
---|
136 | |
---|
137 | /** |
---|
138 | * @brief Fatal source of SMP domain. |
---|
139 | * |
---|
140 | * @see SMP_Fatal_code. |
---|
141 | */ |
---|
142 | RTEMS_FATAL_SOURCE_SMP = 10, |
---|
143 | |
---|
144 | /** |
---|
145 | * @brief Fatal source of rtems_panic(). |
---|
146 | * |
---|
147 | * @see rtem |
---|
148 | */ |
---|
149 | RTEMS_FATAL_SOURCE_PANIC = 11, |
---|
150 | |
---|
151 | /** |
---|
152 | * @brief Fatal source for invalid C program heap frees via free(). |
---|
153 | * |
---|
154 | * The fatal code is the bad pointer. |
---|
155 | */ |
---|
156 | RTEMS_FATAL_SOURCE_INVALID_HEAP_FREE = 12, |
---|
157 | |
---|
158 | /** |
---|
159 | * @brief Fatal source for heap errors. |
---|
160 | * |
---|
161 | * The fatal code is the address to a heap error context (Heap_Error_context). |
---|
162 | */ |
---|
163 | RTEMS_FATAL_SOURCE_HEAP = 13, |
---|
164 | |
---|
165 | /** |
---|
166 | * @brief Fatal source for spurious interrupts. |
---|
167 | * |
---|
168 | * The fatal code is the interrupt vector number of the spurious interrupt. |
---|
169 | */ |
---|
170 | RTEMS_FATAL_SOURCE_SPURIOUS_INTERRUPT = 14, |
---|
171 | |
---|
172 | /** |
---|
173 | * @brief The last available fatal source. |
---|
174 | * |
---|
175 | * This enum value ensures that the enum type needs at least 32-bits for |
---|
176 | * architectures with short enums. |
---|
177 | */ |
---|
178 | RTEMS_FATAL_SOURCE_LAST = 0x7fffffff |
---|
179 | } Internal_errors_Source; |
---|
180 | |
---|
181 | /** |
---|
182 | * @brief A list of errors which are generated internally by the executive |
---|
183 | * core. |
---|
184 | * |
---|
185 | * Do not re-use numbers of obsolete error codes. Comment no longer used |
---|
186 | * error codes and do not uncomment commented or obsolete error codes. |
---|
187 | */ |
---|
188 | typedef enum { |
---|
189 | /* INTERNAL_ERROR_NO_CONFIGURATION_TABLE = 0, */ |
---|
190 | /* INTERNAL_ERROR_NO_CPU_TABLE = 1, */ |
---|
191 | INTERNAL_ERROR_TOO_LITTLE_WORKSPACE = 2, |
---|
192 | /* INTERNAL_ERROR_WORKSPACE_ALLOCATION = 3, */ |
---|
193 | /* INTERNAL_ERROR_INTERRUPT_STACK_TOO_SMALL = 4, */ |
---|
194 | INTERNAL_ERROR_THREAD_EXITTED = 5, |
---|
195 | INTERNAL_ERROR_INCONSISTENT_MP_INFORMATION = 6, |
---|
196 | INTERNAL_ERROR_INVALID_NODE = 7, |
---|
197 | INTERNAL_ERROR_NO_MPCI = 8, |
---|
198 | INTERNAL_ERROR_BAD_PACKET = 9, |
---|
199 | INTERNAL_ERROR_OUT_OF_PACKETS = 10, |
---|
200 | INTERNAL_ERROR_OUT_OF_GLOBAL_OBJECTS = 11, |
---|
201 | INTERNAL_ERROR_OUT_OF_PROXIES = 12, |
---|
202 | INTERNAL_ERROR_INVALID_GLOBAL_ID = 13, |
---|
203 | /* INTERNAL_ERROR_BAD_STACK_HOOK = 14, */ |
---|
204 | /* INTERNAL_ERROR_BAD_ATTRIBUTES = 15, */ |
---|
205 | /* INTERNAL_ERROR_IMPLEMENTATION_KEY_CREATE_INCONSISTENCY = 16, */ |
---|
206 | /* INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL = 17, */ |
---|
207 | /* INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_FROM_BAD_STATE = 18, */ |
---|
208 | /* INTERNAL_ERROR_UNLIMITED_AND_MAXIMUM_IS_0 = 19, */ |
---|
209 | /* INTERNAL_ERROR_SHUTDOWN_WHEN_NOT_UP = 20, */ |
---|
210 | /* INTERNAL_ERROR_GXX_KEY_ADD_FAILED = 21, */ |
---|
211 | /* INTERNAL_ERROR_GXX_MUTEX_INIT_FAILED = 22, */ |
---|
212 | INTERNAL_ERROR_NO_MEMORY_FOR_HEAP = 23, |
---|
213 | INTERNAL_ERROR_CPU_ISR_INSTALL_VECTOR = 24, |
---|
214 | INTERNAL_ERROR_RESOURCE_IN_USE = 25, |
---|
215 | /* INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL = 26, */ |
---|
216 | /* INTERNAL_ERROR_POSIX_INIT_THREAD_ENTRY_IS_NULL = 27, */ |
---|
217 | INTERNAL_ERROR_THREAD_QUEUE_DEADLOCK = 28, |
---|
218 | INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_STICKY_FROM_BAD_STATE = 29, |
---|
219 | INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL = 30, |
---|
220 | INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT = 31, |
---|
221 | INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED = 32, |
---|
222 | INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED = 33, |
---|
223 | /* INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED = 34, */ |
---|
224 | /* INTERNAL_ERROR_LIBIO_SEM_CREATE_FAILED = 35, */ |
---|
225 | INTERNAL_ERROR_LIBIO_STDOUT_FD_OPEN_FAILED = 36, |
---|
226 | INTERNAL_ERROR_LIBIO_STDERR_FD_OPEN_FAILED = 37, |
---|
227 | INTERNAL_ERROR_ILLEGAL_USE_OF_FLOATING_POINT_UNIT = 38, |
---|
228 | INTERNAL_ERROR_ARC4RANDOM_GETENTROPY_FAIL = 39, |
---|
229 | INTERNAL_ERROR_NO_MEMORY_FOR_PER_CPU_DATA = 40, |
---|
230 | INTERNAL_ERROR_TOO_LARGE_TLS_SIZE = 41, |
---|
231 | INTERNAL_ERROR_RTEMS_INIT_TASK_CONSTRUCT_FAILED = 42, |
---|
232 | INTERNAL_ERROR_IDLE_THREAD_CREATE_FAILED = 43, |
---|
233 | INTERNAL_ERROR_NO_MEMORY_FOR_IDLE_TASK_STORAGE = 44, |
---|
234 | INTERNAL_ERROR_IDLE_THREAD_STACK_TOO_SMALL = 45 |
---|
235 | } Internal_errors_Core_list; |
---|
236 | |
---|
237 | typedef CPU_Uint32ptr Internal_errors_t; |
---|
238 | |
---|
239 | /** |
---|
240 | * @brief Initiates system termination. |
---|
241 | * |
---|
242 | * This routine is invoked when the application or the executive itself |
---|
243 | * determines that a fatal error has occurred or a final system state is |
---|
244 | * reached (for example after exit()). |
---|
245 | * |
---|
246 | * The first action of this function is to call the fatal handler of the user |
---|
247 | * extensions. For the initial extensions the following conditions are |
---|
248 | * required |
---|
249 | * - a valid stack pointer and enough stack space, |
---|
250 | * - a valid code memory, and |
---|
251 | * - valid read-only data. |
---|
252 | * |
---|
253 | * For the initial extensions the read-write data (including BSS segment) is |
---|
254 | * not required on single processor configurations. On SMP configurations |
---|
255 | * however the read-write data must be initialized since this function must |
---|
256 | * determine the state of the other processors and request them to shut-down if |
---|
257 | * necessary. |
---|
258 | * |
---|
259 | * Non-initial extensions require in addition valid read-write data. The BSP |
---|
260 | * may install an initial extension that performs a system reset. In this case |
---|
261 | * the non-initial extensions will be not called. |
---|
262 | * |
---|
263 | * Once all fatal handler executed the system state is set to |
---|
264 | * SYSTEM_STATE_TERMINATED. |
---|
265 | * |
---|
266 | * The final step is to call the CPU specific _CPU_Fatal_halt(). |
---|
267 | * |
---|
268 | * @param the_source The fatal source indicating the subsystem the fatal |
---|
269 | * condition originated in. |
---|
270 | * @param the_error The fatal error code. This value must be interpreted |
---|
271 | * with respect to the source. |
---|
272 | * |
---|
273 | * @see rtems_fatal() and _Internal_error(). |
---|
274 | */ |
---|
275 | RTEMS_NO_RETURN void _Terminate( |
---|
276 | Internal_errors_Source the_source, |
---|
277 | Internal_errors_t the_error |
---|
278 | ); |
---|
279 | |
---|
280 | /** |
---|
281 | * @brief Terminates the system with an INTERNAL_ERROR_CORE fatal source and |
---|
282 | * the specified core error code. |
---|
283 | * |
---|
284 | * @param core_error The core error code. |
---|
285 | * |
---|
286 | * @see _Terminate(). |
---|
287 | */ |
---|
288 | RTEMS_NO_RETURN void _Internal_error( Internal_errors_Core_list core_error ); |
---|
289 | |
---|
290 | #ifdef __cplusplus |
---|
291 | } |
---|
292 | #endif |
---|
293 | |
---|
294 | /** @} */ |
---|
295 | |
---|
296 | #endif |
---|
297 | /* end of include file */ |
---|