L4Re Operating System Framework – Interface and Usage Documentation
Loading...
Searching...
No Matches
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
34namespace L4 {
35
48class Irq_eoi : public Kobject_0t<Irq_eoi, L4::PROTO_EMPTY>
49{
50public:
75 l4_msgtag_t unmask(unsigned irqnum, l4_umword_t *label = 0,
77 l4_utcb_t *utcb = l4_utcb()) noexcept
78 {
79 return l4_icu_control_u(cap(), irqnum, L4_ICU_CTL_UNMASK, label, to, utcb);
80 }
81};
82
90struct Triggerable : Kobject_t<Triggerable, Irq_eoi, L4_PROTO_IRQ>
91{
103 { return l4_irq_trigger_u(cap(), utcb); }
104};
105
131class Irq : public Kobject_2t<Irq, Triggerable, Rcv_endpoint, L4_PROTO_IRQ_SENDER>
132{
133public:
135
149 { return l4_irq_detach_u(cap(), utcb); }
150
151
164 l4_utcb_t *utcb = l4_utcb()) noexcept
165 { return l4_irq_receive_u(cap(), timeout, utcb); }
166
177 l4_utcb_t *utcb = l4_utcb()) noexcept
178 { return unmask(-1, label, timeout, utcb); }
179
196 { return unmask(-1, 0, L4_IPC_NEVER, utcb); }
197};
198
214struct Irq_mux : Kobject_t<Irq_mux, Triggerable, L4_PROTO_IRQ_MUX>
215{
230 l4_utcb_t *utcb = l4_utcb()) noexcept
231 { return l4_irq_mux_chain_u(cap(), slave.cap(), utcb); }
232};
233
234
259class Icu :
260 public Kobject_t<Icu, Irq_eoi, L4_PROTO_IRQ,
261 Type_info::Demand_t<1> >
262{
263public:
264 enum Mode
265 {
266 F_none = L4_IRQ_F_NONE,
267 F_level_high = L4_IRQ_F_LEVEL_HIGH,
268 F_level_low = L4_IRQ_F_LEVEL_LOW,
269 F_pos_edge = L4_IRQ_F_POS_EDGE,
270 F_neg_edge = L4_IRQ_F_NEG_EDGE,
271 F_both_edge = L4_IRQ_F_BOTH_EDGE,
272 F_mask = L4_IRQ_F_MASK,
273
274 F_set_wakeup = L4_IRQ_F_SET_WAKEUP,
275 F_clear_wakeup = L4_IRQ_F_CLEAR_WAKEUP,
276 };
277
278 enum Flags
279 {
280 F_msi = L4_ICU_FLAG_MSI
281 };
282
286 class Info : public l4_icu_info_t
287 {
288 public:
290 bool supports_msi() const noexcept { return features & F_msi; }
291 };
292
319 l4_utcb_t *utcb = l4_utcb()) noexcept
320 { return l4_icu_bind_u(cap(), irqnum, irq.cap(), utcb); }
321
325 );
326
337 l4_utcb_t *utcb = l4_utcb()) noexcept
338 { return l4_icu_unbind_u(cap(), irqnum, irq.cap(), utcb); }
339
343 );
344
354 { return l4_icu_info_u(cap(), info, utcb); }
355
356 struct _Info { l4_umword_t features, nr_irqs, nr_msis; };
358
374
378 l4_msgtag_t control(unsigned irqnum, unsigned op, l4_umword_t *label,
379 l4_timeout_t to, l4_utcb_t *utcb = l4_utcb()) noexcept
380 { return l4_icu_control_u(cap(), irqnum, op, label, to, utcb); }
381
401 l4_msgtag_t mask(unsigned irqnum,
402 l4_umword_t *label = 0,
404 l4_utcb_t *utcb = l4_utcb()) noexcept
405 { return l4_icu_mask_u(cap(), irqnum, label, to, utcb); }
406
409 l4_msgtag_t, mask, (l4_umword_t irqnum),
411 );
412
413
416 l4_msgtag_t, unmask, (l4_umword_t irqnum),
418 );
419
429 l4_msgtag_t set_mode(unsigned irqnum, l4_umword_t mode,
430 l4_utcb_t *utcb = l4_utcb()) noexcept
431 { return l4_icu_set_mode_u(cap(), irqnum, mode, utcb); }
432
436 );
437
438 typedef L4::Typeid::Rpcs_sys<
439 bind_t, unbind_t, info_t, msi_info_t, unmask_t, mask_t, set_mode_t
440 > Rpcs;
441};
442
443}
L4::Cap related definitions.
l4_cap_idx_t cap() const noexcept
Return capability selector.
Definition capability.h:52
C++ interface for capabilities.
Definition capability.h:222
This class encapsulates information about an ICU.
Definition irq:287
bool supports_msi() const noexcept
True, if the ICU has support for MSIs.
Definition irq:290
C++ Icu interface, see Interrupt controller for the C interface.
Definition irq:262
l4_msgtag_t msi_info(l4_umword_t irqnum, l4_uint64_t source, l4_icu_msi_info_t *msi_info)
Get MSI info about IRQ.
l4_msgtag_t info(l4_icu_info_t *info, l4_utcb_t *utcb=l4_utcb()) noexcept
Get information about the ICU features.
Definition irq:353
l4_msgtag_t set_mode(unsigned irqnum, l4_umword_t mode, l4_utcb_t *utcb=l4_utcb()) noexcept
Set interrupt mode.
Definition irq:429
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:336
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:401
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:318
Capability type for RPC interfaces (see L4::Cap<T>).
Definition ipc_types:546
Interface for sending an unmask message to an object.
Definition irq:49
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
Unmask the given interrupt line.
Definition irq:75
C++ Irq interface, see IRQs for the C interface.
Definition irq:132
l4_msgtag_t detach(l4_utcb_t *utcb=l4_utcb()) noexcept
Detach from this interrupt.
Definition irq:148
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:176
l4_msgtag_t unmask(l4_utcb_t *utcb=l4_utcb()) noexcept
Unmask IRQ.
Definition irq:195
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:163
Helper class to create an L4Re interface class that is derived from two base classes (see L4::Kobject...
Definition __typeinfo.h:838
Helper class to create an L4Re interface class that is derived from a single base class.
Definition __typeinfo.h:760
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:51
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition l4int.h:42
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:404
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 ICU features.
Definition icu.h:428
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:465
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:491
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:416
@ L4_ICU_FLAG_MSI
Flag to denote that the IRQ is actually an MSI.
Definition icu.h:72
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:242
l4_msgtag_t l4_irq_trigger_u(l4_cap_idx_t irq, l4_utcb_t *utcb) L4_NOTHROW
Trigger the object.
Definition irq.h:262
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:269
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:254
@ L4_IRQ_F_MASK
Mask.
Definition icu.h:94
@ L4_IRQ_F_NEG_EDGE
Negative edge trigger.
Definition icu.h:92
@ L4_IRQ_F_CLEAR_WAKEUP
Do not use irq as wakeup source.
Definition icu.h:98
@ L4_IRQ_F_SET_WAKEUP
Wakeup source?
Definition icu.h:97
@ L4_IRQ_F_LEVEL_HIGH
Level high trigger.
Definition icu.h:89
@ L4_IRQ_F_BOTH_EDGE
Both edges trigger.
Definition icu.h:93
@ L4_IRQ_F_POS_EDGE
Positive edge trigger.
Definition icu.h:91
@ L4_IRQ_F_NONE
Flow types.
Definition icu.h:83
@ L4_IRQ_F_LEVEL_LOW
Level low trigger.
Definition icu.h:90
@ L4_ICU_OP_MASK
Mask opcode.
Definition icu.h:148
@ L4_ICU_OP_SET_MODE
Set-mode opcode.
Definition icu.h:155
@ L4_ICU_OP_UNMASK
Unmask opcode.
Definition icu.h:141
@ L4_ICU_OP_INFO
Info opcode.
Definition icu.h:127
@ L4_ICU_OP_MSI_INFO
Msi-info opcode.
Definition icu.h:134
@ L4_ICU_OP_UNBIND
Unbind opcode.
Definition icu.h:120
@ L4_ICU_OP_BIND
Bind opcode.
Definition icu.h:113
#define L4_IPC_NEVER
never timeout
Definition __timeout.h:82
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
Interrupt controller.
Interface Definition Language.
#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
#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
C Irq interface.
L4 low-level kernel interface.
The C++ Receive endpoint interface.
RPC attribute for a send-only RPC.
Definition ipc_iface:275
IRQ multiplexer for shared IRQs.
Definition irq:215
l4_msgtag_t chain(Cap< Triggerable > const &slave, l4_utcb_t *utcb=l4_utcb()) noexcept
Attach an IRQ to this multiplexer.
Definition irq:229
Interface that allows an object to be triggered by some source.
Definition irq:91
l4_msgtag_t trigger(l4_utcb_t *utcb=l4_utcb()) noexcept
Trigger the object.
Definition irq:102
List of RPCs typically used for kernel interfaces.
Definition __typeinfo.h:475
Info structure for an ICU.
Definition icu.h:173
unsigned features
Feature flags.
Definition icu.h:179
Info to use for a specific MSI.
Definition icu.h:194
Message tag data structure.
Definition types.h:163
Timeout pair.
Definition __timeout.h:59