* rtems/src/taskmode.c, sapi/src/exshutdown.c,
	score/include/rtems/score/sysstate.h,
	score/inline/rtems/score/sysstate.inl: Added
	_System_state_Is_shutdown().  Removed direct uses of
	_System_state_Current.  Documentation.
This commit is contained in:
Joel Sherrill
2009-09-04 13:09:48 +00:00
parent 4c7eb6570e
commit 56e171066d
5 changed files with 69 additions and 87 deletions

View File

@@ -1,3 +1,11 @@
2009-09-04 Sebastian Huber <Sebastian.Huber@embedded-brains.de>
* rtems/src/taskmode.c, sapi/src/exshutdown.c,
score/include/rtems/score/sysstate.h,
score/inline/rtems/score/sysstate.inl: Added
_System_state_Is_shutdown(). Removed direct uses of
_System_state_Current. Documentation.
2009-08-28 Joel Sherrill <joel.sherrill@OARcorp.com>
* libcsupport/src/malloc_initialize.c, sapi/src/exinit.c,

View File

@@ -122,7 +122,7 @@ rtems_status_code rtems_task_mode(
}
}
if ( _System_state_Is_up(_System_state_Current) )
if ( _System_state_Is_up( _System_state_Get() ) )
if ( _Thread_Evaluate_mode() || needs_asr_dispatching )
_Thread_Dispatch();

View File

@@ -35,7 +35,7 @@ void rtems_shutdown_executive(
uint32_t result
)
{
if ( _System_state_Current != SYSTEM_STATE_SHUTDOWN ) {
if ( !_System_state_Is_shutdown( _System_state_Get() ) ) {
_System_state_Set( SYSTEM_STATE_SHUTDOWN );
_Thread_Stop_multitasking();
}

View File

@@ -1,7 +1,9 @@
/**
* @file rtems/score/sysstate.h
* @file
*
* This include file contains information regarding the system state.
* @ingroup ScoreSysState
*
* @brief System State Handler API.
*/
/*
@@ -18,63 +20,64 @@
#ifndef _RTEMS_SCORE_SYSSTATE_H
#define _RTEMS_SCORE_SYSSTATE_H
/**
* @defgroup ScoreSysState System State Handler
*
* This handler encapsulates functionality related to the management of the
* internal system state of RTEMS.
*/
/**@{*/
#ifdef __cplusplus
extern "C" {
#endif
/* types */
/* enumerated constants */
/**
* @defgroup ScoreSysState System State Handler
*
* @ingroup Score
*
* @brief Management of the internal system state of RTEMS.
*
* @{
*/
/**
* The following type defines the possible system states.
* @brief System states.
*/
typedef enum {
/** This indicates that the system state is between the start
* of rtems_initialize_executive_early and the end of the first
* phase of initialization.
/**
* @brief The system is before the end of the first phase of initialization.
*/
SYSTEM_STATE_BEFORE_INITIALIZATION,
/** This indicates that the system state is between end of the first
* phase of initializatin but before multitasking is started.
/**
* @brief The system is between end of the first phase of initializatin but
* before multitasking is started.
*/
SYSTEM_STATE_BEFORE_MULTITASKING,
/** This indicates that the system state is attempting to initiate
* multitasking.
/**
* @brief The system is attempting to initiate multitasking.
*/
SYSTEM_STATE_BEGIN_MULTITASKING,
/** This indicates that the system is up and operating normally. */
/**
* @brief The system is up and operating normally.
*/
SYSTEM_STATE_UP,
/** This indicates that the system is in the midst of a shutdown. */
/**
* @brief The system is in the midst of a shutdown.
*/
SYSTEM_STATE_SHUTDOWN,
/** This indicates that a fatal error has occurred. */
/**
* @brief A fatal error has occurred.
*/
SYSTEM_STATE_FAILED
} System_state_Codes;
/** This defines the first system state. */
#define SYSTEM_STATE_CODES_FIRST SYSTEM_STATE_BEFORE_INITIALIZATION
/** This defines the highest value system state. */
#define SYSTEM_STATE_CODES_LAST SYSTEM_STATE_FAILED
#define SYSTEM_STATE_CODES_LAST SYSTEM_STATE_FAILED
#if defined(RTEMS_MULTIPROCESSING)
/**
* The following variable indicates whether or not this is
* an multiprocessing system.
*/
SCORE_EXTERN bool _System_state_Is_multiprocessing;
#endif
/**
* The following variable contains the current system state.
*/
SCORE_EXTERN System_state_Codes _System_state_Current;
/*
@@ -83,11 +86,11 @@ SCORE_EXTERN System_state_Codes _System_state_Current;
#include <rtems/score/sysstate.inl>
/** @} */
#ifdef __cplusplus
}
#endif
/**@}*/
#endif
/* end of include file */

View File

@@ -1,8 +1,9 @@
/**
* @file rtems/score/sysstate.inl
* @file
*
* This file contains the inline implementation of routines regarding the
* system state.
* @ingroup ScoreSysState
*
* @brief System State Handler API.
*/
/*
@@ -24,31 +25,9 @@
#define _RTEMS_SCORE_SYSSTATE_INL
/**
* @addtogroup ScoreSysState
* @{
*/
/**
* This routine initializes the system state handler.
*/
RTEMS_INLINE_ROUTINE void _System_state_Handler_initialization (
#if defined(RTEMS_MULTIPROCESSING)
bool is_multiprocessing
#else
bool is_multiprocessing __attribute__((unused))
#endif
)
{
_System_state_Current = SYSTEM_STATE_BEFORE_INITIALIZATION;
#if defined(RTEMS_MULTIPROCESSING)
_System_state_Is_multiprocessing = is_multiprocessing;
#endif
}
/**
* This routine sets the current system state to that specified by
* the called.
* @addtogroup ScoreSysState
*
* @{
*/
RTEMS_INLINE_ROUTINE void _System_state_Set (
@@ -58,20 +37,25 @@ RTEMS_INLINE_ROUTINE void _System_state_Set (
_System_state_Current = state;
}
/**
* This function returns the current system state.
*/
RTEMS_INLINE_ROUTINE void _System_state_Handler_initialization (
#if defined(RTEMS_MULTIPROCESSING)
bool is_multiprocessing
#else
bool is_multiprocessing __attribute__((unused))
#endif
)
{
_System_state_Set( SYSTEM_STATE_BEFORE_INITIALIZATION );
#if defined(RTEMS_MULTIPROCESSING)
_System_state_Is_multiprocessing = is_multiprocessing;
#endif
}
RTEMS_INLINE_ROUTINE System_state_Codes _System_state_Get ( void )
{
return _System_state_Current;
}
/**
* This function returns true if the state is equal to the
* "before initialization" state, and false otherwise.
*/
RTEMS_INLINE_ROUTINE bool _System_state_Is_before_initialization (
System_state_Codes state
)
@@ -79,11 +63,6 @@ RTEMS_INLINE_ROUTINE bool _System_state_Is_before_initialization (
return (state == SYSTEM_STATE_BEFORE_INITIALIZATION);
}
/**
* This function returns true if the state is equal to the
* "before multitasking" state, and false otherwise.
*/
RTEMS_INLINE_ROUTINE bool _System_state_Is_before_multitasking (
System_state_Codes state
)
@@ -91,11 +70,6 @@ RTEMS_INLINE_ROUTINE bool _System_state_Is_before_multitasking (
return (state == SYSTEM_STATE_BEFORE_MULTITASKING);
}
/**
* This function returns true if the state is equal to the
* "begin multitasking" state, and false otherwise.
*/
RTEMS_INLINE_ROUTINE bool _System_state_Is_begin_multitasking (
System_state_Codes state
)
@@ -103,10 +77,12 @@ RTEMS_INLINE_ROUTINE bool _System_state_Is_begin_multitasking (
return (state == SYSTEM_STATE_BEGIN_MULTITASKING);
}
/**
* This function returns true if the state is equal to the
* "up" state, and false otherwise.
*/
RTEMS_INLINE_ROUTINE bool _System_state_Is_shutdown (
System_state_Codes state
)
{
return (state == SYSTEM_STATE_SHUTDOWN);
}
RTEMS_INLINE_ROUTINE bool _System_state_Is_up (
System_state_Codes state
@@ -115,11 +91,6 @@ RTEMS_INLINE_ROUTINE bool _System_state_Is_up (
return (state == SYSTEM_STATE_UP);
}
/**
* This function returns true if the state is equal to the
* "failed" state, and false otherwise.
*/
RTEMS_INLINE_ROUTINE bool _System_state_Is_failed (
System_state_Codes state
)