summaryrefslogtreecommitdiffstats
path: root/cpukit/include/rtems/rtems/intr.h
blob: c9222fcc4d42ee36b53e6037ca3631a900845e8c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
/* SPDX-License-Identifier: BSD-2-Clause */

/**
 * @file
 *
 * @brief This header file defines the Interrupt Manager API.
 */

/*
 * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
 * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR)
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * This file is part of the RTEMS quality process and was automatically
 * generated.  If you find something that needs to be fixed or
 * worded better please post a report or patch to an RTEMS mailing list
 * or raise a bug report:
 *
 * https://www.rtems.org/bugs.html
 *
 * For information on updating and regenerating please refer to the How-To
 * section in the Software Requirements Engineering chapter of the
 * RTEMS Software Engineering manual.  The manual is provided as a part of
 * a release.  For development sources please refer to the online
 * documentation at:
 *
 * https://docs.rtems.org
 */

/* Generated from spec:/rtems/intr/if/header */

#ifndef _RTEMS_RTEMS_INTR_H
#define _RTEMS_RTEMS_INTR_H

#include <rtems/rtems/status.h>
#include <rtems/score/basedefs.h>
#include <rtems/score/cpu.h>
#include <rtems/score/isr.h>
#include <rtems/score/isrlevel.h>
#include <rtems/score/isrlock.h>
#include <rtems/score/smplock.h>

#ifdef __cplusplus
extern "C" {
#endif

/* Generated from spec:/rtems/intr/if/group */

/**
 * @defgroup RTEMSAPIClassicIntr Interrupt Manager
 *
 * @ingroup RTEMSAPIClassic
 *
 * @brief Any real-time executive must provide a mechanism for quick response
 *   to externally generated interrupts to satisfy the critical time
 *   constraints of the application.  The Interrupt Manager provides this
 *   mechanism for RTEMS. This manager permits quick interrupt response times
 *   by providing the critical ability to alter task execution which allows a
 *   task to be preempted upon exit from an ISR.
 */

/* Generated from spec:/rtems/intr/if/isr */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief This type defines the return type of interrupt service routines.
 *
 * This type can be used to document interrupt service routines in the source
 * code.
 */
typedef ISR_Handler rtems_isr;

/* Generated from spec:/rtems/intr/if/isr-entry */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief Interrupt service routines installed by rtems_interrupt_catch() shall
 *   have this function pointer type.
 */
#if CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE
  typedef ISR_Handler_entry rtems_isr_entry;
#else
  typedef void ( *rtems_isr_entry )( void * );
#endif

/* Generated from spec:/rtems/intr/if/level */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief This integer type represents interrupt levels.
 */
typedef ISR_Level rtems_interrupt_level;

/* Generated from spec:/rtems/intr/if/lock */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief This structure represents an ISR lock.
 */
typedef ISR_lock_Control rtems_interrupt_lock;

/* Generated from spec:/rtems/intr/if/lock-context */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief This structure provides an ISR lock context for acquire and release
 *   pairs.
 */
typedef ISR_lock_Context rtems_interrupt_lock_context;

/* Generated from spec:/rtems/intr/if/vector-number */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief This integer type represents interrupt vector numbers.
 */
typedef ISR_Vector_number rtems_vector_number;

/* Generated from spec:/rtems/intr/if/catch */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief Establishes an interrupt service routine.
 *
 * @param new_isr_handler is the new interrupt service routine.
 *
 * @param vector is the interrupt vector number.
 *
 * @param[out] old_isr_handler is the pointer to an ::rtems_isr_entry variable.
 *   When the directive call is successful, the previous interrupt service
 *   routine established for this interrupt vector will be stored in this
 *   variable.
 *
 * This directive establishes an interrupt service routine (ISR) for the
 * interrupt specified by the ``vector`` number.  The ``new_isr_handler``
 * parameter specifies the entry point of the ISR.  The entry point of the
 * previous ISR for the specified vector is returned in ``old_isr_handler``.
 *
 * To release an interrupt vector, pass the old handler's address obtained when
 * the vector was first capture.
 *
 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
 *
 * @retval ::RTEMS_INVALID_NUMBER The interrupt vector number was illegal.
 *
 * @retval ::RTEMS_INVALID_ADDRESS The ``new_isr_handler`` parameter was NULL.
 *
 * @retval ::RTEMS_INVALID_ADDRESS The ``old_isr_handler`` parameter was NULL.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within interrupt context.
 *
 * * The directive may be called from within device driver initialization
 *   context.
 *
 * * The directive may be called from within task context.
 *
 * * The directive will not cause the calling task to be preempted.
 *
 * * The directive is only available where the target architecture support
 *   enabled simple vectored interrupts.
 * @endparblock
 */
rtems_status_code rtems_interrupt_catch(
  rtems_isr_entry     new_isr_handler,
  rtems_vector_number vector,
  rtems_isr_entry    *old_isr_handler
);

#if !defined(RTEMS_SMP)
  /* Generated from spec:/rtems/intr/if/disable */

  /**
   * @ingroup RTEMSAPIClassicIntr
   *
   * @brief Disables the maskable interrupts on the current processor.
   *
   * @param[out] _isr_cookie is a variable of type ::rtems_interrupt_level which
   *   will be used to save the previous interrupt level.
   *
   * This directive disables all maskable interrupts on the current processor and
   * returns the previous interrupt level in ``_isr_cookie``.
   *
   * @par Notes
   * @parblock
   * A later invocation of the rtems_interrupt_enable() directive should be used
   * to restore the previous interrupt level.
   *
   * This directive is implemented as a macro which sets the ``_isr_cookie``
   * parameter.
   *
   * @code
   * #include <rtems.h>
   *
   * void local_critical_section( void )
   * {
   *   rtems_interrupt_level level;
   *
   *   // Please note that the rtems_interrupt_disable() is a macro.  The
   *   // previous interrupt level (before the maskable interrupts are
   *   // disabled) is returned here in the level macro parameter.  This
   *   // would be wrong:
   *   //
   *   // rtems_interrupt_disable( &level );
   *   rtems_interrupt_disable( level );
   *
   *   // Here is the critical section: maskable interrupts are disabled
   *
   *   {
   *     rtems_interrupt_level nested_level;
   *
   *     rtems_interrupt_disable( nested_level );
   *
   *     // Here is a nested critical section
   *
   *     rtems_interrupt_enable( nested_level );
   *   }
   *
   *   // Maskable interrupts are still disabled
   *
   *   rtems_interrupt_enable( level );
   * }
   * @endcode
   * @endparblock
   *
   * @par Constraints
   * @parblock
   * The following constraints apply to this directive:
   *
   * * The directive may be called from within any runtime context.
   *
   * * The directive will not cause the calling task to be preempted.
   *
   * * Where the system was built with SMP support enabled, the directive is not
   *   available.  Its use will result in compiler warnings and linker errors.
   *   The rtems_interrupt_local_disable() and rtems_interrupt_local_enable()
   *   directives are available in all build configurations.
   * @endparblock
   */
  #define rtems_interrupt_disable( _isr_cookie ) _ISR_Local_disable( _isr_cookie )
#endif

#if !defined(RTEMS_SMP)
  /* Generated from spec:/rtems/intr/if/enable */

  /**
   * @ingroup RTEMSAPIClassicIntr
   *
   * @brief Restores the previous interrupt level on the current processor.
   *
   * @param[in] _isr_cookie is the previous interrupt level to restore.  The
   *   value must be obtained by a previous call to rtems_interrupt_disable() or
   *   rtems_interrupt_flash().
   *
   * This directive restores the interrupt level specified by ``_isr_cookie`` on
   * the current processor.
   *
   * @par Notes
   * @parblock
   * The ``_isr_cookie`` parameter value must be obtained by a previous call to
   * rtems_interrupt_disable() or rtems_interrupt_flash().  Using an otherwise
   * obtained value is undefined behaviour.
   *
   * This directive is unsuitable to enable particular interrupt sources, for
   * example in an interrupt controller.
   * @endparblock
   *
   * @par Constraints
   * @parblock
   * The following constraints apply to this directive:
   *
   * * The directive may be called from within any runtime context.
   *
   * * The directive will not cause the calling task to be preempted.
   *
   * * While at least one maskable interrupt is pending, when the directive
   *   enables maskable interrupts, the pending interrupts are immediately
   *   serviced.  The interrupt service routines may unblock higher priority
   *   tasks which may preempt the calling task.
   *
   * * Where the system was built with SMP support enabled, the directive is not
   *   available.  Its use will result in compiler warnings and linker errors.
   *   The rtems_interrupt_local_disable() and rtems_interrupt_local_enable()
   *   directives are available in all build configurations.
   * @endparblock
   */
  #define rtems_interrupt_enable( _isr_cookie ) _ISR_Local_enable( _isr_cookie )
#endif

#if !defined(RTEMS_SMP)
  /* Generated from spec:/rtems/intr/if/flash */

  /**
   * @ingroup RTEMSAPIClassicIntr
   *
   * @brief Flashes interrupts on the current processor.
   *
   * @param[in,out] _isr_cookie is the previous interrupt level.
   *
   * This directive is functionally equivalent to a calling
   * rtems_interrupt_enable() immediately followed by a
   * rtems_interrupt_disable().  On some architectures it is possible to provide
   * an optimized implementation for this sequence.
   *
   * @par Notes
   * @parblock
   * The ``_isr_cookie`` parameter value must be obtained by a previous call to
   * rtems_interrupt_disable() or rtems_interrupt_flash().  Using an otherwise
   * obtained value is undefined behaviour.
   *
   * Historically, the interrupt flash directive was heavily used in the
   * operating system implementation.  However, this is no longer the case.  The
   * interrupt flash directive is provided for backward compatibility reasons.
   * @endparblock
   *
   * @par Constraints
   * @parblock
   * The following constraints apply to this directive:
   *
   * * The directive may be called from within any runtime context.
   *
   * * The directive will not cause the calling task to be preempted.
   *
   * * Where the system was built with SMP support enabled, the directive is not
   *   available.  Its use will result in compiler warnings and linker errors.
   *   The rtems_interrupt_local_disable() and rtems_interrupt_local_enable()
   *   directives are available in all build configurations.
   * @endparblock
   */
  #define rtems_interrupt_flash( _isr_cookie ) _ISR_Local_flash( _isr_cookie )
#endif

/* Generated from spec:/rtems/intr/if/local-disable */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief Disables the maskable interrupts on the current processor.
 *
 * @param[out] _isr_cookie is a variable of type ::rtems_interrupt_level which
 *   will be used to save the previous interrupt level.
 *
 * This directive disables all maskable interrupts on the current processor and
 * returns the previous interrupt level in ``_isr_cookie``.
 *
 * @par Notes
 * @parblock
 * A later invocation of the rtems_interrupt_local_enable() directive should be
 * used to restore the previous interrupt level.
 *
 * This directive is implemented as a macro which sets the ``_isr_cookie``
 * parameter.
 *
 * Where the system was built with SMP support enabled, this will not ensure
 * system wide mutual exclusion.  Use interrupt locks instead, see
 * rtems_interrupt_lock_acquire().  Interrupt disabled critical sections may be
 * used to access processor-specific data structures or disable thread
 * dispatching.
 *
 * @code
 * #include <rtems.h>
 *
 * void local_critical_section( void )
 * {
 *   rtems_interrupt_level level;
 *
 *   // Please note that the rtems_interrupt_local_disable() is a macro.
 *   // The previous interrupt level (before the maskable interrupts are
 *   // disabled) is returned here in the level macro parameter.  This would
 *   // be wrong:
 *   //
 *   // rtems_interrupt_local_disable( &level );
 *   rtems_interrupt_local_disable( level );
 *
 *   // Here is the critical section: maskable interrupts are disabled
 *
 *   {
 *     rtems_interrupt_level nested_level;
 *
 *     rtems_interrupt_local_disable( nested_level );
 *
 *     // Here is a nested critical section
 *
 *     rtems_interrupt_local_enable( nested_level );
 *   }
 *
 *   // Maskable interrupts are still disabled
 *
 *   rtems_interrupt_local_enable( level );
 * }
 * @endcode
 * @endparblock
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
#define rtems_interrupt_local_disable( _isr_cookie ) \
  _ISR_Local_disable( _isr_cookie )

/* Generated from spec:/rtems/intr/if/local-enable */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief Restores the previous interrupt level on the current processor.
 *
 * @param[in] _isr_cookie is the previous interrupt level to restore.  The
 *   value must be obtained by a previous call to
 *   rtems_interrupt_local_disable().
 *
 * This directive restores the interrupt level specified by ``_isr_cookie`` on
 * the current processor.
 *
 * @par Notes
 * @parblock
 * The ``_isr_cookie`` parameter value must be obtained by a previous call to
 * rtems_interrupt_local_disable().  Using an otherwise obtained value is
 * undefined behaviour.
 *
 * This directive is unsuitable to enable particular interrupt sources, for
 * example in an interrupt controller.
 * @endparblock
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 *
 * * While at least one maskable interrupt is pending, when the directive
 *   enables maskable interrupts, the pending interrupts are immediately
 *   serviced.  The interrupt service routines may unblock higher priority
 *   tasks which may preempt the calling task.
 * @endparblock
 */
#define rtems_interrupt_local_enable( _isr_cookie ) \
  _ISR_Local_enable( _isr_cookie )

/* Generated from spec:/rtems/intr/if/is-in-progress */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief Checks if an ISR is in progress on the current processor.
 *
 * This directive returns ``true``, if the current processor is currently
 * servicing an interrupt, and ``false`` otherwise.  A return value of ``true``
 * indicates that the caller is an interrupt service routine, **not** a task.
 * The directives available to an interrupt service routine are restricted.
 *
 * @return Returns true, if the current processor is currently servicing an
 *   interrupt, otherwise false.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
#define rtems_interrupt_is_in_progress() _ISR_Is_in_progress()

/* Generated from spec:/rtems/intr/if/cause */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief Causes the interrupt.
 *
 * @param _vector is the vector number of the interrupt to cause.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive is not implemented.
 * @endparblock
 */
#define rtems_interrupt_cause( _vector ) do { } while ( 0 )

/* Generated from spec:/rtems/intr/if/clear */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief Clears the interrupt.
 *
 * @param _vector is the vector number of the interrupt to clear.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive is not implemented.
 * @endparblock
 */
#define rtems_interrupt_clear( _vector ) do { } while ( 0 )

/* Generated from spec:/rtems/intr/if/lock-initialize */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief Initializes the ISR lock.
 *
 * @param[out] _lock is the ISR lock to initialize.
 *
 * @param _name is the ISR lock name.  It shall be a string.  The name is only
 *   used where the system was built with profiling support enabled.
 *
 * @par Notes
 * ISR locks may also be statically defined by RTEMS_INTERRUPT_LOCK_DEFINE() or
 * statically initialized by RTEMS_INTERRUPT_LOCK_INITIALIZER().
 */
#define rtems_interrupt_lock_initialize( _lock, _name ) \
  _ISR_lock_Initialize( _lock, _name )

/* Generated from spec:/rtems/intr/if/lock-destroy */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief Destroys the ISR lock.
 *
 * @param[in,out] _lock is the ISR lock to destroy.
 *
 * @par Notes
 * @parblock
 * The lock must have been dynamically initialized by
 * rtems_interrupt_lock_initialize(), statically defined by
 * RTEMS_INTERRUPT_LOCK_DEFINE(), or statically initialized by
 * RTEMS_INTERRUPT_LOCK_INITIALIZER().
 *
 * Concurrent lock use during the destruction or concurrent destruction leads
 * to unpredictable results.
 * @endparblock
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
#define rtems_interrupt_lock_destroy( _lock ) _ISR_lock_Destroy( _lock )

/* Generated from spec:/rtems/intr/if/lock-acquire */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief Acquires the ISR lock.
 *
 * @param[in,out] _lock is the ISR lock to acquire.
 *
 * @param[out] _lock_context is the ISR lock context.  This lock context shall
 *   be used to release the lock by calling rtems_interrupt_lock_release().
 *
 * This directive acquires the ISR lock specified by ``_lock`` using the lock
 * context provided by ``_lock_context``.  Maskable interrupts will be disabled
 * on the current processor.
 *
 * @par Notes
 * @parblock
 * A caller-specific lock context shall be provided for each acquire/release
 * pair, for example an automatic variable.
 *
 * Where the system was built with SMP support enabled, this directive acquires
 * an SMP lock.  An attempt to recursively acquire the lock may result in an
 * infinite loop with maskable interrupts disabled.
 *
 * This directive establishes a non-preemptive critical section with system
 * wide mutual exclusion on the local node in all RTEMS build configurations.
 *
 * @code
 * #include <rtems.h>
 *
 * void critical_section( rtems_interrupt_lock *lock )
 * {
 *   rtems_interrupt_lock_context lock_context;
 *
 *   rtems_interrupt_lock_acquire( lock, &lock_context );
 *
 *   // Here is the critical section.  Maskable interrupts are disabled.
 *   // Where the system was built with SMP support enabled, this section
 *   // is protected by an SMP lock.
 *
 *   rtems_interrupt_lock_release( lock, &lock_context );
 * }
 * @endcode
 * @endparblock
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
#define rtems_interrupt_lock_acquire( _lock, _lock_context ) \
  _ISR_lock_ISR_disable_and_acquire( _lock, _lock_context )

/* Generated from spec:/rtems/intr/if/lock-release */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief Releases the ISR lock.
 *
 * @param[in,out] _lock is the ISR lock to release.
 *
 * @param[in,out] _lock_context is the ISR lock context.  This lock context
 *   shall have been used to acquire the lock by calling
 *   rtems_interrupt_lock_acquire().
 *
 * This directive releases the ISR lock specified by ``_lock`` using the lock
 * context provided by ``_lock_context``.  The previous interrupt level will be
 * restored on the current processor.
 *
 * @par Notes
 * @parblock
 * The lock context shall be the one used to acquire the lock, otherwise the
 * result is unpredictable.
 *
 * Where the system was built with SMP support enabled, this directive releases
 * an SMP lock.
 * @endparblock
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 *
 * * While at least one maskable interrupt is pending, when the directive
 *   enables maskable interrupts, the pending interrupts are immediately
 *   serviced.  The interrupt service routines may unblock higher priority
 *   tasks which may preempt the calling task.
 * @endparblock
 */
#define rtems_interrupt_lock_release( _lock, _lock_context ) \
  _ISR_lock_Release_and_ISR_enable( _lock, _lock_context )

/* Generated from spec:/rtems/intr/if/lock-acquire-isr */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief Acquires the ISR lock from within an ISR.
 *
 * @param[in,out] _lock is the ISR lock to acquire within an ISR.
 *
 * @param[out] _lock_context is the ISR lock context.  This lock context shall
 *   be used to release the lock by calling rtems_interrupt_lock_release_isr().
 *
 * This directive acquires the ISR lock specified by ``_lock`` using the lock
 * context provided by ``_lock_context``.  The interrupt level will remain
 * unchanged.
 *
 * @par Notes
 * @parblock
 * A caller-specific lock context shall be provided for each acquire/release
 * pair, for example an automatic variable.
 *
 * Where the system was built with SMP support enabled, this directive acquires
 * an SMP lock.  An attempt to recursively acquire the lock may result in an
 * infinite loop.
 *
 * This directive is intended for device drivers and should be called from the
 * corresponding interrupt service routine.
 *
 * In case the corresponding interrupt service routine can be interrupted by
 * higher priority interrupts and these interrupts enter the critical section
 * protected by this lock, then the result is unpredictable.  This directive
 * may be used under specific circumstances as an optimization.  In doubt, use
 * rtems_interrupt_lock_acquire() and rtems_interrupt_lock_release().
 * @endparblock
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
#if defined(RTEMS_SMP)
  #define rtems_interrupt_lock_acquire_isr( _lock, _lock_context ) \
    _SMP_lock_Acquire( \
      &( _lock )->Lock, \
      &( _lock_context )->Lock_context \
    )
#else
  #define rtems_interrupt_lock_acquire_isr( _lock, _lock_context ) \
    do { (void) _lock_context; } while ( 0 )
#endif

/* Generated from spec:/rtems/intr/if/lock-release-isr */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief Releases the ISR lock from within an ISR.
 *
 * @param[in,out] _lock is the ISR lock to release within an ISR.
 *
 * @param[in,out] _lock_context is the ISR lock context.  This lock context
 *   shall have been used to acquire the lock by calling
 *   rtems_interrupt_lock_acquire_isr().
 *
 * This directive releases the ISR lock specified by ``_lock`` using the lock
 * context provided by ``_lock_context``.  The interrupt level will remain
 * unchanged.
 *
 * @par Notes
 * @parblock
 * The lock context shall be the one used to acquire the lock, otherwise the
 * result is unpredictable.
 *
 * Where the system was built with SMP support enabled, this directive releases
 * an SMP lock.
 * @endparblock
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
#if defined(RTEMS_SMP)
  #define rtems_interrupt_lock_release_isr( _lock, _lock_context ) \
    _SMP_lock_Release( \
      &( _lock )->Lock, \
      &( _lock_context )->Lock_context \
    )
#else
  #define rtems_interrupt_lock_release_isr( _lock, _lock_context ) \
    do { (void) _lock_context; } while ( 0 )
#endif

/* Generated from spec:/rtems/intr/if/lock-isr-disable */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief Disables maskable interrupts on the current processor.
 *
 * @param[out] _lock_context is the ISR lock context for an acquire and release
 *   pair.
 *
 * This directive disables maskable interrupts on the current processor and
 * stores the previous interrupt level in ``_lock_context``.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
#define rtems_interrupt_lock_interrupt_disable( _lock_context ) \
  _ISR_lock_ISR_disable( _lock_context )

/* Generated from spec:/rtems/intr/if/lock-declare */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief Declares an ISR lock object.
 *
 * @param _specifier is the storage-class specifier for the ISR lock to
 *   declare, for example ``extern`` or ``static``.
 *
 * @param _designator is the ISR lock object designator.
 *
 * @par Notes
 * Do not add a ";" after this macro.
 */
#define RTEMS_INTERRUPT_LOCK_DECLARE( _specifier, _designator ) \
  ISR_LOCK_DECLARE( _specifier, _designator )

/* Generated from spec:/rtems/intr/if/lock-define */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief Defines an ISR lock object.
 *
 * @param _specifier is the storage-class specifier for the ISR lock to
 *   declare, for example ``extern`` or ``static``.
 *
 * @param _designator is the ISR lock object designator.
 *
 * @param _name is the ISR lock name.  It shall be a string.  The name is only
 *   used where the system was built with profiling support enabled.
 *
 * @par Notes
 * @parblock
 * Do not add a ";" after this macro.
 *
 * ISR locks may also be dynamically initialized by
 * rtems_interrupt_lock_initialize() or statically by
 * RTEMS_INTERRUPT_LOCK_INITIALIZER().
 * @endparblock
 */
#define RTEMS_INTERRUPT_LOCK_DEFINE( _specifier, _designator, _name ) \
  ISR_LOCK_DEFINE( _specifier, _designator, _name )

/* Generated from spec:/rtems/intr/if/lock-initializer */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief Statically initializes an ISR lock object.
 *
 * @param _name is the ISR lock name.  It shall be a string.  The name is only
 *   used where the system was built with profiling support enabled.
 *
 * @par Notes
 * ISR locks may also be dynamically initialized by
 * rtems_interrupt_lock_initialize() or statically defined by
 * RTEMS_INTERRUPT_LOCK_DEFINE().
 */
#define RTEMS_INTERRUPT_LOCK_INITIALIZER( _name ) ISR_LOCK_INITIALIZER( _name )

/* Generated from spec:/rtems/intr/if/lock-member */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief Defines an ISR lock member.
 *
 * @param _designator is the ISR lock member designator.
 *
 * @par Notes
 * Do not add a ";" after this macro.
 */
#define RTEMS_INTERRUPT_LOCK_MEMBER( _designator ) \
  ISR_LOCK_MEMBER( _designator )

/* Generated from spec:/rtems/intr/if/lock-reference */

/**
 * @ingroup RTEMSAPIClassicIntr
 *
 * @brief Defines an ISR lock object reference.
 *
 * @param _designator is the ISR lock reference designator.
 *
 * @param _target is the target object to reference.
 *
 * @par Notes
 * Do not add a ";" after this macro.
 */
#define RTEMS_INTERRUPT_LOCK_REFERENCE( _designator, _target ) \
  ISR_LOCK_REFERENCE( _designator, _target )

#ifdef __cplusplus
}
#endif

#endif /* _RTEMS_RTEMS_INTR_H */