source: rtems/cpukit/score/include/rtems/score/isr.h @ 484a769

4.104.114.95
Last change on this file since 484a769 was 484a769, checked in by Ralf Corsepius <ralf.corsepius@…>, on 09/04/08 at 17:46:39

Convert to "bool".

  • Property mode set to 100644
File size: 6.4 KB
Line 
1/**
2 *  @file  rtems/score/isr.h
3 *
4 *  This include file contains all the constants and structures associated
5 *  with the management of processor interrupt levels.  This handler
6 *  supports interrupt critical sections, vectoring of user interrupt
7 *  handlers, nesting of interrupts, and manipulating interrupt levels.
8 */
9
10/*
11 *  COPYRIGHT (c) 1989-2006.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.com/license/LICENSE.
17 *
18 *  $Id$
19 */
20
21#ifndef _RTEMS_SCORE_ISR_H
22#define _RTEMS_SCORE_ISR_H
23
24/**
25 *  @defgroup ScoreISR ISR Handler
26 *
27 *  This handler encapsulates functionality which provides the foundation
28 *  ISR services used in all of the APIs supported by RTEMS.
29 */
30/**@{*/
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36/**
37 *  The following type defines the control block used to manage
38 *  the interrupt level portion of the status register.
39 */
40typedef uint32_t   ISR_Level;
41
42/**
43 *  The following type defines the type used to manage the vectors.
44 */
45typedef uint32_t   ISR_Vector_number;
46
47/**
48 *  Return type for ISR Handler
49 */
50typedef void ISR_Handler;
51
52/**
53 *  Pointer to an ISR Handler
54 */
55#if (CPU_ISR_PASSES_FRAME_POINTER == 1)
56typedef ISR_Handler ( *ISR_Handler_entry )(
57                 ISR_Vector_number,
58                 CPU_Interrupt_frame *
59             );
60#else
61typedef ISR_Handler ( *ISR_Handler_entry )(
62                 ISR_Vector_number
63             );
64#endif
65
66/**
67 *  This constant promotes out the number of vectors truly supported by
68 *  the current CPU being used.  This is usually the number of distinct vectors
69 *  the cpu can vector.
70 */
71#define ISR_NUMBER_OF_VECTORS                CPU_INTERRUPT_NUMBER_OF_VECTORS
72
73/**
74 *  This constant promotes out the highest valid interrupt vector number.
75 */
76#define ISR_INTERRUPT_MAXIMUM_VECTOR_NUMBER  CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER
77
78/**
79 *  The following is TRUE if signals have been sent to the currently
80 *  executing thread by an ISR handler.
81 */
82SCORE_EXTERN bool       _ISR_Signals_to_thread_executing;
83
84/**
85 *  The following contains the interrupt service routine nest level.
86 *  When this variable is zero, a thread is executing.
87 */
88SCORE_EXTERN volatile uint32_t   _ISR_Nest_level;
89
90#if (CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE)
91/**
92 *  The following declares the Vector Table.  Application
93 *  interrupt service routines are vectored by the ISR Handler via this table.
94 */
95SCORE_EXTERN ISR_Handler_entry *_ISR_Vector_table;
96#endif
97
98/**
99 *  This routine performs the initialization necessary for this handler.
100 */
101void _ISR_Handler_initialization ( void );
102
103/**
104 *  This routine disables all interrupts so that a critical section
105 *  of code can be executing without being interrupted.  Upon return,
106 *  the argument _level will contain the previous interrupt mask level.
107 */
108#define _ISR_Disable( _level ) \
109  do { \
110    _CPU_ISR_Disable( _level ); \
111    RTEMS_COMPILER_MEMORY_BARRIER(); \
112  } while (0)
113
114/**
115 *  This routine enables interrupts to the previous interrupt mask
116 *  LEVEL.  It is used at the end of a critical section of code to
117 *  enable interrupts so they can be processed again.
118 */
119#define _ISR_Enable( _level ) \
120  do { \
121    RTEMS_COMPILER_MEMORY_BARRIER(); \
122    _CPU_ISR_Enable( _level ); \
123  } while (0)
124
125/**
126 *  This routine temporarily enables interrupts to the previous
127 *  interrupt mask level and then disables all interrupts so that
128 *  the caller can continue into the second part of a critical
129 *  section.  This routine is used to temporarily enable interrupts
130 *  during a long critical section.  It is used in long sections of
131 *  critical code when a point is reached at which interrupts can
132 *  be temporarily enabled.  Deciding where to flash interrupts
133 *  in a long critical section is often difficult and the point
134 *  must be selected with care to ensure that the critical section
135 *  properly protects itself.
136 */
137#define _ISR_Flash( _level ) \
138  do { \
139    RTEMS_COMPILER_MEMORY_BARRIER(); \
140    _CPU_ISR_Flash( _level ); \
141    RTEMS_COMPILER_MEMORY_BARRIER(); \
142  } while (0)
143
144/**
145 *  This routine installs new_handler as the interrupt service routine
146 *  for the specified vector.  The previous interrupt service routine is
147 *  returned as old_handler.
148 */
149#define _ISR_Install_vector( _vector, _new_handler, _old_handler ) \
150  _CPU_ISR_install_vector( _vector, _new_handler, _old_handler )
151
152/**
153 *  This routine returns the current interrupt level.
154 */
155#define _ISR_Get_level() \
156        _CPU_ISR_Get_level()
157
158/**
159 *  This routine sets the current interrupt level to that specified
160 *  by new_level.  The new interrupt level is effective when the
161 *  routine exits.
162 */
163#define _ISR_Set_level( _new_level ) \
164          do { \
165                RTEMS_COMPILER_MEMORY_BARRIER();  \
166                _CPU_ISR_Set_level( _new_level ); \
167                RTEMS_COMPILER_MEMORY_BARRIER();  \
168        } while (0)
169
170
171/**
172 *  This routine is the interrupt dispatcher.  ALL interrupts
173 *  are vectored to this routine so that minimal context can be saved
174 *  and setup performed before the application's high-level language
175 *  interrupt service routine is invoked.   After the application's
176 *  interrupt service routine returns control to this routine, it
177 *  will determine if a thread dispatch is necessary.  If so, it will
178 *  ensure that the necessary thread scheduling operations are
179 *  performed when the outermost interrupt service routine exits.
180 *
181 *  @note  Implemented in assembly language.
182 */
183void _ISR_Handler( void );
184
185/**
186 *  This routine provides a wrapper so that the routine
187 *  @ref _Thread_Dispatch can be invoked when a reschedule is necessary
188 *  at the end of the outermost interrupt service routine.  This
189 *  wrapper is necessary to establish the processor context needed
190 *  by _Thread_Dispatch and to save the processor context which is
191 *  corrupted by _Thread_Dispatch.  This context typically consists
192 *  of registers which are not preserved across routine invocations.
193 *
194 *  @note  Implemented in assembly language.
195 */
196void _ISR_Dispatch( void );
197
198/**
199 *  This function returns TRUE if the processor is currently servicing
200 *  and interrupt and FALSE otherwise.   A return value of TRUE indicates
201 *  that the caller is an interrupt service routine, NOT a thread.  The
202 */
203#if (CPU_PROVIDES_ISR_IS_IN_PROGRESS == TRUE)
204bool _ISR_Is_in_progress( void );
205#else
206#define _ISR_Is_in_progress() \
207        (_ISR_Nest_level != 0)
208#endif
209
210#include <rtems/score/isr.inl>
211
212#ifdef __cplusplus
213}
214#endif
215
216/**@}*/
217
218#endif
219/* end of include file */
Note: See TracBrowser for help on using the repository browser.