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 RTEMSScoreSysState
0007  *
0008  * @brief This header file provides the interfaces of the
0009  *   @ref RTEMSScoreSysState.
0010  */
0011 
0012 /*
0013  *  COPYRIGHT (c) 1989-2011.
0014  *  On-Line Applications Research Corporation (OAR).
0015  *
0016  * Redistribution and use in source and binary forms, with or without
0017  * modification, are permitted provided that the following conditions
0018  * are met:
0019  * 1. Redistributions of source code must retain the above copyright
0020  *    notice, this list of conditions and the following disclaimer.
0021  * 2. Redistributions in binary form must reproduce the above copyright
0022  *    notice, this list of conditions and the following disclaimer in the
0023  *    documentation and/or other materials provided with the distribution.
0024  *
0025  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0026  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0027  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0028  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0029  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0030  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0031  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0032  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0033  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0034  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0035  * POSSIBILITY OF SUCH DAMAGE.
0036  */
0037 
0038 #ifndef _RTEMS_SCORE_SYSSTATE_H
0039 #define _RTEMS_SCORE_SYSSTATE_H
0040 
0041 #include <rtems/score/basedefs.h>
0042 
0043 #ifdef __cplusplus
0044 extern "C" {
0045 #endif
0046 
0047 /**
0048  * @defgroup RTEMSScoreSysState System State Handler
0049  *
0050  * @ingroup RTEMSScore
0051  *
0052  * @brief This group contains the System State Handler implementation.
0053  *
0054  * @{
0055  */
0056 
0057 /**
0058  * @brief System states.
0059  */
0060 typedef enum {
0061   /**
0062    * @brief The system is before the end of the first phase of initialization.
0063    */
0064   SYSTEM_STATE_BEFORE_INITIALIZATION,
0065 
0066   /**
0067    * @brief The system is between end of the first phase of initialization but
0068    * before  multitasking is started.
0069    */
0070   SYSTEM_STATE_BEFORE_MULTITASKING,
0071 
0072   /**
0073    * @brief The system is up and operating normally.
0074    */
0075   SYSTEM_STATE_UP,
0076 
0077   /**
0078    * @brief The system reached its terminal state.
0079    */
0080   SYSTEM_STATE_TERMINATED
0081 } System_state_Codes;
0082 
0083 #define SYSTEM_STATE_CODES_FIRST SYSTEM_STATE_BEFORE_INITIALIZATION
0084 
0085 #define SYSTEM_STATE_CODES_LAST SYSTEM_STATE_TERMINATED
0086 
0087 #if defined(RTEMS_MULTIPROCESSING)
0088 extern bool _System_state_Is_multiprocessing;
0089 #endif
0090 
0091 extern System_state_Codes _System_state_Current;
0092 
0093 /**
0094  * @brief Sets the current system state to the given state.
0095  *
0096  * @param state The state to set.
0097  */
0098 static inline void _System_state_Set (
0099   System_state_Codes state
0100 )
0101 {
0102   _System_state_Current = state;
0103 }
0104 
0105 /**
0106  * @brief Gets the current system state.
0107  *
0108  * @return The current system state.
0109  */
0110 static inline System_state_Codes _System_state_Get ( void )
0111 {
0112   return _System_state_Current;
0113 }
0114 
0115 /**
0116  * @brief Checks if the state is before initialization.
0117  *
0118  * @param state The state to check.
0119  *
0120  * @retval true @a state is before initialization.
0121  * @retval false @a state is not before initialization.
0122  */
0123 static inline bool _System_state_Is_before_initialization (
0124   System_state_Codes state
0125 )
0126 {
0127   return (state == SYSTEM_STATE_BEFORE_INITIALIZATION);
0128 }
0129 
0130 /**
0131  * @brief Checks if the state is before multitasking.
0132  *
0133  * @param state The state to check.
0134  *
0135  * @retval true @a state is before multitasking.
0136  * @retval false @a state is not before multitasking.
0137  */
0138 static inline bool _System_state_Is_before_multitasking (
0139   System_state_Codes state
0140 )
0141 {
0142   return (state == SYSTEM_STATE_BEFORE_MULTITASKING);
0143 }
0144 
0145 /**
0146  * @brief Checks if the state is up.
0147  *
0148  * @param state The state to check.
0149  *
0150  * @retval true @a state is up.
0151  * @retval false @a state is not up.
0152  */
0153 static inline bool _System_state_Is_up (
0154   System_state_Codes state
0155 )
0156 {
0157   return (state == SYSTEM_STATE_UP);
0158 }
0159 
0160 /**
0161  * @brief Checks if the state is terminated.
0162  *
0163  * @param state The state to check.
0164  *
0165  * @retval true @a state is terminated.
0166  * @retval false @a state is not terminated.
0167  */
0168 static inline bool _System_state_Is_terminated (
0169   System_state_Codes state
0170 )
0171 {
0172   return (state == SYSTEM_STATE_TERMINATED);
0173 }
0174 
0175 /** @} */
0176 
0177 #ifdef __cplusplus
0178 }
0179 #endif
0180 
0181 #endif
0182 /* end of include file */