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 
65 L4_INLINE l4_msgtag_t
67  l4_cap_idx_t thread) L4_NOTHROW;
68 
76 L4_INLINE l4_msgtag_t
78  l4_cap_idx_t thread, l4_utcb_t *utcb) L4_NOTHROW;
79 
99 L4_INLINE l4_msgtag_t
101 
108 L4_INLINE l4_msgtag_t
110  l4_utcb_t *utcb) L4_NOTHROW;
111 
120 L4_INLINE l4_msgtag_t
122 
129 L4_INLINE l4_msgtag_t
131 
132 
148 L4_INLINE l4_msgtag_t
150 
157 L4_INLINE l4_msgtag_t
159 
169 L4_INLINE l4_msgtag_t
171 
178 L4_INLINE l4_msgtag_t
180 
191 L4_INLINE l4_msgtag_t
194 
201 L4_INLINE l4_msgtag_t
203  l4_timeout_t timeout, l4_utcb_t *utcb) L4_NOTHROW;
204 
215 L4_INLINE l4_msgtag_t
217 
224 L4_INLINE l4_msgtag_t
226 
230 enum L4_irq_sender_op
231 {
232  L4_IRQ_SENDER_OP_ATTACH = 0,
233  L4_IRQ_SENDER_OP_DETACH = 1
234 };
235 
239 enum L4_irq_mux_op
240 {
241  L4_IRQ_MUX_OP_CHAIN = 0
242 };
243 
247 enum L4_irq_op
248 {
249  L4_IRQ_OP_TRIGGER = 2,
250  L4_IRQ_OP_EOI = 4
251 };
252 
253 /**************************************************************************
254  * Implementations
255  */
256 
257 L4_INLINE l4_msgtag_t
259  l4_cap_idx_t thread, l4_utcb_t *utcb) L4_NOTHROW
260 {
261  int items = 0;
262  l4_msg_regs_t *m = l4_utcb_mr_u(utcb);
263  m->mr[0] = L4_IRQ_SENDER_OP_ATTACH;
264  m->mr[1] = label;
265 
266  if (!l4_is_invalid_cap(thread))
267  {
268  items = 1;
269  m->mr[2] = l4_map_obj_control(0, 0);
270  m->mr[3] = l4_obj_fpage(thread, 0, L4_FPAGE_RWX).raw;
271  }
272  return l4_ipc_call(irq, utcb, l4_msgtag(L4_PROTO_IRQ_SENDER, 2, items, 0),
273  L4_IPC_NEVER);
274 }
275 
276 L4_INLINE l4_msgtag_t
278  l4_utcb_t *utcb) L4_NOTHROW
279 {
280  l4_msg_regs_t *m = l4_utcb_mr_u(utcb);
281  m->mr[0] = L4_IRQ_MUX_OP_CHAIN;
282  m->mr[1] = l4_map_obj_control(0, 0);
283  m->mr[2] = l4_obj_fpage(slave, 0, L4_FPAGE_RWX).raw;
284  return l4_ipc_call(irq, utcb, l4_msgtag(L4_PROTO_IRQ_MUX, 1, 1, 0),
285  L4_IPC_NEVER);
286 }
287 
288 L4_INLINE l4_msgtag_t
290 {
291  l4_utcb_mr_u(utcb)->mr[0] = L4_IRQ_SENDER_OP_DETACH;
292  return l4_ipc_call(irq, utcb, l4_msgtag(L4_PROTO_IRQ_SENDER, 1, 0, 0),
293  L4_IPC_NEVER);
294 }
295 
296 L4_INLINE l4_msgtag_t
298 {
299  return l4_ipc_send(irq, utcb, l4_msgtag(L4_PROTO_IRQ, 0, 0, 0),
301 }
302 
303 L4_INLINE l4_msgtag_t
305 {
306  l4_utcb_mr_u(utcb)->mr[0] = L4_IRQ_OP_EOI;
307  return l4_ipc_call(irq, utcb, l4_msgtag(L4_PROTO_IRQ, 1, 0, 0), to);
308 }
309 
310 L4_INLINE l4_msgtag_t
313 {
314  l4_utcb_mr_u(utcb)->mr[0] = L4_IRQ_OP_EOI;
315  return l4_ipc_send_and_wait(irq, utcb, l4_msgtag(L4_PROTO_IRQ, 1, 0, 0),
316  label, to);
317 }
318 
319 L4_INLINE l4_msgtag_t
321 {
322  l4_utcb_mr_u(utcb)->mr[0] = L4_IRQ_OP_EOI;
323  return l4_ipc_send(irq, utcb, l4_msgtag(L4_PROTO_IRQ, 1, 0, 0), L4_IPC_NEVER);
324 }
325 
326 
327 L4_INLINE l4_msgtag_t
329  l4_cap_idx_t thread) L4_NOTHROW
330 {
331  return l4_irq_attach_u(irq, label, thread, l4_utcb());
332 }
333 
334 L4_INLINE l4_msgtag_t
336 {
337  return l4_irq_mux_chain_u(irq, slave, l4_utcb());
338 }
339 
340 L4_INLINE l4_msgtag_t
342 {
343  return l4_irq_detach_u(irq, l4_utcb());
344 }
345 
346 L4_INLINE l4_msgtag_t
348 {
349  return l4_irq_trigger_u(irq, l4_utcb());
350 }
351 
352 L4_INLINE l4_msgtag_t
354 {
355  return l4_irq_receive_u(irq, to, l4_utcb());
356 }
357 
358 L4_INLINE l4_msgtag_t
361 {
362  return l4_irq_wait_u(irq, label, to, l4_utcb());
363 }
364 
365 L4_INLINE l4_msgtag_t
367 {
368  return l4_irq_unmask_u(irq, l4_utcb());
369 }
370 
Encapsulation of the message-register block in the UTCB.
Definition: utcb.h:78
unsigned l4_is_invalid_cap(l4_cap_idx_t c) L4_NOTHROW
Test if a capability selector is the invalid capability.
Definition: types.h:391
l4_msgtag_t l4_irq_trigger_u(l4_cap_idx_t irq, l4_utcb_t *utcb) L4_NOTHROW
Trigger.
Definition: irq.h:297
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:461
l4_msgtag_t l4_irq_unmask_u(l4_cap_idx_t irq, l4_utcb_t *utcb) L4_NOTHROW
Unmask IRQ.
Definition: irq.h:320
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition: utcb.h:80
Read-write-execute flex page.
Definition: __l4_fpage.h:114
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:445
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:304
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:277
unsigned long l4_cap_idx_t
L4 Capability selector Type.
Definition: types.h:341
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition: utcb.h:67
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:335
#define L4_IPC_NEVER
never timeout
Definition: __timeout.h:80
Timeout pair.
Definition: __timeout.h:57
l4_msgtag_t l4_irq_detach(l4_cap_idx_t irq) L4_NOTHROW
Detach from an interrupt source.
Definition: irq.h:341
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:289
Protocol for IRQ senders (IRQ -> IPC)
Definition: types.h:70
unsigned long l4_umword_t
Unsigned machine word.
Definition: l4int.h:52
l4_umword_t raw
Raw value.
Definition: __l4_fpage.h:83
l4_msgtag_t l4_irq_trigger(l4_cap_idx_t irq) L4_NOTHROW
Trigger an IRQ.
Definition: irq.h:347
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:679
l4_msgtag_t l4_irq_attach(l4_cap_idx_t irq, l4_umword_t label, l4_cap_idx_t thread) L4_NOTHROW
Attach a thread to an interrupt source.
Definition: irq.h:328
l4_msgtag_t l4_irq_unmask(l4_cap_idx_t irq) L4_NOTHROW
Unmask IRQ.
Definition: irq.h:366
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition: utcb.h:340
Protocol for IRQ mux (IRQ -> n x IRQ)
Definition: types.h:71
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:407
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:470
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:359
Kernel object system calls.
IRQ message.
Definition: types.h:55
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:353
Message tag data structure.
Definition: types.h:158
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:645
l4_msgtag_t l4_irq_attach_u(l4_cap_idx_t irq, l4_umword_t label, l4_cap_idx_t thread, l4_utcb_t *utcb) L4_NOTHROW
Attach a thread to this interrupt.
Definition: irq.h:258
#define L4_IPC_BOTH_TIMEOUT_0
0 receive and send timeout
Definition: __timeout.h:83
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition: compiler.h:185
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:311