1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup rtems_interrupt_extension |
---|
5 | * |
---|
6 | * @brief Header file for the Interrupt Manager Extension. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Based on concepts of Pavel Pisa, Till Straumann and Eric Valette. |
---|
11 | * |
---|
12 | * Copyright (c) 2008, 2016 embedded brains GmbH. |
---|
13 | * |
---|
14 | * embedded brains GmbH |
---|
15 | * Dornierstr. 4 |
---|
16 | * 82178 Puchheim |
---|
17 | * Germany |
---|
18 | * <rtems@embedded-brains.de> |
---|
19 | * |
---|
20 | * The license and distribution terms for this file may be |
---|
21 | * found in the file LICENSE in this distribution or at |
---|
22 | * http://www.rtems.org/license/LICENSE. |
---|
23 | */ |
---|
24 | |
---|
25 | #ifndef RTEMS_IRQ_EXTENSION_H |
---|
26 | #define RTEMS_IRQ_EXTENSION_H |
---|
27 | |
---|
28 | #include <rtems.h> |
---|
29 | |
---|
30 | #ifdef __cplusplus |
---|
31 | extern "C" { |
---|
32 | #endif /* __cplusplus */ |
---|
33 | |
---|
34 | /** |
---|
35 | * @defgroup rtems_interrupt_extension Interrupt Manager Extension |
---|
36 | * |
---|
37 | * @ingroup ClassicINTR |
---|
38 | * |
---|
39 | * In addition to the Classic API interrupt handler with a handle are |
---|
40 | * supported. You can also install multiple shared handler for one interrupt |
---|
41 | * vector. |
---|
42 | */ |
---|
43 | /**@{**/ |
---|
44 | |
---|
45 | /** |
---|
46 | * @brief Makes the interrupt handler unique. Prevents other handler from |
---|
47 | * using the same interrupt vector. |
---|
48 | */ |
---|
49 | #define RTEMS_INTERRUPT_UNIQUE ((rtems_option) 0x00000001) |
---|
50 | |
---|
51 | /** |
---|
52 | * @brief Allows that this interrupt handler may share a common interrupt |
---|
53 | * vector with other handler. |
---|
54 | */ |
---|
55 | #define RTEMS_INTERRUPT_SHARED ((rtems_option) 0x00000000) |
---|
56 | |
---|
57 | /** |
---|
58 | * @brief Forces that this interrupt handler replaces the first handler with |
---|
59 | * the same argument. |
---|
60 | */ |
---|
61 | #define RTEMS_INTERRUPT_REPLACE ((rtems_option) 0x00000002) |
---|
62 | |
---|
63 | /** |
---|
64 | * @brief Returns true if the interrupt handler unique option is set. |
---|
65 | */ |
---|
66 | #define RTEMS_INTERRUPT_IS_UNIQUE( options) \ |
---|
67 | ((options) & RTEMS_INTERRUPT_UNIQUE) |
---|
68 | |
---|
69 | /** |
---|
70 | * @brief Returns true if the interrupt handler shared option is set. |
---|
71 | */ |
---|
72 | #define RTEMS_INTERRUPT_IS_SHARED( options) \ |
---|
73 | (!RTEMS_INTERRUPT_IS_UNIQUE( options)) |
---|
74 | |
---|
75 | /** |
---|
76 | * @brief Returns true if the interrupt handler replace option is set. |
---|
77 | */ |
---|
78 | #define RTEMS_INTERRUPT_IS_REPLACE( options) \ |
---|
79 | ((options) & RTEMS_INTERRUPT_REPLACE) |
---|
80 | |
---|
81 | /** |
---|
82 | * @brief Interrupt handler routine type. |
---|
83 | */ |
---|
84 | typedef void (*rtems_interrupt_handler)(void *); |
---|
85 | |
---|
86 | /** |
---|
87 | * @brief Installs the interrupt handler routine @a handler for the interrupt |
---|
88 | * vector with number @a vector. |
---|
89 | * |
---|
90 | * You can set one of the mutually exclusive options |
---|
91 | * |
---|
92 | * - @ref RTEMS_INTERRUPT_UNIQUE |
---|
93 | * - @ref RTEMS_INTERRUPT_SHARED |
---|
94 | * - @ref RTEMS_INTERRUPT_REPLACE |
---|
95 | * |
---|
96 | * with the @a options parameter for the interrupt handler. |
---|
97 | * |
---|
98 | * The handler routine shall be called with argument @a arg when dispatched. |
---|
99 | * The order in which the shared interrupt handlers are dispatched for one |
---|
100 | * vector is BSP dependent. |
---|
101 | * |
---|
102 | * If the option @ref RTEMS_INTERRUPT_UNIQUE is set then it shall be ensured |
---|
103 | * that this handler will be the only one for this vector. |
---|
104 | * |
---|
105 | * If the option @ref RTEMS_INTERRUPT_REPLACE is set then it shall be ensured |
---|
106 | * that this handler will replace the first handler with the same argument for |
---|
107 | * this vector if it exists, otherwise an error status shall be returned. A |
---|
108 | * second handler with the same argument for this vector shall remain |
---|
109 | * unchanged. The new handler will inherit the unique or shared option from |
---|
110 | * the replaced handler. |
---|
111 | * |
---|
112 | * You can provide an informative description @a info. This may be used for |
---|
113 | * system debugging and status tools. The string has to be persistent during |
---|
114 | * the handler life time. |
---|
115 | * |
---|
116 | * This function may block. |
---|
117 | * |
---|
118 | * @retval RTEMS_SUCCESSFUL Shall be returned in case of success. |
---|
119 | * @retval RTEMS_CALLED_FROM_ISR If this function is called from interrupt |
---|
120 | * context this shall be returned. |
---|
121 | * @retval RTEMS_INVALID_ADDRESS If the handler address is NULL this shall be |
---|
122 | * returned. |
---|
123 | * @retval RTEMS_INVALID_ID If the vector number is out of range this shall be |
---|
124 | * returned. |
---|
125 | * @retval RTEMS_INVALID_NUMBER If an option is not applicable this shall be |
---|
126 | * returned. |
---|
127 | * @retval RTEMS_RESOURCE_IN_USE If the vector is already occupied with a |
---|
128 | * unique handler this shall be returned. If a unique handler should be |
---|
129 | * installed and there is already a handler installed this shall be returned. |
---|
130 | * @retval RTEMS_TOO_MANY If a handler with this argument is already installed |
---|
131 | * for the vector this shall be returned. |
---|
132 | * @retval RTEMS_UNSATISFIED If no handler exists to replace with the specified |
---|
133 | * argument and vector this shall be returned. |
---|
134 | * @retval RTEMS_IO_ERROR Reserved for board support package specific error |
---|
135 | * conditions. |
---|
136 | */ |
---|
137 | rtems_status_code rtems_interrupt_handler_install( |
---|
138 | rtems_vector_number vector, |
---|
139 | const char *info, |
---|
140 | rtems_option options, |
---|
141 | rtems_interrupt_handler handler, |
---|
142 | void *arg |
---|
143 | ); |
---|
144 | |
---|
145 | /** |
---|
146 | * @brief Removes the interrupt handler routine @a handler with argument @a arg |
---|
147 | * for the interrupt vector with number @a vector. |
---|
148 | * |
---|
149 | * This function may block. |
---|
150 | * |
---|
151 | * @retval RTEMS_SUCCESSFUL Shall be returned in case of success. |
---|
152 | * @retval RTEMS_CALLED_FROM_ISR If this function is called from interrupt |
---|
153 | * context this shall be returned. |
---|
154 | * @retval RTEMS_INVALID_ADDRESS If the handler address is NULL this shall be |
---|
155 | * returned. |
---|
156 | * @retval RTEMS_INVALID_ID If the vector number is out of range this shall be |
---|
157 | * returned. |
---|
158 | * @retval RTEMS_UNSATISFIED If the handler with its argument is not installed |
---|
159 | * for the vector this shall be returned. |
---|
160 | * @retval RTEMS_IO_ERROR Reserved for board support package specific error |
---|
161 | * conditions. |
---|
162 | */ |
---|
163 | rtems_status_code rtems_interrupt_handler_remove( |
---|
164 | rtems_vector_number vector, |
---|
165 | rtems_interrupt_handler handler, |
---|
166 | void *arg |
---|
167 | ); |
---|
168 | |
---|
169 | /** |
---|
170 | * @brief Interrupt handler iteration routine type. |
---|
171 | * |
---|
172 | * @see rtems_interrupt_handler_iterate() |
---|
173 | */ |
---|
174 | typedef void (*rtems_interrupt_per_handler_routine)( |
---|
175 | void *, const char *, rtems_option, rtems_interrupt_handler, void * |
---|
176 | ); |
---|
177 | |
---|
178 | /** |
---|
179 | * @brief Iterates over all installed interrupt handler of the interrupt vector |
---|
180 | * with number @a vector. |
---|
181 | * |
---|
182 | * For each installed handler of the vector the function @a routine will be |
---|
183 | * called with the supplied argument @a arg and the handler information, |
---|
184 | * options, routine and argument. |
---|
185 | * |
---|
186 | * This function is intended for system information and diagnostics. |
---|
187 | * |
---|
188 | * This function may block. Never install or remove an interrupt handler |
---|
189 | * within the iteration routine. This may result in a deadlock. |
---|
190 | * |
---|
191 | * @retval RTEMS_SUCCESSFUL Shall be returned in case of success. |
---|
192 | * @retval RTEMS_CALLED_FROM_ISR If this function is called from interrupt |
---|
193 | * context this shall be returned. |
---|
194 | * @retval RTEMS_INVALID_ID If the vector number is out of range this shall be |
---|
195 | * returned. |
---|
196 | * @retval RTEMS_IO_ERROR Reserved for board support package specific error |
---|
197 | * conditions. |
---|
198 | */ |
---|
199 | rtems_status_code rtems_interrupt_handler_iterate( |
---|
200 | rtems_vector_number vector, |
---|
201 | rtems_interrupt_per_handler_routine routine, |
---|
202 | void *arg |
---|
203 | ); |
---|
204 | |
---|
205 | /** |
---|
206 | * @brief Initializes an interrupt server task. |
---|
207 | * |
---|
208 | * The task will have the priority @a priority, the stack size @a stack_size, |
---|
209 | * the modes @a modes and the attributes @a attributes. The identifier of the |
---|
210 | * server task will be returned in @a server. Interrupt handlers can be |
---|
211 | * installed on the server with rtems_interrupt_server_handler_install() and |
---|
212 | * removed with rtems_interrupt_server_handler_remove() using this identifier. |
---|
213 | * In case of an interrupt the request will be forwarded to the server. The |
---|
214 | * handlers are executed within the server context. If one handler blocks on |
---|
215 | * something this may delay the processing of other handlers. |
---|
216 | * |
---|
217 | * The server identifier pointer @a server may be @a NULL to initialize the |
---|
218 | * default server. |
---|
219 | * |
---|
220 | * This function may block. |
---|
221 | * |
---|
222 | * @see rtems_task_create(). |
---|
223 | * |
---|
224 | * @retval RTEMS_SUCCESSFUL Shall be returned in case of success. |
---|
225 | * @retval RTEMS_INCORRECT_STATE If the default server is already initialized |
---|
226 | * this shall be returned. |
---|
227 | * @retval RTEMS_TOO_MANY No free task available to create the server task. |
---|
228 | * @retval RTEMS_UNSATISFIED Task stack size too large. |
---|
229 | * @retval RTEMS_INVALID_PRIORITY Invalid task priority. |
---|
230 | */ |
---|
231 | rtems_status_code rtems_interrupt_server_initialize( |
---|
232 | rtems_task_priority priority, |
---|
233 | size_t stack_size, |
---|
234 | rtems_mode modes, |
---|
235 | rtems_attribute attributes, |
---|
236 | rtems_id *server |
---|
237 | ); |
---|
238 | |
---|
239 | /** |
---|
240 | * @brief Installs the interrupt handler routine @a handler for the interrupt |
---|
241 | * vector with number @a vector on the server @a server. |
---|
242 | * |
---|
243 | * The handler routine will be executed on the corresponding interrupt server |
---|
244 | * task. A server identifier @a server of @c RTEMS_ID_NONE may be used to |
---|
245 | * install the handler on the default server. |
---|
246 | * |
---|
247 | * This function may block. |
---|
248 | * |
---|
249 | * @see rtems_interrupt_handler_install(). |
---|
250 | * |
---|
251 | * @retval RTEMS_SUCCESSFUL Shall be returned in case of success. |
---|
252 | * @retval RTEMS_INCORRECT_STATE If the interrupt handler server is not |
---|
253 | * initialized this shall be returned. |
---|
254 | * @retval * For other errors see rtems_interrupt_handler_install(). |
---|
255 | */ |
---|
256 | rtems_status_code rtems_interrupt_server_handler_install( |
---|
257 | rtems_id server, |
---|
258 | rtems_vector_number vector, |
---|
259 | const char *info, |
---|
260 | rtems_option options, |
---|
261 | rtems_interrupt_handler handler, |
---|
262 | void *arg |
---|
263 | ); |
---|
264 | |
---|
265 | /** |
---|
266 | * @brief Removes the interrupt handler routine @a handler with argument @a arg |
---|
267 | * for the interrupt vector with number @a vector from the server @a server. |
---|
268 | * |
---|
269 | * A server identifier @a server of @c RTEMS_ID_NONE may be used to remove the |
---|
270 | * handler from the default server. |
---|
271 | * |
---|
272 | * This function may block. |
---|
273 | * |
---|
274 | * @see rtems_interrupt_handler_remove(). |
---|
275 | * |
---|
276 | * @retval RTEMS_SUCCESSFUL Shall be returned in case of success. |
---|
277 | * @retval RTEMS_INCORRECT_STATE If the interrupt handler server is not |
---|
278 | * initialized this shall be returned. |
---|
279 | * @retval * For other errors see rtems_interrupt_handler_remove(). |
---|
280 | */ |
---|
281 | rtems_status_code rtems_interrupt_server_handler_remove( |
---|
282 | rtems_id server, |
---|
283 | rtems_vector_number vector, |
---|
284 | rtems_interrupt_handler handler, |
---|
285 | void *arg |
---|
286 | ); |
---|
287 | |
---|
288 | /** @} */ |
---|
289 | |
---|
290 | #ifdef __cplusplus |
---|
291 | } |
---|
292 | #endif /* __cplusplus */ |
---|
293 | |
---|
294 | #endif /* RTEMS_IRQ_EXTENSION_H */ |
---|