Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:13

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RTEMSImplClassic
0007  *
0008  * @brief This header file defines the Fatal Error Manager API.
0009  */
0010 
0011 /*
0012  * Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG
0013  * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR)
0014  *
0015  * Redistribution and use in source and binary forms, with or without
0016  * modification, are permitted provided that the following conditions
0017  * are met:
0018  * 1. Redistributions of source code must retain the above copyright
0019  *    notice, this list of conditions and the following disclaimer.
0020  * 2. Redistributions in binary form must reproduce the above copyright
0021  *    notice, this list of conditions and the following disclaimer in the
0022  *    documentation and/or other materials provided with the distribution.
0023  *
0024  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0025  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0026  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0027  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0028  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0029  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0030  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0031  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0032  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0033  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0034  * POSSIBILITY OF SUCH DAMAGE.
0035  */
0036 
0037 /*
0038  * This file is part of the RTEMS quality process and was automatically
0039  * generated.  If you find something that needs to be fixed or
0040  * worded better please post a report or patch to an RTEMS mailing list
0041  * or raise a bug report:
0042  *
0043  * https://www.rtems.org/bugs.html
0044  *
0045  * For information on updating and regenerating please refer to the How-To
0046  * section in the Software Requirements Engineering chapter of the
0047  * RTEMS Software Engineering manual.  The manual is provided as a part of
0048  * a release.  For development sources please refer to the online
0049  * documentation at:
0050  *
0051  * https://docs.rtems.org
0052  */
0053 
0054 /* Generated from spec:/rtems/fatal/if/header */
0055 
0056 #ifndef _RTEMS_FATAL_H
0057 #define _RTEMS_FATAL_H
0058 
0059 #include <stdint.h>
0060 #include <rtems/extension.h>
0061 #include <rtems/score/basedefs.h>
0062 #include <rtems/score/cpu.h>
0063 #include <rtems/score/interr.h>
0064 
0065 #ifdef __cplusplus
0066 extern "C" {
0067 #endif
0068 
0069 /* Generated from spec:/rtems/fatal/if/group */
0070 
0071 /**
0072  * @defgroup RTEMSAPIClassicFatal Fatal Error Manager
0073  *
0074  * @ingroup RTEMSAPIClassic
0075  *
0076  * @brief The Fatal Error Manager processes all fatal or irrecoverable errors
0077  *   and other sources of system termination (for example after exit()).  Fatal
0078  *   errors are identified by the fatal source and code pair.
0079  */
0080 
0081 /* Generated from spec:/rtems/fatal/if/assert-context */
0082 
0083 /**
0084  * @ingroup RTEMSAPIClassicFatal
0085  *
0086  * @brief This structure provides the context in which an assertion failed.
0087  */
0088 typedef struct {
0089   /**
0090    * @brief This member provides the file name of the source code file containing
0091    *   the failed assertion statement.
0092    */
0093   const char *file;
0094 
0095   /**
0096    * @brief This member provides the line number in the source code file
0097    *   containing the failed assertion statement.
0098    */
0099   int line;
0100 
0101   /**
0102    * @brief This member provides the function name containing the failed
0103    *   assertion statement.
0104    */
0105   const char *function;
0106 
0107   /**
0108    * @brief This member provides the expression of the failed assertion
0109    *   statement.
0110    */
0111   const char *failed_expression;
0112 } rtems_assert_context;
0113 
0114 /* Generated from spec:/rtems/fatal/if/exception-frame */
0115 
0116 /**
0117  * @ingroup RTEMSAPIClassicFatal
0118  *
0119  * @brief This structure represents an architecture-dependent exception frame.
0120  */
0121 typedef CPU_Exception_frame rtems_exception_frame;
0122 
0123 /* Generated from spec:/rtems/fatal/if/fatal */
0124 
0125 /**
0126  * @ingroup RTEMSAPIClassicFatal
0127  *
0128  * @brief Invokes the fatal error handler.
0129  *
0130  * @param fatal_source is the fatal source.
0131  *
0132  * @param fatal_code is the fatal code.
0133  *
0134  * This directive processes fatal errors.  The fatal source is set to the value
0135  * of the ``fatal_source`` parameter.  The fatal code is set to the value of
0136  * the ``fatal_code`` parameter.
0137  *
0138  * @par Constraints
0139  * @parblock
0140  * The following constraints apply to this directive:
0141  *
0142  * * The directive may be called from within any runtime context.
0143  *
0144  * * The directive will not return to the caller.
0145  *
0146  * * The directive invokes the fatal error extensions in extension forward
0147  *   order.
0148  *
0149  * * The directive does not invoke handlers registered by atexit() or
0150  *   on_exit().
0151  *
0152  * * The directive may terminate the system.
0153  * @endparblock
0154  */
0155 RTEMS_NO_RETURN static inline void rtems_fatal(
0156   rtems_fatal_source fatal_source,
0157   rtems_fatal_code   fatal_code
0158 )
0159 {
0160   _Terminate( fatal_source, fatal_code );
0161 }
0162 
0163 /* Generated from spec:/rtems/fatal/if/panic */
0164 
0165 /**
0166  * @ingroup RTEMSAPIClassicFatal
0167  *
0168  * @brief Prints the message and invokes the fatal error handler.
0169  *
0170  * @param fmt is the message format.
0171  *
0172  * @param ... is a list of optional parameters required by the message format.
0173  *
0174  * This directive prints a message via printk() specified by the ``fmt``
0175  * parameter and optional parameters and then invokes the fatal error handler.
0176  * The fatal source is set to RTEMS_FATAL_SOURCE_PANIC.  The fatal code is set
0177  * to the value of the ``fmt`` parameter value.
0178  *
0179  * @par Constraints
0180  * @parblock
0181  * The following constraints apply to this directive:
0182  *
0183  * * The directive may be called from within any runtime context.
0184  *
0185  * * The directive will not return to the caller.
0186  *
0187  * * The directive invokes the fatal error extensions in extension forward
0188  *   order.
0189  *
0190  * * The directive does not invoke handlers registered by atexit() or
0191  *   on_exit().
0192  *
0193  * * The directive may terminate the system.
0194  * @endparblock
0195  */
0196 RTEMS_NO_RETURN RTEMS_PRINTFLIKE( 1, 2 ) void rtems_panic(
0197   const char *fmt,
0198   ...
0199 );
0200 
0201 /* Generated from spec:/rtems/fatal/if/exception-frame-print */
0202 
0203 /**
0204  * @ingroup RTEMSAPIClassicFatal
0205  *
0206  * @brief Prints the exception frame.
0207  *
0208  * @param frame is the reference to the exception frame to print.
0209  *
0210  * The exception frame is printed in an architecture-dependent format using
0211  * printk().
0212  */
0213 static inline void rtems_exception_frame_print(
0214   const rtems_exception_frame *frame
0215 )
0216 {
0217   _CPU_Exception_frame_print( frame );
0218 }
0219 
0220 /* Generated from spec:/rtems/fatal/if/source-text */
0221 
0222 /**
0223  * @ingroup RTEMSAPIClassicFatal
0224  *
0225  * @brief Returns a descriptive text for the fatal source.
0226  *
0227  * @param fatal_source is the fatal source.
0228  *
0229  * @retval "?" The ``fatal_source`` parameter value was not a fatal source.
0230  *
0231  * @return Returns a descriptive text for the fatal source.  The text for the
0232  *   fatal source is the enumerator constant name.
0233  *
0234  * @par Constraints
0235  * @parblock
0236  * The following constraints apply to this directive:
0237  *
0238  * * The directive may be called from within any runtime context.
0239  * @endparblock
0240  */
0241 const char *rtems_fatal_source_text( rtems_fatal_source fatal_source );
0242 
0243 /* Generated from spec:/rtems/fatal/if/internal-error-text */
0244 
0245 /**
0246  * @ingroup RTEMSAPIClassicFatal
0247  *
0248  * @brief Returns a descriptive text for the internal error code.
0249  *
0250  * @param internal_error_code is the internal error code.
0251  *
0252  * @retval "?" The ``internal_error_code`` parameter value was not an internal
0253  *   error code.
0254  *
0255  * @return Returns a descriptive text for the internal error code.  The text
0256  *   for the internal error code is the enumerator constant name.
0257  *
0258  * @par Constraints
0259  * @parblock
0260  * The following constraints apply to this directive:
0261  *
0262  * * The directive may be called from within any runtime context.
0263  * @endparblock
0264  */
0265 const char *rtems_internal_error_text( rtems_fatal_code internal_error_code );
0266 
0267 /* Generated from spec:/rtems/fatal/if/error-occurred */
0268 
0269 /**
0270  * @ingroup RTEMSAPIClassicFatal
0271  *
0272  * @brief Invokes the fatal error handler.
0273  *
0274  * @param fatal_code is the fatal code.
0275  *
0276  * This directive processes fatal errors.  The fatal source is set to
0277  * INTERNAL_ERROR_RTEMS_API.  The fatal code is set to the value of the
0278  * ``fatal_code`` parameter.
0279  *
0280  * @par Notes
0281  * This directive is deprecated and should not be used in new code.  It is
0282  * recommended to not use this directive since error locations cannot be
0283  * uniquely identified.  A recommended alternative directive is rtems_fatal().
0284  *
0285  * @par Constraints
0286  * @parblock
0287  * The following constraints apply to this directive:
0288  *
0289  * * The directive may be called from within any runtime context.
0290  *
0291  * * The directive will not return to the caller.
0292  *
0293  * * The directive invokes the fatal error extensions in extension forward
0294  *   order.
0295  *
0296  * * The directive does not invoke handlers registered by atexit() or
0297  *   on_exit().
0298  *
0299  * * The directive may terminate the system.
0300  * @endparblock
0301  */
0302 RTEMS_NO_RETURN void rtems_fatal_error_occurred( uint32_t fatal_code );
0303 
0304 #ifdef __cplusplus
0305 }
0306 #endif
0307 
0308 #endif /* _RTEMS_FATAL_H */