1 | .. COMMENT: COPYRIGHT (c) 1988-2008. |
---|
2 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
3 | .. COMMENT: All rights reserved. |
---|
4 | |
---|
5 | Fatal Error Manager |
---|
6 | ################### |
---|
7 | |
---|
8 | .. index:: fatal errors |
---|
9 | |
---|
10 | Introduction |
---|
11 | ============ |
---|
12 | |
---|
13 | The fatal error manager processes all fatal or irrecoverable errors and other |
---|
14 | sources of system termination (for example after ``exit()``). The directives |
---|
15 | provided by the fatal error manager are: |
---|
16 | |
---|
17 | - rtems_fatal_error_occurred_ - Invoke the fatal error handler |
---|
18 | |
---|
19 | - rtems_fatal_ - Invoke the fatal error handler with error source |
---|
20 | |
---|
21 | - rtems_exception_frame_print_ - Print the CPU exception frame |
---|
22 | |
---|
23 | - rtems_fatal_source_text_ - Return the falet source text |
---|
24 | |
---|
25 | - rtems_internal_error_text_ - Return the error code text |
---|
26 | |
---|
27 | Background |
---|
28 | ========== |
---|
29 | .. index:: fatal error detection |
---|
30 | .. index:: fatal error processing |
---|
31 | .. index:: fatal error user extension |
---|
32 | |
---|
33 | The fatal error manager is called upon detection of an irrecoverable error |
---|
34 | condition by either RTEMS or the application software. Fatal errors can be |
---|
35 | detected from three sources: |
---|
36 | |
---|
37 | - the executive (RTEMS) |
---|
38 | |
---|
39 | - user system code |
---|
40 | |
---|
41 | - user application code |
---|
42 | |
---|
43 | RTEMS automatically invokes the fatal error manager upon detection of an error |
---|
44 | it considers to be fatal. Similarly, the user should invoke the fatal error |
---|
45 | manager upon detection of a fatal error. |
---|
46 | |
---|
47 | Each static or dynamic user extension set may include a fatal error handler. |
---|
48 | The fatal error handler in the static extension set can be used to provide |
---|
49 | access to debuggers and monitors which may be present on the target hardware. |
---|
50 | If any user-supplied fatal error handlers are installed, the fatal error |
---|
51 | manager will invoke them. If no user handlers are configured or if all the |
---|
52 | user handler return control to the fatal error manager, then the RTEMS default |
---|
53 | fatal error handler is invoked. If the default fatal error handler is invoked, |
---|
54 | then the system state is marked as failed. |
---|
55 | |
---|
56 | Although the precise behavior of the default fatal error handler is processor |
---|
57 | specific, in general, it will disable all maskable interrupts, place the error |
---|
58 | code in a known processor dependent place (generally either on the stack or in |
---|
59 | a register), and halt the processor. The precise actions of the RTEMS fatal |
---|
60 | error are discussed in the Default Fatal Error Processing chapter of the |
---|
61 | Applications Supplement document for a specific target processor. |
---|
62 | |
---|
63 | Operations |
---|
64 | ========== |
---|
65 | |
---|
66 | Announcing a Fatal Error |
---|
67 | ------------------------ |
---|
68 | .. index:: _Internal_errors_What_happened |
---|
69 | |
---|
70 | The ``rtems_fatal_error_occurred`` directive is invoked when a fatal error is |
---|
71 | detected. Before invoking any user-supplied fatal error handlers or the RTEMS |
---|
72 | fatal error handler, the ``rtems_fatal_error_occurred`` directive stores useful |
---|
73 | information in the variable ``_Internal_errors_What_happened``. This structure |
---|
74 | contains three pieces of information: |
---|
75 | |
---|
76 | - the source of the error (API or executive core), |
---|
77 | |
---|
78 | - whether the error was generated internally by the executive, and a |
---|
79 | |
---|
80 | - a numeric code to indicate the error type. |
---|
81 | |
---|
82 | The error type indicator is dependent on the source of the error and whether or |
---|
83 | not the error was internally generated by the executive. If the error was |
---|
84 | generated from an API, then the error code will be of that API's error or |
---|
85 | status codes. The status codes for the RTEMS API are in |
---|
86 | cpukit/rtems/include/rtems/rtems/status.h. Those for the POSIX API can be |
---|
87 | found in <errno.h>. |
---|
88 | |
---|
89 | The ``rtems_fatal_error_occurred`` directive is responsible for invoking an |
---|
90 | optional user-supplied fatal error handler and/or the RTEMS fatal error |
---|
91 | handler. All fatal error handlers are passed an error code to describe the |
---|
92 | error detected. |
---|
93 | |
---|
94 | Occasionally, an application requires more sophisticated fatal error processing |
---|
95 | such as passing control to a debugger. For these cases, a user-supplied fatal |
---|
96 | error handler can be specified in the RTEMS configuration table. The User |
---|
97 | Extension Table field fatal contains the address of the fatal error handler to |
---|
98 | be executed when the ``rtems_fatal_error_occurred`` directive is called. If |
---|
99 | the field is set to NULL or if the configured fatal error handler returns to |
---|
100 | the executive, then the default handler provided by RTEMS is executed. This |
---|
101 | default handler will halt execution on the processor where the error occurred. |
---|
102 | |
---|
103 | Directives |
---|
104 | ========== |
---|
105 | |
---|
106 | This section details the fatal error manager's directives. A subsection is |
---|
107 | dedicated to each of this manager's directives and describes the calling |
---|
108 | sequence, related constants, usage, and status codes. |
---|
109 | |
---|
110 | .. _rtems_fatal_error_occurred: |
---|
111 | |
---|
112 | FATAL_ERROR_OCCURRED - Invoke the fatal error handler |
---|
113 | ----------------------------------------------------- |
---|
114 | .. index:: announce fatal error |
---|
115 | .. index:: fatal error, announce |
---|
116 | |
---|
117 | **CALLING SEQUENCE:** |
---|
118 | |
---|
119 | .. index:: rtems_fatal_error_occurred |
---|
120 | |
---|
121 | .. code:: c |
---|
122 | |
---|
123 | void rtems_fatal_error_occurred( |
---|
124 | uint32_t the_error |
---|
125 | ); |
---|
126 | |
---|
127 | **DIRECTIVE STATUS CODES** |
---|
128 | |
---|
129 | NONE |
---|
130 | |
---|
131 | **DESCRIPTION:** |
---|
132 | |
---|
133 | This directive processes fatal errors. If the FATAL error extension is defined |
---|
134 | in the configuration table, then the user-defined error extension is called. |
---|
135 | If configured and the provided FATAL error extension returns, then the RTEMS |
---|
136 | default error handler is invoked. This directive can be invoked by RTEMS or by |
---|
137 | the user's application code including initialization tasks, other tasks, and |
---|
138 | ISRs. |
---|
139 | |
---|
140 | **NOTES:** |
---|
141 | |
---|
142 | This directive supports local operations only. |
---|
143 | |
---|
144 | Unless the user-defined error extension takes special actions such as |
---|
145 | restarting the calling task, this directive WILL NOT RETURN to the caller. |
---|
146 | |
---|
147 | The user-defined extension for this directive may wish to initiate a global |
---|
148 | shutdown. |
---|
149 | |
---|
150 | .. _rtems_fatal: |
---|
151 | |
---|
152 | FATAL - Invoke the fatal error handler with error source |
---|
153 | -------------------------------------------------------- |
---|
154 | .. index:: announce fatal error |
---|
155 | .. index:: fatal error, announce |
---|
156 | |
---|
157 | **CALLING SEQUENCE:** |
---|
158 | |
---|
159 | .. index:: rtems_fatal |
---|
160 | |
---|
161 | .. code:: c |
---|
162 | |
---|
163 | void rtems_fatal( |
---|
164 | rtems_fatal_source source, |
---|
165 | rtems_fatal_code error |
---|
166 | ); |
---|
167 | |
---|
168 | **DIRECTIVE STATUS CODES** |
---|
169 | |
---|
170 | NONE |
---|
171 | |
---|
172 | **DESCRIPTION:** |
---|
173 | |
---|
174 | This directive invokes the internal error handler with is internal set to |
---|
175 | false. See also ``rtems_fatal_error_occurred``. |
---|
176 | |
---|
177 | .. _rtems_exception_frame_print: |
---|
178 | |
---|
179 | EXCEPTION_FRAME_PRINT - Prints the exception frame |
---|
180 | -------------------------------------------------- |
---|
181 | .. index:: exception frame |
---|
182 | |
---|
183 | **CALLING SEQUENCE:** |
---|
184 | |
---|
185 | .. index:: rtems_exception_frame_print |
---|
186 | |
---|
187 | .. code:: c |
---|
188 | |
---|
189 | void rtems_exception_frame_print( |
---|
190 | const rtems_exception_frame *frame |
---|
191 | ); |
---|
192 | |
---|
193 | **DIRECTIVE STATUS CODES** |
---|
194 | |
---|
195 | NONE |
---|
196 | |
---|
197 | **DESCRIPTION:** |
---|
198 | |
---|
199 | Prints the exception frame via ``printk()``. |
---|
200 | |
---|
201 | .. _rtems_fatal_source_text: |
---|
202 | |
---|
203 | FATAL_SOURCE_TEXT - Returns a text for a fatal source |
---|
204 | ----------------------------------------------------- |
---|
205 | .. index:: fatal error |
---|
206 | |
---|
207 | **CALLING SEQUENCE:** |
---|
208 | |
---|
209 | .. index:: rtems_fatal_source_text |
---|
210 | |
---|
211 | .. code:: c |
---|
212 | |
---|
213 | const char *rtems_fatal_source_text( |
---|
214 | rtems_fatal_source source |
---|
215 | ); |
---|
216 | |
---|
217 | **DIRECTIVE STATUS CODES** |
---|
218 | |
---|
219 | The fatal source text or "?" in case the passed fatal source is invalid. |
---|
220 | |
---|
221 | **DESCRIPTION:** |
---|
222 | |
---|
223 | Returns a text for a fatal source. The text for fatal source is the enumerator |
---|
224 | constant. |
---|
225 | |
---|
226 | .. _rtems_internal_error_text: |
---|
227 | |
---|
228 | INTERNAL_ERROR_TEXT - Returns a text for an internal error code |
---|
229 | --------------------------------------------------------------- |
---|
230 | .. index:: fatal error |
---|
231 | |
---|
232 | **CALLING SEQUENCE:** |
---|
233 | |
---|
234 | .. index:: rtems_internal_error_text |
---|
235 | |
---|
236 | .. code:: c |
---|
237 | |
---|
238 | const char *rtems_internal_error_text( |
---|
239 | rtems_fatal_code error |
---|
240 | ); |
---|
241 | |
---|
242 | **DIRECTIVE STATUS CODES** |
---|
243 | |
---|
244 | The error code text or "?" in case the passed error code is invalid. |
---|
245 | |
---|
246 | **DESCRIPTION:** |
---|
247 | |
---|
248 | Returns a text for an internal error code. The text for each internal error |
---|
249 | code is the enumerator constant. |
---|