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