summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/score')
-rw-r--r--cpukit/score/Makefile.am1
-rw-r--r--cpukit/score/include/rtems/score/corebarrierimpl.h42
-rw-r--r--cpukit/score/include/rtems/score/coremsgimpl.h45
-rw-r--r--cpukit/score/include/rtems/score/coremuteximpl.h146
-rw-r--r--cpukit/score/include/rtems/score/corerwlockimpl.h32
-rw-r--r--cpukit/score/include/rtems/score/coresemimpl.h69
-rw-r--r--cpukit/score/include/rtems/score/corespinlockimpl.h36
-rw-r--r--cpukit/score/include/rtems/score/mpciimpl.h11
-rw-r--r--cpukit/score/include/rtems/score/mrsp.h31
-rw-r--r--cpukit/score/include/rtems/score/mrspimpl.h49
-rw-r--r--cpukit/score/include/rtems/score/status.h129
-rw-r--r--cpukit/score/include/rtems/score/thread.h5
-rw-r--r--cpukit/score/include/rtems/score/threadimpl.h22
-rw-r--r--cpukit/score/include/rtems/score/threadqimpl.h40
-rw-r--r--cpukit/score/preinstall.am4
-rw-r--r--cpukit/score/src/condition.c6
-rw-r--r--cpukit/score/src/corebarrier.c11
-rw-r--r--cpukit/score/src/corebarrierwait.c9
-rw-r--r--cpukit/score/src/coremsgbroadcast.c6
-rw-r--r--cpukit/score/src/coremsgclose.c2
-rw-r--r--cpukit/score/src/coremsgseize.c16
-rw-r--r--cpukit/score/src/coremsgsubmit.c19
-rw-r--r--cpukit/score/src/coremutex.c28
-rw-r--r--cpukit/score/src/coremutexseize.c5
-rw-r--r--cpukit/score/src/coremutexsurrender.c14
-rw-r--r--cpukit/score/src/corerwlockobtainread.c17
-rw-r--r--cpukit/score/src/corerwlockobtainwrite.c14
-rw-r--r--cpukit/score/src/corerwlockrelease.c8
-rw-r--r--cpukit/score/src/coresem.c22
-rw-r--r--cpukit/score/src/corespinlockrelease.c6
-rw-r--r--cpukit/score/src/corespinlockwait.c10
-rw-r--r--cpukit/score/src/futex.c3
-rw-r--r--cpukit/score/src/mpci.c14
-rw-r--r--cpukit/score/src/mutex.c7
-rw-r--r--cpukit/score/src/semaphore.c3
-rw-r--r--cpukit/score/src/threadmp.c1
-rw-r--r--cpukit/score/src/threadqenqueue.c4
-rw-r--r--cpukit/score/src/threadqflush.c27
-rw-r--r--cpukit/score/src/threadrestart.c10
-rw-r--r--cpukit/score/src/threadtimeout.c3
40 files changed, 395 insertions, 532 deletions
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index a3f3dfc92d..b178e8e328 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -87,6 +87,7 @@ include_rtems_score_HEADERS += include/rtems/score/stack.h
include_rtems_score_HEADERS += include/rtems/score/stackimpl.h
include_rtems_score_HEADERS += include/rtems/score/states.h
include_rtems_score_HEADERS += include/rtems/score/statesimpl.h
+include_rtems_score_HEADERS += include/rtems/score/status.h
include_rtems_score_HEADERS += include/rtems/score/sysstate.h
include_rtems_score_HEADERS += include/rtems/score/thread.h
include_rtems_score_HEADERS += include/rtems/score/threadimpl.h
diff --git a/cpukit/score/include/rtems/score/corebarrierimpl.h b/cpukit/score/include/rtems/score/corebarrierimpl.h
index 051990e818..d2d9997d95 100644
--- a/cpukit/score/include/rtems/score/corebarrierimpl.h
+++ b/cpukit/score/include/rtems/score/corebarrierimpl.h
@@ -20,6 +20,7 @@
#define _RTEMS_SCORE_COREBARRIERIMPL_H
#include <rtems/score/corebarrier.h>
+#include <rtems/score/status.h>
#include <rtems/score/threadqimpl.h>
#ifdef __cplusplus
@@ -31,35 +32,6 @@ extern "C" {
*/
/**@{**/
-/**
- * Core Barrier handler return statuses.
- */
-typedef enum {
- /** This status indicates that the operation completed successfully. */
- CORE_BARRIER_STATUS_SUCCESSFUL,
- /** This status indicates that the barrier is configured for automatic
- * release and the caller tripped the automatic release. The caller
- * thus did not block.
- */
- CORE_BARRIER_STATUS_AUTOMATICALLY_RELEASED,
- /** This status indicates that the thread was blocked waiting for an
- * operation to complete and the barrier was deleted.
- */
- CORE_BARRIER_WAS_DELETED,
- /** This status indicates that the calling task was willing to block
- * but the operation was unable to complete within the time allotted
- * because the resource never became available.
- */
- CORE_BARRIER_TIMEOUT
-} CORE_barrier_Status;
-
-/**
- * @brief Core barrier last status value.
- *
- * This is the last status value.
- */
-#define CORE_BARRIER_STATUS_LAST CORE_BARRIER_TIMEOUT
-
#define CORE_BARRIER_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
/**
@@ -120,9 +92,9 @@ RTEMS_INLINE_ROUTINE void _CORE_barrier_Release(
* @param[in] mp_callout is the routine to invoke if the
* thread unblocked is remote
*
- * @note Status is returned via the thread control block.
+ * @return The method status.
*/
-void _CORE_barrier_Seize(
+Status_Control _CORE_barrier_Seize(
CORE_barrier_Control *the_barrier,
Thread_Control *executing,
bool wait,
@@ -160,12 +132,6 @@ RTEMS_INLINE_ROUTINE uint32_t _CORE_barrier_Surrender(
);
}
-Thread_Control *_CORE_barrier_Was_deleted(
- Thread_Control *the_thread,
- Thread_queue_Queue *queue,
- Thread_queue_Context *queue_context
-);
-
RTEMS_INLINE_ROUTINE void _CORE_barrier_Flush(
CORE_barrier_Control *the_barrier,
Thread_queue_Context *queue_context
@@ -173,7 +139,7 @@ RTEMS_INLINE_ROUTINE void _CORE_barrier_Flush(
{
_CORE_barrier_Do_flush(
the_barrier,
- _CORE_barrier_Was_deleted,
+ _Thread_queue_Flush_status_object_was_deleted,
queue_context
);
}
diff --git a/cpukit/score/include/rtems/score/coremsgimpl.h b/cpukit/score/include/rtems/score/coremsgimpl.h
index 30abe0470e..d240c4a405 100644
--- a/cpukit/score/include/rtems/score/coremsgimpl.h
+++ b/cpukit/score/include/rtems/score/coremsgimpl.h
@@ -20,6 +20,7 @@
#define _RTEMS_SCORE_COREMSGIMPL_H
#include <rtems/score/coremsg.h>
+#include <rtems/score/status.h>
#include <rtems/score/chainimpl.h>
#include <rtems/score/threaddispatch.h>
#include <rtems/score/threadqimpl.h>
@@ -65,40 +66,6 @@ extern "C" {
typedef int CORE_message_queue_Submit_types;
/**
- * @brief The possible set of Core Message Queue handler return statuses.
- *
- * This enumerated type defines the possible set of Core Message
- * Queue handler return statuses.
- */
-typedef enum {
- /** This value indicates the operation completed sucessfully. */
- CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL,
- /** This value indicates that the message was too large for this queue. */
- CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE,
- /** This value indicates that there are too many messages pending. */
- CORE_MESSAGE_QUEUE_STATUS_TOO_MANY,
- /** This value indicates that a receive was unsuccessful. */
- CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED,
- /** This value indicates that a blocking send was unsuccessful. */
- CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT,
- /** This value indicates that the message queue being blocked upon
- * was deleted while the thread was waiting.
- */
- CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED,
- /** This value indicates that the thread had to timeout while waiting
- * to receive a message because one did not become available.
- */
- CORE_MESSAGE_QUEUE_STATUS_TIMEOUT,
-} CORE_message_queue_Status;
-
-/**
- * @brief Core message queue last status value.
- *
- * This is the last status value.
- */
-#define CORE_MESSAGE_QUEUE_STATUS_LAST CORE_MESSAGE_QUEUE_STATUS_TIMEOUT
-
-/**
* @brief Initialize a message queue.
*
* This package is the implementation of the CORE Message Queue Handler.
@@ -202,7 +169,7 @@ uint32_t _CORE_message_queue_Flush(
* @retval @a *count will contain the number of messages sent
* @retval indication of the successful completion or reason for failure
*/
-CORE_message_queue_Status _CORE_message_queue_Broadcast(
+Status_Control _CORE_message_queue_Broadcast(
CORE_message_queue_Control *the_message_queue,
const void *buffer,
size_t size,
@@ -233,7 +200,7 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast(
* _CORE_message_queue_Acquire() or _CORE_message_queue_Acquire_critical().
* @retval indication of the successful completion or reason for failure
*/
-CORE_message_queue_Status _CORE_message_queue_Submit(
+Status_Control _CORE_message_queue_Submit(
CORE_message_queue_Control *the_message_queue,
Thread_Control *executing,
const void *buffer,
@@ -278,7 +245,7 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
* + available
* + wait
*/
-void _CORE_message_queue_Seize(
+Status_Control _CORE_message_queue_Seize(
CORE_message_queue_Control *the_message_queue,
Thread_Control *executing,
void *buffer,
@@ -309,7 +276,7 @@ void _CORE_message_queue_Insert_message(
CORE_message_queue_Submit_types submit_type
);
-RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Send(
+RTEMS_INLINE_ROUTINE Status_Control _CORE_message_queue_Send(
CORE_message_queue_Control *the_message_queue,
const void *buffer,
size_t size,
@@ -330,7 +297,7 @@ RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Send(
);
}
-RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Urgent(
+RTEMS_INLINE_ROUTINE Status_Control _CORE_message_queue_Urgent(
CORE_message_queue_Control *the_message_queue,
const void *buffer,
size_t size,
diff --git a/cpukit/score/include/rtems/score/coremuteximpl.h b/cpukit/score/include/rtems/score/coremuteximpl.h
index a32022aa23..f5faf9517a 100644
--- a/cpukit/score/include/rtems/score/coremuteximpl.h
+++ b/cpukit/score/include/rtems/score/coremuteximpl.h
@@ -20,6 +20,7 @@
#include <rtems/score/coremutex.h>
#include <rtems/score/chainimpl.h>
+#include <rtems/score/status.h>
#include <rtems/score/sysstate.h>
#include <rtems/score/threadimpl.h>
#include <rtems/score/threadqimpl.h>
@@ -34,53 +35,6 @@ extern "C" {
/**@{**/
/**
- * @brief The possible Mutex handler return statuses.
- *
- * This enumerated type defines the possible Mutex handler return statuses.
- */
-typedef enum {
- /** This status indicates that the operation completed successfully. */
- CORE_MUTEX_STATUS_SUCCESSFUL,
- /** This status indicates that the calling task did not want to block
- * and the operation was unable to complete immediately because the
- * resource was unavailable.
- */
- CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT,
-#if defined(RTEMS_POSIX_API)
- /** This status indicates that an attempt was made to relock a mutex
- * for which nesting is not configured.
- */
- CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED,
-#endif
- /** This status indicates that an attempt was made to release a mutex
- * by a thread other than the thread which locked it.
- */
- CORE_MUTEX_STATUS_NOT_OWNER_OF_RESOURCE,
- /** This status indicates that the thread was blocked waiting for an
- * operation to complete and the mutex was deleted.
- */
- CORE_MUTEX_WAS_DELETED,
- /** This status indicates that the calling task was willing to block
- * but the operation was unable to complete within the time allotted
- * because the resource never became available.
- */
- CORE_MUTEX_TIMEOUT,
-
- /** This status indicates that a thread of logically greater importance
- * than the ceiling priority attempted to lock this mutex.
- */
- CORE_MUTEX_STATUS_CEILING_VIOLATED
-
-} CORE_mutex_Status;
-
-/**
- * @brief The last status value.
- *
- * This is the last status value.
- */
-#define CORE_MUTEX_STATUS_LAST CORE_MUTEX_STATUS_CEILING_VIOLATED
-
-/**
* @brief Initializes the mutex based on the parameters passed.
*
* This routine initializes the mutex based on the parameters passed.
@@ -92,9 +46,9 @@ typedef enum {
* @param[in] initially_locked If true, then the mutex is initially locked by
* the executing thread.
*
- * @retval This method returns CORE_MUTEX_STATUS_SUCCESSFUL if successful.
+ * @retval This method returns STATUS_SUCCESSFUL if successful.
*/
-CORE_mutex_Status _CORE_mutex_Initialize(
+Status_Control _CORE_mutex_Initialize(
CORE_mutex_Control *the_mutex,
Thread_Control *executing,
const CORE_mutex_Attributes *the_mutex_attributes,
@@ -140,7 +94,7 @@ RTEMS_INLINE_ROUTINE void _CORE_mutex_Release(
* @param[in] timeout is the maximum number of ticks to block
* @param[in] lock_context is the interrupt level
*/
-void _CORE_mutex_Seize_interrupt_blocking(
+Status_Control _CORE_mutex_Seize_interrupt_blocking(
CORE_mutex_Control *the_mutex,
Thread_Control *executing,
Watchdog_Interval timeout,
@@ -227,12 +181,10 @@ RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_priority_ceiling(
* @param[in,out] the_mutex is the mutex to attempt to lock
* @param[in] queue_context is the interrupt level
*
- * @retval This routine returns 0 if "trylock" can resolve whether or not
- * the mutex is immediately obtained or there was an error attempting to
- * get it. It returns 1 to indicate that the caller cannot obtain
- * the mutex and will have to block to do so.
+ * @retval STATUS_UNAVAILABLE The mutex is already locked.
+ * @retval other Otherwise.
*/
-RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock(
+RTEMS_INLINE_ROUTINE Status_Control _CORE_mutex_Seize_interrupt_trylock(
CORE_mutex_Control *the_mutex,
Thread_Control *executing,
Thread_queue_Context *queue_context
@@ -240,7 +192,6 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock(
{
/* disabled when you get here */
- executing->Wait.return_code = CORE_MUTEX_STATUS_SUCCESSFUL;
if ( !_CORE_mutex_Is_locked( the_mutex ) ) {
the_mutex->holder = executing;
the_mutex->nest_count = 1;
@@ -251,13 +202,13 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock(
if ( !_CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) {
_CORE_mutex_Release( the_mutex, queue_context );
- return 0;
- } /* else must be CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING
+ } else {
+ /*
+ * must be CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING
*
* we possibly bump the priority of the current holder -- which
* happens to be _Thread_Executing.
*/
- {
Priority_Control ceiling;
Priority_Control current;
@@ -265,10 +216,7 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock(
current = executing->current_priority;
if ( current == ceiling ) {
_CORE_mutex_Release( the_mutex, queue_context );
- return 0;
- }
-
- if ( current > ceiling ) {
+ } else if ( current > ceiling ) {
Per_CPU_Control *cpu_self;
cpu_self = _Thread_Dispatch_disable_critical(
@@ -277,18 +225,16 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock(
_CORE_mutex_Release( the_mutex, queue_context );
_Thread_Raise_priority( executing, ceiling );
_Thread_Dispatch_enable( cpu_self );
- return 0;
- }
- /* if ( current < ceiling ) */ {
- executing->Wait.return_code = CORE_MUTEX_STATUS_CEILING_VIOLATED;
+ } else /* if ( current < ceiling ) */ {
the_mutex->holder = NULL;
the_mutex->nest_count = 0; /* undo locking above */
executing->resource_count--; /* undo locking above */
_CORE_mutex_Release( the_mutex, queue_context );
- return 0;
+ return STATUS_MUTEX_CEILING_VIOLATED;
}
}
- return 0;
+
+ return STATUS_SUCCESSFUL;
}
/*
@@ -301,12 +247,11 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock(
case CORE_MUTEX_NESTING_ACQUIRES:
the_mutex->nest_count++;
_CORE_mutex_Release( the_mutex, queue_context );
- return 0;
+ return STATUS_SUCCESSFUL;
#if defined(RTEMS_POSIX_API)
case CORE_MUTEX_NESTING_IS_ERROR:
- executing->Wait.return_code = CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED;
_CORE_mutex_Release( the_mutex, queue_context );
- return 0;
+ return STATUS_NESTING_NOT_ALLOWED;
#endif
case CORE_MUTEX_NESTING_BLOCKS:
break;
@@ -317,7 +262,7 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock(
* The mutex is not available and the caller must deal with the possibility
* of blocking.
*/
- return 1;
+ return STATUS_UNAVAILABLE;
}
/**
@@ -346,7 +291,7 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock(
* * If the caller is willing to wait
* then they are blocked.
*/
-RTEMS_INLINE_ROUTINE void _CORE_mutex_Seize(
+RTEMS_INLINE_ROUTINE Status_Control _CORE_mutex_Seize(
CORE_mutex_Control *the_mutex,
Thread_Control *executing,
bool wait,
@@ -354,6 +299,8 @@ RTEMS_INLINE_ROUTINE void _CORE_mutex_Seize(
Thread_queue_Context *queue_context
)
{
+ Status_Control status;
+
if ( _CORE_mutex_Check_dispatch_for_seize( wait ) ) {
_Terminate(
INTERNAL_ERROR_CORE,
@@ -361,39 +308,34 @@ RTEMS_INLINE_ROUTINE void _CORE_mutex_Seize(
INTERNAL_ERROR_MUTEX_OBTAIN_FROM_BAD_STATE
);
}
+
_CORE_mutex_Acquire_critical( the_mutex, queue_context );
- if (
- _CORE_mutex_Seize_interrupt_trylock( the_mutex, executing, queue_context )
- ) {
- if ( !wait ) {
- _CORE_mutex_Release( the_mutex, queue_context );
- executing->Wait.return_code =
- CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT;
- } else {
- _CORE_mutex_Seize_interrupt_blocking(
- the_mutex,
- executing,
- timeout,
- &queue_context->Lock_context
- );
- }
+
+ status = _CORE_mutex_Seize_interrupt_trylock(
+ the_mutex,
+ executing,
+ queue_context
+ );
+
+ if ( status != STATUS_UNAVAILABLE ) {
+ return status;
}
-}
-CORE_mutex_Status _CORE_mutex_Surrender(
- CORE_mutex_Control *the_mutex,
- Thread_queue_Context *queue_context
-);
+ if ( !wait ) {
+ _CORE_mutex_Release( the_mutex, queue_context );
+ return status;
+ }
-Thread_Control *_CORE_mutex_Was_deleted(
- Thread_Control *the_thread,
- Thread_queue_Queue *queue,
- Thread_queue_Context *queue_context
-);
+ return _CORE_mutex_Seize_interrupt_blocking(
+ the_mutex,
+ executing,
+ timeout,
+ &queue_context->Lock_context
+ );
+}
-Thread_Control *_CORE_mutex_Unsatisfied_nowait(
- Thread_Control *the_thread,
- Thread_queue_Queue *queue,
+Status_Control _CORE_mutex_Surrender(
+ CORE_mutex_Control *the_mutex,
Thread_queue_Context *queue_context
);
diff --git a/cpukit/score/include/rtems/score/corerwlockimpl.h b/cpukit/score/include/rtems/score/corerwlockimpl.h
index 67084c136a..e80ab0ef0c 100644
--- a/cpukit/score/include/rtems/score/corerwlockimpl.h
+++ b/cpukit/score/include/rtems/score/corerwlockimpl.h
@@ -22,6 +22,7 @@
#include <rtems/score/corerwlock.h>
#include <rtems/score/thread.h>
#include <rtems/score/threadqimpl.h>
+#include <rtems/score/status.h>
#include <rtems/score/watchdog.h>
#ifdef __cplusplus
@@ -36,27 +37,6 @@ extern "C" {
#define CORE_RWLOCK_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
/**
- * Core RWLock handler return statuses.
- */
-typedef enum {
- /** This status indicates that the operation completed successfully. */
- CORE_RWLOCK_SUCCESSFUL,
- /** This status indicates that the thread was blocked waiting for an */
- CORE_RWLOCK_WAS_DELETED,
- /** This status indicates that the rwlock was not immediately available. */
- CORE_RWLOCK_UNAVAILABLE,
- /** This status indicates that the calling task was willing to block
- * but the operation was unable to complete within the time allotted
- * because the resource never became available.
- */
- CORE_RWLOCK_TIMEOUT
-} CORE_RWLock_Status;
-
-/** This is the last status value.
- */
-#define CORE_RWLOCK_STATUS_LAST CORE_RWLOCK_TIMEOUT
-
-/**
* This is used to denote that a thread is blocking waiting for
* read-only access to the RWLock.
*/
@@ -117,11 +97,9 @@ RTEMS_INLINE_ROUTINE void _CORE_RWLock_Release(
* @param[in] wait is true if the calling thread is willing to wait
* @param[in] timeout is the number of ticks the calling thread is willing
* to wait if @a wait is true.
- *
- * @note Status is returned via the thread control block.
*/
-void _CORE_RWLock_Seize_for_reading(
+Status_Control _CORE_RWLock_Seize_for_reading(
CORE_RWLock_Control *the_rwlock,
Thread_Control *executing,
bool wait,
@@ -138,10 +116,8 @@ void _CORE_RWLock_Seize_for_reading(
* @param[in] wait is true if the calling thread is willing to wait
* @param[in] timeout is the number of ticks the calling thread is willing
* to wait if @a wait is true.
- *
- * @note Status is returned via the thread control block.
*/
-void _CORE_RWLock_Seize_for_writing(
+Status_Control _CORE_RWLock_Seize_for_writing(
CORE_RWLock_Control *the_rwlock,
Thread_Control *executing,
bool wait,
@@ -159,7 +135,7 @@ void _CORE_RWLock_Seize_for_writing(
*
* @retval Status is returned to indicate successful or failure.
*/
-CORE_RWLock_Status _CORE_RWLock_Surrender(
+Status_Control _CORE_RWLock_Surrender(
CORE_RWLock_Control *the_rwlock,
Thread_queue_Context *queue_context
);
diff --git a/cpukit/score/include/rtems/score/coresemimpl.h b/cpukit/score/include/rtems/score/coresemimpl.h
index 5dad11bc46..ac90f20b7d 100644
--- a/cpukit/score/include/rtems/score/coresemimpl.h
+++ b/cpukit/score/include/rtems/score/coresemimpl.h
@@ -22,8 +22,10 @@
#include <rtems/score/coresem.h>
#include <rtems/score/objectimpl.h>
#include <rtems/score/threaddispatch.h>
+#include <rtems/score/threadimpl.h>
#include <rtems/score/threadqimpl.h>
#include <rtems/score/statesimpl.h>
+#include <rtems/score/status.h>
#ifdef __cplusplus
extern "C" {
@@ -35,39 +37,6 @@ extern "C" {
/**@{**/
/**
- * Core Semaphore handler return statuses.
- */
-typedef enum {
- /** This status indicates that the operation completed successfully. */
- CORE_SEMAPHORE_STATUS_SUCCESSFUL,
- /** This status indicates that the calling task did not want to block
- * and the operation was unable to complete immediately because the
- * resource was unavailable.
- */
- CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT,
- /** This status indicates that the thread was blocked waiting for an
- * operation to complete and the semaphore was deleted.
- */
- CORE_SEMAPHORE_WAS_DELETED,
- /** This status indicates that the calling task was willing to block
- * but the operation was unable to complete within the time allotted
- * because the resource never became available.
- */
- CORE_SEMAPHORE_TIMEOUT,
- /** This status indicates that an attempt was made to unlock the semaphore
- * and this would have made its count greater than that allowed.
- */
- CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED
-} CORE_semaphore_Status;
-
-/**
- * @brief Core semaphore last status value.
- *
- * This is the last status value.
- */
-#define CORE_SEMAPHORE_STATUS_LAST CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED
-
-/**
* @brief Initialize the semaphore based on the parameters passed.
*
* This package is the implementation of the CORE Semaphore Handler.
@@ -108,18 +77,6 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Release(
);
}
-Thread_Control *_CORE_semaphore_Was_deleted(
- Thread_Control *the_thread,
- Thread_queue_Queue *queue,
- Thread_queue_Context *queue_context
-);
-
-Thread_Control *_CORE_semaphore_Unsatisfied_nowait(
- Thread_Control *the_thread,
- Thread_queue_Queue *queue,
- Thread_queue_Context *queue_context
-);
-
RTEMS_INLINE_ROUTINE void _CORE_semaphore_Destroy(
CORE_semaphore_Control *the_semaphore,
Thread_queue_Context *queue_context
@@ -128,7 +85,7 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Destroy(
_Thread_queue_Flush_critical(
&the_semaphore->Wait_queue.Queue,
the_semaphore->operations,
- _CORE_semaphore_Was_deleted,
+ _Thread_queue_Flush_status_object_was_deleted,
queue_context
);
_Thread_queue_Destroy( &the_semaphore->Wait_queue );
@@ -147,16 +104,16 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Destroy(
*
* @retval an indication of whether the routine succeeded or failed
*/
-RTEMS_INLINE_ROUTINE CORE_semaphore_Status _CORE_semaphore_Surrender(
+RTEMS_INLINE_ROUTINE Status_Control _CORE_semaphore_Surrender(
CORE_semaphore_Control *the_semaphore,
uint32_t maximum_count,
Thread_queue_Context *queue_context
)
{
Thread_Control *the_thread;
- CORE_semaphore_Status status;
+ Status_Control status;
- status = CORE_SEMAPHORE_STATUS_SUCCESSFUL;
+ status = STATUS_SUCCESSFUL;
_CORE_semaphore_Acquire_critical( the_semaphore, queue_context );
@@ -175,7 +132,7 @@ RTEMS_INLINE_ROUTINE CORE_semaphore_Status _CORE_semaphore_Surrender(
if ( the_semaphore->count < maximum_count )
the_semaphore->count += 1;
else
- status = CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED;
+ status = STATUS_MAXIMUM_COUNT_EXCEEDED;
_CORE_semaphore_Release( the_semaphore, queue_context );
}
@@ -191,7 +148,7 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Flush(
_Thread_queue_Flush_critical(
&the_semaphore->Wait_queue.Queue,
the_semaphore->operations,
- _CORE_semaphore_Unsatisfied_nowait,
+ _Thread_queue_Flush_status_unavailable,
queue_context
);
}
@@ -225,7 +182,7 @@ RTEMS_INLINE_ROUTINE uint32_t _CORE_semaphore_Get_count(
*
* @note There is currently no MACRO version of this routine.
*/
-RTEMS_INLINE_ROUTINE void _CORE_semaphore_Seize(
+RTEMS_INLINE_ROUTINE Status_Control _CORE_semaphore_Seize(
CORE_semaphore_Control *the_semaphore,
Thread_Control *executing,
bool wait,
@@ -235,18 +192,16 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Seize(
{
/* disabled when you get here */
- executing->Wait.return_code = CORE_SEMAPHORE_STATUS_SUCCESSFUL;
_CORE_semaphore_Acquire_critical( the_semaphore, queue_context );
if ( the_semaphore->count != 0 ) {
the_semaphore->count -= 1;
_CORE_semaphore_Release( the_semaphore, queue_context );
- return;
+ return STATUS_SUCCESSFUL;
}
if ( !wait ) {
_CORE_semaphore_Release( the_semaphore, queue_context );
- executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT;
- return;
+ return STATUS_UNSATISFIED;
}
_Thread_queue_Enqueue_critical(
@@ -255,9 +210,9 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Seize(
executing,
STATES_WAITING_FOR_SEMAPHORE,
timeout,
- CORE_SEMAPHORE_TIMEOUT,
&queue_context->Lock_context
);
+ return _Thread_Wait_get_status( executing );
}
/** @} */
diff --git a/cpukit/score/include/rtems/score/corespinlockimpl.h b/cpukit/score/include/rtems/score/corespinlockimpl.h
index fd4fcf29db..140529b573 100644
--- a/cpukit/score/include/rtems/score/corespinlockimpl.h
+++ b/cpukit/score/include/rtems/score/corespinlockimpl.h
@@ -20,6 +20,7 @@
#define _RTEMS_SCORE_CORESPINLOCKIMPL_H
#include <rtems/score/corespinlock.h>
+#include <rtems/score/status.h>
#include <rtems/score/watchdog.h>
#include <string.h>
@@ -33,37 +34,6 @@ extern "C" {
*/
/**@{**/
-/**
- * Core Spinlock handler return statuses.
- */
-typedef enum {
- /** This status indicates that the operation completed successfully. */
- CORE_SPINLOCK_SUCCESSFUL,
- /** This status indicates that the current thread already holds the spinlock.
- * An attempt to relock it will result in deadlock.
- */
- CORE_SPINLOCK_HOLDER_RELOCKING,
- /** This status indicates that the current thread is attempting to unlock a
- * spinlock that is held by another thread.
- */
- CORE_SPINLOCK_NOT_HOLDER,
- /** This status indicates that a thread reached the limit of time it
- * was willing to wait on the spin lock.
- */
- CORE_SPINLOCK_TIMEOUT,
- /** This status indicates that a thread is currently waiting for this
- * spin lock.
- */
- CORE_SPINLOCK_IS_BUSY,
- /** This status indicates that the spinlock is currently locked and thus
- * unavailable.
- */
- CORE_SPINLOCK_UNAVAILABLE
-} CORE_spinlock_Status;
-
-/** This is a shorthand for the last status code. */
-#define CORE_SPINLOCK_STATUS_LAST CORE_SPINLOCK_UNAVAILABLE
-
/** This indicates the lock is available. */
#define CORE_SPINLOCK_UNLOCKED 0
@@ -115,7 +85,7 @@ RTEMS_INLINE_ROUTINE void _CORE_spinlock_Release(
* @retval A status is returned which indicates the success or failure of
* this operation.
*/
-CORE_spinlock_Status _CORE_spinlock_Seize(
+Status_Control _CORE_spinlock_Seize(
CORE_spinlock_Control *the_spinlock,
bool wait,
Watchdog_Interval timeout,
@@ -130,7 +100,7 @@ CORE_spinlock_Status _CORE_spinlock_Seize(
*
* @param[in] the_spinlock is the spinlock to surrender
*/
-CORE_spinlock_Status _CORE_spinlock_Surrender(
+Status_Control _CORE_spinlock_Surrender(
CORE_spinlock_Control *the_spinlock,
ISR_lock_Context *lock_context
);
diff --git a/cpukit/score/include/rtems/score/mpciimpl.h b/cpukit/score/include/rtems/score/mpciimpl.h
index 8d19956fbc..eb03a1d7b3 100644
--- a/cpukit/score/include/rtems/score/mpciimpl.h
+++ b/cpukit/score/include/rtems/score/mpciimpl.h
@@ -19,6 +19,7 @@
#define _RTEMS_SCORE_MPCIIMPL_H
#include <rtems/score/mpci.h>
+#include <rtems/score/status.h>
#ifdef __cplusplus
extern "C" {
@@ -162,15 +163,13 @@ void _MPCI_Send_process_packet (
* set in addition to the remote operation pending state. It
* may indicate the caller is blocking on a message queue
* operation.
- * @param[in] timeout_code is the timeout code
*
* @retval This method returns the operation status from the remote node.
*/
-uint32_t _MPCI_Send_request_packet (
- uint32_t destination,
- MP_packet_Prefix *the_packet,
- States_Control extra_state,
- uint32_t timeout_code
+Status_Control _MPCI_Send_request_packet(
+ uint32_t destination,
+ MP_packet_Prefix *the_packet,
+ States_Control extra_state
);
/**
diff --git a/cpukit/score/include/rtems/score/mrsp.h b/cpukit/score/include/rtems/score/mrsp.h
index cb3de67e26..595884864f 100644
--- a/cpukit/score/include/rtems/score/mrsp.h
+++ b/cpukit/score/include/rtems/score/mrsp.h
@@ -51,31 +51,6 @@ extern "C" {
* @{
*/
-/**
- * @brief MrsP status code.
- *
- * The values are chosen to directly map to RTEMS status codes. In case this
- * implementation is used for other APIs, then for example the errno values can
- * be added with a bit shift.
- */
-typedef enum {
- MRSP_SUCCESSFUL = 0,
- MRSP_TIMEOUT = 6,
- MRSP_INVALID_NUMBER = 10,
- MRSP_RESOUCE_IN_USE = 12,
- MRSP_UNSATISFIED = 13,
- MRSP_INCORRECT_STATE = 14,
- MRSP_INVALID_PRIORITY = 19,
- MRSP_NOT_OWNER_OF_RESOURCE = 23,
- MRSP_NO_MEMORY = 26,
-
- /**
- * @brief Internal state used for MRSP_Rival::status to indicate that this
- * rival waits for resource ownership.
- */
- MRSP_WAIT_FOR_OWNERSHIP = 255
-} MRSP_Status;
-
typedef struct MRSP_Control MRSP_Control;
/**
@@ -124,10 +99,10 @@ typedef struct {
* @brief The rival status.
*
* Initially the status is set to MRSP_WAIT_FOR_OWNERSHIP. The rival will
- * busy wait until a status change happens. This can be MRSP_SUCCESSFUL or
- * MRSP_TIMEOUT. State changes are protected by the MrsP control lock.
+ * busy wait until a status change happens. This can be STATUS_SUCCESSFUL or
+ * STATUS_TIMEOUT. State changes are protected by the MrsP control lock.
*/
- volatile MRSP_Status status;
+ volatile int status;
/**
* @brief Watchdog for timeouts.
diff --git a/cpukit/score/include/rtems/score/mrspimpl.h b/cpukit/score/include/rtems/score/mrspimpl.h
index 5173343293..ffdc802f6f 100644
--- a/cpukit/score/include/rtems/score/mrspimpl.h
+++ b/cpukit/score/include/rtems/score/mrspimpl.h
@@ -23,6 +23,7 @@
#include <rtems/score/chainimpl.h>
#include <rtems/score/resourceimpl.h>
#include <rtems/score/schedulerimpl.h>
+#include <rtems/score/status.h>
#include <rtems/score/watchdogimpl.h>
#include <rtems/score/wkspace.h>
@@ -36,6 +37,12 @@ extern "C" {
* @{
*/
+/**
+ * @brief Internal state used for MRSP_Rival::status to indicate that this
+ * rival waits for resource ownership.
+ */
+#define MRSP_WAIT_FOR_OWNERSHIP STATUS_MINUS_ONE
+
/*
* FIXME: Operations with the resource dependency tree are protected by the
* global scheduler lock. Since the scheduler lock should be scheduler
@@ -126,7 +133,7 @@ RTEMS_INLINE_ROUTINE void _MRSP_Claim_ownership(
_Thread_Dispatch_enable( cpu_self );
}
-RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Initialize(
+RTEMS_INLINE_ROUTINE Status_Control _MRSP_Initialize(
MRSP_Control *mrsp,
Priority_Control ceiling_priority,
Thread_Control *executing,
@@ -137,14 +144,14 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Initialize(
uint32_t i;
if ( initially_locked ) {
- return MRSP_INVALID_NUMBER;
+ return STATUS_INVALID_NUMBER;
}
mrsp->ceiling_priorities = _Workspace_Allocate(
sizeof( *mrsp->ceiling_priorities ) * scheduler_count
);
if ( mrsp->ceiling_priorities == NULL ) {
- return MRSP_NO_MEMORY;
+ return STATUS_NO_MEMORY;
}
for ( i = 0 ; i < scheduler_count ; ++i ) {
@@ -155,7 +162,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Initialize(
_Chain_Initialize_empty( &mrsp->Rivals );
_ISR_lock_Initialize( &mrsp->Lock, "MrsP" );
- return MRSP_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
}
RTEMS_INLINE_ROUTINE Priority_Control _MRSP_Get_ceiling_priority(
@@ -199,7 +206,7 @@ RTEMS_INLINE_ROUTINE void _MRSP_Timeout( Watchdog_Control *watchdog )
_MRSP_Giant_release( &giant_lock_context );
- rival->status = MRSP_TIMEOUT;
+ rival->status = STATUS_TIMEOUT;
_MRSP_Release( mrsp, &queue_context );
} else {
@@ -207,7 +214,7 @@ RTEMS_INLINE_ROUTINE void _MRSP_Timeout( Watchdog_Control *watchdog )
}
}
-RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Wait_for_ownership(
+RTEMS_INLINE_ROUTINE Status_Control _MRSP_Wait_for_ownership(
MRSP_Control *mrsp,
Resource_Node *owner,
Thread_Control *executing,
@@ -217,7 +224,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Wait_for_ownership(
Thread_queue_Context *queue_context
)
{
- MRSP_Status status;
+ Status_Control status;
MRSP_Rival rival;
Thread_Life_state life_state;
Per_CPU_Control *cpu_self;
@@ -278,7 +285,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Wait_for_ownership(
);
_ISR_Local_enable( level );
- if ( status == MRSP_TIMEOUT ) {
+ if ( status == STATUS_TIMEOUT ) {
_MRSP_Restore_priority( executing, initial_priority );
}
}
@@ -286,7 +293,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Wait_for_ownership(
return status;
}
-RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Seize(
+RTEMS_INLINE_ROUTINE Status_Control _MRSP_Seize(
MRSP_Control *mrsp,
Thread_Control *executing,
bool wait,
@@ -294,7 +301,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Seize(
Thread_queue_Context *queue_context
)
{
- MRSP_Status status;
+ Status_Control status;
const Scheduler_Control *scheduler = _Scheduler_Get_own( executing );
uint32_t scheduler_index = _Scheduler_Get_index( scheduler );
Priority_Control initial_priority = executing->current_priority;
@@ -308,7 +315,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Seize(
if ( !priority_ok) {
_ISR_lock_ISR_enable( &queue_context->Lock_context );
- return MRSP_INVALID_PRIORITY;
+ return STATUS_MUTEX_CEILING_VIOLATED;
}
_MRSP_Acquire_critical( mrsp, queue_context );
@@ -321,7 +328,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Seize(
ceiling_priority,
queue_context
);
- status = MRSP_SUCCESSFUL;
+ status = STATUS_SUCCESSFUL;
} else if (
wait
&& _Resource_Node_get_root( owner ) != &executing->Resource_node
@@ -338,13 +345,13 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Seize(
} else {
_MRSP_Release( mrsp, queue_context );
/* Not available, nested access or deadlock */
- status = MRSP_UNSATISFIED;
+ status = STATUS_UNAVAILABLE;
}
return status;
}
-RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Surrender(
+RTEMS_INLINE_ROUTINE Status_Control _MRSP_Surrender(
MRSP_Control *mrsp,
Thread_Control *executing,
Thread_queue_Context *queue_context
@@ -356,7 +363,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Surrender(
if ( _Resource_Get_owner( &mrsp->Resource ) != &executing->Resource_node ) {
_ISR_lock_ISR_enable( &queue_context->Lock_context );
- return MRSP_NOT_OWNER_OF_RESOURCE;
+ return STATUS_NOT_OWNER;
}
if (
@@ -366,7 +373,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Surrender(
)
) {
_ISR_lock_ISR_enable( &queue_context->Lock_context );
- return MRSP_INCORRECT_STATE;
+ return STATUS_RELEASE_ORDER_VIOLATION;
}
initial_priority = mrsp->initial_priority_of_owner;
@@ -388,7 +395,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Surrender(
* This must be inside the critical section since the status prevents a
* potential double extraction in _MRSP_Timeout().
*/
- rival->status = MRSP_SUCCESSFUL;
+ rival->status = STATUS_SUCCESSFUL;
new_owner = rival->thread;
mrsp->initial_priority_of_owner = rival->initial_priority;
@@ -413,16 +420,16 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Surrender(
_Thread_Dispatch_enable( cpu_self );
- return MRSP_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
}
-RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Can_destroy( MRSP_Control *mrsp )
+RTEMS_INLINE_ROUTINE Status_Control _MRSP_Can_destroy( MRSP_Control *mrsp )
{
if ( _Resource_Get_owner( &mrsp->Resource ) != NULL ) {
- return MRSP_RESOUCE_IN_USE;
+ return STATUS_RESOURCE_IN_USE;
}
- return MRSP_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
}
RTEMS_INLINE_ROUTINE void _MRSP_Destroy(
diff --git a/cpukit/score/include/rtems/score/status.h b/cpukit/score/include/rtems/score/status.h
new file mode 100644
index 0000000000..eaf69c1597
--- /dev/null
+++ b/cpukit/score/include/rtems/score/status.h
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2016 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_SCORE_STATUS_H
+#define _RTEMS_SCORE_STATUS_H
+
+#include <rtems/score/basedefs.h>
+
+#if defined(RTEMS_POSIX_API)
+#include <errno.h>
+#include <pthread.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @brief Status code parts for the Classic API.
+ *
+ * Must be in synchronization with rtems_status_code.
+ */
+typedef enum {
+ STATUS_CLASSIC_INCORRECT_STATE = 14,
+ STATUS_CLASSIC_INTERNAL_ERROR = 13,
+ STATUS_CLASSIC_INVALID_NUMBER = 10,
+ STATUS_CLASSIC_INVALID_PRIORITY = 19,
+ STATUS_CLASSIC_INVALID_SIZE = 8,
+ STATUS_CLASSIC_NO_MEMORY = 26,
+ STATUS_CLASSIC_NOT_OWNER_OF_RESOURCE = 23,
+ STATUS_CLASSIC_OBJECT_WAS_DELETED = 7,
+ STATUS_CLASSIC_RESOURCE_IN_USE = 12,
+ STATUS_CLASSIC_SUCCESSFUL = 0,
+ STATUS_CLASSIC_TIMEOUT = 6,
+ STATUS_CLASSIC_TOO_MANY = 5,
+ STATUS_CLASSIC_UNSATISFIED = 13
+} Status_Classic;
+
+/**
+ * @brief Macro to build a status code from Classic and POSIX API parts.
+ */
+#if defined(RTEMS_POSIX_API)
+ #define STATUS_BUILD( classic_status, posix_status ) \
+ ( ( ( posix_status ) << 8 ) | ( classic_status ) )
+#else
+ #define STATUS_BUILD( classic_status, posix_status ) \
+ ( classic_status )
+#endif
+
+/**
+ * @brief Macro to get the Classic API status code.
+ */
+#define STATUS_GET_CLASSIC( status ) \
+ ( ( status ) & 0xff )
+
+/**
+ * @brief Macro to get the POSIX API status code.
+ *
+ * Performs an arithmetic shift to reconstruct a negative POSIX status.
+ */
+#define STATUS_GET_POSIX( status ) \
+ ( ( ( (int) ( status ) ) | 0xff ) >> 8 )
+
+/**
+ * @brief Status codes.
+ */
+typedef enum {
+ STATUS_BARRIER_AUTOMATICALLY_RELEASED =
+ STATUS_BUILD( STATUS_CLASSIC_SUCCESSFUL, PTHREAD_BARRIER_SERIAL_THREAD ),
+ STATUS_DEADLOCK =
+ STATUS_BUILD( STATUS_CLASSIC_INCORRECT_STATE, EDEADLK ),
+ STATUS_FLUSHED =
+ STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, EAGAIN ),
+ STATUS_INTERRUPTED =
+ STATUS_BUILD( STATUS_CLASSIC_INTERNAL_ERROR, EINTR ),
+ STATUS_INVALID_NUMBER =
+ STATUS_BUILD( STATUS_CLASSIC_INVALID_NUMBER, EINVAL ),
+ STATUS_MAXIMUM_COUNT_EXCEEDED =
+ STATUS_BUILD( STATUS_CLASSIC_INTERNAL_ERROR, EOVERFLOW ),
+ STATUS_MESSAGE_INVALID_SIZE =
+ STATUS_BUILD( STATUS_CLASSIC_INVALID_SIZE, EMSGSIZE ),
+ STATUS_MESSAGE_QUEUE_WAIT_IN_ISR =
+ STATUS_BUILD( STATUS_CLASSIC_INTERNAL_ERROR, ENOMEM ),
+ STATUS_MESSAGE_QUEUE_WAS_DELETED =
+ STATUS_BUILD( STATUS_CLASSIC_OBJECT_WAS_DELETED, EBADF ),
+ STATUS_MINUS_ONE =
+ -1,
+ STATUS_MUTEX_CEILING_VIOLATED =
+ STATUS_BUILD( STATUS_CLASSIC_INVALID_PRIORITY, EINVAL ),
+ STATUS_NESTING_NOT_ALLOWED =
+ STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, EDEADLK ),
+ STATUS_NO_MEMORY =
+ STATUS_BUILD( STATUS_CLASSIC_NO_MEMORY, EINVAL ),
+ STATUS_NOT_OWNER =
+ STATUS_BUILD( STATUS_CLASSIC_NOT_OWNER_OF_RESOURCE, EPERM ),
+ STATUS_OBJECT_WAS_DELETED =
+ STATUS_BUILD( STATUS_CLASSIC_OBJECT_WAS_DELETED, EINVAL ),
+ STATUS_RELEASE_ORDER_VIOLATION =
+ STATUS_BUILD( STATUS_CLASSIC_INCORRECT_STATE, EPERM ),
+ STATUS_RESOURCE_IN_USE =
+ STATUS_BUILD( STATUS_CLASSIC_RESOURCE_IN_USE, EBUSY ),
+ STATUS_SUCCESSFUL =
+ STATUS_BUILD( STATUS_CLASSIC_SUCCESSFUL, 0 ),
+ STATUS_TIMEOUT =
+ STATUS_BUILD( STATUS_CLASSIC_TIMEOUT, ETIMEDOUT ),
+ STATUS_TOO_MANY =
+ STATUS_BUILD( STATUS_CLASSIC_TOO_MANY, EAGAIN ),
+ STATUS_UNAVAILABLE =
+ STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, EBUSY ),
+ STATUS_UNSATISFIED =
+ STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, EAGAIN )
+} Status_Control;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _RTEMS_SCORE_STATUS_H */
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h
index ee19c0430f..4618a409eb 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -288,11 +288,6 @@ typedef struct {
uint32_t return_code;
/**
- * @brief Code to set the timeout return code in _Thread_Timeout().
- */
- uint32_t timeout_code;
-
- /**
* @brief The current thread queue.
*
* In case this field is @c NULL, then the thread is not blocked on a thread
diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
index cef2786ae4..10811088c9 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -29,6 +29,7 @@
#include <rtems/score/objectimpl.h>
#include <rtems/score/resourceimpl.h>
#include <rtems/score/statesimpl.h>
+#include <rtems/score/status.h>
#include <rtems/score/sysstate.h>
#include <rtems/score/threadqimpl.h>
#include <rtems/score/todimpl.h>
@@ -1450,20 +1451,6 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_restore_default_operations(
}
/**
- * @brief Sets the thread wait timeout code.
- *
- * @param[in] the_thread The thread.
- * @param[in] timeout_code The new thread wait timeout code.
- */
-RTEMS_INLINE_ROUTINE void _Thread_Wait_set_timeout_code(
- Thread_Control *the_thread,
- uint32_t timeout_code
-)
-{
- the_thread->Wait.timeout_code = timeout_code;
-}
-
-/**
* @brief Returns the object identifier of the object containing the current
* thread wait queue.
*
@@ -1479,6 +1466,13 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_set_timeout_code(
*/
Objects_Id _Thread_Wait_get_id( const Thread_Control *the_thread );
+RTEMS_INLINE_ROUTINE Status_Control _Thread_Wait_get_status(
+ const Thread_Control *the_thread
+)
+{
+ return (Status_Control) the_thread->Wait.return_code;
+}
+
/**
* @brief General purpose thread wait timeout.
*
diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h
index 752e13e76e..7489d5466b 100644
--- a/cpukit/score/include/rtems/score/threadqimpl.h
+++ b/cpukit/score/include/rtems/score/threadqimpl.h
@@ -341,7 +341,6 @@ Thread_Control *_Thread_queue_Do_dequeue(
* @param[in] state The new state of the thread.
* @param[in] timeout Interval to wait. Use WATCHDOG_NO_TIMEOUT to block
* potentially forever.
- * @param[in] timeout_code The return code in case a timeout occurs.
* @param[in] lock_context The lock context of the lock acquire.
*/
void _Thread_queue_Enqueue_critical(
@@ -350,7 +349,6 @@ void _Thread_queue_Enqueue_critical(
Thread_Control *the_thread,
States_Control state,
Watchdog_Interval timeout,
- uint32_t timeout_code,
ISR_lock_Context *lock_context
);
@@ -363,8 +361,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Enqueue(
const Thread_queue_Operations *operations,
Thread_Control *the_thread,
States_Control state,
- Watchdog_Interval timeout,
- uint32_t timeout_code
+ Watchdog_Interval timeout
)
{
ISR_lock_Context lock_context;
@@ -376,7 +373,6 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Enqueue(
the_thread,
state,
timeout,
- timeout_code,
&lock_context
);
}
@@ -628,6 +624,40 @@ Thread_Control *_Thread_queue_Flush_default_filter(
);
/**
+ * @brief Status unavailable thread queue flush filter function.
+ *
+ * Sets the thread wait return code of the thread to STATUS_UNAVAILABLE.
+ *
+ * @param the_thread The thread to extract.
+ * @param queue Unused.
+ * @param queue_context Unused.
+ *
+ * @retval the_thread Extract this thread.
+ */
+Thread_Control *_Thread_queue_Flush_status_unavailable(
+ Thread_Control *the_thread,
+ Thread_queue_Queue *queue,
+ Thread_queue_Context *queue_context
+);
+
+/**
+ * @brief Status object was deleted thread queue flush filter function.
+ *
+ * Sets the thread wait return code of the thread to STATUS_OBJECT_WAS_DELETED
+ *
+ * @param the_thread The thread to extract.
+ * @param queue Unused.
+ * @param queue_context Unused.
+ *
+ * @retval the_thread Extract this thread.
+ */
+Thread_Control *_Thread_queue_Flush_status_object_was_deleted(
+ Thread_Control *the_thread,
+ Thread_queue_Queue *queue,
+ Thread_queue_Context *queue_context
+);
+
+/**
* @brief Unblocks all threads enqueued on the thread queue.
*
* This function iteratively extracts the first enqueued thread of the thread
diff --git a/cpukit/score/preinstall.am b/cpukit/score/preinstall.am
index 94851407d4..2ed07b91e8 100644
--- a/cpukit/score/preinstall.am
+++ b/cpukit/score/preinstall.am
@@ -316,6 +316,10 @@ $(PROJECT_INCLUDE)/rtems/score/statesimpl.h: include/rtems/score/statesimpl.h $(
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/statesimpl.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/statesimpl.h
+$(PROJECT_INCLUDE)/rtems/score/status.h: include/rtems/score/status.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/status.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/status.h
+
$(PROJECT_INCLUDE)/rtems/score/sysstate.h: include/rtems/score/sysstate.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/sysstate.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/sysstate.h
diff --git a/cpukit/score/src/condition.c b/cpukit/score/src/condition.c
index c0320b28d4..39924e8c92 100644
--- a/cpukit/score/src/condition.c
+++ b/cpukit/score/src/condition.c
@@ -91,14 +91,12 @@ static Per_CPU_Control *_Condition_Do_wait(
executing = _Condition_Queue_acquire_critical( condition, lock_context );
cpu_self = _Thread_Dispatch_disable_critical( lock_context );
- executing->Wait.return_code = 0;
_Thread_queue_Enqueue_critical(
&condition->Queue.Queue,
CONDITION_TQ_OPERATIONS,
executing,
STATES_WAITING_FOR_SYS_LOCK_CONDITION,
timeout,
- ETIMEDOUT,
lock_context
);
@@ -152,7 +150,7 @@ int _Condition_Wait_timed(
_Mutex_Release( _mutex );
executing = cpu_self->executing;
_Thread_Dispatch_enable( cpu_self );
- eno = (int) executing->Wait.return_code;
+ eno = STATUS_GET_POSIX( _Thread_Wait_get_status( executing ) );
_Mutex_Acquire( _mutex );
return eno;
@@ -212,7 +210,7 @@ int _Condition_Wait_recursive_timed(
_Mutex_recursive_Release( _mutex );
executing = cpu_self->executing;
_Thread_Dispatch_enable( cpu_self );
- eno = (int) executing->Wait.return_code;
+ eno = STATUS_GET_POSIX( _Thread_Wait_get_status( executing ) );
_Mutex_recursive_Acquire( _mutex );
_mutex->_nest_level = nest_level;
diff --git a/cpukit/score/src/corebarrier.c b/cpukit/score/src/corebarrier.c
index a32f88c46b..8da3ca1063 100644
--- a/cpukit/score/src/corebarrier.c
+++ b/cpukit/score/src/corebarrier.c
@@ -31,14 +31,3 @@ void _CORE_barrier_Initialize(
_Thread_queue_Initialize( &the_barrier->Wait_queue );
}
-
-Thread_Control *_CORE_barrier_Was_deleted(
- Thread_Control *the_thread,
- Thread_queue_Queue *queue,
- Thread_queue_Context *queue_context
-)
-{
- the_thread->Wait.return_code = CORE_BARRIER_WAS_DELETED;
-
- return the_thread;
-}
diff --git a/cpukit/score/src/corebarrierwait.c b/cpukit/score/src/corebarrierwait.c
index 33f1718a66..a1c862d293 100644
--- a/cpukit/score/src/corebarrierwait.c
+++ b/cpukit/score/src/corebarrierwait.c
@@ -20,8 +20,9 @@
#include <rtems/score/corebarrierimpl.h>
#include <rtems/score/statesimpl.h>
+#include <rtems/score/threadimpl.h>
-void _CORE_barrier_Seize(
+Status_Control _CORE_barrier_Seize(
CORE_barrier_Control *the_barrier,
Thread_Control *executing,
bool wait,
@@ -31,8 +32,6 @@ void _CORE_barrier_Seize(
{
uint32_t number_of_waiting_threads;
- executing->Wait.return_code = CORE_BARRIER_STATUS_SUCCESSFUL;
-
_CORE_barrier_Acquire_critical( the_barrier, queue_context );
number_of_waiting_threads = the_barrier->number_of_waiting_threads;
@@ -42,8 +41,8 @@ void _CORE_barrier_Seize(
_CORE_barrier_Is_automatic( &the_barrier->Attributes )
&& number_of_waiting_threads == the_barrier->Attributes.maximum_count
) {
- executing->Wait.return_code = CORE_BARRIER_STATUS_AUTOMATICALLY_RELEASED;
_CORE_barrier_Surrender( the_barrier, queue_context );
+ return STATUS_BARRIER_AUTOMATICALLY_RELEASED;
} else {
the_barrier->number_of_waiting_threads = number_of_waiting_threads;
_Thread_queue_Enqueue_critical(
@@ -52,8 +51,8 @@ void _CORE_barrier_Seize(
executing,
STATES_WAITING_FOR_BARRIER,
timeout,
- CORE_BARRIER_TIMEOUT,
&queue_context->Lock_context
);
+ return _Thread_Wait_get_status( executing );
}
}
diff --git a/cpukit/score/src/coremsgbroadcast.c b/cpukit/score/src/coremsgbroadcast.c
index 23dd343c05..f7579c2d98 100644
--- a/cpukit/score/src/coremsgbroadcast.c
+++ b/cpukit/score/src/coremsgbroadcast.c
@@ -21,7 +21,7 @@
#include <rtems/score/coremsgimpl.h>
#include <rtems/score/objectimpl.h>
-CORE_message_queue_Status _CORE_message_queue_Broadcast(
+Status_Control _CORE_message_queue_Broadcast(
CORE_message_queue_Control *the_message_queue,
const void *buffer,
size_t size,
@@ -34,7 +34,7 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast(
if ( size > the_message_queue->maximum_message_size ) {
_ISR_lock_ISR_enable( &queue_context->Lock_context );
- return CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE;
+ return STATUS_MESSAGE_INVALID_SIZE;
}
number_broadcasted = 0;
@@ -60,5 +60,5 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast(
_CORE_message_queue_Release( the_message_queue, queue_context );
*count = number_broadcasted;
- return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
}
diff --git a/cpukit/score/src/coremsgclose.c b/cpukit/score/src/coremsgclose.c
index e24d756002..f8a53a2fcd 100644
--- a/cpukit/score/src/coremsgclose.c
+++ b/cpukit/score/src/coremsgclose.c
@@ -27,7 +27,7 @@ static Thread_Control *_CORE_message_queue_Was_deleted(
Thread_queue_Context *queue_context
)
{
- the_thread->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED;
+ the_thread->Wait.return_code = STATUS_MESSAGE_QUEUE_WAS_DELETED;
return the_thread;
}
diff --git a/cpukit/score/src/coremsgseize.c b/cpukit/score/src/coremsgseize.c
index b05ddd63f3..00ff437e01 100644
--- a/cpukit/score/src/coremsgseize.c
+++ b/cpukit/score/src/coremsgseize.c
@@ -22,10 +22,10 @@
#include <rtems/score/chain.h>
#include <rtems/score/isr.h>
#include <rtems/score/coremsgimpl.h>
-#include <rtems/score/thread.h>
+#include <rtems/score/threadimpl.h>
#include <rtems/score/statesimpl.h>
-void _CORE_message_queue_Seize(
+Status_Control _CORE_message_queue_Seize(
CORE_message_queue_Control *the_message_queue,
Thread_Control *executing,
void *buffer,
@@ -37,7 +37,6 @@ void _CORE_message_queue_Seize(
{
CORE_message_queue_Buffer_control *the_message;
- executing->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
the_message = _CORE_message_queue_Get_pending_message( the_message_queue );
if ( the_message != NULL ) {
the_message_queue->number_of_pending_messages -= 1;
@@ -58,7 +57,7 @@ void _CORE_message_queue_Seize(
*/
_CORE_message_queue_Free_message_buffer(the_message_queue, the_message);
_CORE_message_queue_Release( the_message_queue, queue_context );
- return;
+ return STATUS_SUCCESSFUL;
#else
{
Thread_Control *the_thread;
@@ -80,7 +79,7 @@ void _CORE_message_queue_Seize(
the_message
);
_CORE_message_queue_Release( the_message_queue, queue_context );
- return;
+ return STATUS_SUCCESSFUL;
}
/*
@@ -101,15 +100,14 @@ void _CORE_message_queue_Seize(
the_thread,
queue_context
);
- return;
+ return STATUS_SUCCESSFUL;
}
#endif
}
if ( !wait ) {
_CORE_message_queue_Release( the_message_queue, queue_context );
- executing->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT;
- return;
+ return STATUS_UNSATISFIED;
}
executing->Wait.return_argument_second.mutable_object = buffer;
@@ -122,7 +120,7 @@ void _CORE_message_queue_Seize(
executing,
STATES_WAITING_FOR_MESSAGE,
timeout,
- CORE_MESSAGE_QUEUE_STATUS_TIMEOUT,
&queue_context->Lock_context
);
+ return _Thread_Wait_get_status( executing );
}
diff --git a/cpukit/score/src/coremsgsubmit.c b/cpukit/score/src/coremsgsubmit.c
index a86774175f..a623291776 100644
--- a/cpukit/score/src/coremsgsubmit.c
+++ b/cpukit/score/src/coremsgsubmit.c
@@ -22,10 +22,11 @@
#include <rtems/score/coremsgimpl.h>
#include <rtems/score/objectimpl.h>
#include <rtems/score/isr.h>
+#include <rtems/score/threadimpl.h>
#include <rtems/score/statesimpl.h>
#include <rtems/score/wkspace.h>
-CORE_message_queue_Status _CORE_message_queue_Submit(
+Status_Control _CORE_message_queue_Submit(
CORE_message_queue_Control *the_message_queue,
Thread_Control *executing,
const void *buffer,
@@ -41,7 +42,7 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
if ( size > the_message_queue->maximum_message_size ) {
_CORE_message_queue_Release( the_message_queue, queue_context );
- return CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE;
+ return STATUS_MESSAGE_INVALID_SIZE;
}
/*
@@ -56,7 +57,7 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
queue_context
);
if ( the_thread != NULL ) {
- return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
}
/*
@@ -95,12 +96,12 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
_CORE_message_queue_Release( the_message_queue, queue_context );
#endif
- return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
}
#if !defined(RTEMS_SCORE_COREMSG_ENABLE_BLOCKING_SEND)
_CORE_message_queue_Release( the_message_queue, queue_context );
- return CORE_MESSAGE_QUEUE_STATUS_TOO_MANY;
+ return STATUS_TOO_MANY;
#else
/*
* No message buffers were available so we may need to return an
@@ -109,7 +110,7 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
*/
if ( !wait ) {
_CORE_message_queue_Release( the_message_queue, queue_context );
- return CORE_MESSAGE_QUEUE_STATUS_TOO_MANY;
+ return STATUS_TOO_MANY;
}
/*
@@ -118,7 +119,7 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
*/
if ( _ISR_Is_in_progress() ) {
_CORE_message_queue_Release( the_message_queue, queue_context );
- return CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED;
+ return STATUS_MESSAGE_QUEUE_WAIT_IN_ISR;
}
/*
@@ -127,7 +128,6 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
* it as a variable. Doing this emphasizes how dangerous it
* would be to use this variable prior to here.
*/
- executing->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
executing->Wait.return_argument_second.immutable_object = buffer;
executing->Wait.option = (uint32_t) size;
executing->Wait.count = submit_type;
@@ -138,9 +138,8 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
executing,
STATES_WAITING_FOR_MESSAGE,
timeout,
- CORE_MESSAGE_QUEUE_STATUS_TIMEOUT,
&queue_context->Lock_context
);
- return executing->Wait.return_code;
+ return _Thread_Wait_get_status( executing );
#endif
}
diff --git a/cpukit/score/src/coremutex.c b/cpukit/score/src/coremutex.c
index ecca2441e0..ec073ff999 100644
--- a/cpukit/score/src/coremutex.c
+++ b/cpukit/score/src/coremutex.c
@@ -23,7 +23,7 @@
#include <rtems/score/coremuteximpl.h>
#include <rtems/score/thread.h>
-CORE_mutex_Status _CORE_mutex_Initialize(
+Status_Control _CORE_mutex_Initialize(
CORE_mutex_Control *the_mutex,
Thread_Control *executing,
const CORE_mutex_Attributes *the_mutex_attributes,
@@ -64,7 +64,7 @@ CORE_mutex_Status _CORE_mutex_Initialize(
* the object creation.
*/
_Thread_Dispatch_enable( cpu_self );
- return CORE_MUTEX_STATUS_CEILING_VIOLATED;
+ return STATUS_MUTEX_CEILING_VIOLATED;
}
executing->resource_count++;
@@ -88,27 +88,5 @@ CORE_mutex_Status _CORE_mutex_Initialize(
the_mutex->operations = &_Thread_queue_Operations_priority;
}
- return CORE_MUTEX_STATUS_SUCCESSFUL;
-}
-
-Thread_Control *_CORE_mutex_Was_deleted(
- Thread_Control *the_thread,
- Thread_queue_Queue *queue,
- Thread_queue_Context *queue_context
-)
-{
- the_thread->Wait.return_code = CORE_MUTEX_WAS_DELETED;
-
- return the_thread;
-}
-
-Thread_Control *_CORE_mutex_Unsatisfied_nowait(
- Thread_Control *the_thread,
- Thread_queue_Queue *queue,
- Thread_queue_Context *queue_context
-)
-{
- the_thread->Wait.return_code = CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT;
-
- return the_thread;
+ return STATUS_SUCCESSFUL;
}
diff --git a/cpukit/score/src/coremutexseize.c b/cpukit/score/src/coremutexseize.c
index 168d69716f..0fc63f4693 100644
--- a/cpukit/score/src/coremutexseize.c
+++ b/cpukit/score/src/coremutexseize.c
@@ -24,7 +24,7 @@
#include <rtems/score/statesimpl.h>
#include <rtems/score/thread.h>
-void _CORE_mutex_Seize_interrupt_blocking(
+Status_Control _CORE_mutex_Seize_interrupt_blocking(
CORE_mutex_Control *the_mutex,
Thread_Control *executing,
Watchdog_Interval timeout,
@@ -67,12 +67,13 @@ void _CORE_mutex_Seize_interrupt_blocking(
executing,
STATES_WAITING_FOR_MUTEX,
timeout,
- CORE_MUTEX_TIMEOUT,
lock_context
);
#if !defined(RTEMS_SMP)
_Thread_Dispatch_enable( _Per_CPU_Get() );
#endif
+
+ return _Thread_Wait_get_status( executing );
}
diff --git a/cpukit/score/src/coremutexsurrender.c b/cpukit/score/src/coremutexsurrender.c
index 040a580592..1da98276bf 100644
--- a/cpukit/score/src/coremutexsurrender.c
+++ b/cpukit/score/src/coremutexsurrender.c
@@ -23,7 +23,7 @@
#include <rtems/score/coremuteximpl.h>
#include <rtems/score/thread.h>
-CORE_mutex_Status _CORE_mutex_Surrender(
+Status_Control _CORE_mutex_Surrender(
CORE_mutex_Control *the_mutex,
Thread_queue_Context *queue_context
)
@@ -44,7 +44,7 @@ CORE_mutex_Status _CORE_mutex_Surrender(
if ( the_mutex->Attributes.only_owner_release ) {
if ( !_Thread_Is_executing( holder ) ) {
_ISR_lock_ISR_enable( &queue_context->Lock_context );
- return CORE_MUTEX_STATUS_NOT_OWNER_OF_RESOURCE;
+ return STATUS_NOT_OWNER;
}
}
@@ -54,7 +54,7 @@ CORE_mutex_Status _CORE_mutex_Surrender(
if ( !the_mutex->nest_count ) {
_CORE_mutex_Release( the_mutex, queue_context );
- return CORE_MUTEX_STATUS_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
}
the_mutex->nest_count--;
@@ -69,12 +69,12 @@ CORE_mutex_Status _CORE_mutex_Surrender(
switch ( the_mutex->Attributes.lock_nesting_behavior ) {
case CORE_MUTEX_NESTING_ACQUIRES:
_CORE_mutex_Release( the_mutex, queue_context );
- return CORE_MUTEX_STATUS_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
#if defined(RTEMS_POSIX_API)
case CORE_MUTEX_NESTING_IS_ERROR:
/* should never occur */
_CORE_mutex_Release( the_mutex, queue_context );
- return CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED;
+ return STATUS_NESTING_NOT_ALLOWED;
#endif
case CORE_MUTEX_NESTING_BLOCKS:
/* Currently no API exercises this behavior. */
@@ -83,7 +83,7 @@ CORE_mutex_Status _CORE_mutex_Surrender(
#else
_CORE_mutex_Release( the_mutex, queue_context );
/* must be CORE_MUTEX_NESTING_ACQUIRES or we wouldn't be here */
- return CORE_MUTEX_STATUS_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
#endif
}
@@ -179,5 +179,5 @@ CORE_mutex_Status _CORE_mutex_Surrender(
}
}
- return CORE_MUTEX_STATUS_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
}
diff --git a/cpukit/score/src/corerwlockobtainread.c b/cpukit/score/src/corerwlockobtainread.c
index 639ea7052d..5192eb1f8f 100644
--- a/cpukit/score/src/corerwlockobtainread.c
+++ b/cpukit/score/src/corerwlockobtainread.c
@@ -19,11 +19,12 @@
#endif
#include <rtems/score/corerwlockimpl.h>
+#include <rtems/score/threadimpl.h>
#include <rtems/score/threadqimpl.h>
#include <rtems/score/statesimpl.h>
#include <rtems/score/watchdog.h>
-void _CORE_RWLock_Seize_for_reading(
+Status_Control _CORE_RWLock_Seize_for_reading(
CORE_RWLock_Control *the_rwlock,
Thread_Control *executing,
bool wait,
@@ -44,8 +45,7 @@ void _CORE_RWLock_Seize_for_reading(
the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_READING;
the_rwlock->number_of_readers += 1;
_CORE_RWLock_Release( the_rwlock, queue_context );
- executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL;
- return;
+ return STATUS_SUCCESSFUL;
case CORE_RWLOCK_LOCKED_FOR_READING: {
Thread_Control *waiter;
@@ -56,8 +56,7 @@ void _CORE_RWLock_Seize_for_reading(
if ( !waiter ) {
the_rwlock->number_of_readers += 1;
_CORE_RWLock_Release( the_rwlock, queue_context );
- executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL;
- return;
+ return STATUS_SUCCESSFUL;
}
break;
}
@@ -71,16 +70,14 @@ void _CORE_RWLock_Seize_for_reading(
if ( !wait ) {
_CORE_RWLock_Release( the_rwlock, queue_context );
- executing->Wait.return_code = CORE_RWLOCK_UNAVAILABLE;
- return;
+ return STATUS_UNAVAILABLE;
}
/*
* We need to wait to enter this critical section
*/
- executing->Wait.option = CORE_RWLOCK_THREAD_WAITING_FOR_READ;
- executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL;
+ executing->Wait.option = CORE_RWLOCK_THREAD_WAITING_FOR_READ;
_Thread_queue_Enqueue_critical(
&the_rwlock->Wait_queue.Queue,
@@ -88,7 +85,7 @@ void _CORE_RWLock_Seize_for_reading(
executing,
STATES_WAITING_FOR_RWLOCK,
timeout,
- CORE_RWLOCK_TIMEOUT,
&queue_context->Lock_context
);
+ return _Thread_Wait_get_status( executing );
}
diff --git a/cpukit/score/src/corerwlockobtainwrite.c b/cpukit/score/src/corerwlockobtainwrite.c
index a7d1bb1b6a..0536b8287f 100644
--- a/cpukit/score/src/corerwlockobtainwrite.c
+++ b/cpukit/score/src/corerwlockobtainwrite.c
@@ -19,11 +19,12 @@
#endif
#include <rtems/score/corerwlockimpl.h>
+#include <rtems/score/threadimpl.h>
#include <rtems/score/threadqimpl.h>
#include <rtems/score/statesimpl.h>
#include <rtems/score/watchdog.h>
-void _CORE_RWLock_Seize_for_writing(
+Status_Control _CORE_RWLock_Seize_for_writing(
CORE_RWLock_Control *the_rwlock,
Thread_Control *executing,
bool wait,
@@ -44,8 +45,7 @@ void _CORE_RWLock_Seize_for_writing(
case CORE_RWLOCK_UNLOCKED:
the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_WRITING;
_CORE_RWLock_Release( the_rwlock, queue_context );
- executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL;
- return;
+ return STATUS_SUCCESSFUL;
case CORE_RWLOCK_LOCKED_FOR_READING:
case CORE_RWLOCK_LOCKED_FOR_WRITING:
@@ -58,16 +58,14 @@ void _CORE_RWLock_Seize_for_writing(
if ( !wait ) {
_CORE_RWLock_Release( the_rwlock, queue_context );
- executing->Wait.return_code = CORE_RWLOCK_UNAVAILABLE;
- return;
+ return STATUS_UNAVAILABLE;
}
/*
* We need to wait to enter this critical section
*/
- executing->Wait.option = CORE_RWLOCK_THREAD_WAITING_FOR_WRITE;
- executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL;
+ executing->Wait.option = CORE_RWLOCK_THREAD_WAITING_FOR_WRITE;
_Thread_queue_Enqueue_critical(
&the_rwlock->Wait_queue.Queue,
@@ -75,7 +73,7 @@ void _CORE_RWLock_Seize_for_writing(
executing,
STATES_WAITING_FOR_RWLOCK,
timeout,
- CORE_RWLOCK_TIMEOUT,
&queue_context->Lock_context
);
+ return _Thread_Wait_get_status( executing );
}
diff --git a/cpukit/score/src/corerwlockrelease.c b/cpukit/score/src/corerwlockrelease.c
index 81e01d1b67..71aa12a190 100644
--- a/cpukit/score/src/corerwlockrelease.c
+++ b/cpukit/score/src/corerwlockrelease.c
@@ -73,7 +73,7 @@ static Thread_Control *_CORE_RWLock_Flush_filter(
return the_thread;
}
-CORE_RWLock_Status _CORE_RWLock_Surrender(
+Status_Control _CORE_RWLock_Surrender(
CORE_RWLock_Control *the_rwlock,
Thread_queue_Context *queue_context
)
@@ -90,7 +90,7 @@ CORE_RWLock_Status _CORE_RWLock_Surrender(
if ( the_rwlock->current_state == CORE_RWLOCK_UNLOCKED){
/* This is an error at the caller site */
_CORE_RWLock_Release( the_rwlock, queue_context );
- return CORE_RWLOCK_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
}
if ( the_rwlock->current_state == CORE_RWLOCK_LOCKED_FOR_READING ) {
@@ -99,7 +99,7 @@ CORE_RWLock_Status _CORE_RWLock_Surrender(
if ( the_rwlock->number_of_readers != 0 ) {
/* must be unlocked again */
_CORE_RWLock_Release( the_rwlock, queue_context );
- return CORE_RWLOCK_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
}
}
@@ -121,5 +121,5 @@ CORE_RWLock_Status _CORE_RWLock_Surrender(
_CORE_RWLock_Flush_filter,
queue_context
);
- return CORE_RWLOCK_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
}
diff --git a/cpukit/score/src/coresem.c b/cpukit/score/src/coresem.c
index c94f2b7e86..2bdd81c76a 100644
--- a/cpukit/score/src/coresem.c
+++ b/cpukit/score/src/coresem.c
@@ -36,25 +36,3 @@ void _CORE_semaphore_Initialize(
the_semaphore->operations = &_Thread_queue_Operations_FIFO;
}
}
-
-Thread_Control *_CORE_semaphore_Was_deleted(
- Thread_Control *the_thread,
- Thread_queue_Queue *queue,
- Thread_queue_Context *queue_context
-)
-{
- the_thread->Wait.return_code = CORE_SEMAPHORE_WAS_DELETED;
-
- return the_thread;
-}
-
-Thread_Control *_CORE_semaphore_Unsatisfied_nowait(
- Thread_Control *the_thread,
- Thread_queue_Queue *queue,
- Thread_queue_Context *queue_context
-)
-{
- the_thread->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT;
-
- return the_thread;
-}
diff --git a/cpukit/score/src/corespinlockrelease.c b/cpukit/score/src/corespinlockrelease.c
index 6f2ea71ac2..4a4f9528b3 100644
--- a/cpukit/score/src/corespinlockrelease.c
+++ b/cpukit/score/src/corespinlockrelease.c
@@ -21,7 +21,7 @@
#include <rtems/score/corespinlockimpl.h>
#include <rtems/score/percpu.h>
-CORE_spinlock_Status _CORE_spinlock_Surrender(
+Status_Control _CORE_spinlock_Surrender(
CORE_spinlock_Control *the_spinlock,
ISR_lock_Context *lock_context
)
@@ -36,7 +36,7 @@ CORE_spinlock_Status _CORE_spinlock_Surrender(
|| the_spinlock->holder != _Thread_Executing
) {
_CORE_spinlock_Release( the_spinlock, lock_context );
- return CORE_SPINLOCK_NOT_HOLDER;
+ return STATUS_NOT_OWNER;
}
/*
@@ -47,5 +47,5 @@ CORE_spinlock_Status _CORE_spinlock_Surrender(
the_spinlock->holder = 0;
_CORE_spinlock_Release( the_spinlock, lock_context );
- return CORE_SPINLOCK_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
}
diff --git a/cpukit/score/src/corespinlockwait.c b/cpukit/score/src/corespinlockwait.c
index cc939c2344..4aacb60b74 100644
--- a/cpukit/score/src/corespinlockwait.c
+++ b/cpukit/score/src/corespinlockwait.c
@@ -21,7 +21,7 @@
#include <rtems/score/corespinlockimpl.h>
#include <rtems/score/percpu.h>
-CORE_spinlock_Status _CORE_spinlock_Seize(
+Status_Control _CORE_spinlock_Seize(
CORE_spinlock_Control *the_spinlock,
bool wait,
Watchdog_Interval timeout,
@@ -40,7 +40,7 @@ CORE_spinlock_Status _CORE_spinlock_Seize(
if ( the_spinlock->lock == CORE_SPINLOCK_LOCKED &&
the_spinlock->holder == executing ) {
_CORE_spinlock_Release( the_spinlock, lock_context );
- return CORE_SPINLOCK_HOLDER_RELOCKING;
+ return STATUS_NESTING_NOT_ALLOWED;
}
the_spinlock->users += 1;
for ( ;; ) {
@@ -48,7 +48,7 @@ CORE_spinlock_Status _CORE_spinlock_Seize(
the_spinlock->lock = CORE_SPINLOCK_LOCKED;
the_spinlock->holder = executing;
_CORE_spinlock_Release( the_spinlock, lock_context );
- return CORE_SPINLOCK_SUCCESSFUL;
+ return STATUS_SUCCESSFUL;
}
/*
@@ -57,7 +57,7 @@ CORE_spinlock_Status _CORE_spinlock_Seize(
if ( !wait ) {
the_spinlock->users -= 1;
_CORE_spinlock_Release( the_spinlock, lock_context );
- return CORE_SPINLOCK_UNAVAILABLE;
+ return STATUS_UNAVAILABLE;
}
#if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API)
@@ -67,7 +67,7 @@ CORE_spinlock_Status _CORE_spinlock_Seize(
if ( timeout && (limit <= _Watchdog_Ticks_since_boot) ) {
the_spinlock->users -= 1;
_CORE_spinlock_Release( the_spinlock, lock_context );
- return CORE_SPINLOCK_TIMEOUT;
+ return STATUS_TIMEOUT;
}
#endif
diff --git a/cpukit/score/src/futex.c b/cpukit/score/src/futex.c
index d7945d12ee..980c7fbccc 100644
--- a/cpukit/score/src/futex.c
+++ b/cpukit/score/src/futex.c
@@ -90,8 +90,7 @@ int _Futex_Wait( struct _Futex_Control *_futex, int *uaddr, int val )
FUTEX_TQ_OPERATIONS,
executing,
STATES_WAITING_FOR_SYS_LOCK_FUTEX,
- 0,
- 0,
+ WATCHDOG_NO_TIMEOUT,
&lock_context
);
eno = 0;
diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c
index 3442bbd2c7..78d8e657fa 100644
--- a/cpukit/score/src/mpci.c
+++ b/cpukit/score/src/mpci.c
@@ -225,11 +225,10 @@ void _MPCI_Send_process_packet (
(*_MPCI_table->send_packet)( destination, the_packet );
}
-uint32_t _MPCI_Send_request_packet (
- uint32_t destination,
- MP_packet_Prefix *the_packet,
- States_Control extra_state,
- uint32_t timeout_code
+Status_Control _MPCI_Send_request_packet(
+ uint32_t destination,
+ MP_packet_Prefix *the_packet,
+ States_Control extra_state
)
{
Per_CPU_Control *cpu_self;
@@ -260,13 +259,12 @@ uint32_t _MPCI_Send_request_packet (
&_Thread_queue_Operations_FIFO,
executing,
STATES_WAITING_FOR_RPC_REPLY | extra_state,
- the_packet->timeout,
- timeout_code
+ the_packet->timeout
);
_Thread_Dispatch_enable( cpu_self );
- return executing->Wait.return_code;
+ return _Thread_Wait_get_status( executing );
}
void _MPCI_Send_response_packet (
diff --git a/cpukit/score/src/mutex.c b/cpukit/score/src/mutex.c
index 0b12232145..28936d6bfc 100644
--- a/cpukit/score/src/mutex.c
+++ b/cpukit/score/src/mutex.c
@@ -119,7 +119,6 @@ static void _Mutex_Acquire_slow(
executing,
STATES_WAITING_FOR_SYS_LOCK_MUTEX,
timeout,
- ETIMEDOUT,
lock_context
);
}
@@ -262,10 +261,9 @@ int _Mutex_Acquire_timed(
break;
}
- executing->Wait.return_code = 0;
_Mutex_Acquire_slow( mutex, owner, executing, ticks, &lock_context );
- return (int) executing->Wait.return_code;
+ return STATUS_GET_POSIX( _Thread_Wait_get_status( executing ) );
}
}
@@ -382,7 +380,6 @@ int _Mutex_recursive_Acquire_timed(
break;
}
- executing->Wait.return_code = 0;
_Mutex_Acquire_slow(
&mutex->Mutex,
owner,
@@ -391,7 +388,7 @@ int _Mutex_recursive_Acquire_timed(
&lock_context
);
- return (int) executing->Wait.return_code;
+ return STATUS_GET_POSIX( _Thread_Wait_get_status( executing ) );
}
}
diff --git a/cpukit/score/src/semaphore.c b/cpukit/score/src/semaphore.c
index 3d0d5f53ab..ea0835d7b5 100644
--- a/cpukit/score/src/semaphore.c
+++ b/cpukit/score/src/semaphore.c
@@ -101,8 +101,7 @@ void _Semaphore_Wait( struct _Semaphore_Control *_sem )
SEMAPHORE_TQ_OPERATIONS,
executing,
STATES_WAITING_FOR_SYS_LOCK_SEMAPHORE,
- 0,
- 0,
+ WATCHDOG_NO_TIMEOUT,
&lock_context
);
}
diff --git a/cpukit/score/src/threadmp.c b/cpukit/score/src/threadmp.c
index 177a60894e..a991d03760 100644
--- a/cpukit/score/src/threadmp.c
+++ b/cpukit/score/src/threadmp.c
@@ -146,7 +146,6 @@ Thread_Control *_Thread_MP_Allocate_proxy (
the_proxy->Wait.return_argument_second = executing->Wait.return_argument_second;
the_proxy->Wait.option = executing->Wait.option;
the_proxy->Wait.return_code = executing->Wait.return_code;
- the_proxy->Wait.timeout_code = executing->Wait.timeout_code;
the_proxy->thread_queue_callout = _Thread_queue_MP_callout_do_nothing;
diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c
index a1a37e1ed1..948275b74c 100644
--- a/cpukit/score/src/threadqenqueue.c
+++ b/cpukit/score/src/threadqenqueue.c
@@ -22,6 +22,7 @@
#include <rtems/score/assert.h>
#include <rtems/score/threaddispatch.h>
#include <rtems/score/threadimpl.h>
+#include <rtems/score/status.h>
#include <rtems/score/watchdogimpl.h>
#define THREAD_QUEUE_INTEND_TO_BLOCK \
@@ -39,7 +40,6 @@ void _Thread_queue_Enqueue_critical(
Thread_Control *the_thread,
States_Control state,
Watchdog_Interval timeout,
- uint32_t timeout_code,
ISR_lock_Context *lock_context
)
{
@@ -54,6 +54,7 @@ void _Thread_queue_Enqueue_critical(
_Thread_Lock_set( the_thread, &queue->Lock );
+ the_thread->Wait.return_code = STATUS_SUCCESSFUL;
_Thread_Wait_set_queue( the_thread, queue );
_Thread_Wait_set_operations( the_thread, operations );
@@ -72,7 +73,6 @@ void _Thread_queue_Enqueue_critical(
* If the thread wants to timeout, then schedule its timer.
*/
if ( timeout != WATCHDOG_NO_TIMEOUT ) {
- _Thread_Wait_set_timeout_code( the_thread, timeout_code );
_Thread_Timer_insert_relative(
the_thread,
cpu_self,
diff --git a/cpukit/score/src/threadqflush.c b/cpukit/score/src/threadqflush.c
index 8b23194357..df2859d51f 100644
--- a/cpukit/score/src/threadqflush.c
+++ b/cpukit/score/src/threadqflush.c
@@ -19,6 +19,7 @@
#endif
#include <rtems/score/threadimpl.h>
+#include <rtems/score/status.h>
Thread_Control *_Thread_queue_Flush_default_filter(
Thread_Control *the_thread,
@@ -31,6 +32,32 @@ Thread_Control *_Thread_queue_Flush_default_filter(
return the_thread;
}
+Thread_Control *_Thread_queue_Flush_status_object_was_deleted(
+ Thread_Control *the_thread,
+ Thread_queue_Queue *queue,
+ Thread_queue_Context *queue_context
+)
+{
+ the_thread->Wait.return_code = STATUS_OBJECT_WAS_DELETED;
+
+ (void) queue;
+ (void) queue_context;
+ return the_thread;
+}
+
+Thread_Control *_Thread_queue_Flush_status_unavailable(
+ Thread_Control *the_thread,
+ Thread_queue_Queue *queue,
+ Thread_queue_Context *queue_context
+)
+{
+ the_thread->Wait.return_code = STATUS_UNAVAILABLE;
+
+ (void) queue;
+ (void) queue_context;
+ return the_thread;
+}
+
size_t _Thread_queue_Flush_critical(
Thread_queue_Queue *queue,
const Thread_queue_Operations *operations,
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index 52d68de69a..f9636e61c7 100644
--- a/cpukit/score/src/threadrestart.c
+++ b/cpukit/score/src/threadrestart.c
@@ -443,17 +443,16 @@ static void _Thread_Finalize_life_change(
}
void _Thread_Join(
- Thread_Control *the_thread,
- States_Control waiting_for_join,
- Thread_Control *executing,
- ISR_lock_Context *lock_context
+ Thread_Control *the_thread,
+ States_Control waiting_for_join,
+ Thread_Control *executing,
+ ISR_lock_Context *lock_context
)
{
_Assert( the_thread != executing );
_Assert( _Thread_State_is_owner( the_thread ) );
#if defined(RTEMS_POSIX_API)
- executing->Wait.return_code = 0;
executing->Wait.return_argument = NULL;
#endif
@@ -463,7 +462,6 @@ void _Thread_Join(
executing,
waiting_for_join,
WATCHDOG_NO_TIMEOUT,
- 0,
lock_context
);
}
diff --git a/cpukit/score/src/threadtimeout.c b/cpukit/score/src/threadtimeout.c
index 59f6bd97f0..9b5cfa637d 100644
--- a/cpukit/score/src/threadtimeout.c
+++ b/cpukit/score/src/threadtimeout.c
@@ -20,10 +20,11 @@
#endif
#include <rtems/score/threadimpl.h>
+#include <rtems/score/status.h>
static void _Thread_Do_timeout( Thread_Control *the_thread )
{
- the_thread->Wait.return_code = the_thread->Wait.timeout_code;
+ the_thread->Wait.return_code = STATUS_TIMEOUT;
( *the_thread->Wait.operations->extract )(
the_thread->Wait.queue,
the_thread