3 * \brief IRQ handling routines.
6 * (c) 2008-2009 Technische Universität Dresden
7 * This file is part of TUD:OS and distributed under the terms of the
8 * GNU General Public License 2.
9 * Please see the COPYING-GPL-2 file for details.
13 #include <l4/sys/compiler.h>
14 #include <l4/sys/types.h>
19 * \defgroup l4irq_api IRQ handling library
21 * \defgroup l4irq_api_irq Interface using direct functionality.
26 typedef struct l4irq_t l4irq_t;
29 * \brief Attach/connect to IRQ.
30 * \ingroup l4irq_api_irq
32 * \param irqnum IRQ number to request
33 * \return Pointer to l4irq_t structure, 0 on error
35 * This l4irq_attach has to be called in the same thread as
36 * l4irq_wait and caller has to be a pthread thread.
39 l4irq_attach(int irqnum);
42 * \brief Attach/connect to IRQ using given type.
43 * \ingroup l4irq_api_irq
45 * \param irqnum IRQ number to request
46 * \param flow_type Interrupt type, \see L4_irq_flow_type
47 * \return Pointer to l4irq_t structure, 0 on error
49 * This l4irq_attach has to be called in the same thread as
50 * l4irq_wait and caller has to be a pthread thread.
53 l4irq_attach_ft(int irqnum, unsigned flow_type);
56 * \brief Attach/connect to IRQ.
57 * \ingroup l4irq_api_irq
59 * \param irqnum IRQ number to request
60 * \param to_thread Attach IRQ to this specified thread.
61 * \return Pointer to l4irq_t structure, 0 on error
63 * The pointer to the IRQ structure is used as a label in the IRQ object.
66 l4irq_attach_thread(int irqnum, l4_cap_idx_t to_thread);
69 * \brief Attach/connect to IRQ using given type.
70 * \ingroup l4irq_api_irq
72 * \param irqnum IRQ number to request
73 * \param to_thread Attach IRQ to this specified thread.
74 * \param flow_type Interrupt type, \see L4_irq_flow_type
75 * \return Pointer to l4irq_t structure, 0 on error
77 * The pointer to the IRQ structure is used as a label in the IRQ object.
80 l4irq_attach_thread_ft(int irqnum, l4_cap_idx_t to_thread,
84 * \brief Wait for specified IRQ.
85 * \ingroup l4irq_api_irq
87 * \param irq IRQ data structure
88 * \return 0 on success, != 0 on error
91 l4irq_wait(l4irq_t *irq);
94 * \brief Unmask a specific IRQ and wait for any attached IRQ.
95 * \ingroup l4irq_api_irq
97 * \param unmask_irq IRQ data structure for unmask.
98 * \retval ret_irq Received interrupt.
99 * \return 0 on success, != 0 on error
102 l4irq_unmask_and_wait_any(l4irq_t *unmask_irq, l4irq_t **ret_irq);
105 * \brief Wait for any attached IRQ.
106 * \ingroup l4irq_api_irq
108 * \retval irq Received interrupt.
109 * \return 0 on success, != 0 on error
112 l4irq_wait_any(l4irq_t **irq);
115 * \brief Unmask a specific IRQ.
116 * \ingroup l4irq_api_irq
118 * \param irq IRQ data structure
119 * \return 0 on success, != 0 on error
121 * This function is useful if a thread wants to wait for multiple IRQs using
125 l4irq_unmask(l4irq_t *irq);
128 * \brief Detach from IRQ.
129 * \ingroup l4irq_api_irq
131 * \param irq IRQ data structure
132 * \return 0 on success, != 0 on error
135 l4irq_detach(l4irq_t *irq);
139 /***********************************************************************/
141 * \defgroup l4irq_api_async Interface for asynchronous ISR handlers.
144 * This interface has just two (main) functions. l4irq_request to install a
145 * handler for an interrupt and l4irq_release to uninstall the handler again
146 * and release all resources associated with it.
150 * \brief Attach asychronous ISR handler to IRQ.
151 * \ingroup l4irq_api_async
153 * \param irqnum IRQ number to request
154 * \param isr_handler Handler routine that is called when an interrupt triggers
155 * \param isr_data Pointer given as argument to isr_handler
156 * \param irq_thread_prio L4 thread priority of the ISR handler. Give -1 for same priority as creator.
157 * \param flow_type Interrupt type, \see L4_irq_flow_type
159 * \return Pointer to l4irq_t structure, 0 on error
162 l4irq_request(int irqnum, void (*isr_handler)(void *), void *isr_data,
163 int irq_thread_prio, unsigned flow_type);
166 * \brief Release asynchronous ISR handler and free resources.
167 * \ingroup l4irq_api_async
169 * \param irq IRQ data structure
170 * \return 0 sucess, != 0 failure
173 l4irq_release(l4irq_t *irq);
177 /***********************************************************************/
178 /***********************************************************************/
181 * \defgroup l4irq_api_irq_cap Interface using direct functionality.
182 * \ingroup l4irq_api_irq
186 * \brief Attach/connect to IRQ.
187 * \ingroup l4irq_api_irq_cap
189 * \param irqcap IRQ capability
190 * \return Pointer to l4irq_t structure, 0 on error
192 * This l4irq_attach has to be called in the same thread as
193 * l4irq_wait and caller has to be a pthread thread.
196 l4irq_attach_cap(l4_cap_idx_t irqcap);
199 * \brief Attach/connect to IRQ using given type.
200 * \ingroup l4irq_api_irq_cap
202 * \param irqcap IRQ capability
203 * \param flow_type Interrupt type, \see L4_irq_flow_type
204 * \return Pointer to l4irq_t structure, 0 on error
206 * This l4irq_attach has to be called in the same thread as
207 * l4irq_wait and caller has to be a pthread thread.
210 l4irq_attach_cap_ft(l4_cap_idx_t irqcap, unsigned flow_type);
213 * \brief Attach/connect to IRQ.
214 * \ingroup l4irq_api_irq_cap
216 * \param irqcap IRQ capability
217 * \param to_thread Attach IRQ to this thread.
218 * \return Pointer to l4irq_t structure, 0 on error
220 * The pointer to the IRQ structure is used as a label in the IRQ object.
223 l4irq_attach_thread_cap(l4_cap_idx_t irqcap, l4_cap_idx_t to_thread);
226 * \brief Attach/connect to IRQ using given type.
227 * \ingroup l4irq_api_irq_cap
229 * \param irqcap IRQ capability
230 * \param to_thread Attach IRQ to this thread.
231 * \param flow_type Interrupt type, \see L4_irq_flow_type
232 * \return Pointer to l4irq_t structure, 0 on error
234 * The pointer to the IRQ structure is used as a label in the IRQ object.
237 l4irq_attach_thread_cap_ft(l4_cap_idx_t irqcap, l4_cap_idx_t to_thread,
240 /***********************************************************************/
242 * \defgroup l4irq_api_async_cap Interface for asynchronous ISR handlers with a given IRQ capability.
243 * \ingroup l4irq_api_async
245 * This group is just an enhanced version to l4irq_request() which takes a
246 * capability object instead of a plain number.
250 * \brief Attach asychronous ISR handler to IRQ.
251 * \ingroup l4irq_api_async_cap
253 * \param irqcap IRQ capability
254 * \param isr_handler Handler routine that is called when an interrupt triggers
255 * \param isr_data Pointer given as argument to isr_handler
256 * \param irq_thread_prio L4 thread priority of the ISR handler. Give -1 for same priority as creator.
257 * \param flow_type Interrupt type, \see L4_irq_flow_type
259 * \return Pointer to l4irq_t structure, 0 on error
262 l4irq_request_cap(l4_cap_idx_t irqcap,
263 void (*isr_handler)(void *), void *isr_data,
264 int irq_thread_prio, unsigned flow_type);