diff options
Diffstat (limited to 'cpukit/rtems/include/rtems')
-rw-r--r-- | cpukit/rtems/include/rtems/rtems/attr.h | 14 | ||||
-rw-r--r-- | cpukit/rtems/include/rtems/rtems/attrimpl.h | 31 | ||||
-rw-r--r-- | cpukit/rtems/include/rtems/rtems/sem.h | 46 | ||||
-rw-r--r-- | cpukit/rtems/include/rtems/rtems/semimpl.h | 9 |
4 files changed, 100 insertions, 0 deletions
diff --git a/cpukit/rtems/include/rtems/rtems/attr.h b/cpukit/rtems/include/rtems/rtems/attr.h index d326539714..7e8fa4818a 100644 --- a/cpukit/rtems/include/rtems/rtems/attr.h +++ b/cpukit/rtems/include/rtems/rtems/attr.h @@ -139,6 +139,20 @@ typedef uint32_t rtems_attribute; */ #define RTEMS_PRIORITY_CEILING 0x00000080 +/** + * This attribute constant indicates that the Classic API Semaphore instance + * created will NOT use the Multiprocessor Resource Sharing Protocol. + */ +#define RTEMS_NO_MULTIPROCESSOR_RESOURCE_SHARING 0x00000000 + +/** + * This attribute constant indicates that the Classic API Semaphore instance + * created will use the Multiprocessor Resource Sharing Protocol. + * + * @note The semaphore instance must be a binary semaphore. + */ +#define RTEMS_MULTIPROCESSOR_RESOURCE_SHARING 0x00000100 + /******************** RTEMS Barrier Specific Attributes ********************/ /** diff --git a/cpukit/rtems/include/rtems/rtems/attrimpl.h b/cpukit/rtems/include/rtems/rtems/attrimpl.h index 0f78c44672..a32c37096d 100644 --- a/cpukit/rtems/include/rtems/rtems/attrimpl.h +++ b/cpukit/rtems/include/rtems/rtems/attrimpl.h @@ -185,6 +185,23 @@ RTEMS_INLINE_ROUTINE bool _Attributes_Is_inherit_priority( } /** + * @brief Returns true if the attribute set has at most one protocol, and false + * otherwise. + * + * The protocols are RTEMS_INHERIT_PRIORITY, RTEMS_PRIORITY_CEILING and + * RTEMS_MULTIPROCESSOR_RESOURCE_SHARING. + */ +RTEMS_INLINE_ROUTINE bool _Attributes_Has_at_most_one_protocol( + rtems_attribute attribute_set +) +{ + attribute_set &= RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY_CEILING + | RTEMS_MULTIPROCESSOR_RESOURCE_SHARING; + + return ( attribute_set & ( attribute_set - 1 ) ) == 0; +} + +/** * @brief Checks if the priority ceiling attribute * is enabled in the attribute_set * @@ -199,6 +216,20 @@ RTEMS_INLINE_ROUTINE bool _Attributes_Is_priority_ceiling( } /** + * @brief Checks if the Multiprocessor Resource Sharing Protocol attribute + * is enabled in the attribute_set + * + * This function returns TRUE if the Multiprocessor Resource Sharing Protocol + * attribute is enabled in the attribute_set and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Attributes_Is_multiprocessor_resource_sharing( + rtems_attribute attribute_set +) +{ + return ( attribute_set & RTEMS_MULTIPROCESSOR_RESOURCE_SHARING ) != 0; +} + +/** * @brief Checks if the barrier automatic release * attribute is enabled in the attribute_set * diff --git a/cpukit/rtems/include/rtems/rtems/sem.h b/cpukit/rtems/include/rtems/rtems/sem.h index 782314d163..2442010113 100644 --- a/cpukit/rtems/include/rtems/rtems/sem.h +++ b/cpukit/rtems/include/rtems/rtems/sem.h @@ -38,6 +38,7 @@ #include <rtems/score/coremutex.h> #include <rtems/score/object.h> #include <rtems/score/coresem.h> +#include <rtems/score/mrsp.h> #ifdef __cplusplus extern "C" { @@ -88,6 +89,10 @@ typedef struct { * API Semaphore instance. */ CORE_semaphore_Control semaphore; + +#if defined(RTEMS_SMP) + MRSP_Control mrsp; +#endif } Core_control; } Semaphore_Control; @@ -208,6 +213,47 @@ rtems_status_code rtems_semaphore_flush( rtems_id id ); +/** + * @brief Sets the priority value with respect to the specified scheduler of a + * semaphore. + * + * The special priority value @ref RTEMS_CURRENT_PRIORITY can be used to get + * the current priority value without changing it. + * + * The interpretation of the priority value depends on the protocol of the + * semaphore object. + * + * - The Multiprocessor Resource Sharing Protocol needs a ceiling priority per + * scheduler instance. This operation can be used to specify these priority + * values. + * - For the Priority Ceiling Protocol the ceiling priority is used with this + * operation. + * - For other protocols this operation is not defined. + * + * @param[in] semaphore_id Identifier of the semaphore. + * @param[in] scheduler_id Identifier of the scheduler. + * @param[in] new_priority The new priority value. Use + * @ref RTEMS_CURRENT_PRIORITY to not set a new priority and only get the + * current priority. + * @param[out] old_priority Reference to store the old priority value. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ID Invalid semaphore or scheduler identifier. + * @retval RTEMS_INVALID_ADDRESS The old priority reference is @c NULL. + * @retval RTEMS_INVALID_PRIORITY The new priority value is invalid. + * @retval RTEMS_NOT_DEFINED The set priority operation is not defined for the + * protocol of this semaphore object. + * @retval RTEMS_ILLEGAL_ON_REMOTE_OBJECT Not supported for remote semaphores. + * + * @see rtems_scheduler_ident() and rtems_task_set_priority(). + */ +rtems_status_code rtems_semaphore_set_priority( + rtems_id semaphore_id, + rtems_id scheduler_id, + rtems_task_priority new_priority, + rtems_task_priority *old_priority +); + /**@}*/ #ifdef __cplusplus diff --git a/cpukit/rtems/include/rtems/rtems/semimpl.h b/cpukit/rtems/include/rtems/rtems/semimpl.h index 51da4cdbcf..e0a35a2e33 100644 --- a/cpukit/rtems/include/rtems/rtems/semimpl.h +++ b/cpukit/rtems/include/rtems/rtems/semimpl.h @@ -20,6 +20,7 @@ #include <rtems/rtems/sem.h> #include <rtems/score/coremuteximpl.h> #include <rtems/score/coresemimpl.h> +#include <rtems/score/mrspimpl.h> #ifdef __cplusplus extern "C" { @@ -92,6 +93,14 @@ _Semaphore_Translate_core_mutex_return_code( return _Semaphore_Translate_core_mutex_return_code_[status]; } +#if defined(RTEMS_SMP) +RTEMS_INLINE_ROUTINE rtems_status_code +_Semaphore_Translate_MRSP_status_code( MRSP_Status mrsp_status ) +{ + return (rtems_status_code) mrsp_status; +} +#endif + /** * @brief Semaphore Translate Core Semaphore Return Code * |