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