[PATCH 2/2] score: Change _Internal_error_Occurred()

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Nov 21 15:44:09 UTC 2012


Call the fatal handlers of the user extensions before the update of
_Internal_errors_What_happened.  This reduces the requirements on the
execution context further.  Now a valid read-write data is only required
after the call to the fatal handlers.
---
 cpukit/score/include/rtems/score/interr.h |   31 +++++++++++++++++++++-------
 cpukit/score/src/interr.c                 |    3 +-
 doc/user/fatal.t                          |    8 +++---
 3 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/cpukit/score/include/rtems/score/interr.h b/cpukit/score/include/rtems/score/interr.h
index 0492649..367c1ab 100644
--- a/cpukit/score/include/rtems/score/interr.h
+++ b/cpukit/score/include/rtems/score/interr.h
@@ -166,17 +166,32 @@ typedef struct {
 extern Internal_errors_Information _Internal_errors_What_happened;
 
 /**
- * @brief An internal or fatal error occurred.
+ * @brief Initiates system termination.
  *
  * This routine is invoked when the application or the executive itself
- * determines that a fatal error has occurred.
+ * determines that a fatal error has occurred or a final system state is
+ * reached (for example after exit()).
  *
- * This function can be called in every system state provided the following
- * conditions are true
- * - the stack pointer is valid,
- * - the code memory is valid,
- * - the read-only data is valid, and
- * - the read-write data is accessible.
+ * The first action of this function is to call the fatal handler of the user
+ * extensions.  For the initial extensions the following conditions are
+ * required
+ * - a valid stack pointer and enough stack space,
+ * - a valid code memory, and
+ * - valid read-only data.
+ * For the initial extensions the read-write data (including BSS segment) is
+ * not required.
+ *
+ * Non-initial extensions require in addition valid read-write data.  The BSP
+ * may install an initial extension that performs a system reset.  In this case
+ * the non-initial extensions will be not called.
+ *
+ * Once all fatal handler executed the error information will be stored to
+ * _Internal_errors_What_happened and the system state is set to
+ * SYSTEM_STATE_FAILED.
+ *
+ * The final step is to call the CPU specific _CPU_Fatal_halt().
+ *
+ * @see rtems_fatal_error_occurred() and rtems_fatal().
  */
 void _Internal_error_Occurred(
   Internal_errors_Source  the_source,
diff --git a/cpukit/score/src/interr.c b/cpukit/score/src/interr.c
index a9f1efc..50b3ffd 100644
--- a/cpukit/score/src/interr.c
+++ b/cpukit/score/src/interr.c
@@ -50,13 +50,12 @@ void _Internal_error_Occurred(
   Internal_errors_t       the_error
 )
 {
+  _User_extensions_Fatal( the_source, is_internal, the_error );
 
   _Internal_errors_What_happened.the_source  = the_source;
   _Internal_errors_What_happened.is_internal = is_internal;
   _Internal_errors_What_happened.the_error   = the_error;
 
-  _User_extensions_Fatal( the_source, is_internal, the_error );
-
   _System_state_Set( SYSTEM_STATE_FAILED );
 
   _CPU_Fatal_halt( the_error );
diff --git a/doc/user/fatal.t b/doc/user/fatal.t
index aa9c2bf..42a2432 100644
--- a/doc/user/fatal.t
+++ b/doc/user/fatal.t
@@ -9,9 +9,9 @@
 
 @section Introduction
 
-The fatal error manager processes all fatal or
-irrecoverable errors.  The directive provided by the fatal error
-manager is:
+The fatal error manager processes all fatal or irrecoverable errors and other
+sources of system termination (for example after exit()).  The directives
+provided by the fatal error manager are:
 
 @itemize @bullet
 @item @code{@value{DIRPREFIX}fatal_error_occurred} - Invoke the fatal error handler
@@ -40,7 +40,7 @@ upon detection of an error it considers to be fatal.  Similarly,
 the user should invoke the fatal error manager upon detection of
 a fatal error.
 
-Each status or dynamic user extension set may include
+Each static or dynamic user extension set may include
 a fatal error handler.  The fatal error handler in the static
 extension set can be used to provide access to debuggers and
 monitors which may be present on the target hardware.  If any
-- 
1.7.7




More information about the devel mailing list