RTEMS CPU Kit with SuperCore  4.11.2
isrlock.h
Go to the documentation of this file.
1 
9 /*
10  * Copyright (c) 2013-2015 embedded brains GmbH. All rights reserved.
11  *
12  * embedded brains GmbH
13  * Dornierstr. 4
14  * 82178 Puchheim
15  * Germany
16  * <rtems@embedded-brains.de>
17  *
18  * The license and distribution terms for this file may be
19  * found in the file LICENSE in this distribution or at
20  * http://www.rtems.org/license/LICENSE.
21  */
22 
23 #ifndef _RTEMS_SCORE_ISR_LOCK_H
24 #define _RTEMS_SCORE_ISR_LOCK_H
25 
26 #include <rtems/score/isrlevel.h>
27 #include <rtems/score/smplock.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
56 typedef struct {
57 #if defined( RTEMS_SMP )
58  SMP_lock_Control Lock;
59 #endif
61 
65 typedef struct {
66 #if defined( RTEMS_SMP )
67  SMP_lock_Context Lock_context;
68 #else
69  ISR_Level isr_level;
70 #endif
71 #if defined( RTEMS_PROFILING )
72 
75  CPU_Counter_ticks ISR_disable_instant;
76 #endif
78 
86 #if defined( RTEMS_SMP )
87  #define ISR_LOCK_MEMBER( _designator ) ISR_lock_Control _designator;
88 #else
89  #define ISR_LOCK_MEMBER( _designator )
90 #endif
91 
100 #if defined( RTEMS_SMP )
101  #define ISR_LOCK_DECLARE( _qualifier, _designator ) \
102  _qualifier ISR_lock_Control _designator;
103 #else
104  #define ISR_LOCK_DECLARE( _qualifier, _designator )
105 #endif
106 
117 #if defined( RTEMS_SMP )
118  #define ISR_LOCK_DEFINE( _qualifier, _designator, _name ) \
119  _qualifier ISR_lock_Control _designator = { SMP_LOCK_INITIALIZER( _name ) };
120 #else
121  #define ISR_LOCK_DEFINE( _qualifier, _designator, _name )
122 #endif
123 
132 #if defined( RTEMS_SMP )
133  #define ISR_LOCK_REFERENCE( _designator, _target ) \
134  ISR_lock_Control *_designator = _target;
135 #else
136  #define ISR_LOCK_REFERENCE( _designator, _target )
137 #endif
138 
145 #if defined( RTEMS_SMP )
146  #define ISR_LOCK_INITIALIZER( _name ) \
147  { SMP_LOCK_INITIALIZER( _name ) }
148 #else
149  #define ISR_LOCK_INITIALIZER( _name ) \
150  { }
151 #endif
152 
163 #if defined( RTEMS_SMP )
164  #define _ISR_lock_Initialize( _lock, _name ) \
165  _SMP_lock_Initialize( &( _lock )->Lock, _name )
166 #else
167  #define _ISR_lock_Initialize( _lock, _name )
168 #endif
169 
177 #if defined( RTEMS_SMP )
178  #define _ISR_lock_Destroy( _lock ) \
179  _SMP_lock_Destroy( &( _lock )->Lock )
180 #else
181  #define _ISR_lock_Destroy( _lock )
182 #endif
183 
198 #if defined( RTEMS_SMP )
199  #define _ISR_lock_ISR_disable_and_acquire( _lock, _context ) \
200  _SMP_lock_ISR_disable_and_acquire( \
201  &( _lock )->Lock, \
202  &( _context )->Lock_context \
203  )
204 #else
205  #define _ISR_lock_ISR_disable_and_acquire( _lock, _context ) \
206  _ISR_Disable( ( _context )->isr_level )
207 #endif
208 
223 #if defined( RTEMS_SMP )
224  #define _ISR_lock_Release_and_ISR_enable( _lock, _context ) \
225  _SMP_lock_Release_and_ISR_enable( \
226  &( _lock )->Lock, \
227  &( _context )->Lock_context \
228  )
229 #else
230  #define _ISR_lock_Release_and_ISR_enable( _lock, _context ) \
231  _ISR_Enable( ( _context )->isr_level )
232 #endif
233 
250 #if defined( RTEMS_SMP )
251  #define _ISR_lock_Acquire( _lock, _context ) \
252  _SMP_lock_Acquire( \
253  &( _lock )->Lock, \
254  &( _context )->Lock_context \
255  )
256 #else
257  #define _ISR_lock_Acquire( _lock, _context )
258 #endif
259 
272 #if defined( RTEMS_SMP )
273  #define _ISR_lock_Release( _lock, _context ) \
274  _SMP_lock_Release( \
275  &( _lock )->Lock, \
276  &( _context )->Lock_context \
277  )
278 #else
279  #define _ISR_lock_Release( _lock, _context )
280 #endif
281 
298 #if defined( RTEMS_SMP )
299  #define _ISR_lock_Flash( _lock, _context ) \
300  _SMP_lock_Release_and_ISR_enable( \
301  &( _lock )->Lock, \
302  &( _context )->Lock_context \
303  ); \
304  _SMP_lock_ISR_disable_and_acquire( \
305  &( _lock )->Lock, \
306  &( _context )->Lock_context \
307  )
308 #else
309  #define _ISR_lock_Flash( _lock, _context ) \
310  _ISR_Flash( ( _context )->isr_level )
311 #endif
312 
313 #if defined( RTEMS_PROFILING )
314  #define _ISR_lock_ISR_disable_profile( _context ) \
315  ( _context )->ISR_disable_instant = _CPU_Counter_read();
316 #else
317  #define _ISR_lock_ISR_disable_profile( _context )
318 #endif
319 
330 #if defined( RTEMS_SMP )
331  #define _ISR_lock_ISR_disable( _context ) \
332  do { \
333  _ISR_Disable_without_giant( ( _context )->Lock_context.isr_level ); \
334  _ISR_lock_ISR_disable_profile( _context ) \
335  } while ( 0 )
336 #else
337  #define _ISR_lock_ISR_disable( _context ) \
338  do { \
339  _ISR_Disable( ( _context )->isr_level ); \
340  _ISR_lock_ISR_disable_profile( _context ) \
341  } while ( 0 )
342 #endif
343 
354 #if defined( RTEMS_SMP )
355  #define _ISR_lock_ISR_enable( _context ) \
356  _ISR_Enable_without_giant( ( _context )->Lock_context.isr_level )
357 #else
358  #define _ISR_lock_ISR_enable( _context ) \
359  _ISR_Enable( ( _context )->isr_level )
360 #endif
361 
364 #ifdef __cplusplus
365 }
366 #endif
367 
368 #endif /* _RTEMS_SCORE_ISR_LOCK_H */
ISR Level Type.
ISR lock control.
Definition: isrlock.h:56
uint32_t ISR_Level
The following type defines the control block used to manage the interrupt level portion of the status...
Definition: isrlevel.h:42
SMP Lock API.
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65