L4Re - L4 Runtime Environment
irq
Go to the documentation of this file.
1 // vi:set ft=cpp: -*- Mode: C++ -*-
6 /*
7  * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
8  * Alexander Warg <warg@os.inf.tu-dresden.de>
9  * economic rights: Technische Universit├Ąt Dresden (Germany)
10  *
11  * This file is part of TUD:OS and distributed under the terms of the
12  * GNU General Public License 2.
13  * Please see the COPYING-GPL-2 file for details.
14  *
15  * As a special exception, you may use this file as part of a free software
16  * library without restriction. Specifically, if other files instantiate
17  * templates or use macros or inline functions from this file, or you compile
18  * this file and link it with other files to produce an executable, this
19  * file does not by itself cause the resulting executable to be covered by
20  * the GNU General Public License. This exception does not however
21  * invalidate any other reasons why the executable file might be covered by
22  * the GNU General Public License.
23  */
24 
25 #pragma once
26 
27 #include <l4/sys/icu.h>
28 #include <l4/sys/irq.h>
29 #include <l4/sys/capability>
30 #include <l4/sys/rcv_endpoint>
31 #include <l4/sys/cxx/ipc_iface>
32 #include <l4/sys/cxx/ipc_types>
33 
34 namespace L4 {
35 
43 class Irq_eoi : public Kobject_0t<Irq_eoi, L4::PROTO_EMPTY>
44 {
45 public:
65  l4_msgtag_t unmask(unsigned irqnum, l4_umword_t *label = 0,
67  l4_utcb_t *utcb = l4_utcb()) noexcept
68  {
69  return l4_icu_control_u(cap(), irqnum, L4_ICU_CTL_UNMASK, label, to, utcb);
70  }
71 };
72 
78 struct Triggerable : Kobject_t<Triggerable, Irq_eoi, L4_PROTO_IRQ>
79 {
93  l4_msgtag_t trigger(l4_utcb_t *utcb = l4_utcb()) noexcept
94  { return l4_irq_trigger_u(cap(), utcb); }
95 };
96 
117 class Irq : public Kobject_2t<Irq, Triggerable, Rcv_endpoint, L4_PROTO_IRQ_SENDER>
118 {
119 public:
120  using Triggerable::unmask;
121 
139  Cap<Thread> const &thread = Cap<Thread>::Invalid,
140  l4_utcb_t *utcb = l4_utcb()) noexcept
141  L4_DEPRECATED("Use bind_thread(thread, label).")
142  {
143 #pragma GCC diagnostic push
144 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
145  return l4_irq_attach_u(cap(), label, thread.cap(), utcb);
146 #pragma GCC diagnostic pop
147  }
148 
156  l4_msgtag_t detach(l4_utcb_t *utcb = l4_utcb()) noexcept
157  { return l4_irq_detach_u(cap(), utcb); }
158 
159 
172  l4_utcb_t *utcb = l4_utcb()) noexcept
173  { return l4_irq_receive_u(cap(), timeout, utcb); }
174 
185  l4_utcb_t *utcb = l4_utcb()) noexcept
186  { return unmask(-1, label, timeout, utcb); }
187 
207  l4_msgtag_t unmask(l4_utcb_t *utcb = l4_utcb()) noexcept
208  { return unmask(-1, 0, L4_IPC_NEVER, utcb); }
209 };
210 
224 struct Irq_mux : Kobject_t<Irq_mux, Triggerable, L4_PROTO_IRQ_MUX>
225 {
240  l4_utcb_t *utcb = l4_utcb()) noexcept
241  { return l4_irq_mux_chain_u(cap(), slave.cap(), utcb); }
242 };
243 
244 
263 class Icu :
264  public Kobject_t<Icu, Irq_eoi, L4_PROTO_IRQ,
265  Type_info::Demand_t<1> >
266 {
267 public:
268  enum Mode
269  {
270  F_none = L4_IRQ_F_NONE,
271  F_level_high = L4_IRQ_F_LEVEL_HIGH,
272  F_level_low = L4_IRQ_F_LEVEL_LOW,
273  F_pos_edge = L4_IRQ_F_POS_EDGE,
274  F_neg_edge = L4_IRQ_F_NEG_EDGE,
275  F_both_edge = L4_IRQ_F_BOTH_EDGE,
276  F_mask = L4_IRQ_F_MASK,
277 
278  F_set_wakeup = L4_IRQ_F_SET_WAKEUP,
279  F_clear_wakeup = L4_IRQ_F_CLEAR_WAKEUP,
280  };
281 
282  enum Flags
283  {
284  F_msi = L4_ICU_FLAG_MSI
285  };
286 
290  class Info : public l4_icu_info_t
291  {
292  public:
294  bool supports_msi() const noexcept { return features & F_msi; }
295  };
296 
312  l4_msgtag_t bind(unsigned irqnum, L4::Cap<Triggerable> irq,
313  l4_utcb_t *utcb = l4_utcb()) noexcept
314  { return l4_icu_bind_u(cap(), irqnum, irq.cap(), utcb); }
315 
316  L4_RPC_NF_OP(
318  l4_msgtag_t, bind, (l4_umword_t irqnum, Ipc::Cap<Irq> irq)
319  );
320 
331  l4_utcb_t *utcb = l4_utcb()) noexcept
332  { return l4_icu_unbind_u(cap(), irqnum, irq.cap(), utcb); }
333 
334  L4_RPC_NF_OP(
336  l4_msgtag_t, unbind, (l4_umword_t irqnum, Ipc::Cap<Irq> irq)
337  );
338 
347  l4_msgtag_t info(l4_icu_info_t *info, l4_utcb_t *utcb = l4_utcb()) noexcept
348  { return l4_icu_info_u(cap(), info, utcb); }
349 
350  struct _Info { l4_umword_t features, nr_irqs, nr_msis; };
351  L4_RPC_NF_OP(L4_ICU_OP_INFO, l4_msgtag_t, info, (_Info *info));
352 
366  l4_msgtag_t, msi_info, (l4_umword_t irqnum, l4_uint64_t source,
367  l4_icu_msi_info_t *msi_info));
368 
372  l4_msgtag_t control(unsigned irqnum, unsigned op, l4_umword_t *label,
373  l4_timeout_t to, l4_utcb_t *utcb = l4_utcb()) noexcept
374  { return l4_icu_control_u(cap(), irqnum, op, label, to, utcb); }
375 
390  l4_msgtag_t mask(unsigned irqnum,
391  l4_umword_t *label = 0,
393  l4_utcb_t *utcb = l4_utcb()) noexcept
394  { return l4_icu_mask_u(cap(), irqnum, label, to, utcb); }
395 
396  L4_RPC_NF_OP(
398  l4_msgtag_t, mask, (l4_umword_t irqnum),
400  );
401 
402 
403  L4_RPC_NF_OP(
405  l4_msgtag_t, unmask, (l4_umword_t irqnum),
407  );
408 
418  l4_msgtag_t set_mode(unsigned irqnum, l4_umword_t mode,
419  l4_utcb_t *utcb = l4_utcb()) noexcept
420  { return l4_icu_set_mode_u(cap(), irqnum, mode, utcb); }
421 
422  L4_RPC_NF_OP(
424  l4_msgtag_t, set_mode, (l4_umword_t irqnum, l4_umword_t mode)
425  );
426 
427  typedef L4::Typeid::Rpcs_sys<
428  bind_t, unbind_t, info_t, msi_info_t, unmask_t, mask_t, set_mode_t
429  > Rpcs;
430 };
431 
432 }
Mask opcode.
Definition: icu.h:135
C Irq interface.
Capability type for RPC interfaces (see L4::Cap<T>).
Definition: ipc_types:541
Unmask opcode.
Definition: icu.h:128
l4_cap_idx_t cap() const noexcept
Return capability selector.
Definition: capability.h:52
IRQ multiplexer for shared IRQs.
Definition: irq:224
Do not use irq as wakeup source.
Definition: icu.h:85
l4_msgtag_t unmask(unsigned irqnum, l4_umword_t *label=0, l4_timeout_t to=L4_IPC_NEVER, l4_utcb_t *utcb=l4_utcb()) noexcept
Acknowledge the given interrupt line.
Definition: irq:65
l4_msgtag_t l4_irq_trigger_u(l4_cap_idx_t irq, l4_utcb_t *utcb) L4_NOTHROW
Trigger.
Definition: irq.h:300
Unbind opcode.
Definition: icu.h:107
Level high trigger.
Definition: icu.h:76
Set-mode opcode.
Definition: icu.h:142
Info to use for a specific MSI.
Definition: icu.h:180
Both edges trigger.
Definition: icu.h:80
l4_msgtag_t trigger(l4_utcb_t *utcb=l4_utcb()) noexcept
Trigger.
Definition: irq:93
L4 low-level kernel interface.
The C++ Receive endpoint interface.
l4_msgtag_t l4_icu_bind_u(l4_cap_idx_t icu, unsigned irqnum, l4_cap_idx_t irq, l4_utcb_t *utcb) L4_NOTHROW
Bind an interrupt line of an interrupt controller to an interrupt object.
Definition: icu.h:373
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
Level low trigger.
Definition: icu.h:77
C++ Irq interface.
Definition: irq:117
l4_msgtag_t attach(l4_umword_t label, Cap< Thread > const &thread=Cap< Thread >::Invalid, l4_utcb_t *utcb=l4_utcb()) noexcept
Attach a thread to this interrupt.
Definition: irq:138
#define L4_INLINE_RPC_OP(op, res, name, args, attr...)
Define an inline RPC call with specific opcode (type and callable).
Definition: ipc_iface:484
l4_msgtag_t unmask(l4_utcb_t *utcb=l4_utcb()) noexcept
Unmask IRQ.
Definition: irq:207
Info structure for an ICU.
Definition: icu.h:159
Interface for sending an acknowledge message to an object.
Definition: irq:43
l4_msgtag_t bind(unsigned irqnum, L4::Cap< Triggerable > irq, l4_utcb_t *utcb=l4_utcb()) noexcept
Bind an interrupt line of an interrupt controller to an interrupt object.
Definition: irq:312
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
RPC attribute for a send-only RPC.
Definition: ipc_iface:274
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition: utcb.h:67
#define L4_IPC_NEVER
never timeout
Definition: __timeout.h:82
l4_msgtag_t mask(unsigned irqnum, l4_umword_t *label=0, l4_timeout_t to=L4_IPC_NEVER, l4_utcb_t *utcb=l4_utcb()) noexcept
Mask an IRQ line.
Definition: irq:390
Flow types.
Definition: icu.h:70
Timeout pair.
Definition: __timeout.h:59
L4::Cap related definitions.
l4_msgtag_t l4_icu_unbind_u(l4_cap_idx_t icu, unsigned irqnum, l4_cap_idx_t irq, l4_utcb_t *utcb) L4_NOTHROW
Remove binding of an interrupt line from the interrupt controller object.
Definition: icu.h:385
Msi-info opcode.
Definition: icu.h:121
This class encapsulates information about an ICU.
Definition: irq:290
bool supports_msi() const noexcept
True, if the ICU has support for MSIs.
Definition: irq:294
l4_msgtag_t set_mode(unsigned irqnum, l4_umword_t mode, l4_utcb_t *utcb=l4_utcb()) noexcept
Set interrupt mode.
Definition: irq:418
Mask.
Definition: icu.h:81
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
List of RPCs typically used for kernel interfaces.
Definition: __typeinfo.h:475
Flag to denote that the IRQ is actually an MSI.
Definition: icu.h:59
l4_msgtag_t chain(Cap< Triggerable > const &slave, l4_utcb_t *utcb=l4_utcb()) noexcept
Attach an IRQ to this multiplexer.
Definition: irq:239
unsigned long l4_umword_t
Unsigned machine word.
Definition: l4int.h:52
Helper class to create an L4Re interface class that is derived from two base classes (see L4::Kobject...
Definition: __typeinfo.h:835
Info opcode.
Definition: icu.h:114
Negative edge trigger.
Definition: icu.h:79
Interface Definition Language.
l4_msgtag_t l4_icu_set_mode_u(l4_cap_idx_t icu, unsigned irqnum, l4_umword_t mode, l4_utcb_t *utcb) L4_NOTHROW
Set interrupt mode.
Definition: icu.h:434
Wakeup source?
Definition: icu.h:84
l4_msgtag_t wait(l4_umword_t *label, l4_timeout_t timeout=L4_IPC_NEVER, l4_utcb_t *utcb=l4_utcb()) noexcept
Unmask IRQ and (open) wait for any message.
Definition: irq:184
Interrupt controller.
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition: utcb.h:340
l4_msgtag_t unbind(unsigned irqnum, L4::Cap< Triggerable > irq, l4_utcb_t *utcb=l4_utcb()) noexcept
Remove binding of an interrupt line from the interrupt controller object.
Definition: irq:330
Helper class to create an L4Re interface class that is derived from a single base class...
Definition: __typeinfo.h:759
l4_cap_idx_t cap() const noexcept
Return capability selector.
Definition: kobject:79
l4_msgtag_t l4_icu_info_u(l4_cap_idx_t icu, l4_icu_info_t *info, l4_utcb_t *utcb) L4_NOTHROW
Get information about the capabilities of the ICU.
Definition: icu.h:397
Positive edge trigger.
Definition: icu.h:78
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition: l4int.h:42
l4_msgtag_t receive(l4_timeout_t timeout=L4_IPC_NEVER, l4_utcb_t *utcb=l4_utcb()) noexcept
Unmask and wait for this IRQ.
Definition: irq:171
C++ interface for capabilities.
Definition: capability.h:13
Message tag data structure.
Definition: types.h:159
C++ Icu interface.
Definition: irq:263
l4_msgtag_t info(l4_icu_info_t *info, l4_utcb_t *utcb=l4_utcb()) noexcept
Get information about the capabilities of the ICU.
Definition: irq:347
l4_msgtag_t detach(l4_utcb_t *utcb=l4_utcb()) noexcept
Detach from this interrupt.
Definition: irq:156
l4_msgtag_t l4_icu_mask_u(l4_cap_idx_t icu, unsigned irqnum, l4_umword_t *label, l4_timeout_t to, l4_utcb_t *utcb) L4_NOTHROW
Mask an IRQ line.
Definition: icu.h:460
#define L4_DEPRECATED(s)
Mark symbol deprecated.
Definition: compiler.h:243
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_RPC_NF_OP(op, res, name, args...)
Define an RPC call type with specific opcode (the type only, no callable).
Definition: ipc_iface:512
Bind opcode.
Definition: icu.h:100
Interface that allows an object to be triggered by some source.
Definition: irq:78