20 #ifndef _RTEMS_SCORE_SMPLOCK_H 21 #define _RTEMS_SCORE_SMPLOCK_H 23 #include <rtems/score/cpuopts.h> 43 #if defined(RTEMS_SMP) 49 #if defined(RTEMS_DEBUG) 50 #include <rtems/score/assert.h> 58 #if defined(RTEMS_DEBUG) || defined(RTEMS_PROFILING) 59 #define RTEMS_SMP_LOCK_DO_NOT_INLINE 66 SMP_ticket_lock_Control Ticket_lock;
67 #if defined(RTEMS_DEBUG) 82 #if defined(RTEMS_PROFILING) 92 #if defined(RTEMS_DEBUG) 93 SMP_lock_Control *lock_used_for_acquire;
95 #if defined(RTEMS_PROFILING) 96 SMP_lock_Stats_context Stats_context;
100 #if defined(RTEMS_DEBUG) 101 #define SMP_LOCK_NO_OWNER 0 107 #if defined(RTEMS_DEBUG) && defined(RTEMS_PROFILING) 108 #define SMP_LOCK_INITIALIZER( name ) \ 110 SMP_TICKET_LOCK_INITIALIZER, \ 112 SMP_LOCK_STATS_INITIALIZER( name ) \ 114 #elif defined(RTEMS_DEBUG) 115 #define SMP_LOCK_INITIALIZER( name ) \ 116 { SMP_TICKET_LOCK_INITIALIZER, SMP_LOCK_NO_OWNER } 117 #elif defined(RTEMS_PROFILING) 118 #define SMP_LOCK_INITIALIZER( name ) \ 119 { SMP_TICKET_LOCK_INITIALIZER, SMP_LOCK_STATS_INITIALIZER( name ) } 121 #define SMP_LOCK_INITIALIZER( name ) { SMP_TICKET_LOCK_INITIALIZER } 124 static inline void _SMP_lock_Initialize_inline(
125 SMP_lock_Control *lock,
129 _SMP_ticket_lock_Initialize( &lock->Ticket_lock );
130 #if defined(RTEMS_DEBUG) 131 lock->owner = SMP_LOCK_NO_OWNER;
133 #if defined(RTEMS_PROFILING) 134 _SMP_lock_Stats_initialize( &lock->Stats, name );
149 #if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) 150 void _SMP_lock_Initialize(
151 SMP_lock_Control *lock,
155 #define _SMP_lock_Initialize( lock, name ) \ 156 _SMP_lock_Initialize_inline( lock, name ) 159 static inline void _SMP_lock_Destroy_inline( SMP_lock_Control *lock )
161 _SMP_ticket_lock_Destroy( &lock->Ticket_lock );
162 _SMP_lock_Stats_destroy( &lock->Stats );
172 #if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) 173 void _SMP_lock_Destroy( SMP_lock_Control *lock );
175 #define _SMP_lock_Destroy( lock ) \ 176 _SMP_lock_Destroy_inline( lock ) 179 #if defined(RTEMS_DEBUG) 180 static inline uint32_t _SMP_lock_Who_am_I(
void )
186 return _SMP_Get_current_processor() + 1;
190 static inline void _SMP_lock_Acquire_inline(
191 SMP_lock_Control *lock,
195 #if defined(RTEMS_DEBUG) 196 context->lock_used_for_acquire = lock;
200 _SMP_ticket_lock_Acquire(
203 &context->Stats_context
205 #if defined(RTEMS_DEBUG) 206 lock->owner = _SMP_lock_Who_am_I();
221 void _SMP_lock_Acquire(
222 SMP_lock_Control *lock,
226 static inline void _SMP_lock_Release_inline(
227 SMP_lock_Control *lock,
231 #if defined(RTEMS_DEBUG) 232 _Assert( context->lock_used_for_acquire == lock );
233 context->lock_used_for_acquire =
NULL;
234 _Assert( lock->owner == _SMP_lock_Who_am_I() );
235 lock->owner = SMP_LOCK_NO_OWNER;
239 _SMP_ticket_lock_Release(
241 &context->Stats_context
252 #if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) 253 void _SMP_lock_Release(
254 SMP_lock_Control *lock,
255 SMP_lock_Context *context
258 #define _SMP_lock_Release( lock, context ) \ 259 _SMP_lock_Release_inline( lock, context ) 262 static inline void _SMP_lock_ISR_disable_and_acquire_inline(
263 SMP_lock_Control *lock,
264 SMP_lock_Context *context
268 _SMP_lock_Acquire_inline( lock, context );
278 void _SMP_lock_ISR_disable_and_acquire(
279 SMP_lock_Control *lock,
280 SMP_lock_Context *context
283 static inline void _SMP_lock_Release_and_ISR_enable_inline(
284 SMP_lock_Control *lock,
285 SMP_lock_Context *context
288 _SMP_lock_Release_inline( lock, context );
299 #if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) 300 void _SMP_lock_Release_and_ISR_enable(
301 SMP_lock_Control *lock,
302 SMP_lock_Context *context
305 #define _SMP_lock_Release_and_ISR_enable( lock, context ) \ 306 _SMP_lock_Release_and_ISR_enable_inline( lock, context ) 309 #if defined(RTEMS_DEBUG) 316 bool _SMP_lock_Is_owner(
const SMP_lock_Control *lock );
SuperCore SMP Support API.
#define _ISR_Local_disable(_level)
Disables interrupts on this processor.
Definition: isrlevel.h:54
uint32_t ISR_Level
Definition: isrlevel.h:38
#define _ISR_Local_enable(_level)
Enables interrupts on this processor.
Definition: isrlevel.h:71
unsigned context
Definition: tlb.h:108
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77