source: rtems/cpukit/score/include/rtems/score/isr.h @ f68401e

4.115
Last change on this file since f68401e was bf30999, checked in by Sebastian Huber <sebastian.huber@…>, on 08/23/13 at 14:15:50

smp: Add and use _Assert_Owner_of_giant()

Add and use _ISR_Disable_without_giant() and
_ISR_Enable_without_giant() if RTEMS_SMP is defined.

On single processor systems the ISR disable/enable was the big hammer
which ensured system-wide mutual exclusion. On SMP configurations this
no longer works since other processors do not care about disabled
interrupts on this processor and continue to execute freely.

On SMP in addition to ISR disable/enable an SMP lock must be used.
Currently we have only the Giant lock so we can check easily that ISR
disable/enable is used only in the right context.

  • Property mode set to 100644
File size: 5.6 KB
Line 
1/**
2 *  @file  rtems/score/isr.h
3 *
4 *  @brief Data Related to the Management of Processor Interrupt Levels
5 *
6 *  This include file contains all the constants and structures associated
7 *  with the management of processor interrupt levels.  This handler
8 *  supports interrupt critical sections, vectoring of user interrupt
9 *  handlers, nesting of interrupts, and manipulating interrupt levels.
10 */
11
12/*
13 *  COPYRIGHT (c) 1989-2012.
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_SCORE_ISR_H
22#define _RTEMS_SCORE_ISR_H
23
24#include <rtems/score/isrlevel.h>
25#include <rtems/score/percpu.h>
26
27/**
28 *  @defgroup ScoreISR ISR Handler
29 *
30 *  @ingroup Score
31 *
32 *  This handler encapsulates functionality which provides the foundation
33 *  ISR services used in all of the APIs supported by RTEMS.
34 *
35 *  The ISR Nest level counter variable is maintained as part of the
36 *  per cpu data structure.
37 */
38/**@{*/
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44/**
45 *  The following type defines the type used to manage the vectors.
46 */
47typedef uint32_t   ISR_Vector_number;
48
49/**
50 *  Return type for ISR Handler
51 */
52typedef void ISR_Handler;
53
54#if (CPU_SIMPLE_VECTORED_INTERRUPTS == FALSE)
55
56typedef void * ISR_Handler_entry;
57
58#else
59/**
60 *  Pointer to an ISR Handler
61 */
62#if (CPU_ISR_PASSES_FRAME_POINTER == 1)
63typedef ISR_Handler ( *ISR_Handler_entry )(
64                 ISR_Vector_number,
65                 CPU_Interrupt_frame *
66             );
67#else
68typedef ISR_Handler ( *ISR_Handler_entry )(
69                 ISR_Vector_number
70             );
71#endif
72
73/**
74 *  This constant promotes out the number of vectors truly supported by
75 *  the current CPU being used.  This is usually the number of distinct vectors
76 *  the cpu can vector.
77 */
78#define ISR_NUMBER_OF_VECTORS                CPU_INTERRUPT_NUMBER_OF_VECTORS
79
80/**
81 *  This constant promotes out the highest valid interrupt vector number.
82 */
83#define ISR_INTERRUPT_MAXIMUM_VECTOR_NUMBER  CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER
84
85/**
86 *  The following declares the Vector Table.  Application
87 *  interrupt service routines are vectored by the ISR Handler via this table.
88 */
89SCORE_EXTERN ISR_Handler_entry *_ISR_Vector_table;
90#endif
91
92/**
93 *  @brief Initialize the ISR handler.
94 *
95 *  This routine performs the initialization necessary for the ISR handler.
96 */
97void _ISR_Handler_initialization ( void );
98
99/**
100 *  @brief Install interrupt handler vector.
101 *
102 *  This routine installs new_handler as the interrupt service routine
103 *  for the specified vector.  The previous interrupt service routine is
104 *  returned as old_handler.
105 *
106 *  LM32 Specific Information:
107 *  XXX document implementation including references if appropriate
108 *
109 *  @param[in] _vector is the vector number
110 *  @param[in] _new_handler is ISR handler to install
111 *  @param[in] _old_handler is a pointer to a variable which will be set
112 *             to the old handler
113 *
114 *  @retval *_old_handler will be set to the old ISR handler
115 */
116#define _ISR_Install_vector( _vector, _new_handler, _old_handler ) \
117  _CPU_ISR_install_vector( _vector, _new_handler, _old_handler )
118
119/**
120 *  @brief ISR interrupt dispatcher.
121 *
122 *  This routine is the interrupt dispatcher.  ALL interrupts
123 *  are vectored to this routine so that minimal context can be saved
124 *  and setup performed before the application's high-level language
125 *  interrupt service routine is invoked.   After the application's
126 *  interrupt service routine returns control to this routine, it
127 *  will determine if a thread dispatch is necessary.  If so, it will
128 *  ensure that the necessary thread scheduling operations are
129 *  performed when the outermost interrupt service routine exits.
130 *
131 *  @note  Typically implemented in assembly language.
132 */
133void _ISR_Handler( void );
134
135/**
136 *  @brief ISR wrapper for thread dispatcher.
137 *
138 *  This routine provides a wrapper so that the routine
139 *  @ref _Thread_Dispatch can be invoked when a reschedule is necessary
140 *  at the end of the outermost interrupt service routine.  This
141 *  wrapper is necessary to establish the processor context needed
142 *  by _Thread_Dispatch and to save the processor context which is
143 *  corrupted by _Thread_Dispatch.  This context typically consists
144 *  of registers which are not preserved across routine invocations.
145 *
146 *  @note  Typically mplemented in assembly language.
147 */
148void _ISR_Dispatch( void );
149
150/**
151 * @brief Returns the current ISR nest level
152 *
153 * This function can be called in any context.  On SMP configurations
154 * interrupts are disabled to ensure that the processor index is used
155 * consistently.
156 *
157 * @return The current ISR nest level.
158 */
159RTEMS_INLINE_ROUTINE uint32_t _ISR_Get_nest_level( void )
160{
161  uint32_t isr_nest_level;
162
163  #if defined( RTEMS_SMP )
164    ISR_Level level;
165
166    _ISR_Disable_without_giant( level );
167  #endif
168
169  isr_nest_level = _ISR_Nest_level;
170
171  #if defined( RTEMS_SMP )
172    _ISR_Enable_without_giant( level );
173  #endif
174
175  return isr_nest_level;
176}
177
178/**
179 *  @brief Checks if an ISR in progress.
180 *
181 *  This function returns true if the processor is currently servicing
182 *  and interrupt and false otherwise.   A return value of true indicates
183 *  that the caller is an interrupt service routine, NOT a thread.
184 *
185 *  @retval This methods returns true when called from an ISR.
186 */
187#if (CPU_PROVIDES_ISR_IS_IN_PROGRESS == TRUE)
188  bool _ISR_Is_in_progress( void );
189#else
190  #define _ISR_Is_in_progress() \
191          (_ISR_Get_nest_level() != 0)
192#endif
193
194#ifdef __cplusplus
195}
196#endif
197
198/**@}*/
199
200#endif
201/* end of include file */
Note: See TracBrowser for help on using the repository browser.