RTEMS 6.1-rc5
Loading...
Searching...
No Matches
semimpl.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
12/* COPYRIGHT (c) 1989-2008.
13 * On-Line Applications Research Corporation (OAR).
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef _RTEMS_RTEMS_SEMIMPL_H
38#define _RTEMS_RTEMS_SEMIMPL_H
39
40#include <rtems/rtems/semdata.h>
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
64typedef enum {
65 SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY,
66 SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING,
67 SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL,
68 SEMAPHORE_VARIANT_SIMPLE_BINARY,
69 SEMAPHORE_VARIANT_COUNTING
70#if defined(RTEMS_SMP)
71 ,
72 SEMAPHORE_VARIANT_MRSP
73#endif
75
76typedef enum {
77 SEMAPHORE_DISCIPLINE_PRIORITY,
78 SEMAPHORE_DISCIPLINE_FIFO
79} Semaphore_Discipline;
80
81static inline uintptr_t _Semaphore_Get_flags(
82 const Semaphore_Control *the_semaphore
83)
84{
85 _Assert( _Chain_Is_node_off_chain( &the_semaphore->Object.Node ) );
86 return (uintptr_t) the_semaphore->Object.Node.previous;
87}
88
89static inline void _Semaphore_Set_flags(
90 Semaphore_Control *the_semaphore,
91 uintptr_t flags
92)
93{
94 _Assert( _Chain_Is_node_off_chain( &the_semaphore->Object.Node ) );
95 the_semaphore->Object.Node.previous = (Chain_Node *) flags;
96}
97
98static inline Semaphore_Variant _Semaphore_Get_variant(
99 uintptr_t flags
100)
101{
102 return (Semaphore_Variant) ( flags & 0x7 );
103}
104
105static inline uintptr_t _Semaphore_Set_variant(
106 uintptr_t flags,
107 Semaphore_Variant variant
108)
109{
110 return flags | variant;
111}
112
113static inline Semaphore_Discipline _Semaphore_Get_discipline(
114 uintptr_t flags
115)
116{
117 return (Semaphore_Discipline) ( ( flags >> 3 ) & 0x1 );
118}
119
120static inline uintptr_t _Semaphore_Set_discipline(
121 uintptr_t flags,
122 Semaphore_Discipline discipline
123)
124{
125 return flags | ( discipline << 3 );
126}
127
128#if defined(RTEMS_MULTIPROCESSING)
129static inline bool _Semaphore_Is_global(
130 uintptr_t flags
131)
132{
133 return ( flags & 0x10 ) != 0;
134}
135
136static inline uintptr_t _Semaphore_Make_global( uintptr_t flags )
137{
138 return flags | 0x10;
139}
140#endif
141
142static inline const Thread_queue_Operations *_Semaphore_Get_operations(
143 uintptr_t flags
144)
145{
146 if (
147 _Semaphore_Get_variant( flags ) == SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY
148 ) {
150 }
151
152 if ( _Semaphore_Get_discipline( flags ) == SEMAPHORE_DISCIPLINE_PRIORITY ) {
154 }
155
157}
158
166static inline Semaphore_Control *_Semaphore_Allocate( void )
167{
169}
170
178static inline void _Semaphore_Free (
179 Semaphore_Control *the_semaphore
180)
181{
182 _Objects_Free( &_Semaphore_Information, &the_semaphore->Object );
183}
184
185static inline Semaphore_Control *_Semaphore_Get(
186 Objects_Id id,
187 Thread_queue_Context *queue_context
188)
189{
190 _Thread_queue_Context_initialize( queue_context );
192 id,
193 &queue_context->Lock_context.Lock_context,
195 );
196}
197
200#ifdef __cplusplus
201}
202#endif
203
204#ifdef RTEMS_MULTIPROCESSING
205#include <rtems/rtems/semmp.h>
206#endif
207
208#endif
209/* end of include file */
This header file provides interfaces of the Mutex Handler which are only used by the implementation.
This header file provides interfaces of the Semaphore Handler which are only used by the implementati...
Objects_Information _Semaphore_Information
The Classic Semaphore objects information.
Semaphore_Variant
Classic semaphore variants.
Definition: semimpl.h:64
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG and static analysis runs.
Definition: assert.h:96
Objects_Control * _Objects_Allocate(Objects_Information *information)
Allocates an object.
Definition: objectallocate.c:43
uint32_t Objects_Id
Definition: object.h:101
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:43
const Thread_queue_Operations _Thread_queue_Operations_priority
The FIFO thread queue operations are used when a thread is enqueued on a thread queue and provide pri...
Definition: threadqops.c:1517
const Thread_queue_Operations _Thread_queue_Operations_FIFO
The FIFO thread queue operations are used when a thread is enqueued on a thread queue and provide FIF...
Definition: threadqops.c:1509
const Thread_queue_Operations _Thread_queue_Operations_priority_inherit
The FIFO thread queue operations are used when a thread is enqueued on a thread queue and provide pri...
Definition: threadqops.c:1525
This header file provides interfaces of the Multiprocessor Resource Sharing Protocol (MrsP) which are...
This header file provides data structures used by the implementation and the Application Configuratio...
This header file provides the implementation interfaces of the Semaphore Manager Multiprocessing (MP)...
This structure represents a chain node.
Definition: chain.h:78
struct Chain_Node * previous
Definition: chain.h:82
Chain_Node Node
Definition: objectdata.h:63
Definition: semdata.h:60
Objects_Control Object
The object management portion of a semaphore instance.
Definition: semdata.h:70
Thread queue context for the thread queue methods.
Definition: threadq.h:216
Thread_queue_Lock_context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:221
ISR_lock_Context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:148
The thread queue operations are used to manage the threads of a thread queue.
Definition: threadq.h:554