1 | @c |
---|
2 | @c COPYRIGHT (c) 1988-2002. |
---|
3 | @c On-Line Applications Research Corporation (OAR). |
---|
4 | @c All rights reserved. |
---|
5 | @c |
---|
6 | @c $Id$ |
---|
7 | @c |
---|
8 | |
---|
9 | @chapter Fatal Error Manager |
---|
10 | |
---|
11 | @cindex fatal errors |
---|
12 | |
---|
13 | @section Introduction |
---|
14 | |
---|
15 | The fatal error manager processes all fatal or |
---|
16 | irrecoverable errors. The directive provided by the fatal error |
---|
17 | manager is: |
---|
18 | |
---|
19 | @itemize @bullet |
---|
20 | @item @code{@value{DIRPREFIX}fatal_error_occurred} - Invoke the fatal error handler |
---|
21 | @end itemize |
---|
22 | |
---|
23 | @section Background |
---|
24 | |
---|
25 | @cindex fatal error detection |
---|
26 | @cindex fatal error processing |
---|
27 | @cindex fatal error user extension |
---|
28 | |
---|
29 | The fatal error manager is called upon detection of |
---|
30 | an irrecoverable error condition by either RTEMS or the |
---|
31 | application software. Fatal errors can be detected from three |
---|
32 | sources: |
---|
33 | |
---|
34 | @itemize @bullet |
---|
35 | @item the executive (RTEMS) |
---|
36 | @item user system code |
---|
37 | @item user application code |
---|
38 | @end itemize |
---|
39 | |
---|
40 | RTEMS automatically invokes the fatal error manager |
---|
41 | upon detection of an error it considers to be fatal. Similarly, |
---|
42 | the user should invoke the fatal error manager upon detection of |
---|
43 | a fatal error. |
---|
44 | |
---|
45 | Each status or dynamic user extension set may include |
---|
46 | a fatal error handler. The fatal error handler in the static |
---|
47 | extension set can be used to provide access to debuggers and |
---|
48 | monitors which may be present on the target hardware. If any |
---|
49 | user-supplied fatal error handlers are installed, the fatal |
---|
50 | error manager will invoke them. If no user handlers are |
---|
51 | configured or if all the user handler return control to the |
---|
52 | fatal error manager, then the RTEMS default fatal error handler |
---|
53 | is invoked. If the default fatal error handler is invoked, then |
---|
54 | the system state is marked as failed. |
---|
55 | |
---|
56 | Although the precise behavior of the default fatal |
---|
57 | error handler is processor specific, in general, it will disable |
---|
58 | all maskable interrupts, place the error code in a known |
---|
59 | processor dependent place (generally either on the stack or in a |
---|
60 | register), and halt the processor. The precise actions of the |
---|
61 | RTEMS fatal error are discussed in the Default Fatal Error |
---|
62 | Processing chapter of the Applications Supplement document for |
---|
63 | a specific target processor. |
---|
64 | |
---|
65 | @section Operations |
---|
66 | |
---|
67 | @subsection Announcing a Fatal Error |
---|
68 | |
---|
69 | @findex _Internal_errors_What_happened |
---|
70 | |
---|
71 | The @code{@value{DIRPREFIX}fatal_error_occurred} directive is invoked when a |
---|
72 | fatal error is detected. Before invoking any user-supplied |
---|
73 | fatal error handlers or the RTEMS fatal error handler, the |
---|
74 | @code{@value{DIRPREFIX}fatal_error_occurred} |
---|
75 | directive stores useful information in the |
---|
76 | variable @code{_Internal_errors_What_happened}. This @value{STRUCTURE} |
---|
77 | contains three pieces of information: |
---|
78 | |
---|
79 | @itemize @bullet |
---|
80 | @item the source of the error (API or executive core), |
---|
81 | |
---|
82 | @item whether the error was generated internally by the |
---|
83 | executive, and a |
---|
84 | |
---|
85 | @item a numeric code to indicate the error type. |
---|
86 | @end itemize |
---|
87 | |
---|
88 | The error type indicator is dependent on the source |
---|
89 | of the error and whether or not the error was internally |
---|
90 | generated by the executive. If the error was generated |
---|
91 | from an API, then the error code will be of that API's |
---|
92 | error or status codes. The status codes for the RTEMS |
---|
93 | API are in c/src/exec/rtems/headers/status.h. Those |
---|
94 | for the POSIX API can be found in <errno.h>. |
---|
95 | |
---|
96 | The @code{@value{DIRPREFIX}fatal_error_occurred} directive is responsible |
---|
97 | for invoking an optional user-supplied fatal error handler |
---|
98 | and/or the RTEMS fatal error handler. All fatal error handlers |
---|
99 | are passed an error code to describe the error detected. |
---|
100 | |
---|
101 | Occasionally, an application requires more |
---|
102 | sophisticated fatal error processing such as passing control to |
---|
103 | a debugger. For these cases, a user-supplied fatal error |
---|
104 | handler can be specified in the RTEMS configuration table. The |
---|
105 | User Extension Table field fatal contains the address of the |
---|
106 | fatal error handler to be executed when the |
---|
107 | @code{@value{DIRPREFIX}fatal_error_occurred} |
---|
108 | directive is called. If the field is set to NULL or if the |
---|
109 | configured fatal error handler returns to the executive, then |
---|
110 | the default handler provided by RTEMS is executed. This default |
---|
111 | handler will halt execution on the processor where the error |
---|
112 | occurred. |
---|
113 | |
---|
114 | @section Directives |
---|
115 | |
---|
116 | This section details the fatal error manager's |
---|
117 | directives. A subsection is dedicated to each of this manager's |
---|
118 | directives and describes the calling sequence, related |
---|
119 | constants, usage, and status codes. |
---|
120 | |
---|
121 | @c |
---|
122 | @c |
---|
123 | @c |
---|
124 | @page |
---|
125 | @subsection FATAL_ERROR_OCCURRED - Invoke the fatal error handler |
---|
126 | |
---|
127 | @cindex announce fatal error |
---|
128 | @cindex fatal error, announce |
---|
129 | |
---|
130 | @subheading CALLING SEQUENCE: |
---|
131 | |
---|
132 | @ifset is-C |
---|
133 | @findex rtems_fatal_error_occurred |
---|
134 | @example |
---|
135 | void volatile rtems_fatal_error_occurred( |
---|
136 | rtems_unsigned32 the_error |
---|
137 | ); |
---|
138 | @end example |
---|
139 | @end ifset |
---|
140 | |
---|
141 | @ifset is-Ada |
---|
142 | @example |
---|
143 | procedure Fatal_Error_Occurred ( |
---|
144 | The_Error : in RTEMS.Unsigned32 |
---|
145 | ); |
---|
146 | @end example |
---|
147 | @end ifset |
---|
148 | |
---|
149 | @subheading DIRECTIVE STATUS CODES |
---|
150 | |
---|
151 | NONE |
---|
152 | |
---|
153 | @subheading DESCRIPTION: |
---|
154 | |
---|
155 | This directive processes fatal errors. If the FATAL |
---|
156 | error extension is defined in the configuration table, then the |
---|
157 | user-defined error extension is called. If configured and the |
---|
158 | provided FATAL error extension returns, then the RTEMS default |
---|
159 | error handler is invoked. This directive can be invoked by |
---|
160 | RTEMS or by the user's application code including initialization |
---|
161 | tasks, other tasks, and ISRs. |
---|
162 | |
---|
163 | @subheading NOTES: |
---|
164 | |
---|
165 | This directive supports local operations only. |
---|
166 | |
---|
167 | Unless the user-defined error extension takes special |
---|
168 | actions such as restarting the calling task, this directive WILL |
---|
169 | NOT RETURN to the caller. |
---|
170 | |
---|
171 | The user-defined extension for this directive may |
---|
172 | wish to initiate a global shutdown. |
---|