40#ifndef _RTEMS_SCORE_SMPLOCK_H
41#define _RTEMS_SCORE_SMPLOCK_H
43#include <rtems/score/cpuopts.h>
70#if defined(RTEMS_DEBUG)
79#if defined(RTEMS_DEBUG) || defined(RTEMS_PROFILING)
80#define RTEMS_SMP_LOCK_DO_NOT_INLINE
87 SMP_ticket_lock_Control Ticket_lock;
88#if defined(RTEMS_DEBUG)
103#if defined(RTEMS_PROFILING)
104 SMP_lock_Stats Stats;
113#if defined(RTEMS_DEBUG)
114 SMP_lock_Control *lock_used_for_acquire;
116#if defined(RTEMS_PROFILING)
117 SMP_lock_Stats_context Stats_context;
121#if defined(RTEMS_DEBUG)
122#define SMP_LOCK_NO_OWNER 0
128#if defined(RTEMS_DEBUG) && defined(RTEMS_PROFILING)
129 #define SMP_LOCK_INITIALIZER( name ) \
131 SMP_TICKET_LOCK_INITIALIZER, \
133 SMP_LOCK_STATS_INITIALIZER( name ) \
135#elif defined(RTEMS_DEBUG)
136 #define SMP_LOCK_INITIALIZER( name ) \
137 { SMP_TICKET_LOCK_INITIALIZER, SMP_LOCK_NO_OWNER }
138#elif defined(RTEMS_PROFILING)
139 #define SMP_LOCK_INITIALIZER( name ) \
140 { SMP_TICKET_LOCK_INITIALIZER, SMP_LOCK_STATS_INITIALIZER( name ) }
142 #define SMP_LOCK_INITIALIZER( name ) { SMP_TICKET_LOCK_INITIALIZER }
150static inline void _SMP_lock_Initialize_inline(
151 SMP_lock_Control *lock,
155 _SMP_ticket_lock_Initialize( &lock->Ticket_lock );
156#if defined(RTEMS_DEBUG)
157 lock->owner = SMP_LOCK_NO_OWNER;
159#if defined(RTEMS_PROFILING)
160 _SMP_lock_Stats_initialize( &lock->Stats, name );
175#if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE)
176void _SMP_lock_Initialize(
177 SMP_lock_Control *lock,
181#define _SMP_lock_Initialize( lock, name ) \
182 _SMP_lock_Initialize_inline( lock, name )
190static inline void _SMP_lock_Destroy_inline( SMP_lock_Control *lock )
192 _SMP_ticket_lock_Destroy( &lock->Ticket_lock );
193 _SMP_lock_Stats_destroy( &lock->Stats );
203#if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE)
204void _SMP_lock_Destroy( SMP_lock_Control *lock );
206#define _SMP_lock_Destroy( lock ) \
207 _SMP_lock_Destroy_inline( lock )
217static inline void _SMP_lock_Set_name(
218 SMP_lock_Control *lock,
222#if defined(RTEMS_PROFILING)
223 lock->Stats.name = name;
235#if defined(RTEMS_DEBUG)
236static inline uint32_t _SMP_lock_Who_am_I(
void )
242 return _SMP_Get_current_processor() + 1;
252static inline void _SMP_lock_Acquire_inline(
253 SMP_lock_Control *lock,
257#if defined(RTEMS_DEBUG)
258 context->lock_used_for_acquire = lock;
262 _SMP_ticket_lock_Acquire(
267#if defined(RTEMS_DEBUG)
268 lock->owner = _SMP_lock_Who_am_I();
283void _SMP_lock_Acquire(
284 SMP_lock_Control *lock,
294static inline void _SMP_lock_Release_inline(
295 SMP_lock_Control *lock,
299#if defined(RTEMS_DEBUG)
301 context->lock_used_for_acquire = NULL;
302 _Assert( lock->owner == _SMP_lock_Who_am_I() );
303 lock->owner = SMP_LOCK_NO_OWNER;
307 _SMP_ticket_lock_Release(
320#if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE)
321void _SMP_lock_Release(
322 SMP_lock_Control *lock,
326#define _SMP_lock_Release( lock, context ) \
327 _SMP_lock_Release_inline( lock, context )
336static inline void _SMP_lock_ISR_disable_and_acquire_inline(
337 SMP_lock_Control *lock,
342 _SMP_lock_Acquire_inline( lock,
context );
352void _SMP_lock_ISR_disable_and_acquire(
353 SMP_lock_Control *lock,
363static inline void _SMP_lock_Release_and_ISR_enable_inline(
364 SMP_lock_Control *lock,
368 _SMP_lock_Release_inline( lock,
context );
379#if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE)
380void _SMP_lock_Release_and_ISR_enable(
381 SMP_lock_Control *lock,
385#define _SMP_lock_Release_and_ISR_enable( lock, context ) \
386 _SMP_lock_Release_and_ISR_enable_inline( lock, context )
389#if defined(RTEMS_DEBUG)
398bool _SMP_lock_Is_owner(
const SMP_lock_Control *lock );
This header file provides the interfaces of the Assert Handler.
This header file provides interfaces of the SMP Support which are used by the implementation and the ...
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG and static analysis runs.
Definition: assert.h:96
#define _ISR_Local_disable(_level)
Disables interrupts on this processor.
Definition: isrlevel.h:76
#define _ISR_Local_enable(_level)
Enables interrupts on this processor.
Definition: isrlevel.h:93
uint32_t ISR_Level
Definition: isrlevel.h:60
This header file provides the ISR_Level related interfaces of the ISR Handler.
rtems_termios_device_context * context
Definition: console-config.c:62
This header file provides the interfaces of the SMP Locks related to lock statistics.
This header file provides the interfaces of the SMP Locks related to ticket locks.