source: rtems/cpukit/rtems/include/rtems/rtems/intr.h @ d50acdbb

4.115
Last change on this file since d50acdbb was d50acdbb, checked in by Sebastian Huber <sebastian.huber@…>, on 03/10/14 at 07:25:32

score: Add local context to SMP lock API

Add a local context structure to the SMP lock API for acquire and
release pairs. This context can be used to store the ISR level and
profiling information. It may be later used to enable more
sophisticated lock algorithms, e.g. MCS locks.

There is only one lock that cannot be used with a local context. This
is the per-CPU lock since here we would have to transfer the local
context through a context switch which is very complicated.

  • Property mode set to 100644
File size: 6.6 KB
Line 
1/**
2 *  @file rtems/rtems/intr.h
3 *
4 * @defgroup ClassicINTR Interrupts
5 *
6 * @ingroup ClassicRTEMS
7 * @brief Header file for Interrupt Manager
8 *
9 * This include file contains all the constants and structures associated with
10 * the Interrupt Manager.
11 */
12
13/* COPYRIGHT (c) 1989-2013.
14 * On-Line Applications Research Corporation (OAR).
15 *
16 * The license and distribution terms for this file may be
17 * found in the file LICENSE in this distribution or at
18 * http://www.rtems.com/license/LICENSE.
19 */
20
21#ifndef _RTEMS_RTEMS_INTR_H
22#define _RTEMS_RTEMS_INTR_H
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28#include <rtems/rtems/status.h>
29#include <rtems/score/isr.h>
30#include <rtems/score/isrlock.h>
31
32/**
33 *  @defgroup ClassicINTR Interrupts
34 *
35 *  @ingroup ClassicRTEMS
36 *
37 *  This encapsulates functionality related to the Classic API Interrupt
38 *  Manager.
39 */
40/**@{*/
41
42/**
43 *  @brief Interrupt level type.
44 */
45typedef ISR_Level rtems_interrupt_level;
46
47/**
48 *  @brief Control block type used to manage the vectors.
49 */
50typedef ISR_Vector_number rtems_vector_number;
51
52/**
53 *  @brief Return type for interrupt handler.
54 */
55typedef ISR_Handler rtems_isr;
56
57#if (CPU_SIMPLE_VECTORED_INTERRUPTS == FALSE)
58
59typedef ISR_Handler_entry rtems_isr_entry;
60
61#else
62/**
63 *  @brief Interrupt handler type.
64 *
65 *  @see rtems_interrupt_catch()
66 */
67typedef rtems_isr ( *rtems_isr_entry )(
68                 rtems_vector_number
69             );
70
71/**
72 * @brief RTEMS Interrupt Catch
73 *
74 * This directive installs @a new_isr_handler as the RTEMS interrupt service
75 * routine for the interrupt vector with number @a vector. The previous RTEMS
76 * interrupt service routine is returned in @a old_isr_handler.
77 * 
78 * @param[in] new_isr_handler is the address of interrupt service routine
79 * @param[in] vector is the interrupt vector number
80 * @param[in] old_isr_handler address at which to store previous ISR address
81 *
82 * @retval RTEMS_SUCCESSFUL and *old_isr_handler filled with previous ISR
83 *              address
84 */
85rtems_status_code rtems_interrupt_catch(
86  rtems_isr_entry      new_isr_handler,
87  rtems_vector_number  vector,
88  rtems_isr_entry     *old_isr_handler
89);
90#endif
91
92/**
93 *  @brief Disable RTEMS Interrupt
94 *
95 *  @note The interrupt level shall be of type @ref rtems_interrupt_level.
96 */
97#define rtems_interrupt_disable( _isr_cookie ) \
98    _ISR_Disable(_isr_cookie)
99
100/**
101 *  @brief Enable RTEMS Interrupt
102 *
103 *  @note The interrupt level shall be of type @ref rtems_interrupt_level.
104 */
105#define rtems_interrupt_enable( _isr_cookie ) \
106    _ISR_Enable(_isr_cookie)
107
108/**
109 *  @brief Flash RTEMS Interrupt
110 *
111 *  @note The interrupt level shall be of type @ref rtems_interrupt_level.
112 */
113#define rtems_interrupt_flash( _isr_cookie ) \
114    _ISR_Flash(_isr_cookie)
115
116/**
117 *  @brief RTEMS Interrupt Is in Progress
118 *
119 *  A return value of true indicates that the caller is an interrupt service
120 *  routine and @b not a thread.  The directives available to an interrupt
121 *  service routine are restricted.
122 */
123#define rtems_interrupt_is_in_progress() \
124    _ISR_Is_in_progress()
125
126/**
127 *  @brief This routine generates an interrupt.
128 *
129 *  @note No implementation.
130 */
131#define rtems_interrupt_cause( _interrupt_to_cause )
132
133/**
134 *  @brief This routine clears the specified interrupt.
135 *
136 *  @note No implementation.
137 */
138#define rtems_interrupt_clear( _interrupt_to_clear )
139
140/**
141 * @defgroup ClassicINTRLocks Interrupt Locks
142 *
143 * @ingroup ClassicINTR
144 *
145 * @brief Low-level lock to protect critical sections accessed by threads and
146 * interrupt service routines.
147 *
148 * On single processor configurations the interrupt locks degrade to simple
149 * interrupt disable/enable sequences.  No additional storage or objects are
150 * required.
151 *
152 * This synchronization primitive is supported on SMP configurations.  Here SMP
153 * locks are used.
154 * @{
155 */
156
157/**
158 * @brief Interrupt lock control.
159 */
160typedef ISR_lock_Control rtems_interrupt_lock;
161
162/**
163 * @brief Local interrupt lock context for acquire and release pairs.
164 */
165typedef ISR_lock_Context rtems_interrupt_lock_context;
166
167/**
168 * @brief Initializer for static initialization of interrupt locks.
169 */
170#define RTEMS_INTERRUPT_LOCK_INITIALIZER ISR_LOCK_INITIALIZER
171
172/**
173 * @brief Initializes an interrupt lock.
174 *
175 * Concurrent initialization leads to unpredictable results.
176 *
177 * @param[in,out] _lock The interrupt lock.
178 */
179#define rtems_interrupt_lock_initialize( _lock ) \
180  _ISR_lock_Initialize( _lock )
181
182/**
183 * @brief Acquires an interrupt lock.
184 *
185 * Interrupts will be disabled.  On SMP configurations this function acquires
186 * an SMP lock.
187 *
188 * This function can be used in thread and interrupt context.
189 *
190 * @param[in,out] _lock The interrupt lock.
191 * @param[in,out] _lock_context The local interrupt lock context for an acquire
192 * and release pair.
193 *
194 * @see rtems_interrupt_lock_release().
195 */
196#define rtems_interrupt_lock_acquire( _lock, _lock_context ) \
197  _ISR_lock_ISR_disable_and_acquire( _lock, _lock_context )
198
199/**
200 * @brief Releases an interrupt lock.
201 *
202 * The interrupt status will be restored.  On SMP configurations this function
203 * releases an SMP lock.
204 *
205 * This function can be used in thread and interrupt context.
206 *
207 * @param[in,out] _lock The interrupt lock.
208 * @param[in,out] _lock_context The local interrupt lock context for an acquire
209 * and release pair.
210 *
211 * @see rtems_interrupt_lock_acquire().
212 */
213#define rtems_interrupt_lock_release( _lock, _lock_context ) \
214  _ISR_lock_Release_and_ISR_enable( _lock, _lock_context )
215
216/**
217 * @brief Acquires an interrupt lock in the corresponding interrupt service
218 * routine.
219 *
220 * The interrupt status will remain unchanged.  On SMP configurations this
221 * function acquires an SMP lock.
222 *
223 * In case the corresponding interrupt service routine can be interrupted by
224 * higher priority interrupts and these interrupts enter the critical section
225 * protected by this lock, then the result is unpredictable.
226 *
227 * @param[in,out] _lock The interrupt lock.
228 * @param[in,out] _lock_context The local interrupt lock context for an acquire
229 * and release pair.
230 *
231 * @see rtems_interrupt_lock_release_isr().
232 */
233#define rtems_interrupt_lock_acquire_isr( _lock, _lock_context ) \
234  _ISR_lock_Acquire( _lock, _lock_context )
235
236/**
237 * @brief Releases an interrupt lock in the corresponding interrupt service
238 * routine.
239 *
240 * The interrupt status will remain unchanged.  On SMP configurations this
241 * function releases an SMP lock.
242 *
243 * @param[in,out] _lock The interrupt lock.
244 * @param[in,out] _lock_context The local interrupt lock context for an acquire
245 * and release pair.
246 *
247 * @see rtems_interrupt_lock_acquire_isr().
248 */
249#define rtems_interrupt_lock_release_isr( _lock, _lock_context ) \
250  _ISR_lock_Release( _lock, _lock_context )
251
252/** @} */
253
254#ifdef __cplusplus
255}
256#endif
257
258/**@}*/
259
260#endif
261/* end of include file */
Note: See TracBrowser for help on using the repository browser.