L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
icu.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 * Torsten Frenzel <frenzel@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
28#include <l4/sys/ipc.h>
29
64{
72 L4_ICU_FLAG_MSI = 0x80000000,
73};
74
75
100
101
157
158enum L4_icu_ctl_op
159{
160 L4_ICU_CTL_UNMASK = 0,
161 L4_ICU_CTL_MASK = 1
162};
163
164
172typedef struct l4_icu_info_t
173{
179 unsigned features;
180
184 unsigned nr_irqs;
185
189 unsigned nr_msis;
191
200
228l4_icu_bind(l4_cap_idx_t icu, unsigned irqnum, l4_cap_idx_t irq) L4_NOTHROW;
229
237l4_icu_bind_u(l4_cap_idx_t icu, unsigned irqnum, l4_cap_idx_t irq,
238 l4_utcb_t *utcb) L4_NOTHROW;
239
251l4_icu_unbind(l4_cap_idx_t icu, unsigned irqnum, l4_cap_idx_t irq) L4_NOTHROW;
252
260l4_icu_unbind_u(l4_cap_idx_t icu, unsigned irqnum, l4_cap_idx_t irq,
261 l4_utcb_t *utcb) L4_NOTHROW;
262
274l4_icu_set_mode(l4_cap_idx_t icu, unsigned irqnum, l4_umword_t mode) L4_NOTHROW;
275
283l4_icu_set_mode_u(l4_cap_idx_t icu, unsigned irqnum, l4_umword_t mode,
284 l4_utcb_t *utcb) L4_NOTHROW;
285
296
305 l4_utcb_t *utcb) L4_NOTHROW;
306
314l4_icu_msi_info(l4_cap_idx_t icu, unsigned irqnum, l4_uint64_t source,
315 l4_icu_msi_info_t *msi_info) L4_NOTHROW;
316
324l4_icu_msi_info_u(l4_cap_idx_t icu, unsigned irqnum, l4_uint64_t source,
325 l4_icu_msi_info_t *msi_info, l4_utcb_t *utcb) L4_NOTHROW;
326
327
346l4_icu_unmask(l4_cap_idx_t icu, unsigned irqnum, l4_umword_t *label,
348
356l4_icu_unmask_u(l4_cap_idx_t icu, unsigned irqnum, l4_umword_t *label,
358
377l4_icu_mask(l4_cap_idx_t icu, unsigned irqnum, l4_umword_t *label,
379
387l4_icu_mask_u(l4_cap_idx_t icu, unsigned irqnum, l4_umword_t *label,
389
394l4_icu_control_u(l4_cap_idx_t icu, unsigned irqnum, unsigned op,
395 l4_umword_t *label,l4_timeout_t to,
396 l4_utcb_t *utcb) L4_NOTHROW;
397
398
399/**************************************************************************
400 * Implementations
401 */
402
404l4_icu_bind_u(l4_cap_idx_t icu, unsigned irqnum, l4_cap_idx_t irq,
405 l4_utcb_t *utcb) L4_NOTHROW
406{
407 l4_msg_regs_t *m = l4_utcb_mr_u(utcb);
408 m->mr[0] = L4_ICU_OP_BIND;
409 m->mr[1] = irqnum;
410 m->mr[2] = l4_map_obj_control(0, 0);
411 m->mr[3] = l4_obj_fpage(irq, 0, L4_CAP_FPAGE_RWS).raw;
412 return l4_ipc_call(icu, utcb, l4_msgtag(L4_PROTO_IRQ, 2, 1, 0), L4_IPC_NEVER);
413}
414
416l4_icu_unbind_u(l4_cap_idx_t icu, unsigned irqnum, l4_cap_idx_t irq,
417 l4_utcb_t *utcb) L4_NOTHROW
418{
419 l4_msg_regs_t *m = l4_utcb_mr_u(utcb);
420 m->mr[0] = L4_ICU_OP_UNBIND;
421 m->mr[1] = irqnum;
422 m->mr[2] = l4_map_obj_control(0, 0);
423 m->mr[3] = l4_obj_fpage(irq, 0, L4_CAP_FPAGE_RWS).raw;
424 return l4_ipc_call(icu, utcb, l4_msgtag(L4_PROTO_IRQ, 2, 1, 0), L4_IPC_NEVER);
425}
426
429 l4_utcb_t *utcb) L4_NOTHROW
430{
431 l4_msgtag_t res;
432 l4_msg_regs_t *m = l4_utcb_mr_u(utcb);
433 m->mr[0] = L4_ICU_OP_INFO;
434 res = l4_ipc_call(icu, utcb, l4_msgtag(L4_PROTO_IRQ, 1, 0, 0), L4_IPC_NEVER);
435 info->features = m->mr[0];
436 info->nr_irqs = m->mr[1];
437 info->nr_msis = m->mr[2];
438 return res;
439}
440
442l4_icu_msi_info_u(l4_cap_idx_t icu, unsigned irqnum, l4_uint64_t source,
443 l4_icu_msi_info_t *msi_info, l4_utcb_t *utcb) L4_NOTHROW
444{
445 l4_msgtag_t res;
446 l4_msg_regs_t *m = l4_utcb_mr_u(utcb);
447 m->mr[0] = L4_ICU_OP_MSI_INFO;
448 m->mr[1] = irqnum;
449 m->mr64[l4_utcb_mr64_idx(2)] = source;
450 res = l4_ipc_call(icu, utcb, l4_msgtag(L4_PROTO_IRQ,
451 2 + 1 * sizeof(l4_uint64_t)
452 / sizeof(l4_umword_t),
453 0, 0), L4_IPC_NEVER);
455 return res;
456
457 if (L4_UNLIKELY(l4_msgtag_words(res) * sizeof(l4_umword_t) < sizeof(*msi_info)))
458 return res;
459
460 __builtin_memcpy(msi_info, &m->mr[0], sizeof(*msi_info));
461 return res;
462}
463
465l4_icu_set_mode_u(l4_cap_idx_t icu, unsigned irqnum, l4_umword_t mode,
466 l4_utcb_t *utcb) L4_NOTHROW
467{
468 l4_msg_regs_t *mr = l4_utcb_mr_u(utcb);
469 mr->mr[0] = L4_ICU_OP_SET_MODE;
470 mr->mr[1] = irqnum;
471 mr->mr[2] = mode;
472 return l4_ipc_call(icu, utcb, l4_msgtag(L4_PROTO_IRQ, 3, 0, 0), L4_IPC_NEVER);
473}
474
476l4_icu_control_u(l4_cap_idx_t icu, unsigned irqnum, unsigned op,
477 l4_umword_t *label, l4_timeout_t to,
478 l4_utcb_t *utcb) L4_NOTHROW
479{
480 l4_msg_regs_t *m = l4_utcb_mr_u(utcb);
481 m->mr[0] = L4_ICU_OP_UNMASK + op;
482 m->mr[1] = irqnum;
483 if (label)
484 return l4_ipc_send_and_wait(icu, utcb, l4_msgtag(L4_PROTO_IRQ, 2, 0, 0),
485 label, to);
486 else
487 return l4_ipc_send(icu, utcb, l4_msgtag(L4_PROTO_IRQ, 2, 0, 0), to);
488}
489
491l4_icu_mask_u(l4_cap_idx_t icu, unsigned irqnum, l4_umword_t *label,
493{ return l4_icu_control_u(icu, irqnum, L4_ICU_CTL_MASK, label, to, utcb); }
494
496l4_icu_unmask_u(l4_cap_idx_t icu, unsigned irqnum, l4_umword_t *label,
498{ return l4_icu_control_u(icu, irqnum, L4_ICU_CTL_UNMASK, label, to, utcb); }
499
500
501
502
505{ return l4_icu_bind_u(icu, irqnum, irq, l4_utcb()); }
506
509{ return l4_icu_unbind_u(icu, irqnum, irq, l4_utcb()); }
510
513{ return l4_icu_info_u(icu, info, l4_utcb()); }
514
516l4_icu_msi_info(l4_cap_idx_t icu, unsigned irqnum, l4_uint64_t source,
518{ return l4_icu_msi_info_u(icu, irqnum, source, msi_info, l4_utcb()); }
519
521l4_icu_unmask(l4_cap_idx_t icu, unsigned irqnum, l4_umword_t *label,
523{ return l4_icu_control_u(icu, irqnum, L4_ICU_CTL_UNMASK, label, to, l4_utcb()); }
524
526l4_icu_mask(l4_cap_idx_t icu, unsigned irqnum, l4_umword_t *label,
528{ return l4_icu_control_u(icu, irqnum, L4_ICU_CTL_MASK, label, to, l4_utcb()); }
529
532{
533 return l4_icu_set_mode_u(icu, irqnum, mode, l4_utcb());
534}
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:51
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition l4int.h:40
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition l4int.h:42
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:359
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:680
@ L4_CAP_FPAGE_RWS
Read, interface specific 'W', and 'S' rights for capability flex-pages.
Definition __l4_fpage.h:209
l4_msgtag_t l4_icu_info(l4_cap_idx_t icu, l4_icu_info_t *info) L4_NOTHROW
Get information about the ICU features.
Definition icu.h:512
l4_msgtag_t l4_icu_msi_info_u(l4_cap_idx_t icu, unsigned irqnum, l4_uint64_t source, l4_icu_msi_info_t *msi_info, l4_utcb_t *utcb) L4_NOTHROW
Get MSI info about IRQ.
Definition icu.h:442
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_msi_info(l4_cap_idx_t icu, unsigned irqnum, l4_uint64_t source, l4_icu_msi_info_t *msi_info) L4_NOTHROW
Get MSI info about IRQ.
Definition icu.h:516
l4_msgtag_t l4_icu_mask(l4_cap_idx_t icu, unsigned irqnum, l4_umword_t *label, l4_timeout_t to) L4_NOTHROW
Mask an IRQ line.
Definition icu.h:526
l4_msgtag_t l4_icu_unbind(l4_cap_idx_t icu, unsigned irqnum, l4_cap_idx_t irq) L4_NOTHROW
Remove binding of an interrupt line from the interrupt controller object.
Definition icu.h:508
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_bind(l4_cap_idx_t icu, unsigned irqnum, l4_cap_idx_t irq) L4_NOTHROW
Bind an interrupt line of an interrupt controller to an interrupt object.
Definition icu.h:504
l4_msgtag_t l4_icu_unmask_u(l4_cap_idx_t icu, unsigned irqnum, l4_umword_t *label, l4_timeout_t to, l4_utcb_t *utcb) L4_NOTHROW
Unmask the given interrupt line.
Definition icu.h:496
l4_msgtag_t l4_icu_unmask(l4_cap_idx_t icu, unsigned irqnum, l4_umword_t *label, l4_timeout_t to) L4_NOTHROW
Unmask an IRQ line.
Definition icu.h:521
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_set_mode(l4_cap_idx_t icu, unsigned irqnum, l4_umword_t mode) L4_NOTHROW
Set interrupt mode.
Definition icu.h:531
L4_icu_flags
Flags for IRQ numbers used for the ICU.
Definition icu.h:64
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_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:590
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:597
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:576
L4_irq_mode
Interrupt attributes.
Definition icu.h:81
@ L4_IRQ_F_MASK
Mask.
Definition icu.h:94
@ L4_IRQ_F_LEVEL
Level triggered.
Definition icu.h:84
@ L4_IRQ_F_NEG_EDGE
Negative edge trigger.
Definition icu.h:92
@ L4_IRQ_F_BOTH
Both edges trigger.
Definition icu.h:88
@ 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_EDGE
Edge triggered.
Definition icu.h:85
@ L4_IRQ_F_NONE
Flow types.
Definition icu.h:83
@ L4_IRQ_F_POS
Positive trigger.
Definition icu.h:86
@ L4_IRQ_F_LEVEL_LOW
Level low trigger.
Definition icu.h:90
@ L4_IRQ_F_NEG
Negative trigger.
Definition icu.h:87
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:714
unsigned l4_msgtag_has_error(l4_msgtag_t t) L4_NOTHROW
Test for error indicator flag.
Definition types.h:457
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:428
unsigned l4_msgtag_words(l4_msgtag_t t) L4_NOTHROW
Get the number of untyped words.
Definition types.h:444
@ L4_PROTO_IRQ
IRQ message.
Definition types.h:55
L4_icu_opcode
Opcodes to the ICU interface.
Definition icu.h:107
@ 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
unsigned l4_utcb_mr64_idx(unsigned idx) L4_NOTHROW
Get index into 64bit message registers alias from native-sized index.
Definition utcb.h:386
#define L4_IPC_NEVER
never timeout
Definition __timeout.h:84
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
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition compiler.h:188
#define L4_UNLIKELY(x)
Expression is unlikely to execute.
Definition compiler.h:296
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:62
Kernel object system calls.
Info structure for an ICU.
Definition icu.h:173
unsigned nr_msis
The number of MSI vectors supported by the ICU,.
Definition icu.h:189
unsigned nr_irqs
The number of IRQ lines supported by the ICU,.
Definition icu.h:184
unsigned features
Feature flags.
Definition icu.h:179
Info to use for a specific MSI.
Definition icu.h:194
l4_uint64_t msi_addr
Value to use as address when sending this MSI.
Definition icu.h:196
l4_uint32_t msi_data
Value to use as data written to msi_addr, when sending this MSI.
Definition icu.h:198
Message tag data structure.
Definition types.h:164
l4_umword_t raw
Raw value.
Definition __l4_fpage.h:87
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
l4_uint64_t mr64[L4_UTCB_GENERIC_DATA_SIZE/(sizeof(l4_uint64_t)/sizeof(l4_umword_t))]
Message registers 64bit alias.
Definition utcb.h:81
Timeout pair.
Definition __timeout.h:61