L4Re – L4 Runtime Environment
irq.h
Go to the documentation of this file.
1 
6 /*
7  * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
8  * Alexander Warg <warg@os.inf.tu-dresden.de>,
9  * Björn Döbel <doebel@os.inf.tu-dresden.de>
10  * economic rights: Technische Universität Dresden (Germany)
11  *
12  * This file is part of TUD:OS and distributed under the terms of the
13  * GNU General Public License 2.
14  * Please see the COPYING-GPL-2 file for details.
15  *
16  * As a special exception, you may use this file as part of a free software
17  * library without restriction. Specifically, if other files instantiate
18  * templates or use macros or inline functions from this file, or you compile
19  * this file and link it with other files to produce an executable, this
20  * file does not by itself cause the resulting executable to be covered by
21  * the GNU General Public License. This exception does not however
22  * invalidate any other reasons why the executable file might be covered by
23  * the GNU General Public License.
24  */
25 #pragma once
26 
27 #include <l4/sys/kernel_object.h>
28 #include <l4/sys/ipc.h>
29 #include <l4/sys/rcv_endpoint.h>
30 
71 L4_INLINE l4_msgtag_t
73 
80 L4_INLINE l4_msgtag_t
82  l4_utcb_t *utcb) L4_NOTHROW;
83 
92 L4_INLINE l4_msgtag_t
94 
101 L4_INLINE l4_msgtag_t
103 
104 
120 L4_INLINE l4_msgtag_t
122 
129 L4_INLINE l4_msgtag_t
131 
141 L4_INLINE l4_msgtag_t
143 
150 L4_INLINE l4_msgtag_t
152 
163 L4_INLINE l4_msgtag_t
166 
173 L4_INLINE l4_msgtag_t
175  l4_timeout_t timeout, l4_utcb_t *utcb) L4_NOTHROW;
176 
187 L4_INLINE l4_msgtag_t
189 
196 L4_INLINE l4_msgtag_t
198 
202 enum L4_irq_sender_op
203 {
204  L4_IRQ_SENDER_OP_RESERVED1 = 0, // Ex ATTACH
205  L4_IRQ_SENDER_OP_DETACH = 1
206 };
207 
211 enum L4_irq_mux_op
212 {
213  L4_IRQ_MUX_OP_CHAIN = 0
214 };
215 
219 enum L4_irq_op
220 {
221  L4_IRQ_OP_TRIGGER = 2,
222  L4_IRQ_OP_EOI = 4
223 };
224 
225 /**************************************************************************
226  * Implementations
227  */
228 
229 L4_INLINE l4_msgtag_t
231  l4_utcb_t *utcb) L4_NOTHROW
232 {
233  l4_msg_regs_t *m = l4_utcb_mr_u(utcb);
234  m->mr[0] = L4_IRQ_MUX_OP_CHAIN;
235  m->mr[1] = l4_map_obj_control(0, 0);
236  m->mr[2] = l4_obj_fpage(slave, 0, L4_CAP_FPAGE_RWS).raw;
237  return l4_ipc_call(irq, utcb, l4_msgtag(L4_PROTO_IRQ_MUX, 1, 1, 0),
238  L4_IPC_NEVER);
239 }
240 
241 L4_INLINE l4_msgtag_t
243 {
244  l4_utcb_mr_u(utcb)->mr[0] = L4_IRQ_SENDER_OP_DETACH;
245  return l4_ipc_call(irq, utcb, l4_msgtag(L4_PROTO_IRQ_SENDER, 1, 0, 0),
246  L4_IPC_NEVER);
247 }
248 
249 L4_INLINE l4_msgtag_t
251 {
252  return l4_ipc_send(irq, utcb, l4_msgtag(L4_PROTO_IRQ, 0, 0, 0),
253  L4_IPC_BOTH_TIMEOUT_0);
254 }
255 
256 L4_INLINE l4_msgtag_t
258 {
259  l4_utcb_mr_u(utcb)->mr[0] = L4_IRQ_OP_EOI;
260  return l4_ipc_call(irq, utcb, l4_msgtag(L4_PROTO_IRQ, 1, 0, 0), to);
261 }
262 
263 L4_INLINE l4_msgtag_t
266 {
267  l4_utcb_mr_u(utcb)->mr[0] = L4_IRQ_OP_EOI;
268  return l4_ipc_send_and_wait(irq, utcb, l4_msgtag(L4_PROTO_IRQ, 1, 0, 0),
269  label, to);
270 }
271 
272 L4_INLINE l4_msgtag_t
274 {
275  l4_utcb_mr_u(utcb)->mr[0] = L4_IRQ_OP_EOI;
276  return l4_ipc_send(irq, utcb, l4_msgtag(L4_PROTO_IRQ, 1, 0, 0), L4_IPC_NEVER);
277 }
278 
279 
280 L4_INLINE l4_msgtag_t
282 {
283  return l4_irq_mux_chain_u(irq, slave, l4_utcb());
284 }
285 
286 L4_INLINE l4_msgtag_t
288 {
289  return l4_irq_detach_u(irq, l4_utcb());
290 }
291 
292 L4_INLINE l4_msgtag_t
294 {
295  return l4_irq_trigger_u(irq, l4_utcb());
296 }
297 
298 L4_INLINE l4_msgtag_t
300 {
301  return l4_irq_receive_u(irq, to, l4_utcb());
302 }
303 
304 L4_INLINE l4_msgtag_t
307 {
308  return l4_irq_wait_u(irq, label, to, l4_utcb());
309 }
310 
311 L4_INLINE l4_msgtag_t
313 {
314  return l4_irq_unmask_u(irq, l4_utcb());
315 }
316 
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition: compiler.h:186
unsigned long l4_umword_t
Unsigned machine word.
Definition: l4int.h:51
unsigned long l4_cap_idx_t
L4 Capability selector Type.
Definition: types.h:342
l4_fpage_t l4_obj_fpage(l4_cap_idx_t obj, unsigned int order, unsigned char rights) L4_NOTHROW
Create a kernel-object flex page.
Definition: __l4_fpage.h:647
@ L4_CAP_FPAGE_RWS
Read, interface specific 'W', and 'S' rights for capability flex-pages.
Definition: __l4_fpage.h:192
l4_msgtag_t l4_ipc_send_and_wait(l4_cap_idx_t dest, l4_utcb_t *utcb, l4_msgtag_t tag, l4_umword_t *label, l4_timeout_t timeout) L4_NOTHROW
Send a message and do an open wait.
Definition: ipc.h:479
l4_msgtag_t l4_ipc_send(l4_cap_idx_t dest, l4_utcb_t *utcb, l4_msgtag_t tag, l4_timeout_t timeout) L4_NOTHROW
Send a message to an object (do not wait for a reply).
Definition: ipc.h:488
l4_msgtag_t l4_ipc_call(l4_cap_idx_t object, l4_utcb_t *utcb, l4_msgtag_t tag, l4_timeout_t timeout) L4_NOTHROW
Object call (usual invocation).
Definition: ipc.h:463
l4_msgtag_t l4_irq_mux_chain_u(l4_cap_idx_t irq, l4_cap_idx_t slave, l4_utcb_t *utcb) L4_NOTHROW
Attach an IRQ to this multiplexer.
Definition: irq.h:230
l4_msgtag_t l4_irq_wait_u(l4_cap_idx_t irq, l4_umword_t *label, l4_timeout_t timeout, l4_utcb_t *utcb) L4_NOTHROW
Unmask IRQ and (open) wait for any message.
Definition: irq.h:264
l4_msgtag_t l4_irq_trigger_u(l4_cap_idx_t irq, l4_utcb_t *utcb) L4_NOTHROW
Trigger.
Definition: irq.h:250
l4_msgtag_t l4_irq_detach(l4_cap_idx_t irq) L4_NOTHROW
Detach from an interrupt source.
Definition: irq.h:287
l4_msgtag_t l4_irq_unmask_u(l4_cap_idx_t irq, l4_utcb_t *utcb) L4_NOTHROW
Unmask IRQ.
Definition: irq.h:273
l4_msgtag_t l4_irq_unmask(l4_cap_idx_t irq) L4_NOTHROW
Unmask IRQ.
Definition: irq.h:312
l4_msgtag_t l4_irq_mux_chain(l4_cap_idx_t irq, l4_cap_idx_t slave) L4_NOTHROW
Chain an IRQ to another master IRQ source.
Definition: irq.h:281
l4_msgtag_t l4_irq_receive_u(l4_cap_idx_t irq, l4_timeout_t timeout, l4_utcb_t *utcb) L4_NOTHROW
Unmask and wait for this IRQ.
Definition: irq.h:257
l4_msgtag_t l4_irq_detach_u(l4_cap_idx_t irq, l4_utcb_t *utcb) L4_NOTHROW
Detach from this interrupt.
Definition: irq.h:242
l4_msgtag_t l4_irq_receive(l4_cap_idx_t irq, l4_timeout_t to) L4_NOTHROW
Unmask and wait for specified IRQ.
Definition: irq.h:299
l4_msgtag_t l4_irq_wait(l4_cap_idx_t irq, l4_umword_t *label, l4_timeout_t to) L4_NOTHROW
Unmask IRQ and wait for any message.
Definition: irq.h:305
l4_msgtag_t l4_irq_trigger(l4_cap_idx_t irq) L4_NOTHROW
Trigger an IRQ.
Definition: irq.h:293
l4_umword_t l4_map_obj_control(l4_umword_t spot, unsigned grant) L4_NOTHROW
Create the first word for a map item for the object space.
Definition: __l4_fpage.h:681
l4_msgtag_t l4_msgtag(long label, unsigned words, unsigned items, unsigned flags) L4_NOTHROW
Create a message tag from the specified values.
Definition: types.h:408
@ L4_PROTO_IRQ
IRQ message.
Definition: types.h:55
@ L4_PROTO_IRQ_SENDER
Protocol for IRQ senders (IRQ -> IPC)
Definition: types.h:70
@ L4_PROTO_IRQ_MUX
Protocol for IRQ mux (IRQ -> n x IRQ)
Definition: types.h:71
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition: utcb.h:67
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition: utcb.h:340
Kernel object system calls.
Receive endpoint C interface.
Message tag data structure.
Definition: types.h:160
l4_umword_t raw
Raw value.
Definition: __l4_fpage.h:85
Encapsulation of the message-register block in the UTCB.
Definition: utcb.h:79
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition: utcb.h:80
Timeout pair.
Definition: __timeout.h:59