RTEMS
5.1
cpukit
include
rtems
score
isrlock.h
Go to the documentation of this file.
1
9
/*
10
* Copyright (c) 2013, 2019 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
60
}
ISR_lock_Control
;
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
77
}
ISR_lock_Context
;
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
159
RTEMS_INLINE_ROUTINE
void
_ISR_lock_Context_set_level
(
160
ISR_lock_Context
*
context
,
161
ISR_Level
level
162
)
163
{
164
#if defined( RTEMS_SMP )
165
context
->Lock_context.isr_level = level;
166
#else
167
context
->isr_level = level;
168
#endif
169
}
170
181
#if defined( RTEMS_SMP )
182
#define _ISR_lock_Initialize( _lock, _name ) \
183
_SMP_lock_Initialize( &( _lock )->Lock, _name )
184
#else
185
#define _ISR_lock_Initialize( _lock, _name )
186
#endif
187
195
#if defined( RTEMS_SMP )
196
#define _ISR_lock_Destroy( _lock ) \
197
_SMP_lock_Destroy( &( _lock )->Lock )
198
#else
199
#define _ISR_lock_Destroy( _lock )
200
#endif
201
210
#if defined( RTEMS_SMP )
211
#define _ISR_lock_Set_name( _lock, _name ) \
212
_SMP_lock_Set_name( &( _lock )->Lock, _name )
213
#else
214
#define _ISR_lock_Set_name( _lock, _name )
215
#endif
216
231
#if defined( RTEMS_SMP )
232
#define _ISR_lock_ISR_disable_and_acquire( _lock, _context ) \
233
_SMP_lock_ISR_disable_and_acquire( \
234
&( _lock )->Lock, \
235
&( _context )->Lock_context \
236
)
237
#else
238
#define _ISR_lock_ISR_disable_and_acquire( _lock, _context ) \
239
_ISR_Local_disable( ( _context )->isr_level )
240
#endif
241
256
#if defined( RTEMS_SMP )
257
#define _ISR_lock_Release_and_ISR_enable( _lock, _context ) \
258
_SMP_lock_Release_and_ISR_enable( \
259
&( _lock )->Lock, \
260
&( _context )->Lock_context \
261
)
262
#else
263
#define _ISR_lock_Release_and_ISR_enable( _lock, _context ) \
264
_ISR_Local_enable( ( _context )->isr_level )
265
#endif
266
283
#if defined( RTEMS_SMP )
284
#define _ISR_lock_Acquire( _lock, _context ) \
285
do { \
286
_Assert( _ISR_Get_level() != 0 ); \
287
_SMP_lock_Acquire( \
288
&( _lock )->Lock, \
289
&( _context )->Lock_context \
290
); \
291
} while ( 0 )
292
#else
293
#define _ISR_lock_Acquire( _lock, _context ) \
294
do { (void) _context; } while ( 0 )
295
#endif
296
309
#if defined( RTEMS_SMP )
310
#define _ISR_lock_Release( _lock, _context ) \
311
_SMP_lock_Release( \
312
&( _lock )->Lock, \
313
&( _context )->Lock_context \
314
)
315
#else
316
#define _ISR_lock_Release( _lock, _context ) \
317
do { (void) _context; } while ( 0 )
318
#endif
319
325
#if defined( RTEMS_SMP )
326
#define _ISR_lock_Acquire_inline( _lock, _context ) \
327
do { \
328
_Assert( _ISR_Get_level() != 0 ); \
329
_SMP_lock_Acquire_inline( \
330
&( _lock )->Lock, \
331
&( _context )->Lock_context \
332
); \
333
} while ( 0 )
334
#else
335
#define _ISR_lock_Acquire_inline( _lock, _context ) \
336
do { (void) _context; } while ( 0 )
337
#endif
338
344
#if defined( RTEMS_SMP )
345
#define _ISR_lock_Release_inline( _lock, _context ) \
346
_SMP_lock_Release_inline( \
347
&( _lock )->Lock, \
348
&( _context )->Lock_context \
349
)
350
#else
351
#define _ISR_lock_Release_inline( _lock, _context ) \
352
do { (void) _context; } while ( 0 )
353
#endif
354
355
#if defined( RTEMS_DEBUG )
356
365
#if defined( RTEMS_SMP )
366
#define _ISR_lock_Is_owner( _lock ) \
367
_SMP_lock_Is_owner( &( _lock )->Lock )
368
#else
369
#define _ISR_lock_Is_owner( _lock ) \
370
( _ISR_Get_level() != 0 )
371
#endif
372
#endif
373
374
#if defined( RTEMS_PROFILING )
375
#define _ISR_lock_ISR_disable_profile( _context ) \
376
( _context )->ISR_disable_instant = _CPU_Counter_read();
377
#else
378
#define _ISR_lock_ISR_disable_profile( _context )
379
#endif
380
391
#if defined( RTEMS_SMP )
392
#define _ISR_lock_ISR_disable( _context ) \
393
do { \
394
_ISR_Local_disable( ( _context )->Lock_context.isr_level ); \
395
_ISR_lock_ISR_disable_profile( _context ) \
396
} while ( 0 )
397
#else
398
#define _ISR_lock_ISR_disable( _context ) \
399
do { \
400
_ISR_Local_disable( ( _context )->isr_level ); \
401
_ISR_lock_ISR_disable_profile( _context ) \
402
} while ( 0 )
403
#endif
404
415
#if defined( RTEMS_SMP )
416
#define _ISR_lock_ISR_enable( _context ) \
417
_ISR_Local_enable( ( _context )->Lock_context.isr_level )
418
#else
419
#define _ISR_lock_ISR_enable( _context ) \
420
_ISR_Local_enable( ( _context )->isr_level )
421
#endif
422
425
#ifdef __cplusplus
426
}
427
#endif
428
429
#endif
/* _RTEMS_SCORE_ISR_LOCK_H */
isrlevel.h
ISR Level Type.
ISR_lock_Control
ISR lock control.
Definition:
isrlock.h:56
ISR_Level
uint32_t ISR_Level
Definition:
isrlevel.h:41
context
unsigned context
Definition:
tlb.h:108
smplock.h
SMP Lock API.
ISR_lock_Context
Local ISR lock context for acquire and release pairs.
Definition:
isrlock.h:65
_ISR_lock_Context_set_level
RTEMS_INLINE_ROUTINE void _ISR_lock_Context_set_level(ISR_lock_Context *context, ISR_Level level)
Sets the ISR level in the ISR lock context.
Definition:
isrlock.h:159
RTEMS_INLINE_ROUTINE
#define RTEMS_INLINE_ROUTINE
Definition:
basedefs.h:66
Generated by
1.8.15