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.org/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 |
---|
41 | extern "C" { |
---|
42 | #endif |
---|
43 | |
---|
44 | /** |
---|
45 | * The following type defines the type used to manage the vectors. |
---|
46 | */ |
---|
47 | typedef uint32_t ISR_Vector_number; |
---|
48 | |
---|
49 | /** |
---|
50 | * Return type for ISR Handler |
---|
51 | */ |
---|
52 | typedef void ISR_Handler; |
---|
53 | |
---|
54 | #if (CPU_SIMPLE_VECTORED_INTERRUPTS == FALSE) |
---|
55 | |
---|
56 | typedef void * ISR_Handler_entry; |
---|
57 | |
---|
58 | #else |
---|
59 | /** |
---|
60 | * Pointer to an ISR Handler |
---|
61 | */ |
---|
62 | #if (CPU_ISR_PASSES_FRAME_POINTER == 1) |
---|
63 | typedef ISR_Handler ( *ISR_Handler_entry )( |
---|
64 | ISR_Vector_number, |
---|
65 | CPU_Interrupt_frame * |
---|
66 | ); |
---|
67 | #else |
---|
68 | typedef ISR_Handler ( *ISR_Handler_entry )( |
---|
69 | ISR_Vector_number |
---|
70 | ); |
---|
71 | #endif |
---|
72 | |
---|
73 | /** |
---|
74 | * The following declares the Vector Table. Application |
---|
75 | * interrupt service routines are vectored by the ISR Handler via this table. |
---|
76 | */ |
---|
77 | extern ISR_Handler_entry _ISR_Vector_table[ CPU_INTERRUPT_NUMBER_OF_VECTORS ]; |
---|
78 | #endif |
---|
79 | |
---|
80 | /** |
---|
81 | * @brief Initialize the ISR handler. |
---|
82 | * |
---|
83 | * This routine performs the initialization necessary for the ISR handler. |
---|
84 | */ |
---|
85 | void _ISR_Handler_initialization ( void ); |
---|
86 | |
---|
87 | /** |
---|
88 | * @brief Install interrupt handler vector. |
---|
89 | * |
---|
90 | * This routine installs new_handler as the interrupt service routine |
---|
91 | * for the specified vector. The previous interrupt service routine is |
---|
92 | * returned as old_handler. |
---|
93 | * |
---|
94 | * LM32 Specific Information: |
---|
95 | * XXX document implementation including references if appropriate |
---|
96 | * |
---|
97 | * @param[in] _vector is the vector number |
---|
98 | * @param[in] _new_handler is ISR handler to install |
---|
99 | * @param[in] _old_handler is a pointer to a variable which will be set |
---|
100 | * to the old handler |
---|
101 | * |
---|
102 | * @retval *_old_handler will be set to the old ISR handler |
---|
103 | */ |
---|
104 | #define _ISR_Install_vector( _vector, _new_handler, _old_handler ) \ |
---|
105 | _CPU_ISR_install_vector( _vector, _new_handler, _old_handler ) |
---|
106 | |
---|
107 | /** |
---|
108 | * @brief ISR interrupt dispatcher. |
---|
109 | * |
---|
110 | * This routine is the interrupt dispatcher. ALL interrupts |
---|
111 | * are vectored to this routine so that minimal context can be saved |
---|
112 | * and setup performed before the application's high-level language |
---|
113 | * interrupt service routine is invoked. After the application's |
---|
114 | * interrupt service routine returns control to this routine, it |
---|
115 | * will determine if a thread dispatch is necessary. If so, it will |
---|
116 | * ensure that the necessary thread scheduling operations are |
---|
117 | * performed when the outermost interrupt service routine exits. |
---|
118 | * |
---|
119 | * @note Typically implemented in assembly language. |
---|
120 | */ |
---|
121 | void _ISR_Handler( void ); |
---|
122 | |
---|
123 | /** |
---|
124 | * @brief ISR wrapper for thread dispatcher. |
---|
125 | * |
---|
126 | * This routine provides a wrapper so that the routine |
---|
127 | * @ref _Thread_Dispatch can be invoked when a reschedule is necessary |
---|
128 | * at the end of the outermost interrupt service routine. This |
---|
129 | * wrapper is necessary to establish the processor context needed |
---|
130 | * by _Thread_Dispatch and to save the processor context which is |
---|
131 | * corrupted by _Thread_Dispatch. This context typically consists |
---|
132 | * of registers which are not preserved across routine invocations. |
---|
133 | * |
---|
134 | * @note Typically mplemented in assembly language. |
---|
135 | */ |
---|
136 | void _ISR_Dispatch( void ); |
---|
137 | |
---|
138 | /** |
---|
139 | * @brief Returns the current ISR nest level |
---|
140 | * |
---|
141 | * This function can be called in any context. On SMP configurations |
---|
142 | * interrupts are disabled to ensure that the processor index is used |
---|
143 | * consistently. |
---|
144 | * |
---|
145 | * @return The current ISR nest level. |
---|
146 | */ |
---|
147 | RTEMS_INLINE_ROUTINE uint32_t _ISR_Get_nest_level( void ) |
---|
148 | { |
---|
149 | uint32_t isr_nest_level; |
---|
150 | |
---|
151 | #if defined( RTEMS_SMP ) |
---|
152 | ISR_Level level; |
---|
153 | |
---|
154 | _ISR_Disable_without_giant( level ); |
---|
155 | #endif |
---|
156 | |
---|
157 | isr_nest_level = _ISR_Nest_level; |
---|
158 | |
---|
159 | #if defined( RTEMS_SMP ) |
---|
160 | _ISR_Enable_without_giant( level ); |
---|
161 | #endif |
---|
162 | |
---|
163 | return isr_nest_level; |
---|
164 | } |
---|
165 | |
---|
166 | /** |
---|
167 | * @brief Checks if an ISR in progress. |
---|
168 | * |
---|
169 | * This function returns true if the processor is currently servicing |
---|
170 | * and interrupt and false otherwise. A return value of true indicates |
---|
171 | * that the caller is an interrupt service routine, NOT a thread. |
---|
172 | * |
---|
173 | * @retval This methods returns true when called from an ISR. |
---|
174 | */ |
---|
175 | #if (CPU_PROVIDES_ISR_IS_IN_PROGRESS == TRUE) |
---|
176 | bool _ISR_Is_in_progress( void ); |
---|
177 | #else |
---|
178 | #define _ISR_Is_in_progress() \ |
---|
179 | (_ISR_Get_nest_level() != 0) |
---|
180 | #endif |
---|
181 | |
---|
182 | #ifdef __cplusplus |
---|
183 | } |
---|
184 | #endif |
---|
185 | |
---|
186 | /**@}*/ |
---|
187 | |
---|
188 | #endif |
---|
189 | /* end of include file */ |
---|