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) 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 } 129 static inline void _SMP_lock_Initialize_inline(
130 SMP_lock_Control *lock,
134 _SMP_ticket_lock_Initialize( &lock->Ticket_lock );
135 #if defined(RTEMS_DEBUG) 136 lock->owner = SMP_LOCK_NO_OWNER;
138 #if defined(RTEMS_PROFILING) 139 _SMP_lock_Stats_initialize( &lock->Stats, name );
154 #if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) 155 void _SMP_lock_Initialize(
156 SMP_lock_Control *lock,
160 #define _SMP_lock_Initialize( lock, name ) \ 161 _SMP_lock_Initialize_inline( lock, name ) 169 static inline void _SMP_lock_Destroy_inline( SMP_lock_Control *lock )
171 _SMP_ticket_lock_Destroy( &lock->Ticket_lock );
172 _SMP_lock_Stats_destroy( &lock->Stats );
182 #if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) 183 void _SMP_lock_Destroy( SMP_lock_Control *lock );
185 #define _SMP_lock_Destroy( lock ) \ 186 _SMP_lock_Destroy_inline( lock ) 196 static inline void _SMP_lock_Set_name(
197 SMP_lock_Control *lock,
201 #if defined(RTEMS_PROFILING) 202 lock->Stats.name = name;
213 #if defined(RTEMS_DEBUG) 214 static inline uint32_t _SMP_lock_Who_am_I(
void )
220 return _SMP_Get_current_processor() + 1;
230 static inline void _SMP_lock_Acquire_inline(
231 SMP_lock_Control *lock,
235 #if defined(RTEMS_DEBUG) 236 context->lock_used_for_acquire = lock;
240 _SMP_ticket_lock_Acquire(
245 #if defined(RTEMS_DEBUG) 246 lock->owner = _SMP_lock_Who_am_I();
261 void _SMP_lock_Acquire(
262 SMP_lock_Control *lock,
272 static inline void _SMP_lock_Release_inline(
273 SMP_lock_Control *lock,
277 #if defined(RTEMS_DEBUG) 280 _Assert( lock->owner == _SMP_lock_Who_am_I() );
281 lock->owner = SMP_LOCK_NO_OWNER;
285 _SMP_ticket_lock_Release(
298 #if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) 299 void _SMP_lock_Release(
300 SMP_lock_Control *lock,
304 #define _SMP_lock_Release( lock, context ) \ 305 _SMP_lock_Release_inline( lock, context ) 314 static inline void _SMP_lock_ISR_disable_and_acquire_inline(
315 SMP_lock_Control *lock,
320 _SMP_lock_Acquire_inline( lock,
context );
330 void _SMP_lock_ISR_disable_and_acquire(
331 SMP_lock_Control *lock,
341 static inline void _SMP_lock_Release_and_ISR_enable_inline(
342 SMP_lock_Control *lock,
346 _SMP_lock_Release_inline( lock,
context );
357 #if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) 358 void _SMP_lock_Release_and_ISR_enable(
359 SMP_lock_Control *lock,
363 #define _SMP_lock_Release_and_ISR_enable( lock, context ) \ 364 _SMP_lock_Release_and_ISR_enable_inline( lock, context ) 367 #if defined(RTEMS_DEBUG) 376 bool _SMP_lock_Is_owner(
const SMP_lock_Control *lock );
#define _ISR_Local_disable(_level)
Disables interrupts on this processor.
Definition: isrlevel.h:57
SuperCore SMP Support API.
Information for the Assert Handler.
uint32_t ISR_Level
Definition: isrlevel.h:41
#define _ISR_Local_enable(_level)
Enables interrupts on this processor.
Definition: isrlevel.h:74
unsigned context
Definition: tlb.h:108
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
Definition: assert.h:100
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77