source: rtems/cpukit/include/rtems/irq-extension.h @ 48588ab

4.115
Last change on this file since 48588ab was 60e5832, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 10/21/09 at 13:24:35

interrupt handler type change

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