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 
66 L4_INLINE l4_msgtag_t
68  l4_cap_idx_t thread) L4_NOTHROW
69  L4_DEPRECATED("Use l4_rcv_ep_bind_thread().");
70 
78 L4_INLINE l4_msgtag_t
80  l4_cap_idx_t thread, l4_utcb_t *utcb) L4_NOTHROW
81  L4_DEPRECATED("Use l4_rcv_ep_bind_thread_u().");
82 
102 L4_INLINE l4_msgtag_t
104 
111 L4_INLINE l4_msgtag_t
113  l4_utcb_t *utcb) L4_NOTHROW;
114 
123 L4_INLINE l4_msgtag_t
125 
132 L4_INLINE l4_msgtag_t
134 
135 
151 L4_INLINE l4_msgtag_t
153 
160 L4_INLINE l4_msgtag_t
162 
172 L4_INLINE l4_msgtag_t
174 
181 L4_INLINE l4_msgtag_t
183 
194 L4_INLINE l4_msgtag_t
197 
204 L4_INLINE l4_msgtag_t
206  l4_timeout_t timeout, l4_utcb_t *utcb) L4_NOTHROW;
207 
218 L4_INLINE l4_msgtag_t
220 
227 L4_INLINE l4_msgtag_t
229 
233 enum L4_irq_sender_op
234 {
235  L4_IRQ_SENDER_OP_ATTACH = 0,
236  L4_IRQ_SENDER_OP_DETACH = 1
237 };
238 
242 enum L4_irq_mux_op
243 {
244  L4_IRQ_MUX_OP_CHAIN = 0
245 };
246 
250 enum L4_irq_op
251 {
252  L4_IRQ_OP_TRIGGER = 2,
253  L4_IRQ_OP_EOI = 4
254 };
255 
256 /**************************************************************************
257  * Implementations
258  */
259 
260 L4_INLINE l4_msgtag_t
262  l4_cap_idx_t thread, l4_utcb_t *utcb) L4_NOTHROW
263 {
264  int items = 0;
265  l4_msg_regs_t *m = l4_utcb_mr_u(utcb);
266  m->mr[0] = L4_IRQ_SENDER_OP_ATTACH;
267  m->mr[1] = label;
268 
269  if (!l4_is_invalid_cap(thread))
270  {
271  items = 1;
272  m->mr[2] = l4_map_obj_control(0, 0);
273  m->mr[3] = l4_obj_fpage(thread, 0, L4_FPAGE_RWX).raw;
274  }
275  return l4_ipc_call(irq, utcb, l4_msgtag(L4_PROTO_IRQ_SENDER, 2, items, 0),
276  L4_IPC_NEVER);
277 }
278 
279 L4_INLINE l4_msgtag_t
281  l4_utcb_t *utcb) L4_NOTHROW
282 {
283  l4_msg_regs_t *m = l4_utcb_mr_u(utcb);
284  m->mr[0] = L4_IRQ_MUX_OP_CHAIN;
285  m->mr[1] = l4_map_obj_control(0, 0);
286  m->mr[2] = l4_obj_fpage(slave, 0, L4_FPAGE_RWX).raw;
287  return l4_ipc_call(irq, utcb, l4_msgtag(L4_PROTO_IRQ_MUX, 1, 1, 0),
288  L4_IPC_NEVER);
289 }
290 
291 L4_INLINE l4_msgtag_t
293 {
294  l4_utcb_mr_u(utcb)->mr[0] = L4_IRQ_SENDER_OP_DETACH;
295  return l4_ipc_call(irq, utcb, l4_msgtag(L4_PROTO_IRQ_SENDER, 1, 0, 0),
296  L4_IPC_NEVER);
297 }
298 
299 L4_INLINE l4_msgtag_t
301 {
302  return l4_ipc_send(irq, utcb, l4_msgtag(L4_PROTO_IRQ, 0, 0, 0),
304 }
305 
306 L4_INLINE l4_msgtag_t
308 {
309  l4_utcb_mr_u(utcb)->mr[0] = L4_IRQ_OP_EOI;
310  return l4_ipc_call(irq, utcb, l4_msgtag(L4_PROTO_IRQ, 1, 0, 0), to);
311 }
312 
313 L4_INLINE l4_msgtag_t
316 {
317  l4_utcb_mr_u(utcb)->mr[0] = L4_IRQ_OP_EOI;
318  return l4_ipc_send_and_wait(irq, utcb, l4_msgtag(L4_PROTO_IRQ, 1, 0, 0),
319  label, to);
320 }
321 
322 L4_INLINE l4_msgtag_t
324 {
325  l4_utcb_mr_u(utcb)->mr[0] = L4_IRQ_OP_EOI;
326  return l4_ipc_send(irq, utcb, l4_msgtag(L4_PROTO_IRQ, 1, 0, 0), L4_IPC_NEVER);
327 }
328 
329 
330 L4_INLINE l4_msgtag_t
332  l4_cap_idx_t thread) L4_NOTHROW
333 {
334 #pragma GCC diagnostic push
335 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
336  return l4_irq_attach_u(irq, label, thread, l4_utcb());
337 #pragma GCC diagnostic pop
338 }
339 
340 L4_INLINE l4_msgtag_t
342 {
343  return l4_irq_mux_chain_u(irq, slave, l4_utcb());
344 }
345 
346 L4_INLINE l4_msgtag_t
348 {
349  return l4_irq_detach_u(irq, l4_utcb());
350 }
351 
352 L4_INLINE l4_msgtag_t
354 {
355  return l4_irq_trigger_u(irq, l4_utcb());
356 }
357 
358 L4_INLINE l4_msgtag_t
360 {
361  return l4_irq_receive_u(irq, to, l4_utcb());
362 }
363 
364 L4_INLINE l4_msgtag_t
367 {
368  return l4_irq_wait_u(irq, label, to, l4_utcb());
369 }
370 
371 L4_INLINE l4_msgtag_t
373 {
374  return l4_irq_unmask_u(irq, l4_utcb());
375 }
376 
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:300
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:323
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:307
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:280
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:341
#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:347
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:292
Protocol for IRQ senders (IRQ -> IPC)
Definition: types.h:70
unsigned long l4_umword_t
Unsigned machine word.
Definition: l4int.h:52
Receive endpoint C interface.
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:353
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:331
l4_msgtag_t l4_irq_unmask(l4_cap_idx_t irq) L4_NOTHROW
Unmask IRQ.
Definition: irq.h:372
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:365
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:359
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
#define L4_DEPRECATED(s)
Mark symbol deprecated.
Definition: compiler.h:239
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:261
#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:314