RTEMS: cpukit/include/rtems/rtems/semimpl.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
semimpl.h
Go to the documentation of this file.
1
9/* COPYRIGHT (c) 1989-2008.
10 * On-Line Applications Research Corporation (OAR).
11 *
12 * The license and distribution terms for this file may be
13 * found in the file LICENSE in this distribution or at
14 * http://www.rtems.org/license/LICENSE.
15 */
16
17#ifndef _RTEMS_RTEMS_SEMIMPL_H
18#define _RTEMS_RTEMS_SEMIMPL_H
19
20#include <rtems/rtems/semdata.h>
21#include <rtems/score/coremuteximpl.h>
22#include <rtems/score/coresemimpl.h>
23#include <rtems/score/mrspimpl.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
42 typedef enum {
43 SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY,
44 SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING,
45 SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL,
46 SEMAPHORE_VARIANT_SIMPLE_BINARY,
47 SEMAPHORE_VARIANT_COUNTING
48#if defined(RTEMS_SMP)
49 ,
50 SEMAPHORE_VARIANT_MRSP
51#endif
52} Semaphore_Variant;
53
54typedef enum {
55 SEMAPHORE_DISCIPLINE_PRIORITY,
56 SEMAPHORE_DISCIPLINE_FIFO
57} Semaphore_Discipline;
58
59 RTEMS_INLINE_ROUTINE uintptr_t _Semaphore_Get_flags(
60 const Semaphore_Control *the_semaphore
61)
62{
63 _Assert( _Chain_Is_node_off_chain( &the_semaphore->Object.Node ) );
64 return (uintptr_t) the_semaphore->Object.Node.previous;
65}
66
67 RTEMS_INLINE_ROUTINE void _Semaphore_Set_flags(
68 Semaphore_Control *the_semaphore,
69 uintptr_t flags
70)
71{
72 _Assert( _Chain_Is_node_off_chain( &the_semaphore->Object.Node ) );
73 the_semaphore->Object.Node.previous = (Chain_Node *) flags;
74}
75
76 RTEMS_INLINE_ROUTINE Semaphore_Variant _Semaphore_Get_variant(
77 uintptr_t flags
78)
79{
80 return (Semaphore_Discipline) ( flags & 0x7 );
81}
82
83 RTEMS_INLINE_ROUTINE uintptr_t _Semaphore_Set_variant(
84 uintptr_t flags,
85 Semaphore_Variant variant
86)
87{
88 return flags | variant;
89}
90
91 RTEMS_INLINE_ROUTINE Semaphore_Discipline _Semaphore_Get_discipline(
92 uintptr_t flags
93)
94{
95 return (Semaphore_Discipline) ( ( flags >> 3 ) & 0x1 );
96}
97
98 RTEMS_INLINE_ROUTINE uintptr_t _Semaphore_Set_discipline(
99 uintptr_t flags,
100 Semaphore_Discipline discipline
101)
102{
103 return flags | ( discipline << 3 );
104}
105
106#if defined(RTEMS_MULTIPROCESSING)
107 RTEMS_INLINE_ROUTINE bool _Semaphore_Is_global(
108 uintptr_t flags
109)
110{
111 return ( flags & 0x10 ) != 0;
112}
113
114 RTEMS_INLINE_ROUTINE uintptr_t _Semaphore_Make_global( uintptr_t flags )
115{
116 return flags | 0x10;
117}
118#endif
119
120 RTEMS_INLINE_ROUTINE const Thread_queue_Operations *_Semaphore_Get_operations(
121 uintptr_t flags
122)
123{
124 if (
125 _Semaphore_Get_variant( flags ) == SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY
126 ) {
127 return &_Thread_queue_Operations_priority_inherit;
128 }
129
130 if ( _Semaphore_Get_discipline( flags ) == SEMAPHORE_DISCIPLINE_PRIORITY ) {
131 return &_Thread_queue_Operations_priority;
132 }
133
134 return &_Thread_queue_Operations_FIFO;
135}
136
144 RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Allocate( void )
145{
146 return (Semaphore_Control *) _Objects_Allocate( &_Semaphore_Information );
147}
148
156 RTEMS_INLINE_ROUTINE void _Semaphore_Free (
157 Semaphore_Control *the_semaphore
158)
159{
160 _Objects_Free( &_Semaphore_Information, &the_semaphore->Object );
161}
162
163 RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Get(
164 Objects_Id id,
165 Thread_queue_Context *queue_context
166)
167{
168 _Thread_queue_Context_initialize( queue_context );
169 return (Semaphore_Control *) _Objects_Get(
170 id,
171 &queue_context->Lock_context.Lock_context,
172 &_Semaphore_Information
173 );
174}
175
178#ifdef __cplusplus
179}
180#endif
181
182#ifdef RTEMS_MULTIPROCESSING
183#include <rtems/rtems/semmp.h>
184#endif
185
186#endif
187/* end of include file */
coremuteximpl.h
CORE Mutex Implementation.
coresemimpl.h
Inlined Routines Associated with the SuperCore Semaphore.
_Semaphore_Information
Objects_Information _Semaphore_Information
The Classic Semaphore objects information.
Semaphore_Variant
Semaphore_Variant
Classic semaphore variants.
Definition: semimpl.h:42
_Semaphore_Allocate
RTEMS_INLINE_ROUTINE Semaphore_Control * _Semaphore_Allocate(void)
Allocates a semaphore control block from the inactive chain of free semaphore control blocks.
Definition: semimpl.h:144
_Semaphore_Free
RTEMS_INLINE_ROUTINE void _Semaphore_Free(Semaphore_Control *the_semaphore)
Frees a semaphore control block to the inactive chain of free semaphore control blocks.
Definition: semimpl.h:156
_Assert
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
Definition: assert.h:100
RTEMS_INLINE_ROUTINE
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
_Chain_Is_node_off_chain
RTEMS_INLINE_ROUTINE bool _Chain_Is_node_off_chain(const Chain_Node *node)
Checks if the node is off chain.
Definition: chainimpl.h:142
_Objects_Free
RTEMS_INLINE_ROUTINE void _Objects_Free(Objects_Information *information, Objects_Control *the_object)
Frees an object.
Definition: objectimpl.h:930
_Objects_Allocate
Objects_Control * _Objects_Allocate(Objects_Information *information)
Allocates an object.
Definition: objectallocate.c:42
Objects_Id
uint32_t Objects_Id
Definition: object.h:80
_Objects_Get
Objects_Control * _Objects_Get(Objects_Id id, ISR_lock_Context *lock_context, const Objects_Information *information)
Maps the specified object identifier to the associated local object control block.
Definition: objectgetlocal.c:28
_Thread_queue_Context_initialize
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_initialize(Thread_queue_Context *queue_context)
Initializes a thread queue context.
Definition: threadqimpl.h:152
mrspimpl.h
Definitions for Multiprocessor Resource Sharing Protocol (MrsP) Implementation.
semdata.h
Classic Semaphore Manager Data Structures.
semmp.h
Chain_Node_struct
Definition: chain.h:68
Chain_Node_struct::previous
Chain_Node * previous
Definition: chain.h:72
Objects_Control::Node
Chain_Node Node
Definition: objectdata.h:41
Semaphore_Control
Definition: semdata.h:40
Semaphore_Control::Object
Objects_Control Object
The object management portion of a semaphore instance.
Definition: semdata.h:50
Thread_queue_Context
Thread queue context for the thread queue methods.
Definition: threadq.h:198
Thread_queue_Context::Lock_context
Thread_queue_Lock_context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:203
Thread_queue_Lock_context::Lock_context
ISR_lock_Context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:130
Thread_queue_Operations
Thread queue operations.
Definition: threadq.h:518