mirror of
https://git.rtems.org/rtems-docs/
synced 2025-07-26 15:52:50 +08:00
c-user: Clarify interrupt manager directives
Use RTEMS coding style in all code blocks.
This commit is contained in:
parent
674b71470b
commit
b2c766bc72
@ -23,13 +23,13 @@ from an ISR. The interrupt manager includes the following directive:
|
|||||||
|
|
||||||
- rtems_interrupt_disable_ - Disable Interrupts
|
- rtems_interrupt_disable_ - Disable Interrupts
|
||||||
|
|
||||||
- rtems_interrupt_enable_ - Enable Interrupts
|
- rtems_interrupt_enable_ - Restore Interrupt Level
|
||||||
|
|
||||||
- rtems_interrupt_flash_ - Flash Interrupt
|
- rtems_interrupt_flash_ - Flash Interrupt
|
||||||
|
|
||||||
- rtems_interrupt_local_disable_ - Disable Interrupts on Current Processor
|
- rtems_interrupt_local_disable_ - Disable Interrupts on Current Processor
|
||||||
|
|
||||||
- rtems_interrupt_local_enable_ - Enable Interrupts on Current Processor
|
- rtems_interrupt_local_enable_ - Restore Interrupt Level on Current Processor
|
||||||
|
|
||||||
- rtems_interrupt_lock_initialize_ - Initialize an ISR Lock
|
- rtems_interrupt_lock_initialize_ - Initialize an ISR Lock
|
||||||
|
|
||||||
@ -330,32 +330,66 @@ DIRECTIVE STATUS CODES:
|
|||||||
|
|
||||||
DESCRIPTION:
|
DESCRIPTION:
|
||||||
This directive disables all maskable interrupts and returns the previous
|
This directive disables all maskable interrupts and returns the previous
|
||||||
``level``. A later invocation of the ``rtems_interrupt_enable`` directive
|
interrupt level in ``level``.
|
||||||
should be used to restore the interrupt level.
|
|
||||||
|
|
||||||
.. sidebar:: *Macro*
|
|
||||||
|
|
||||||
This directive is implemented as a macro which modifies the ``level``
|
|
||||||
parameter.
|
|
||||||
|
|
||||||
NOTES:
|
NOTES:
|
||||||
|
A later invocation of the ``rtems_interrupt_enable`` directive should be
|
||||||
|
used to restore the interrupt level.
|
||||||
|
|
||||||
|
This directive is implemented as a macro which sets the ``level``
|
||||||
|
parameter.
|
||||||
|
|
||||||
This directive will not cause the calling task to be preempted.
|
This directive will not cause the calling task to be preempted.
|
||||||
|
|
||||||
This directive is only available on uni-processor configurations. The
|
This directive is only available in uni-processor configurations. The
|
||||||
directive ``rtems_interrupt_local_disable`` is available on all
|
directive ``rtems_interrupt_local_disable`` is available in all
|
||||||
configurations.
|
configurations.
|
||||||
|
|
||||||
|
.. code-block:: c
|
||||||
|
|
||||||
|
void critical_section( void )
|
||||||
|
{
|
||||||
|
rtems_interrupt 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 );
|
||||||
|
|
||||||
|
/* Critical section, maskable interrupts are disabled */
|
||||||
|
|
||||||
|
{
|
||||||
|
rtems_interrupt level2;
|
||||||
|
|
||||||
|
rtems_interrupt_disable( level2 );
|
||||||
|
|
||||||
|
/* Nested critical section */
|
||||||
|
|
||||||
|
rtems_interrupt_enable( level2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Maskable interrupts are still disabled */
|
||||||
|
|
||||||
|
rtems_interrupt_enable( level );
|
||||||
|
}
|
||||||
|
|
||||||
.. raw:: latex
|
.. raw:: latex
|
||||||
|
|
||||||
\clearpage
|
\clearpage
|
||||||
|
|
||||||
.. index:: enable interrupts
|
.. index:: enable interrupts
|
||||||
|
.. index:: restore interrupt level
|
||||||
.. index:: rtems_interrupt_enable
|
.. index:: rtems_interrupt_enable
|
||||||
|
|
||||||
.. _rtems_interrupt_enable:
|
.. _rtems_interrupt_enable:
|
||||||
|
|
||||||
INTERRUPT_ENABLE - Enable Interrupts
|
INTERRUPT_ENABLE - Restore Interrupt Level
|
||||||
------------------------------------
|
------------------------------------------
|
||||||
|
|
||||||
CALLING SEQUENCE:
|
CALLING SEQUENCE:
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
@ -368,17 +402,20 @@ DIRECTIVE STATUS CODES:
|
|||||||
NONE
|
NONE
|
||||||
|
|
||||||
DESCRIPTION:
|
DESCRIPTION:
|
||||||
This directive enables maskable interrupts to the ``level`` which was
|
This directive restores the interrupt level specified by ``level``.
|
||||||
returned by a previous call to ``rtems_interrupt_disable``. Immediately
|
|
||||||
prior to invoking this directive, maskable interrupts should be disabled by
|
|
||||||
a call to ``rtems_interrupt_disable`` and will be enabled when this
|
|
||||||
directive returns to the caller.
|
|
||||||
|
|
||||||
NOTES:
|
NOTES:
|
||||||
|
The ``level`` 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.
|
||||||
|
|
||||||
This directive will not cause the calling task to be preempted.
|
This directive will not cause the calling task to be preempted.
|
||||||
|
|
||||||
This directive is only available on uni-processor configurations. The
|
This directive is only available in uni-processor configurations. The
|
||||||
directive ``rtems_interrupt_local_enable`` is available on all
|
directive ``rtems_interrupt_local_enable`` is available in all
|
||||||
configurations.
|
configurations.
|
||||||
|
|
||||||
.. raw:: latex
|
.. raw:: latex
|
||||||
@ -411,6 +448,10 @@ DESCRIPTION:
|
|||||||
this sequence.
|
this sequence.
|
||||||
|
|
||||||
NOTES:
|
NOTES:
|
||||||
|
The ``level`` 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 will not cause the calling task to be preempted.
|
This directive will not cause the calling task to be preempted.
|
||||||
|
|
||||||
This directive is only available in uni-processor configurations. The
|
This directive is only available in uni-processor configurations. The
|
||||||
@ -445,31 +486,65 @@ DIRECTIVE STATUS CODES:
|
|||||||
|
|
||||||
DESCRIPTION:
|
DESCRIPTION:
|
||||||
This directive disables all maskable interrupts and returns the previous
|
This directive disables all maskable interrupts and returns the previous
|
||||||
``level``. A later invocation of the ``rtems_interrupt_local_enable``
|
interrupt level in ``level``.
|
||||||
directive should be used to restore the interrupt level.
|
|
||||||
|
|
||||||
.. sidebar:: *Macro*
|
|
||||||
|
|
||||||
This directive is implemented as a macro which modifies the ``level``
|
|
||||||
parameter.
|
|
||||||
|
|
||||||
NOTES:
|
NOTES:
|
||||||
|
A later invocation of the ``rtems_interrupt_local_enable`` directive should
|
||||||
|
be used to restore the interrupt level.
|
||||||
|
|
||||||
|
This directive is implemented as a macro which sets the ``level``
|
||||||
|
parameter.
|
||||||
|
|
||||||
This directive will not cause the calling task to be preempted.
|
This directive will not cause the calling task to be preempted.
|
||||||
|
|
||||||
In SMP configurations, this will not ensure system wide mutual exclusion.
|
In SMP configurations, this will not ensure system wide mutual exclusion.
|
||||||
Use interrupt locks instead.
|
Use interrupt locks instead.
|
||||||
|
|
||||||
|
.. code-block:: c
|
||||||
|
|
||||||
|
void local_critical_section( void )
|
||||||
|
{
|
||||||
|
rtems_interrupt 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 );
|
||||||
|
|
||||||
|
/* Local critical section, maskable interrupts are disabled */
|
||||||
|
|
||||||
|
{
|
||||||
|
rtems_interrupt level2;
|
||||||
|
|
||||||
|
rtems_interrupt_local_disable( level2 );
|
||||||
|
|
||||||
|
/* Nested local critical section */
|
||||||
|
|
||||||
|
rtems_interrupt_local_enable( level2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Maskable interrupts are still disabled */
|
||||||
|
|
||||||
|
rtems_interrupt_local_enable( level );
|
||||||
|
}
|
||||||
|
|
||||||
.. raw:: latex
|
.. raw:: latex
|
||||||
|
|
||||||
\clearpage
|
\clearpage
|
||||||
|
|
||||||
.. index:: enable interrupts
|
.. index:: enable interrupts
|
||||||
|
.. index:: restore interrupt level
|
||||||
.. index:: rtems_interrupt_local_enable
|
.. index:: rtems_interrupt_local_enable
|
||||||
|
|
||||||
.. _rtems_interrupt_local_enable:
|
.. _rtems_interrupt_local_enable:
|
||||||
|
|
||||||
INTERRUPT_LOCAL_ENABLE - Enable Interrupts on Current Processor
|
INTERRUPT_LOCAL_ENABLE - Restore Interrupt Level on Current Processor
|
||||||
---------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
CALLING SEQUENCE:
|
CALLING SEQUENCE:
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
@ -482,13 +557,17 @@ DIRECTIVE STATUS CODES:
|
|||||||
NONE
|
NONE
|
||||||
|
|
||||||
DESCRIPTION:
|
DESCRIPTION:
|
||||||
This directive enables maskable interrupts to the ``level`` which was
|
This directive restores the interrupt level specified by ``level`` on the
|
||||||
returned by a previous call to ``rtems_interrupt_local_disable``.
|
current processor.
|
||||||
Immediately prior to invoking this directive, maskable interrupts should be
|
|
||||||
disabled by a call to ``rtems_interrupt_local_disable`` and will be enabled
|
|
||||||
when this directive returns to the caller.
|
|
||||||
|
|
||||||
NOTES:
|
NOTES:
|
||||||
|
The ``level`` 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.
|
||||||
|
|
||||||
This directive will not cause the calling task to be preempted.
|
This directive will not cause the calling task to be preempted.
|
||||||
|
|
||||||
.. raw:: latex
|
.. raw:: latex
|
||||||
@ -543,15 +622,15 @@ DIRECTIVE STATUS CODES:
|
|||||||
NONE
|
NONE
|
||||||
|
|
||||||
DESCRIPTION:
|
DESCRIPTION:
|
||||||
Interrupts will be disabled. In SMP configurations, this directive
|
Maskable interrupts will be disabled. In SMP configurations, this
|
||||||
acquires an SMP lock.
|
directive acquires an SMP lock.
|
||||||
|
|
||||||
NOTES:
|
NOTES:
|
||||||
A separate lock context must be provided for each acquire/release pair, for
|
A separate lock context must be provided for each acquire/release pair, for
|
||||||
example an automatic variable.
|
example an automatic variable.
|
||||||
|
|
||||||
An attempt to recursively acquire the lock may result in an infinite loop
|
An attempt to recursively acquire the lock may result in an infinite loop
|
||||||
with interrupts disabled.
|
with maskable interrupts disabled.
|
||||||
|
|
||||||
This directive will not cause the calling thread to be preempted. This
|
This directive will not cause the calling thread to be preempted. This
|
||||||
directive can be used in thread and interrupt context.
|
directive can be used in thread and interrupt context.
|
||||||
@ -579,7 +658,7 @@ DIRECTIVE STATUS CODES:
|
|||||||
NONE
|
NONE
|
||||||
|
|
||||||
DESCRIPTION:
|
DESCRIPTION:
|
||||||
The interrupt status will be restored. In SMP configurations, this
|
The interrupt level will be restored. In SMP configurations, this
|
||||||
directive releases an SMP lock.
|
directive releases an SMP lock.
|
||||||
|
|
||||||
NOTES:
|
NOTES:
|
||||||
@ -612,7 +691,7 @@ DIRECTIVE STATUS CODES:
|
|||||||
NONE
|
NONE
|
||||||
|
|
||||||
DESCRIPTION:
|
DESCRIPTION:
|
||||||
The interrupt status will remain unchanged. In SMP configurations, this
|
The interrupt level will remain unchanged. In SMP configurations, this
|
||||||
directive acquires an SMP lock.
|
directive acquires an SMP lock.
|
||||||
|
|
||||||
NOTES:
|
NOTES:
|
||||||
@ -651,7 +730,7 @@ DIRECTIVE STATUS CODES:
|
|||||||
NONE
|
NONE
|
||||||
|
|
||||||
DESCRIPTION:
|
DESCRIPTION:
|
||||||
The interrupt status will remain unchanged. In SMP configurations, this
|
The interrupt level will remain unchanged. In SMP configurations, this
|
||||||
directive releases an SMP lock.
|
directive releases an SMP lock.
|
||||||
|
|
||||||
NOTES:
|
NOTES:
|
||||||
@ -676,7 +755,7 @@ INTERRUPT_IS_IN_PROGRESS - Is an ISR in Progress
|
|||||||
CALLING SEQUENCE:
|
CALLING SEQUENCE:
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
|
||||||
bool rtems_interrupt_is_in_progress(void);
|
bool rtems_interrupt_is_in_progress( void );
|
||||||
|
|
||||||
DIRECTIVE STATUS CODES:
|
DIRECTIVE STATUS CODES:
|
||||||
NONE
|
NONE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user