source: rtems/cpukit/include/rtems/rtems/intr.h @ 0b9e307

Last change on this file since 0b9e307 was 0b9e307, checked in by Sebastian Huber <sebastian.huber@…>, on 06/22/20 at 12:20:19

rtems: Generate <rtems/rtems/intr.h>

Change license to BSD-2-Clause according to file histories and
documentation re-licensing agreement.

Update #3899.
Update #3993.

  • Property mode set to 100644
File size: 28.7 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @brief This header file defines the Interrupt Manager API.
7 */
8
9/*
10 * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
11 * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR)
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 *    notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 *    notice, this list of conditions and the following disclaimer in the
20 *    documentation and/or other materials provided with the distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 */
34
35/*
36 * This file is part of the RTEMS quality process and was automatically
37 * generated.  If you find something that needs to be fixed or
38 * worded better please post a report or patch to an RTEMS mailing list
39 * or raise a bug report:
40 *
41 * https://www.rtems.org/bugs.html
42 *
43 * For information on updating and regenerating please refer to the How-To
44 * section in the Software Requirements Engineering chapter of the
45 * RTEMS Software Engineering manual.  The manual is provided as a part of
46 * a release.  For development sources please refer to the online
47 * documentation at:
48 *
49 * https://docs.rtems.org
50 */
51
52/* Generated from spec:/rtems/intr/if/header */
53
54#ifndef _RTEMS_RTEMS_INTR_H
55#define _RTEMS_RTEMS_INTR_H
56
57#include <rtems/rtems/status.h>
58#include <rtems/score/basedefs.h>
59#include <rtems/score/cpu.h>
60#include <rtems/score/isr.h>
61#include <rtems/score/isrlevel.h>
62#include <rtems/score/isrlock.h>
63#include <rtems/score/smplock.h>
64
65#ifdef __cplusplus
66extern "C" {
67#endif
68
69/* Generated from spec:/rtems/intr/if/group */
70
71/**
72 * @defgroup RTEMSAPIClassicIntr Interrupt Manager
73 *
74 * @ingroup RTEMSAPIClassic
75 *
76 * @brief Any real-time executive must provide a mechanism for quick response
77 *   to externally generated interrupts to satisfy the critical time
78 *   constraints of the application.  The Interrupt Manager provides this
79 *   mechanism for RTEMS. This manager permits quick interrupt response times
80 *   by providing the critical ability to alter task execution which allows a
81 *   task to be preempted upon exit from an ISR.
82 */
83
84/* Generated from spec:/rtems/intr/if/isr */
85
86/**
87 * @ingroup RTEMSAPIClassicIntr
88 *
89 * @brief This type defines the return type of interrupt service routines.
90 *
91 * This type can be used to document interrupt service routines in the source
92 * code.
93 */
94typedef ISR_Handler rtems_isr;
95
96/* Generated from spec:/rtems/intr/if/isr-entry */
97
98/**
99 * @ingroup RTEMSAPIClassicIntr
100 *
101 * @brief Interrupt service routines installed by rtems_interrupt_catch() shall
102 *   have this function pointer type.
103 */
104#if CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE
105  typedef ISR_Handler_entry rtems_isr_entry;
106#else
107  typedef void ( *rtems_isr_entry )( void * );
108#endif
109
110/* Generated from spec:/rtems/intr/if/level */
111
112/**
113 * @ingroup RTEMSAPIClassicIntr
114 *
115 * @brief This integer type represents interrupt levels.
116 */
117typedef ISR_Level rtems_interrupt_level;
118
119/* Generated from spec:/rtems/intr/if/lock */
120
121/**
122 * @ingroup RTEMSAPIClassicIntr
123 *
124 * @brief This structure represents an ISR lock.
125 */
126typedef ISR_lock_Control rtems_interrupt_lock;
127
128/* Generated from spec:/rtems/intr/if/lock-context */
129
130/**
131 * @ingroup RTEMSAPIClassicIntr
132 *
133 * @brief This structure provides an ISR lock context for acquire and release
134 *   pairs.
135 */
136typedef ISR_lock_Context rtems_interrupt_lock_context;
137
138/* Generated from spec:/rtems/intr/if/vector-number */
139
140/**
141 * @ingroup RTEMSAPIClassicIntr
142 *
143 * @brief This integer type represents interrupt vector numbers.
144 */
145typedef ISR_Vector_number rtems_vector_number;
146
147/* Generated from spec:/rtems/intr/if/catch */
148
149/**
150 * @ingroup RTEMSAPIClassicIntr
151 *
152 * @brief Establishes an interrupt service routine.
153 *
154 * @param new_isr_handler is the new interrupt service routine.
155 *
156 * @param vector is the interrupt vector number.
157 *
158 * @param[out] old_isr_handler is the pointer to an ::rtems_isr_entry variable.
159 *   When the directive call is successful, the previous interrupt service
160 *   routine established for this interrupt vector will be stored in this
161 *   variable.
162 *
163 * This directive establishes an interrupt service routine (ISR) for the
164 * interrupt specified by the ``vector`` number.  The ``new_isr_handler``
165 * parameter specifies the entry point of the ISR.  The entry point of the
166 * previous ISR for the specified vector is returned in ``old_isr_handler``.
167 *
168 * To release an interrupt vector, pass the old handler's address obtained when
169 * the vector was first capture.
170 *
171 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
172 *
173 * @retval ::RTEMS_INVALID_NUMBER The interrupt vector number was illegal.
174 *
175 * @retval ::RTEMS_INVALID_ADDRESS The ``new_isr_handler`` parameter was NULL.
176 *
177 * @retval ::RTEMS_INVALID_ADDRESS The ``old_isr_handler`` parameter was NULL.
178 *
179 * @par Constraints
180 * @parblock
181 * The following constraints apply to this directive:
182 *
183 * * The directive may be called from within interrupt context.
184 *
185 * * The directive may be called from within device driver initialization
186 *   context.
187 *
188 * * The directive may be called from within task context.
189 *
190 * * The directive will not cause the calling task to be preempted.
191 *
192 * * The directive is only available where the target architecture support
193 *   enabled simple vectored interrupts.
194 * @endparblock
195 */
196rtems_status_code rtems_interrupt_catch(
197  rtems_isr_entry     new_isr_handler,
198  rtems_vector_number vector,
199  rtems_isr_entry    *old_isr_handler
200);
201
202#if !defined(RTEMS_SMP)
203  /* Generated from spec:/rtems/intr/if/disable */
204
205  /**
206   * @ingroup RTEMSAPIClassicIntr
207   *
208   * @brief Disables the maskable interrupts on the current processor.
209   *
210   * @param[out] _isr_cookie is a variable of type ::rtems_interrupt_level which
211   *   will be used to save the previous interrupt level.
212   *
213   * This directive disables all maskable interrupts on the current processor and
214   * returns the previous interrupt level in ``_isr_cookie``.
215   *
216   * @par Notes
217   * @parblock
218   * A later invocation of the rtems_interrupt_enable() directive should be used
219   * to restore the previous interrupt level.
220   *
221   * This directive is implemented as a macro which sets the ``_isr_cookie``
222   * parameter.
223   *
224   * @code
225   * #include <rtems.h>
226   *
227   * void local_critical_section( void )
228   * {
229   *   rtems_interrupt_level level;
230   *
231   *   // Please note that the rtems_interrupt_disable() is a macro.  The
232   *   // previous interrupt level (before the maskable interrupts are
233   *   // disabled) is returned here in the level macro parameter.  This
234   *   // would be wrong:
235   *   //
236   *   // rtems_interrupt_disable( &level );
237   *   rtems_interrupt_disable( level );
238   *
239   *   // Here is the critical section: maskable interrupts are disabled
240   *
241   *   {
242   *     rtems_interrupt_level nested_level;
243   *
244   *     rtems_interrupt_disable( nested_level );
245   *
246   *     // Here is a nested critical section
247   *
248   *     rtems_interrupt_enable( nested_level );
249   *   }
250   *
251   *   // Maskable interrupts are still disabled
252   *
253   *   rtems_interrupt_enable( level );
254   * }
255   * @endcode
256   * @endparblock
257   *
258   * @par Constraints
259   * @parblock
260   * The following constraints apply to this directive:
261   *
262   * * The directive may be called from within any runtime context.
263   *
264   * * The directive will not cause the calling task to be preempted.
265   *
266   * * Where the system was built with SMP support enabled, the directive is not
267   *   available.  Its use will result in compiler warnings and linker errors.
268   *   The rtems_interrupt_local_disable() and rtems_interrupt_local_enable()
269   *   directives are available in all build configurations.
270   * @endparblock
271   */
272  #define rtems_interrupt_disable( _isr_cookie ) _ISR_Local_disable( _isr_cookie )
273#endif
274
275#if !defined(RTEMS_SMP)
276  /* Generated from spec:/rtems/intr/if/enable */
277
278  /**
279   * @ingroup RTEMSAPIClassicIntr
280   *
281   * @brief Restores the previous interrupt level on the current processor.
282   *
283   * @param[in] _isr_cookie is the previous interrupt level to restore.  The
284   *   value must be obtained by a previous call to rtems_interrupt_disable() or
285   *   rtems_interrupt_flash().
286   *
287   * This directive restores the interrupt level specified by ``_isr_cookie`` on
288   * the current processor.
289   *
290   * @par Notes
291   * @parblock
292   * The ``_isr_cookie`` parameter value must be obtained by a previous call to
293   * rtems_interrupt_disable() or rtems_interrupt_flash().  Using an otherwise
294   * obtained value is undefined behaviour.
295   *
296   * This directive is unsuitable to enable particular interrupt sources, for
297   * example in an interrupt controller.
298   * @endparblock
299   *
300   * @par Constraints
301   * @parblock
302   * The following constraints apply to this directive:
303   *
304   * * The directive may be called from within any runtime context.
305   *
306   * * The directive will not cause the calling task to be preempted.
307   *
308   * * While at least one maskable interrupt is pending, when the directive
309   *   enables maskable interrupts, the pending interrupts are immediately
310   *   serviced.  The interrupt service routines may unblock higher priority
311   *   tasks which may preempt the calling task.
312   *
313   * * Where the system was built with SMP support enabled, the directive is not
314   *   available.  Its use will result in compiler warnings and linker errors.
315   *   The rtems_interrupt_local_disable() and rtems_interrupt_local_enable()
316   *   directives are available in all build configurations.
317   * @endparblock
318   */
319  #define rtems_interrupt_enable( _isr_cookie ) _ISR_Local_enable( _isr_cookie )
320#endif
321
322#if !defined(RTEMS_SMP)
323  /* Generated from spec:/rtems/intr/if/flash */
324
325  /**
326   * @ingroup RTEMSAPIClassicIntr
327   *
328   * @brief Flashes interrupts on the current processor.
329   *
330   * @param[in,out] _isr_cookie is the previous interrupt level.
331   *
332   * This directive is functionally equivalent to a calling
333   * rtems_interrupt_enable() immediately followed by a
334   * rtems_interrupt_disable().  On some architectures it is possible to provide
335   * an optimized implementation for this sequence.
336   *
337   * @par Notes
338   * @parblock
339   * The ``_isr_cookie`` parameter value must be obtained by a previous call to
340   * rtems_interrupt_disable() or rtems_interrupt_flash().  Using an otherwise
341   * obtained value is undefined behaviour.
342   *
343   * Historically, the interrupt flash directive was heavily used in the
344   * operating system implementation.  However, this is no longer the case.  The
345   * interrupt flash directive is provided for backward compatibility reasons.
346   * @endparblock
347   *
348   * @par Constraints
349   * @parblock
350   * The following constraints apply to this directive:
351   *
352   * * The directive may be called from within any runtime context.
353   *
354   * * The directive will not cause the calling task to be preempted.
355   *
356   * * Where the system was built with SMP support enabled, the directive is not
357   *   available.  Its use will result in compiler warnings and linker errors.
358   *   The rtems_interrupt_local_disable() and rtems_interrupt_local_enable()
359   *   directives are available in all build configurations.
360   * @endparblock
361   */
362  #define rtems_interrupt_flash( _isr_cookie ) _ISR_Local_flash( _isr_cookie )
363#endif
364
365/* Generated from spec:/rtems/intr/if/local-disable */
366
367/**
368 * @ingroup RTEMSAPIClassicIntr
369 *
370 * @brief Disables the maskable interrupts on the current processor.
371 *
372 * @param[out] _isr_cookie is a variable of type ::rtems_interrupt_level which
373 *   will be used to save the previous interrupt level.
374 *
375 * This directive disables all maskable interrupts on the current processor and
376 * returns the previous interrupt level in ``_isr_cookie``.
377 *
378 * @par Notes
379 * @parblock
380 * A later invocation of the rtems_interrupt_local_enable() directive should be
381 * used to restore the previous interrupt level.
382 *
383 * This directive is implemented as a macro which sets the ``_isr_cookie``
384 * parameter.
385 *
386 * Where the system was built with SMP support enabled, this will not ensure
387 * system wide mutual exclusion.  Use interrupt locks instead, see
388 * rtems_interrupt_lock_acquire().  Interrupt disabled critical sections may be
389 * used to access processor-specific data structures or disable thread
390 * dispatching.
391 *
392 * @code
393 * #include <rtems.h>
394 *
395 * void local_critical_section( void )
396 * {
397 *   rtems_interrupt_level level;
398 *
399 *   // Please note that the rtems_interrupt_local_disable() is a macro.
400 *   // The previous interrupt level (before the maskable interrupts are
401 *   // disabled) is returned here in the level macro parameter.  This would
402 *   // be wrong:
403 *   //
404 *   // rtems_interrupt_local_disable( &level );
405 *   rtems_interrupt_local_disable( level );
406 *
407 *   // Here is the critical section: maskable interrupts are disabled
408 *
409 *   {
410 *     rtems_interrupt_level nested_level;
411 *
412 *     rtems_interrupt_local_disable( nested_level );
413 *
414 *     // Here is a nested critical section
415 *
416 *     rtems_interrupt_local_enable( nested_level );
417 *   }
418 *
419 *   // Maskable interrupts are still disabled
420 *
421 *   rtems_interrupt_local_enable( level );
422 * }
423 * @endcode
424 * @endparblock
425 *
426 * @par Constraints
427 * @parblock
428 * The following constraints apply to this directive:
429 *
430 * * The directive may be called from within any runtime context.
431 *
432 * * The directive will not cause the calling task to be preempted.
433 * @endparblock
434 */
435#define rtems_interrupt_local_disable( _isr_cookie ) \
436  _ISR_Local_disable( _isr_cookie )
437
438/* Generated from spec:/rtems/intr/if/local-enable */
439
440/**
441 * @ingroup RTEMSAPIClassicIntr
442 *
443 * @brief Restores the previous interrupt level on the current processor.
444 *
445 * @param[in] _isr_cookie is the previous interrupt level to restore.  The
446 *   value must be obtained by a previous call to
447 *   rtems_interrupt_local_disable().
448 *
449 * This directive restores the interrupt level specified by ``_isr_cookie`` on
450 * the current processor.
451 *
452 * @par Notes
453 * @parblock
454 * The ``_isr_cookie`` parameter value must be obtained by a previous call to
455 * rtems_interrupt_local_disable().  Using an otherwise obtained value is
456 * undefined behaviour.
457 *
458 * This directive is unsuitable to enable particular interrupt sources, for
459 * example in an interrupt controller.
460 * @endparblock
461 *
462 * @par Constraints
463 * @parblock
464 * The following constraints apply to this directive:
465 *
466 * * The directive may be called from within any runtime context.
467 *
468 * * The directive will not cause the calling task to be preempted.
469 *
470 * * While at least one maskable interrupt is pending, when the directive
471 *   enables maskable interrupts, the pending interrupts are immediately
472 *   serviced.  The interrupt service routines may unblock higher priority
473 *   tasks which may preempt the calling task.
474 * @endparblock
475 */
476#define rtems_interrupt_local_enable( _isr_cookie ) \
477  _ISR_Local_enable( _isr_cookie )
478
479/* Generated from spec:/rtems/intr/if/is-in-progress */
480
481/**
482 * @ingroup RTEMSAPIClassicIntr
483 *
484 * @brief Checks if an ISR is in progress on the current processor.
485 *
486 * This directive returns ``true``, if the current processor is currently
487 * servicing an interrupt, and ``false`` otherwise.  A return value of ``true``
488 * indicates that the caller is an interrupt service routine, **not** a task.
489 * The directives available to an interrupt service routine are restricted.
490 *
491 * @return Returns true, if the current processor is currently servicing an
492 *   interrupt, otherwise false.
493 *
494 * @par Constraints
495 * @parblock
496 * The following constraints apply to this directive:
497 *
498 * * The directive may be called from within any runtime context.
499 *
500 * * The directive will not cause the calling task to be preempted.
501 * @endparblock
502 */
503#define rtems_interrupt_is_in_progress() _ISR_Is_in_progress()
504
505/* Generated from spec:/rtems/intr/if/cause */
506
507/**
508 * @ingroup RTEMSAPIClassicIntr
509 *
510 * @brief Causes the interrupt.
511 *
512 * @param _vector is the vector number of the interrupt to cause.
513 *
514 * @par Constraints
515 * @parblock
516 * The following constraints apply to this directive:
517 *
518 * * The directive is not implemented.
519 * @endparblock
520 */
521#define rtems_interrupt_cause( _vector ) do { } while ( 0 )
522
523/* Generated from spec:/rtems/intr/if/clear */
524
525/**
526 * @ingroup RTEMSAPIClassicIntr
527 *
528 * @brief Clears the interrupt.
529 *
530 * @param _vector is the vector number of the interrupt to clear.
531 *
532 * @par Constraints
533 * @parblock
534 * The following constraints apply to this directive:
535 *
536 * * The directive is not implemented.
537 * @endparblock
538 */
539#define rtems_interrupt_clear( _vector ) do { } while ( 0 )
540
541/* Generated from spec:/rtems/intr/if/lock-initialize */
542
543/**
544 * @ingroup RTEMSAPIClassicIntr
545 *
546 * @brief Initializes the ISR lock.
547 *
548 * @param[out] _lock is the ISR lock to initialize.
549 *
550 * @param _name is the ISR lock name.  It shall be a string.  The name is only
551 *   used where the system was built with profiling support enabled.
552 *
553 * @par Notes
554 * ISR locks may also be statically defined by RTEMS_INTERRUPT_LOCK_DEFINE() or
555 * statically initialized by RTEMS_INTERRUPT_LOCK_INITIALIZER().
556 */
557#define rtems_interrupt_lock_initialize( _lock, _name ) \
558  _ISR_lock_Initialize( _lock, _name )
559
560/* Generated from spec:/rtems/intr/if/lock-destroy */
561
562/**
563 * @ingroup RTEMSAPIClassicIntr
564 *
565 * @brief Destroys the ISR lock.
566 *
567 * @param[in,out] _lock is the ISR lock to destroy.
568 *
569 * @par Notes
570 * @parblock
571 * The lock must have been dynamically initialized by
572 * rtems_interrupt_lock_initialize(), statically defined by
573 * RTEMS_INTERRUPT_LOCK_DEFINE(), or statically initialized by
574 * RTEMS_INTERRUPT_LOCK_INITIALIZER().
575 *
576 * Concurrent lock use during the destruction or concurrent destruction leads
577 * to unpredictable results.
578 * @endparblock
579 *
580 * @par Constraints
581 * @parblock
582 * The following constraints apply to this directive:
583 *
584 * * The directive may be called from within any runtime context.
585 *
586 * * The directive will not cause the calling task to be preempted.
587 * @endparblock
588 */
589#define rtems_interrupt_lock_destroy( _lock ) _ISR_lock_Destroy( _lock )
590
591/* Generated from spec:/rtems/intr/if/lock-acquire */
592
593/**
594 * @ingroup RTEMSAPIClassicIntr
595 *
596 * @brief Acquires the ISR lock.
597 *
598 * @param[in,out] _lock is the ISR lock to acquire.
599 *
600 * @param[out] _lock_context is the ISR lock context.  This lock context shall
601 *   be used to release the lock by calling rtems_interrupt_lock_release().
602 *
603 * This directive acquires the ISR lock specified by ``_lock`` using the lock
604 * context provided by ``_lock_context``.  Maskable interrupts will be disabled
605 * on the current processor.
606 *
607 * @par Notes
608 * @parblock
609 * A caller-specific lock context shall be provided for each acquire/release
610 * pair, for example an automatic variable.
611 *
612 * Where the system was built with SMP support enabled, this directive acquires
613 * an SMP lock.  An attempt to recursively acquire the lock may result in an
614 * infinite loop with maskable interrupts disabled.
615 *
616 * This directive establishes a non-preemptive critical section with system
617 * wide mutual exclusion on the local node in all RTEMS build configurations.
618 *
619 * @code
620 * #include <rtems.h>
621 *
622 * void critical_section( rtems_interrupt_lock *lock )
623 * {
624 *   rtems_interrupt_lock_context lock_context;
625 *
626 *   rtems_interrupt_lock_acquire( lock, &lock_context );
627 *
628 *   // Here is the critical section.  Maskable interrupts are disabled.
629 *   // Where the system was built with SMP support enabled, this section
630 *   // is protected by an SMP lock.
631 *
632 *   rtems_interrupt_lock_release( lock, &lock_context );
633 * }
634 * @endcode
635 * @endparblock
636 *
637 * @par Constraints
638 * @parblock
639 * The following constraints apply to this directive:
640 *
641 * * The directive may be called from within any runtime context.
642 *
643 * * The directive will not cause the calling task to be preempted.
644 * @endparblock
645 */
646#define rtems_interrupt_lock_acquire( _lock, _lock_context ) \
647  _ISR_lock_ISR_disable_and_acquire( _lock, _lock_context )
648
649/* Generated from spec:/rtems/intr/if/lock-release */
650
651/**
652 * @ingroup RTEMSAPIClassicIntr
653 *
654 * @brief Releases the ISR lock.
655 *
656 * @param[in,out] _lock is the ISR lock to release.
657 *
658 * @param[in,out] _lock_context is the ISR lock context.  This lock context
659 *   shall have been used to acquire the lock by calling
660 *   rtems_interrupt_lock_acquire().
661 *
662 * This directive releases the ISR lock specified by ``_lock`` using the lock
663 * context provided by ``_lock_context``.  The previous interrupt level will be
664 * restored on the current processor.
665 *
666 * @par Notes
667 * @parblock
668 * The lock context shall be the one used to acquire the lock, otherwise the
669 * result is unpredictable.
670 *
671 * Where the system was built with SMP support enabled, this directive releases
672 * an SMP lock.
673 * @endparblock
674 *
675 * @par Constraints
676 * @parblock
677 * The following constraints apply to this directive:
678 *
679 * * The directive may be called from within any runtime context.
680 *
681 * * The directive will not cause the calling task to be preempted.
682 *
683 * * While at least one maskable interrupt is pending, when the directive
684 *   enables maskable interrupts, the pending interrupts are immediately
685 *   serviced.  The interrupt service routines may unblock higher priority
686 *   tasks which may preempt the calling task.
687 * @endparblock
688 */
689#define rtems_interrupt_lock_release( _lock, _lock_context ) \
690  _ISR_lock_Release_and_ISR_enable( _lock, _lock_context )
691
692/* Generated from spec:/rtems/intr/if/lock-acquire-isr */
693
694/**
695 * @ingroup RTEMSAPIClassicIntr
696 *
697 * @brief Acquires the ISR lock from within an ISR.
698 *
699 * @param[in,out] _lock is the ISR lock to acquire within an ISR.
700 *
701 * @param[out] _lock_context is the ISR lock context.  This lock context shall
702 *   be used to release the lock by calling rtems_interrupt_lock_release_isr().
703 *
704 * This directive acquires the ISR lock specified by ``_lock`` using the lock
705 * context provided by ``_lock_context``.  The interrupt level will remain
706 * unchanged.
707 *
708 * @par Notes
709 * @parblock
710 * A caller-specific lock context shall be provided for each acquire/release
711 * pair, for example an automatic variable.
712 *
713 * Where the system was built with SMP support enabled, this directive acquires
714 * an SMP lock.  An attempt to recursively acquire the lock may result in an
715 * infinite loop.
716 *
717 * This directive is intended for device drivers and should be called from the
718 * corresponding interrupt service routine.
719 *
720 * In case the corresponding interrupt service routine can be interrupted by
721 * higher priority interrupts and these interrupts enter the critical section
722 * protected by this lock, then the result is unpredictable.  This directive
723 * may be used under specific circumstances as an optimization.  In doubt, use
724 * rtems_interrupt_lock_acquire() and rtems_interrupt_lock_release().
725 * @endparblock
726 *
727 * @par Constraints
728 * @parblock
729 * The following constraints apply to this directive:
730 *
731 * * The directive may be called from within any runtime context.
732 *
733 * * The directive will not cause the calling task to be preempted.
734 * @endparblock
735 */
736#if defined(RTEMS_SMP)
737  #define rtems_interrupt_lock_acquire_isr( _lock, _lock_context ) \
738    _SMP_lock_Acquire( \
739      &( _lock )->Lock, \
740      &( _lock_context )->Lock_context \
741    )
742#else
743  #define rtems_interrupt_lock_acquire_isr( _lock, _lock_context ) \
744    do { (void) _lock_context; } while ( 0 )
745#endif
746
747/* Generated from spec:/rtems/intr/if/lock-release-isr */
748
749/**
750 * @ingroup RTEMSAPIClassicIntr
751 *
752 * @brief Releases the ISR lock from within an ISR.
753 *
754 * @param[in,out] _lock is the ISR lock to release within an ISR.
755 *
756 * @param[in,out] _lock_context is the ISR lock context.  This lock context
757 *   shall have been used to acquire the lock by calling
758 *   rtems_interrupt_lock_acquire_isr().
759 *
760 * This directive releases the ISR lock specified by ``_lock`` using the lock
761 * context provided by ``_lock_context``.  The interrupt level will remain
762 * unchanged.
763 *
764 * @par Notes
765 * @parblock
766 * The lock context shall be the one used to acquire the lock, otherwise the
767 * result is unpredictable.
768 *
769 * Where the system was built with SMP support enabled, this directive releases
770 * an SMP lock.
771 * @endparblock
772 *
773 * @par Constraints
774 * @parblock
775 * The following constraints apply to this directive:
776 *
777 * * The directive may be called from within any runtime context.
778 *
779 * * The directive will not cause the calling task to be preempted.
780 * @endparblock
781 */
782#if defined(RTEMS_SMP)
783  #define rtems_interrupt_lock_release_isr( _lock, _lock_context ) \
784    _SMP_lock_Release( \
785      &( _lock )->Lock, \
786      &( _lock_context )->Lock_context \
787    )
788#else
789  #define rtems_interrupt_lock_release_isr( _lock, _lock_context ) \
790    do { (void) _lock_context; } while ( 0 )
791#endif
792
793/* Generated from spec:/rtems/intr/if/lock-isr-disable */
794
795/**
796 * @ingroup RTEMSAPIClassicIntr
797 *
798 * @brief Disables maskable interrupts on the current processor.
799 *
800 * @param[out] _lock_context is the ISR lock context for an acquire and release
801 *   pair.
802 *
803 * This directive disables maskable interrupts on the current processor and
804 * stores the previous interrupt level in ``_lock_context``.
805 *
806 * @par Constraints
807 * @parblock
808 * The following constraints apply to this directive:
809 *
810 * * The directive may be called from within any runtime context.
811 *
812 * * The directive will not cause the calling task to be preempted.
813 * @endparblock
814 */
815#define rtems_interrupt_lock_interrupt_disable( _lock_context ) \
816  _ISR_lock_ISR_disable( _lock_context )
817
818/* Generated from spec:/rtems/intr/if/lock-declare */
819
820/**
821 * @ingroup RTEMSAPIClassicIntr
822 *
823 * @brief Declares an ISR lock object.
824 *
825 * @param _specifier is the storage-class specifier for the ISR lock to
826 *   declare, for example ``extern`` or ``static``.
827 *
828 * @param _designator is the ISR lock object designator.
829 *
830 * @par Notes
831 * Do not add a ";" after this macro.
832 */
833#define RTEMS_INTERRUPT_LOCK_DECLARE( _specifier, _designator ) \
834  ISR_LOCK_DECLARE( _specifier, _designator )
835
836/* Generated from spec:/rtems/intr/if/lock-define */
837
838/**
839 * @ingroup RTEMSAPIClassicIntr
840 *
841 * @brief Defines an ISR lock object.
842 *
843 * @param _specifier is the storage-class specifier for the ISR lock to
844 *   declare, for example ``extern`` or ``static``.
845 *
846 * @param _designator is the ISR lock object designator.
847 *
848 * @param _name is the ISR lock name.  It shall be a string.  The name is only
849 *   used where the system was built with profiling support enabled.
850 *
851 * @par Notes
852 * @parblock
853 * Do not add a ";" after this macro.
854 *
855 * ISR locks may also be dynamically initialized by
856 * rtems_interrupt_lock_initialize() or statically by
857 * RTEMS_INTERRUPT_LOCK_INITIALIZER().
858 * @endparblock
859 */
860#define RTEMS_INTERRUPT_LOCK_DEFINE( _specifier, _designator, _name ) \
861  ISR_LOCK_DEFINE( _specifier, _designator, _name )
862
863/* Generated from spec:/rtems/intr/if/lock-initializer */
864
865/**
866 * @ingroup RTEMSAPIClassicIntr
867 *
868 * @brief Statically initializes an ISR lock object.
869 *
870 * @param _name is the ISR lock name.  It shall be a string.  The name is only
871 *   used where the system was built with profiling support enabled.
872 *
873 * @par Notes
874 * ISR locks may also be dynamically initialized by
875 * rtems_interrupt_lock_initialize() or statically defined by
876 * RTEMS_INTERRUPT_LOCK_DEFINE().
877 */
878#define RTEMS_INTERRUPT_LOCK_INITIALIZER( _name ) ISR_LOCK_INITIALIZER( _name )
879
880/* Generated from spec:/rtems/intr/if/lock-member */
881
882/**
883 * @ingroup RTEMSAPIClassicIntr
884 *
885 * @brief Defines an ISR lock member.
886 *
887 * @param _designator is the ISR lock member designator.
888 *
889 * @par Notes
890 * Do not add a ";" after this macro.
891 */
892#define RTEMS_INTERRUPT_LOCK_MEMBER( _designator ) \
893  ISR_LOCK_MEMBER( _designator )
894
895/* Generated from spec:/rtems/intr/if/lock-reference */
896
897/**
898 * @ingroup RTEMSAPIClassicIntr
899 *
900 * @brief Defines an ISR lock object reference.
901 *
902 * @param _designator is the ISR lock reference designator.
903 *
904 * @param _target is the target object to reference.
905 *
906 * @par Notes
907 * Do not add a ";" after this macro.
908 */
909#define RTEMS_INTERRUPT_LOCK_REFERENCE( _designator, _target ) \
910  ISR_LOCK_REFERENCE( _designator, _target )
911
912#ifdef __cplusplus
913}
914#endif
915
916#endif /* _RTEMS_RTEMS_INTR_H */
Note: See TracBrowser for help on using the repository browser.