source: rtems-docs/c_user/fatal_error.rst @ 4e71fe2

4.115
Last change on this file since 4e71fe2 was 9aafb39, checked in by Chris Johns <chrisj@…>, on 10/28/16 at 12:56:02

c_user: Remove errors and warnings.

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