1 | /* isr.h |
---|
2 | * |
---|
3 | * This include file contains all the constants and structures associated |
---|
4 | * with the management of processor interrupt levels. This handler |
---|
5 | * supports interrupt critical sections, vectoring of user interrupt |
---|
6 | * handlers, nesting of interrupts, and manipulating interrupt levels. |
---|
7 | * |
---|
8 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
9 | * On-Line Applications Research Corporation (OAR). |
---|
10 | * All rights assigned to U.S. Government, 1994. |
---|
11 | * |
---|
12 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
13 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
14 | * notice must appear in all copies of this file and its derivatives. |
---|
15 | * |
---|
16 | * $Id$ |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef __ISR_h |
---|
20 | #define __ISR_h |
---|
21 | |
---|
22 | #ifdef __cplusplus |
---|
23 | extern "C" { |
---|
24 | #endif |
---|
25 | |
---|
26 | /* |
---|
27 | * The following type defines the control block used to manage |
---|
28 | * the interrupt level portion of the status register. |
---|
29 | */ |
---|
30 | |
---|
31 | typedef unsigned32 ISR_Level; |
---|
32 | |
---|
33 | /* |
---|
34 | * The following type defines the type used to manage the vectors. |
---|
35 | */ |
---|
36 | |
---|
37 | typedef unsigned32 ISR_Vector_number; |
---|
38 | |
---|
39 | /* |
---|
40 | * Return type for ISR Handler |
---|
41 | */ |
---|
42 | |
---|
43 | typedef void ISR_Handler; |
---|
44 | |
---|
45 | /* |
---|
46 | * Pointer to an ISR Handler |
---|
47 | */ |
---|
48 | |
---|
49 | typedef ISR_Handler ( *ISR_Handler_entry )( |
---|
50 | ISR_Vector_number |
---|
51 | ); |
---|
52 | /* |
---|
53 | * The following is TRUE if signals have been sent to the currently |
---|
54 | * executing thread by an ISR handler. |
---|
55 | */ |
---|
56 | |
---|
57 | EXTERN boolean _ISR_Signals_to_thread_executing; |
---|
58 | |
---|
59 | /* |
---|
60 | * The following contains the interrupt service routine nest level. |
---|
61 | * When this variable is zero, a thread is executing. |
---|
62 | */ |
---|
63 | |
---|
64 | EXTERN unsigned32 _ISR_Nest_level; |
---|
65 | |
---|
66 | /* |
---|
67 | * The following declares the Vector Table. Application |
---|
68 | * interrupt service routines are vectored by the ISR Handler via this table. |
---|
69 | */ |
---|
70 | |
---|
71 | EXTERN ISR_Handler_entry _ISR_Vector_table[CPU_INTERRUPT_NUMBER_OF_VECTORS]; |
---|
72 | |
---|
73 | /* |
---|
74 | * _ISR_Handler_initialization |
---|
75 | * |
---|
76 | * DESCRIPTION: |
---|
77 | * |
---|
78 | * This routine performs the initialization necessary for this handler. |
---|
79 | */ |
---|
80 | |
---|
81 | void _ISR_Handler_initialization ( void ); |
---|
82 | |
---|
83 | /* |
---|
84 | * _ISR_Disable |
---|
85 | * |
---|
86 | * DESCRIPTION: |
---|
87 | * |
---|
88 | * This routine disables all interrupts so that a critical section |
---|
89 | * of code can be executing without being interrupted. Upon return, |
---|
90 | * the argument _level will contain the previous interrupt mask level. |
---|
91 | */ |
---|
92 | |
---|
93 | #define _ISR_Disable( _level ) \ |
---|
94 | _CPU_ISR_Disable( _level ) |
---|
95 | |
---|
96 | /* |
---|
97 | * _ISR_Enable |
---|
98 | * |
---|
99 | * DESCRIPTION: |
---|
100 | * |
---|
101 | * This routine enables interrupts to the previous interrupt mask |
---|
102 | * LEVEL. It is used at the end of a critical section of code to |
---|
103 | * enable interrupts so they can be processed again. |
---|
104 | */ |
---|
105 | |
---|
106 | #define _ISR_Enable( _level ) \ |
---|
107 | _CPU_ISR_Enable( _level ) |
---|
108 | |
---|
109 | /* |
---|
110 | * _ISR_Flash |
---|
111 | * |
---|
112 | * DESCRIPTION: |
---|
113 | * |
---|
114 | * This routine temporarily enables interrupts to the previous |
---|
115 | * interrupt mask level and then disables all interrupts so that |
---|
116 | * the caller can continue into the second part of a critical |
---|
117 | * section. This routine is used to temporarily enable interrupts |
---|
118 | * during a long critical section. It is used in long sections of |
---|
119 | * critical code when a point is reached at which interrupts can |
---|
120 | * be temporarily enabled. Deciding where to flash interrupts |
---|
121 | * in a long critical section is often difficult and the point |
---|
122 | * must be selected with care to insure that the critical section |
---|
123 | * properly protects itself. |
---|
124 | */ |
---|
125 | |
---|
126 | #define _ISR_Flash( _level ) \ |
---|
127 | _CPU_ISR_Flash( _level ) |
---|
128 | |
---|
129 | /* |
---|
130 | * _ISR_Is_in_progress |
---|
131 | * |
---|
132 | * DESCRIPTION: |
---|
133 | * |
---|
134 | * This function returns TRUE if the processor is currently servicing |
---|
135 | * and interrupt and FALSE otherwise. A return value of TRUE indicates |
---|
136 | * that the caller is an interrupt service routine, NOT a thread. The |
---|
137 | * directives available to an interrupt service routine are restricted. |
---|
138 | */ |
---|
139 | |
---|
140 | STATIC INLINE boolean _ISR_Is_in_progress( void ); |
---|
141 | |
---|
142 | /* |
---|
143 | * _ISR_Install_vector |
---|
144 | * |
---|
145 | * DESCRIPTION: |
---|
146 | * |
---|
147 | * This routine installs new_handler as the interrupt service routine |
---|
148 | * for the specified vector. The previous interrupt service routine is |
---|
149 | * returned as old_handler. |
---|
150 | */ |
---|
151 | |
---|
152 | #define _ISR_Install_vector( _vector, _new_handler, _old_handler ) \ |
---|
153 | _CPU_ISR_install_vector( _vector, _new_handler, _old_handler ) |
---|
154 | |
---|
155 | /* |
---|
156 | * _ISR_Get_level |
---|
157 | * |
---|
158 | * DESCRIPTION: |
---|
159 | * |
---|
160 | * This routine returns the current interrupt level. |
---|
161 | */ |
---|
162 | |
---|
163 | #define _ISR_Get_level() \ |
---|
164 | _CPU_ISR_Get_level() |
---|
165 | |
---|
166 | /* |
---|
167 | * _ISR_Set_level |
---|
168 | * |
---|
169 | * DESCRIPTION: |
---|
170 | * |
---|
171 | * This routine sets the current interrupt level to that specified |
---|
172 | * by new_level. The new interrupt level is effective when the |
---|
173 | * routine exits. |
---|
174 | */ |
---|
175 | |
---|
176 | #define _ISR_Set_level( _new_level ) \ |
---|
177 | _CPU_ISR_Set_level( _new_level ) |
---|
178 | |
---|
179 | /* |
---|
180 | * _ISR_Is_vector_number_valid |
---|
181 | * |
---|
182 | * DESCRIPTION: |
---|
183 | * |
---|
184 | * This function returns TRUE if the vector is a valid vector number |
---|
185 | * for this processor and FALSE otherwise. |
---|
186 | */ |
---|
187 | |
---|
188 | STATIC INLINE boolean _ISR_Is_vector_number_valid ( |
---|
189 | ISR_Vector_number vector |
---|
190 | ); |
---|
191 | |
---|
192 | /* |
---|
193 | * _ISR_Is_valid_user_handler |
---|
194 | * |
---|
195 | * DESCRIPTION: |
---|
196 | * |
---|
197 | * This function returns TRUE if handler is the entry point of a valid |
---|
198 | * use interrupt service routine and FALSE otherwise. |
---|
199 | */ |
---|
200 | |
---|
201 | STATIC INLINE boolean _ISR_Is_valid_user_handler ( |
---|
202 | void *handler |
---|
203 | ); |
---|
204 | |
---|
205 | /* |
---|
206 | * _ISR_Handler |
---|
207 | * |
---|
208 | * DESCRIPTION: |
---|
209 | * |
---|
210 | * This routine is the interrupt dispatcher. ALL interrupts |
---|
211 | * are vectored to this routine so that minimal context can be saved |
---|
212 | * and setup performed before the application's high-level language |
---|
213 | * interrupt service routine is invoked. After the application's |
---|
214 | * interrupt service routine returns control to this routine, it |
---|
215 | * will determine if a thread dispatch is necessary. If so, it will |
---|
216 | * insure that the necessary thread scheduling operations are |
---|
217 | * performed when the outermost interrupt service routine exits. |
---|
218 | * |
---|
219 | * NOTE: Implemented in assembly language. |
---|
220 | */ |
---|
221 | |
---|
222 | void _ISR_Handler( void ); |
---|
223 | |
---|
224 | /* |
---|
225 | * _ISR_Dispatch |
---|
226 | * |
---|
227 | * DESCRIPTION: |
---|
228 | * |
---|
229 | * This routine provides a wrapper so that the routine |
---|
230 | * _Thread_Dispatch can be invoked when a reschedule is necessary |
---|
231 | * at the end of the outermost interrupt service routine. This |
---|
232 | * wrapper is necessary to establish the processor context needed |
---|
233 | * by _Thread_Dispatch and to save the processor context which is |
---|
234 | * corrupted by _Thread_Dispatch. This context typically consists |
---|
235 | * of registers which are not preserved across routine invocations. |
---|
236 | * |
---|
237 | * NOTE: Implemented in assembly language. |
---|
238 | */ |
---|
239 | |
---|
240 | void _ISR_Dispatch( void ); |
---|
241 | |
---|
242 | #include <rtems/core/isr.inl> |
---|
243 | |
---|
244 | #ifdef __cplusplus |
---|
245 | } |
---|
246 | #endif |
---|
247 | |
---|
248 | #endif |
---|
249 | /* end of include file */ |
---|